chore: rename cluster -> context option in commands for consistency

This commit is contained in:
Pasha Sviderski
2025-09-11 20:21:07 +10:00
parent 001acfc6a5
commit 8a273dbf63
6 changed files with 18 additions and 26 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ import (
type inspectOptions struct {
service string
cluster string
context string
}
func NewInspectCommand() *cobra.Command {
@@ -31,14 +31,14 @@ func NewInspectCommand() *cobra.Command {
},
}
cmd.Flags().StringVarP(
&opts.cluster, "context", "c", "",
&opts.context, "context", "c", "",
"Name of the cluster context. (default is the current context)",
)
return cmd
}
func inspect(ctx context.Context, uncli *cli.CLI, opts inspectOptions) error {
client, err := uncli.ConnectCluster(ctx, opts.cluster)
client, err := uncli.ConnectCluster(ctx, opts.context)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}
+5 -6
View File
@@ -12,26 +12,25 @@ import (
)
func NewListCommand() *cobra.Command {
// TODO(lhf): rename to context
var cluster string
var contextName string
cmd := &cobra.Command{
Use: "ls",
Aliases: []string{"list"},
Short: "List services.",
RunE: func(cmd *cobra.Command, args []string) error {
uncli := cmd.Context().Value("cli").(*cli.CLI)
return list(cmd.Context(), uncli, cluster)
return list(cmd.Context(), uncli, contextName)
},
}
cmd.Flags().StringVarP(
&cluster, "context", "c", "",
&contextName, "context", "c", "",
"Name of the cluster context. (default is the current context)",
)
return cmd
}
func list(ctx context.Context, uncli *cli.CLI, clusterName string) error {
client, err := uncli.ConnectCluster(ctx, clusterName)
func list(ctx context.Context, uncli *cli.CLI, contextName string) error {
client, err := uncli.ConnectCluster(ctx, contextName)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}
+3 -3
View File
@@ -11,7 +11,7 @@ import (
type rmOptions struct {
services []string
cluster string
context string
}
func NewRmCommand() *cobra.Command {
@@ -28,14 +28,14 @@ func NewRmCommand() *cobra.Command {
},
}
cmd.Flags().StringVarP(
&opts.cluster, "context", "c", "",
&opts.context, "context", "c", "",
"Name of the cluster context. (default is the current context)",
)
return cmd
}
func rm(ctx context.Context, uncli *cli.CLI, opts rmOptions) error {
client, err := uncli.ConnectCluster(ctx, opts.cluster)
client, err := uncli.ConnectCluster(ctx, opts.context)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}
+3 -3
View File
@@ -35,7 +35,7 @@ type runOptions struct {
user string
volumes []string
cluster string
context string
}
func NewRunCommand() *cobra.Command {
@@ -113,7 +113,7 @@ func NewRunCommand() *cobra.Command {
" -v /host/path:/container/path:ro Bind mount a host directory or file as read-only")
cmd.Flags().StringVarP(
&opts.cluster, "context", "c", "",
&opts.context, "context", "c", "",
"Name of the cluster context to run the service in. (default is the current context)",
)
@@ -126,7 +126,7 @@ func run(ctx context.Context, uncli *cli.CLI, opts runOptions) error {
return err
}
clusterClient, err := uncli.ConnectCluster(ctx, opts.cluster)
clusterClient, err := uncli.ConnectCluster(ctx, opts.context)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}
+3 -3
View File
@@ -15,7 +15,7 @@ import (
type scaleOptions struct {
service string
replicas uint
cluster string
context string
}
func NewScaleCommand() *cobra.Command {
@@ -40,7 +40,7 @@ func NewScaleCommand() *cobra.Command {
}
cmd.Flags().StringVarP(
&opts.cluster, "context", "c", "",
&opts.context, "context", "c", "",
"Name of the cluster context. (default is the current context)",
)
@@ -57,7 +57,7 @@ func scale(ctx context.Context, uncli *cli.CLI, opts scaleOptions) error {
)
}
clusterClient, err := uncli.ConnectCluster(ctx, opts.cluster)
clusterClient, err := uncli.ConnectCluster(ctx, opts.context)
if err != nil {
return fmt.Errorf("connect to cluster: %w", err)
}