Skip to content

Commit

Permalink
fix: docker image parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Oct 10, 2024
1 parent e5f1555 commit dbb0791
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/kubectl-testkube/commands/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ func RunDockerCommand(args []string) (output string, cliErr *CLIError) {
return string(out), nil
}

func DockerRunTestkubeAgent(options HelmOptions, cfg config.Data, containerName string) *CLIError {
func DockerRunTestkubeAgent(options HelmOptions, cfg config.Data, containerName, dockerImage string) *CLIError {
// use config if set
if cfg.CloudContext.AgentKey != "" && options.Master.AgentToken == "" {
options.Master.AgentToken = cfg.CloudContext.AgentKey
Expand All @@ -787,7 +787,7 @@ func DockerRunTestkubeAgent(options HelmOptions, cfg config.Data, containerName
errors.New("agent key is required"))
}

args := prepareTestkubeProDockerArgs(options, containerName)
args := prepareTestkubeProDockerArgs(options, containerName, dockerImage)
output, err := RunDockerCommand(args)
if err != nil {
return err
Expand All @@ -802,15 +802,15 @@ func DockerRunTestkubeAgent(options HelmOptions, cfg config.Data, containerName
}

// prepareTestkubeProDockerArgs prepares docker arguments for Testkube Pro running.
func prepareTestkubeProDockerArgs(options HelmOptions, containerName string) []string {
func prepareTestkubeProDockerArgs(options HelmOptions, containerName, dockerImage string) []string {
args := []string{
"run",
"--name", containerName,
"--privileged",
"-d",
"-e", "CLOUD_URL=" + options.Master.URIs.Agent,
"-e", "AGENT_KEY=" + options.Master.AgentToken,
"kubeshop/testkube-agent",
dockerImage,
}

return args
Expand Down
5 changes: 3 additions & 2 deletions cmd/kubectl-testkube/commands/pro/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func NewDockerCmd() *cobra.Command {
var noLogin bool // ignore ask for login
var containerName string
var containerName, dockerImage string
var options common.HelmOptions

cmd := &cobra.Command{
Expand Down Expand Up @@ -62,7 +62,7 @@ func NewDockerCmd() *cobra.Command {
}

spinner := ui.NewSpinner("Running Testkube Docker Agent")
if cliErr := common.DockerRunTestkubeAgent(options, cfg, containerName); cliErr != nil {
if cliErr := common.DockerRunTestkubeAgent(options, cfg, containerName, dockerImage); cliErr != nil {
spinner.Fail()
sendErrTelemetry(cmd, cfg, "docker_run", cliErr)
common.HandleCLIError(cliErr)
Expand Down Expand Up @@ -101,6 +101,7 @@ func NewDockerCmd() *cobra.Command {

cmd.Flags().BoolVarP(&noLogin, "no-login", "", false, "Ignore login prompt, set existing token later by `testkube set context`")
cmd.Flags().StringVar(&containerName, "container-name", "testkube-agent", "container name for Testkube Docker Agent")
cmd.Flags().StringVar(&dockerImage, "docker-image", "kubeshop/testkube-agent", "docker image for Testkube Docker Agent")

return cmd
}

0 comments on commit dbb0791

Please sign in to comment.