refactor: Make --context cli flag a global option (#174)

* Make `--context` flag a global option and remove duplication

* Remove unused dns showOptions struct

* First pass of refactoring "active context" determination and validation

* Undo some refactoring in cli.go to keep diff more focused
This commit is contained in:
Justin Bradford authored and GitHub committed 2025-11-19 20:30:32 +10:00
1 parent 1d413734d8
commit 939645e144
27 files changed
+55 -175

No files matched your search

+1 -6
View File
@@ -22,7 +22,6 @@ import (
type listOptions struct {
machines []string
nameFilter string
context string
}
func NewListCommand() *cobra.Command {
@@ -60,10 +59,6 @@ func NewListCommand() *cobra.Command {
cmd.Flags().StringSliceVarP(&opts.machines, "machine", "m", nil,
"Filter images by machine name or ID. Can be specified multiple times or as a comma-separated list. "+
"(default is include all machines)")
cmd.Flags().StringVarP(
&opts.context, "context", "c", "",
"Name of the cluster context. (default is the current context)",
)
return cmd
}
@@ -82,7 +77,7 @@ type imageRow struct {
}
func list(ctx context.Context, uncli *cli.CLI, opts listOptions) error {
clusterClient, err := uncli.ConnectCluster(ctx, opts.context)
clusterClient, err := uncli.ConnectCluster(ctx)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}