Skip to content

Commit

Permalink
fix: move docker command (#5941)
Browse files Browse the repository at this point in the history
* fix: move docer command

Signed-off-by: Vladislav Sukhin <[email protected]>

* fix: remove unsued settings

Signed-off-by: Vladislav Sukhin <[email protected]>

* fix: show help

Signed-off-by: Vladislav Sukhin <[email protected]>

---------

Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin authored Oct 17, 2024
1 parent b15d73b commit 86382dc
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 0 additions & 2 deletions cmd/kubectl-testkube/commands/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,6 @@ func prepareTestkubeUpgradeDockerArgs(options HelmOptions, dockerContainerName,
"--set",
"mongodb.enabled=false",
"--set",
"testkube-dashboard.enabled=false",
"--set",
"testkube-api.cloud.key=" + options.Master.AgentToken,
"--set",
"testkube-api.cloud.url=" + options.Master.URIs.Agent,
Expand Down
24 changes: 24 additions & 0 deletions cmd/kubectl-testkube/commands/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package commands

import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/docker"
"github.com/kubeshop/testkube/pkg/ui"
)

func NewDockerCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "docker",
Short: "Testkube Docker commands",
Run: func(cmd *cobra.Command, args []string) {
err := cmd.Help()
ui.PrintOnError("Displaying help", err)
},
}

cmd.AddCommand(docker.NewInitCmd())

return cmd
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package pro
package docker

import (
"errors"
"fmt"
"os"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
"github.com/kubeshop/testkube/pkg/telemetry"
"github.com/kubeshop/testkube/pkg/ui"
)

func NewDockerCmd() *cobra.Command {
func NewInitCmd() *cobra.Command {
var noLogin bool // ignore ask for login
var dockerContainerName, dockerImage string
var options common.HelmOptions
Expand All @@ -25,9 +27,9 @@ func NewDockerCmd() *cobra.Command {
}

cmd := &cobra.Command{
Use: "docker",
Use: "init",
Short: "Run Testkube Docker Agent and connect to Testkube Pro environment",
Aliases: []string{"da", "docker-agent"},
Aliases: []string{"install", "agent"},
Run: func(cmd *cobra.Command, args []string) {
ui.Info("WELCOME TO")
ui.Logo()
Expand Down Expand Up @@ -137,3 +139,28 @@ func NewDockerCmd() *cobra.Command {

return cmd
}

func sendErrTelemetry(cmd *cobra.Command, clientCfg config.Data, errType string, errorLogs error) {
var errorStackTrace string
errorStackTrace = fmt.Sprintf("%+v", errorLogs)
if clientCfg.TelemetryEnabled {
ui.Debug("collecting anonymous telemetry data, you can disable it by calling `kubectl testkube disable telemetry`")
out, err := telemetry.SendCmdErrorEvent(cmd, common.Version, errType, errorStackTrace)
if ui.Verbose && err != nil {
ui.Err(err)
}

ui.Debug("telemetry send event response", out)
}
}

func sendAttemptTelemetry(cmd *cobra.Command, clientCfg config.Data) {
if clientCfg.TelemetryEnabled {
ui.Debug("collecting anonymous telemetry data, you can disable it by calling `kubectl testkube disable telemetry`")
out, err := telemetry.SendCmdAttemptEvent(cmd, common.Version)
if ui.Verbose && err != nil {
ui.Err(err)
}
ui.Debug("telemetry send event response", out)
}
}
1 change: 0 additions & 1 deletion cmd/kubectl-testkube/commands/pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func NewProCmd() *cobra.Command {
cmd.AddCommand(pro.NewDisconnectCmd())
cmd.AddCommand(pro.NewInitCmd())
cmd.AddCommand(pro.NewLoginCmd())
cmd.AddCommand(pro.NewDockerCmd())

return cmd
}
1 change: 1 addition & 0 deletions cmd/kubectl-testkube/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func init() {
RootCmd.AddCommand(NewAgentCmd())
RootCmd.AddCommand(NewCloudCmd())
RootCmd.AddCommand(NewProCmd())
RootCmd.AddCommand(NewDockerCmd())
RootCmd.AddCommand(pro.NewLoginCmd())

RootCmd.SetHelpCommand(NewHelpCmd())
Expand Down

0 comments on commit 86382dc

Please sign in to comment.