Skip to content

Commit

Permalink
fix: move docker command
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Oct 17, 2024
1 parent 0b8bae9 commit eab53e9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
21 changes: 21 additions & 0 deletions cmd/kubectl-testkube/commands/docker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package commands

import (
"github.com/spf13/cobra"

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

func NewDockerCmd() *cobra.Command {

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

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 eab53e9

Please sign in to comment.