commands

package
v1.15.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiVersion         string = "v1"
	DashboardURI       string = "http://dashboard.testkube.io"
	CurrentApiVersion  string = apiclient.Version
	DashboardLocalPort int    = 8080
)

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "testkube",
	Short: "Testkube entrypoint for kubectl plugin",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		ui.SetVerbose(verbose)

		if cmd.Name() == "context" || (cmd.Parent() != nil && cmd.Parent().Name() == "completion") {
			return
		}

		cfg, err := config.Load()
		ui.ExitOnError("loading config", err)

		if err = validator.ValidateCloudContext(cfg); err != nil {
			common.UiCloudContextValidationError(err)
		}
	},

	PersistentPostRun: func(cmd *cobra.Command, args []string) {
		clientCfg, err := config.Load()
		ui.WarnOnError("loading config", err)

		client, _, err := common.GetClient(cmd)
		if err != nil {
			return
		}

		if clientCfg.ContextType != config.ContextTypeCloud {
			serverCfg, err := client.GetConfig()
			if ui.Verbose && err != nil {
				ui.Err(err)
			}

			if clientCfg.TelemetryEnabled != serverCfg.EnableTelemetry && err == nil {
				if serverCfg.EnableTelemetry {
					clientCfg.EnableAnalytics()
					ui.Debug("Sync telemetry on CLI with API", "enabled")
				} else {
					clientCfg.DisableAnalytics()
					ui.Debug("Sync telemetry on CLI with API", "disabled")
				}

				err = config.Save(clientCfg)
				ui.WarnOnError("syncing config", err)
			}
		}
		if clientCfg.TelemetryEnabled {
			ui.Debug("collecting anonymous telemetry data, you can disable it by calling `kubectl testkube disable telemetry`")
			out, err := telemetry.SendCmdEvent(cmd, common.Version)
			if ui.Verbose && err != nil {
				ui.Err(err)
			}
			ui.Debug("telemetry send event response", out)

			clientCfg, err := config.Load()
			ui.WarnOnError("loading config", err)

			if !clientCfg.Initialized {
				clientCfg.SetInitialized()
				err := config.Save(clientCfg)
				ui.WarnOnError("saving config", err)

				ui.Debug("sending 'init' event")

				out, err := telemetry.SendCmdInitEvent(cmd, common.Version)
				if ui.Verbose && err != nil {
					ui.Err(err)
				}
				ui.Debug("telemetry init event response", out)
			}
		}
	},

	Run: func(cmd *cobra.Command, args []string) {
		ui.Logo()
		err := cmd.Usage()
		ui.PrintOnError("Displaying usage", err)
		cmd.DisableAutoGenTag = true
	},
}

Functions

func Execute

func Execute()

func NewAbortCmd added in v0.10.0

func NewAbortCmd() *cobra.Command

func NewAgentCmd added in v1.9.23

func NewAgentCmd() *cobra.Command

func NewCloudCmd added in v1.11.25

func NewCloudCmd() *cobra.Command

func NewConfigCmd added in v0.10.5

func NewConfigCmd() *cobra.Command

func NewCreateCmd added in v0.10.0

func NewCreateCmd() *cobra.Command

func NewCreateTicketCmd added in v1.4.6

func NewCreateTicketCmd() *cobra.Command

func NewDashboardCmd added in v0.5.52

func NewDashboardCmd() *cobra.Command

NewDashboardCmd is a method to create new dashboard command

func NewDebugCmd added in v1.3.45

func NewDebugCmd() *cobra.Command

NewDebugCmd creates the 'testkube debug' command

func NewDeleteCmd added in v0.10.0

func NewDeleteCmd() *cobra.Command

func NewDisableCmd added in v0.10.0

func NewDisableCmd() *cobra.Command

func NewDownloadAllArtifactsCmd added in v0.6.29

func NewDownloadAllArtifactsCmd() *cobra.Command

func NewDownloadCmd added in v0.10.0

func NewDownloadCmd() *cobra.Command

func NewDownloadSingleArtifactsCmd added in v0.6.29

func NewDownloadSingleArtifactsCmd() *cobra.Command

func NewDownloadTestSuiteArtifactsCmd added in v1.15.13

func NewDownloadTestSuiteArtifactsCmd() *cobra.Command

func NewEnableCmd added in v0.10.0

func NewEnableCmd() *cobra.Command

func NewGenerateCmd added in v0.10.0

func NewGenerateCmd() *cobra.Command

func NewGetCmd added in v0.10.0

func NewGetCmd() *cobra.Command

func NewHelpCmd added in v1.5.10

func NewHelpCmd() *cobra.Command

func NewInitCmd added in v1.5.2

func NewInitCmd() *cobra.Command

func NewListArtifactsCmd added in v0.6.9

func NewListArtifactsCmd() *cobra.Command

func NewMigrateCmd added in v0.8.9

func NewMigrateCmd() *cobra.Command

func NewPurgeCmd added in v1.5.2

func NewPurgeCmd() *cobra.Command

func NewRunCmd added in v0.10.0

func NewRunCmd() *cobra.Command

func NewSetCmd added in v1.7.30

func NewSetCmd() *cobra.Command

func NewStatusCmd added in v0.10.0

func NewStatusCmd() *cobra.Command

func NewUpdateCmd added in v0.10.0

func NewUpdateCmd() *cobra.Command

func NewUpgradeCmd added in v0.9.0

func NewUpgradeCmd() *cobra.Command

func NewVersionCmd

func NewVersionCmd() *cobra.Command

func NewWatchCmd added in v0.10.0

func NewWatchCmd() *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL