cmd

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const LatestVersion = "latest"

Variables

View Source
var ConfigCmd = &cobra.Command{
	Use:   "config",
	Short: "Print default install config.",
	Example: `
# Print default install config
tkeel config

# Save default install config to file
tkeel config > config.yaml
`,
	PreRun: func(cmd *cobra.Command, args []string) {
	},
	Run: func(cmd *cobra.Command, args []string) {
		configFromat := `host:
  admin: %s
  tenant: %s
middleware:
  cache:
    customized: false
    url: redis://:Biz0P8Xoup@tkeel-middleware-redis-master:6379/0
  database:
    customized: false
    url: mysql://root:a3fks=ixmeb82a@tkeel-middleware-mysql:3306/tkeelauth
  queue:
    customized: false
    url: kafka://tkeel-middleware-kafka-headless:9092
  search:
    customized: false
    url: elasticsearch://admin:admin@tkeel-middleware-elasticsearch-master:9200
  service_registry:
    customized: false
    url: etcd://tkeel-middleware-etcd:2379
port: %s
repo:
  name: tkeel
  url: https://tkeel-io.github.io/helm-charts
plugins:
  - tkeel/console-portal-admin@v0.4.1
  - tkeel/console-portal-tenant@v0.4.1
  - tkeel/console-plugin-admin-plugins@v0.4.1

`
		config := fmt.Sprintf(configFromat, adminHost, tenantHost, port)
		fmt.Println(config)
	},
}

ConfigCmd is a command from removing a tKeel installation.

View Source
var DoctorCmd = &cobra.Command{
	Use:   "doctor",
	Short: "Check tkeel install environment.",
	PreRun: func(cmd *cobra.Command, args []string) {
	},
	Example: `
tkeel doctor
`,
	Run: func(cmd *cobra.Command, args []string) {
		print.PendingStatusEvent(os.Stdout, "Checking the Dapr runtime status...")
		status := kubernetes.Check()
		installed := fmt.Sprintf("dapr installed: %v", status.Installed)
		print.SuccessStatusEvent(os.Stdout, installed)

		version := fmt.Sprintf("dapr version: %s", status.Version)
		print.SuccessStatusEvent(os.Stdout, version)

		namespace := fmt.Sprintf("dapr namespace: %s", status.Namespace)
		print.SuccessStatusEvent(os.Stdout, namespace)

		mtlsEnabled := fmt.Sprintf("dapr mtls enabled: %v", status.MTLSEnabled)
		print.SuccessStatusEvent(os.Stdout, mtlsEnabled)
	},
}
View Source
var InitCmd = &cobra.Command{
	Use:   "init",
	Short: "Install tKeel platform on dapr.",
	PreRun: func(cmd *cobra.Command, args []string) {
		checkDapr()
		realConfigPath()
		initVersion()
	},
	Example: `
# Initialize Keel in Kubernetes
tkeel init 

# Initialize Keel in Kubernetes and wait for the installation to complete (default timeout is 300s/5m)
tkeel init --wait --timeout 600
`,
	Run: func(cmd *cobra.Command, args []string) {
		print.PendingStatusEvent(os.Stdout, "Making the jump to hyperspace...")
		config := kubernetes.InitConfiguration{
			Namespace:         daprStatus.Namespace,
			KeelVersion:       keelVersion,
			CoreVersion:       coreVersion,
			RudderVersion:     rudderVersion,
			MiddlewareVersion: middlewareVersion,
			DaprVersion:       daprStatus.Version,
			EnableMTLS:        enableMTLS,
			EnableHA:          enableHA,
			Args:              values,
			Wait:              wait,
			Timeout:           timeout,
			DebugMode:         debugMode,
			Secret:            secret,
			Repo: &kitconfig.Repo{
				Url:  repoURL,
				Name: repoName,
			},
			Password:   password,
			ConfigFile: configFile,
		}
		err := kubernetes.Init(config)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		successEvent := fmt.Sprintf("Success! tKeel Platform has been installed to namespace %s. To verify, run `tkeel plugin list' in your terminal. To get started, go here: https://tkeel.io/keel-getting-started", config.Namespace)
		print.SuccessStatusEvent(os.Stdout, successEvent)
	},
}
View Source
var InvokeCmd = &cobra.Command{
	Use:   "invoke",
	Short: "Invoke a method on a given tKeel plugin(application).",
	Example: `
# Invoke a sample method on target app with POST Verb
tkeel invoke --plugin-id target --method v1/sample --dao '{"key":"value"}

# Invoke a sample method on target app with GET Verb
tkeel invoke --plugin-id target --method v1/sample --verb GET
`,
	Run: func(cmd *cobra.Command, args []string) {
		bytePayload := []byte{}
		var err error
		if invokeDataFile != "" && invokeData != "" {
			print.FailureStatusEvent(os.Stdout, "Only one of --dao and --dao-file allowed in the same invoke command")
			os.Exit(1)
		}

		if invokeDataFile != "" {
			bytePayload, err = ioutil.ReadFile(invokeDataFile)
			if err != nil {
				print.FailureStatusEvent(os.Stdout, "Error reading payload from '%s'. Error: %s", invokeDataFile, err)
				os.Exit(1)
			}
		} else if invokeData != "" {
			bytePayload = []byte(invokeData)
		}

		response, err := kubernetes.InvokeByPortForward(invokeAppID, invokeAppMethod, bytePayload, invokeVerb)
		if err != nil {
			err = fmt.Errorf("error invoking plugin %s: %w", invokeAppID, err)
			print.FailureStatusEvent(os.Stdout, err.Error())
			return
		}

		if response != "" {
			fmt.Println(response)
		}

		print.SuccessStatusEvent(os.Stdout, "Plugin invoked successfully")
	},
}
View Source
var RootCmd = &cobra.Command{
	Use:   "tkeel",
	Short: "Keel CLI",
	Long: `
      __             __
     / /_____  ___  / /
    / //_/ _ \/ _ \/ /
   / ,< /  __/  __/ /
  /_/|_|\___/\___/_/
									   
===============================
Things Keel Platform`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
	},
	Version: "0.4.0",
}
View Source
var UninstallCmd = &cobra.Command{
	Use:   "uninstall",
	Short: "Uninstall tKeel Platform.",
	Example: `
# Uninstall from self-hosted mode
tkeel uninstall

@TODO

# Uninstall from self-hosted mode and remove .dapr directory, Redis, Placement and Zipkin containers
dapr uninstall --all

# Uninstall from Kubernetes
dapr uninstall -k
`,
	PreRun: func(cmd *cobra.Command, args []string) {
		checkDapr()
	},
	Run: func(cmd *cobra.Command, args []string) {
		confirm := false
		err := survey.AskOne(&survey.Confirm{Message: "Do you want to uninstall tkeel platform ?"}, &confirm)
		if err != nil || !confirm {
			return
		}

		print.InfoStatusEvent(os.Stdout, "Removing tKeel Platform from your cluster...")

		if uninstallAll {
			err = kubernetes.UninstallAllPlugin(daprStatus.Namespace, debugMode)
			if err != nil {
				print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error removing plugins: %s", err))
			} else {
				print.SuccessStatusEvent(os.Stdout, "tKeel plugins has been removed successfully")
			}
		}

		err = kubernetes.UninstallPlatform(daprStatus.Namespace, timeout, debugMode)

		if err != nil {
			print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error removing tKeel: %s", err))
		} else {
			print.SuccessStatusEvent(os.Stdout, "tKeel Platform has been removed successfully")
		}
		kubernetes.CleanToken()
	},
}

