Skip to content

Commit

Permalink
Rename CLI parameters to match workload ID selector syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyb89 committed Jan 17, 2025
1 parent 51f45b4 commit a1b84c0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/tbot/cli/start_kubernetes_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func NewKubernetesV2Command(parentCmd *kingpin.CmdClause, action MutatorAction,
c.genericMutatorHandler = newGenericMutatorHandler(cmd, c, action)

cmd.Flag("disable-exec-plugin", "If set, disables the exec plugin. This allows credentials to be used without the `tbot` binary.").BoolVar(&c.DisableExecPlugin)
cmd.Flag("kubernetes-cluster-name", "An explicit Kubernetes cluster name to include. Repeatable.").StringsVar(&c.KubernetesClusterNames)
cmd.Flag("kubernetes-cluster-labels", "A set of Kubernetes labels to match in k1=v1,k2=v2 form. Repeatable.").StringsVar(&c.KubernetesClusterLabels)
cmd.Flag("name-selector", "An explicit Kubernetes cluster name to include. Repeatable.").StringsVar(&c.KubernetesClusterNames)
cmd.Flag("label-selector", "A set of Kubernetes labels to match in k1=v1,k2=v2 form. Repeatable.").StringsVar(&c.KubernetesClusterLabels)

// Note: excluding roles; the bot will fetch all available in CLI mode.

Expand Down Expand Up @@ -100,6 +100,7 @@ func (c *KubernetesV2Command) ApplyConfig(cfg *config.BotConfig, l *slog.Logger)
Name: name,
})
}

for _, s := range c.KubernetesClusterLabels {
labels, err := client.ParseLabelSpec(s)
if err != nil {
Expand All @@ -111,6 +112,10 @@ func (c *KubernetesV2Command) ApplyConfig(cfg *config.BotConfig, l *slog.Logger)
})
}

if len(selectors) == 0 {
return trace.BadParameter("at least one name-selector or label-selector must be provided")
}

cfg.Services = append(cfg.Services, &config.KubernetesV2Output{
Destination: dest,
DisableExecPlugin: c.DisableExecPlugin,
Expand Down

0 comments on commit a1b84c0

Please sign in to comment.