From b77d161c757bc3539a5c844fbd38d85240afde98 Mon Sep 17 00:00:00 2001 From: Jacek Wysocki Date: Tue, 6 Aug 2024 08:56:20 +0200 Subject: [PATCH] feat: added runner init command --- cmd/kubectl-testkube/commands/common/flags.go | 1 + .../commands/common/helper.go | 4 ++++ cmd/kubectl-testkube/commands/root.go | 1 + cmd/kubectl-testkube/commands/runner.go | 22 +++++++++++++++++++ cmd/kubectl-testkube/config/master.go | 1 + 5 files changed, 29 insertions(+) create mode 100644 cmd/kubectl-testkube/commands/runner.go diff --git a/cmd/kubectl-testkube/commands/common/flags.go b/cmd/kubectl-testkube/commands/common/flags.go index 0b48f38db59..5437a789133 100644 --- a/cmd/kubectl-testkube/commands/common/flags.go +++ b/cmd/kubectl-testkube/commands/common/flags.go @@ -90,6 +90,7 @@ func PopulateMasterFlags(cmd *cobra.Command, opts *HelmOptions) { cmd.Flags().StringVar(&opts.Master.AgentToken, "agent-token", "", "Testkube Pro agent key [required for centralized mode]") cmd.Flags().StringVar(&opts.Master.OrgId, "org-id", "", "Testkube Pro organization id [required for centralized mode]") cmd.Flags().StringVar(&opts.Master.EnvId, "env-id", "", "Testkube Pro environment id [required for centralized mode]") + cmd.Flags().StringVar(&opts.Master.RunnerId, "runner-id", "", "Testkube Pro Multi Runner id [required for centralized mode]") cmd.Flags().BoolVar(&opts.Master.Features.LogsV2, "feature-logs-v2", false, "Logs v2 feature flag") } diff --git a/cmd/kubectl-testkube/commands/common/helper.go b/cmd/kubectl-testkube/commands/common/helper.go index fb5b6363385..eec4609bcb9 100644 --- a/cmd/kubectl-testkube/commands/common/helper.go +++ b/cmd/kubectl-testkube/commands/common/helper.go @@ -207,6 +207,10 @@ func prepareTestkubeProHelmArgs(options HelmOptions, isMigration bool) []string args = append(args, "--set", fmt.Sprintf("testkube-logs.pro.envId=%s", options.Master.EnvId)) } + if options.Master.RunnerId != "" { + args = append(args, "--set", fmt.Sprintf("testkube-api.cloud.runnerId=%s", options.Master.RunnerId)) + } + if options.Master.OrgId != "" { args = append(args, "--set", fmt.Sprintf("testkube-api.cloud.orgId=%s", options.Master.OrgId)) args = append(args, "--set", fmt.Sprintf("testkube-logs.pro.orgId=%s", options.Master.OrgId)) diff --git a/cmd/kubectl-testkube/commands/root.go b/cmd/kubectl-testkube/commands/root.go index 464f6657f65..96c2dd3ffce 100644 --- a/cmd/kubectl-testkube/commands/root.go +++ b/cmd/kubectl-testkube/commands/root.go @@ -48,6 +48,7 @@ func init() { RootCmd.AddCommand(NewGenerateCmd()) RootCmd.AddCommand(NewInitCmd()) + RootCmd.AddCommand(NewRunnerCmd()) RootCmd.AddCommand(NewUpgradeCmd()) RootCmd.AddCommand(NewPurgeCmd()) RootCmd.AddCommand(NewWatchCmd()) diff --git a/cmd/kubectl-testkube/commands/runner.go b/cmd/kubectl-testkube/commands/runner.go new file mode 100644 index 00000000000..5351bbef682 --- /dev/null +++ b/cmd/kubectl-testkube/commands/runner.go @@ -0,0 +1,22 @@ +package commands + +import ( + "github.com/spf13/cobra" + + "github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/pro" +) + +func NewRunnerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "runner ", + Aliases: []string{""}, + Short: "Testkube Runner related commands", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, + } + + cmd.AddCommand(pro.NewInitCmd()) + + return cmd +} diff --git a/cmd/kubectl-testkube/config/master.go b/cmd/kubectl-testkube/config/master.go index 05de6762290..7e2ceb97a55 100644 --- a/cmd/kubectl-testkube/config/master.go +++ b/cmd/kubectl-testkube/config/master.go @@ -7,6 +7,7 @@ type Master struct { IdToken string `json:"idToken,omitempty"` OrgId string `json:"orgId,omitempty"` EnvId string `json:"envId,omitempty"` + RunnerId string `json:"runnerId,omitempty"` Insecure bool `json:"insecure,omitempty"` UiUrlPrefix string `json:"uiUrlPrefix,omitempty"` AgentUrlPrefix string `json:"agentUrlPrefix,omitempty"`