UninstallCmd is a command from removing a tKeel installation.

View Source
var UpgradeCmd = &cobra.Command{
	Use:   "upgrade",
	Short: "Upgrade tKeel platform.",
	PreRun: func(cmd *cobra.Command, args []string) {
		checkDapr()
		realConfigPath()
		initVersion()
	},
	Example: `
# Initialize Keel in Kubernetes
tkeel init 

# Initialize Keel in Kubernetes and wait for the installation to complete (default timeout is 300s/5m)
tkeel init --wait --timeout 600
`,
	Run: func(cmd *cobra.Command, args []string) {
		print.PendingStatusEvent(os.Stdout, "Making the jump to hyperspace...")
		config := kubernetes.InitConfiguration{
			Namespace:         daprStatus.Namespace,
			KeelVersion:       keelVersion,
			CoreVersion:       coreVersion,
			RudderVersion:     rudderVersion,
			MiddlewareVersion: middlewareVersion,
			DaprVersion:       daprStatus.Version,
			EnableMTLS:        enableMTLS,
			EnableHA:          enableHA,
			Args:              values,
			Wait:              wait,
			Timeout:           timeout,
			DebugMode:         debugMode,
			Repo: &kitconfig.Repo{
				Url:  repoURL,
				Name: repoName,
			},
			ConfigFile: configFile,
		}
		err := kubernetes.Upgrade(config)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		successEvent := "Success! tKeel Platform upgrade success!"
		print.SuccessStatusEvent(os.Stdout, successEvent)
	},
}

Functions

func Execute

func Execute(version, apiVersion string)

Execute adds all child commands to the root command.

Types

This section is empty.

Directories

Path Synopsis
------------------------------------------------------------ Copyright (c) Microsoft Corporation and Dapr Contributors.
------------------------------------------------------------ Copyright (c) Microsoft Corporation and Dapr Contributors.

Jump to

Keyboard shortcuts

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