Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move docker command #5941

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading