Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(cozyctl): add CLI tool for managing Cozystack applications#2088

Draft
kvaps wants to merge 6 commits intomaincozystack/cozystack:mainfrom
feat/cozyctlcozystack/cozystack:feat/cozyctlCopy head branch name to clipboard
Draft

feat(cozyctl): add CLI tool for managing Cozystack applications#2088
kvaps wants to merge 6 commits intomaincozystack/cozystack:mainfrom
feat/cozyctlcozystack/cozystack:feat/cozyctlCopy head branch name to clipboard

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Feb 23, 2026

Summary

Introduce cozyctl — a CLI tool for managing Cozystack applications from the terminal.

  • cozyctl get command with dynamic resource type resolution from ApplicationDefinitions
  • Built-in types: tenant namespaces, tenant modules, PVCs
  • Sub-resource listing (secrets, services, ingresses, workloads) with -t type/name filtering via label selectors
  • VM interaction commands: console, vnc, migrate, port-forward (delegate to virtctl)
  • Makefile build and cross-platform asset packaging targets

Commands

Command Description
cozyctl get <type> [name] List/get applications, built-in types, or sub-resources
cozyctl get secrets -t postgres/mydb Filter sub-resources by parent application
cozyctl console <type> <name> Serial console to a VM via virtctl
cozyctl vnc <type> <name> VNC connection to a VM via virtctl
cozyctl migrate <type> <name> Live-migrate a VM via virtctl
cozyctl port-forward <type/name> [ports] Port forwarding to a VMI via virtctl

Test plan

  • go build ./cmd/cozyctl/... compiles successfully
  • go vet ./cmd/cozyctl/... passes
  • cozyctl --help shows all commands
  • cozyctl get --help shows resource types and flags
  • Test cozyctl get ns against a running cluster
  • Test cozyctl get <app-type> -n <ns> against a running cluster
  • Test cozyctl get secrets -t <type>/<name> against a running cluster

kvaps and others added 6 commits February 23, 2026 17:47
Introduce the cozyctl CLI tool for managing Cozystack applications
from the terminal. This initial commit includes:
- main.go entry point
- Cobra root command with --kubeconfig, --context, -n flags
- K8s client factory (typed + dynamic) with namespace resolution

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Discover ApplicationDefinitions from the cluster and build a lookup
registry by plural/singular/kind names for dynamic resource resolution.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Output formatting for applications, namespaces, modules, PVCs,
secrets, services, ingresses, and workload monitors.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Dispatch logic for all resource types:
- Built-in: ns, modules, pvc
- Sub-resources: secrets, services, ingresses, workloads with -t flag
- Application types via dynamic ApplicationDefinition discovery

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
VM interaction commands that resolve application type to VM name via
ApplicationDefinition discovery and exec virtctl for the actual work.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Add cozyctl build target and cross-platform asset packaging targets
following the same pattern as cozypkg.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cozyctl

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kvaps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces cozyctl, a new command-line interface designed to simplify the management and interaction with Cozystack applications and their underlying Kubernetes resources. It provides a unified way to inspect various resource types, including dynamically defined applications, and offers direct control over Virtual Machines by integrating with virtctl. This tool aims to enhance developer and operator experience by centralizing common management tasks.

Highlights

  • New CLI Tool Introduced: A new command-line interface tool, cozyctl, has been added to manage Cozystack applications directly from the terminal.
  • Resource Listing (cozyctl get): The cozyctl get command allows listing and retrieving various resources, including built-in types like tenant namespaces, tenant modules, and PVCs, as well as dynamically discovered application types from ApplicationDefinitions. It also supports filtering sub-resources (secrets, services, ingresses, workloads) by parent application using the -t flag.
  • Virtual Machine Interaction: Dedicated commands (console, vnc, migrate, port-forward) have been added to interact with Virtual Machines, delegating the actual operations to the virtctl tool.
  • Build System Integration: The Makefile has been updated to include build and cross-platform asset packaging targets for the new cozyctl binary.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Makefile
    • Added a new cozyctl build target.
    • Included cozyctl in the assets target for cross-platform packaging.
  • cmd/cozyctl/cmd/client.go
    • Added functions for building Kubernetes REST configurations.
    • Implemented logic for creating typed and dynamic Kubernetes clients.
    • Included functionality to determine the current Kubernetes namespace.
  • cmd/cozyctl/cmd/console.go
    • Added the console command for opening a serial console to a VirtualMachine.
    • Implemented runConsole to resolve VM arguments and execute virtctl.
  • cmd/cozyctl/cmd/discovery.go
    • Added AppDefInfo and AppDefRegistry structures for managing application definitions.
    • Implemented discoverAppDefs to list and register ApplicationDefinitions from the cluster.
    • Added methods to resolve application definitions by plural, singular, or kind, including module-specific resolution.
  • cmd/cozyctl/cmd/get.go
    • Added the get command for displaying various resources.
    • Implemented functions to retrieve and print tenant namespaces, tenant modules, and PVCs.
    • Included logic for fetching and filtering sub-resources (secrets, services, ingresses, workloads) based on application labels.
    • Added dynamic application retrieval based on discovered ApplicationDefinitions.
  • cmd/cozyctl/cmd/migrate.go
    • Added the migrate command for live-migrating VirtualMachines.
    • Implemented runMigrate to resolve VM arguments and execute virtctl.
  • cmd/cozyctl/cmd/portforward.go
    • Added the port-forward command for forwarding ports to a VirtualMachineInstance.
    • Implemented runPortForward to resolve VM arguments and execute virtctl.
  • cmd/cozyctl/cmd/printer.go
    • Added utility functions for formatted output using tabwriter.
    • Implemented specific print functions for applications, namespaces, modules, PVCs, secrets, services, ingresses, and workloads.
    • Included helper functions for extracting conditions, truncating strings, and formatting service ports.
  • cmd/cozyctl/cmd/root.go
    • Added the root cobra command for cozyctl.
    • Defined global flags for kubeconfig, context, and namespace.
    • Set up version information for the CLI tool.
  • cmd/cozyctl/cmd/vm.go
    • Added vmKindPrefix to map application kinds to KubeVirt VM prefixes.
    • Implemented resolveVMArgs to parse CLI arguments, discover application types, and validate VM kinds.
    • Added execVirtctl to replace the current process with virtctl for VM operations.
  • cmd/cozyctl/cmd/vnc.go
    • Added the vnc command for opening a VNC connection to a VirtualMachine.
    • Implemented runVNC to resolve VM arguments and execute virtctl.
  • cmd/cozyctl/main.go
    • Added the main entry point for the cozyctl application, executing the root command.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces cozyctl, a new CLI tool designed for managing Cozystack applications. The changes include updates to the Makefile for building and packaging the cozyctl binary across different platforms, and a comprehensive set of new Go files implementing the CLI's functionality. The CLI leverages Cobra for command-line parsing and interacts with the Kubernetes API to manage various resource types, including dynamically discovered application definitions. It also provides specialized commands for Virtual Machine interactions by integrating with virtctl. The code is well-structured, follows standard Go and Cobra CLI practices, and includes appropriate error handling and input validation. Overall, the implementation is robust and well-designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.