Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CompletionCmd = &cobra.Command{ Use: "completion [bash|zsh|fish]", Short: "Output a shell completion script", Long: `To load completions: Bash: $ source <(kubecc completion bash) # To load completions for each session, execute once: # Linux: $ kubecc completion bash > /etc/bash_completion.d/kubecc # macOS: $ kubecc completion bash > /usr/local/etc/bash_completion.d/kubecc Zsh: # If shell completion is not already enabled in your environment, # you will need to enable it. You can execute the following once: $ echo "autoload -U compinit; compinit" >> ~/.zshrc # To load completions for each session, execute once: $ kubecc completion zsh > "${fpath[1]}/_kubecc" # You will need to start a new shell for this setup to take effect. fish: $ kubecc completion fish | source # To load completions for each session, execute once: $ kubecc completion fish > ~/.config/fish/completions/kubecc.fish `, DisableFlagsInUseLine: true, ValidArgs: []string{"bash", "zsh", "fish"}, Args: cobra.ExactValidArgs(1), Run: func(cmd *cobra.Command, args []string) { switch args[0] { case "bash": cmd.Root().GenBashCompletion(os.Stdout) case "zsh": cmd.Root().GenZshCompletion(os.Stdout) case "fish": cmd.Root().GenFishCompletion(os.Stdout, true) } }, }
View Source
var DisableCmd = &cobra.Command{ Use: "disable", Short: "Temporarily disable kubecc in your local environment", PreRun: InitCLI, RunE: func(cmd *cobra.Command, args []string) error { kubeccHome, err := homedir.Expand("~/.kubecc") if err != nil { return err } writeEnvFileOrDie(fmt.Sprintf(envDisabled, kubeccHome)) CLILog.Info(zapkc.Yellow.Add("Kubecc disabled")) return nil }, }
View Source
var EnableCmd = &cobra.Command{ Use: "enable", Short: "Re-enable kubecc in your local environment", PreRun: InitCLI, RunE: func(cmd *cobra.Command, args []string) error { kubeccHome, err := homedir.Expand("~/.kubecc") if err != nil { return err } writeEnvFileOrDie(fmt.Sprintf(envEnabled, kubeccHome)) CLILog.Info(zapkc.Green.Add("Kubecc enabled")) return nil }, }
View Source
var ErrShellUnsupported = errors.New("Sorry, your shell is not supported yet.")
View Source
var GetCmd = &cobra.Command{
Use: "get kind [args...]",
Short: "Get information about a Kubecc cluster",
PersistentPreRun: InitCLI,
}
View Source
var SetupCmd = &cobra.Command{ Use: "setup", Short: "Set up and configure Kubecc on your machine", Long: `The setup command will configure the client-side components needed to connect to and use a kubecc cluster. This includes the consumerd service, config files, and toolchain discovery. By default, the setup command will run interactively. If you need to run setup non-interactively (i.e. through a script), you can set the following environment variables which will skip the prompts: Required: KUBECC_SETUP_SCHEDULER_ADDRESS [ip/fqdn:port to connect to the scheduler] KUBECC_SETUP_MONITOR_ADDRESS [ip/fqdn:port to connect to the monitor] Optional: KUBECC_SETUP_INSTALL_DIR [default: ~/.local/bin or /usr/local/bin] KUBECC_SETUP_CONSUMERD_LISTEN_PORT [default: 10991] KUBECC_SETUP_TLS_ENABLED [true/false, default: false] KUBECC_SETUP_SHELL_RC_CONFIG [true/false, default: true] If both of the required environment variables are set, the setup command will run non-interactively. The optional environment variables can be set to override the default values. `, PreRun: sudoPreRun, PostRun: sudoPostRun, Run: func(cmd *cobra.Command, args []string) { checkNonInteractiveConfig() binPath, result, err := installOrUpdateBinary() if err != nil { printErr(err.Error()) os.Exit(1) } sd, option, err := installConsumerd(binPath) if err != nil { printErr(err.Error()) os.Exit(1) } if result == installResultUpdated { if err := restartConsumerd(sd); err != nil { printErr(err.Error()) os.Exit(1) } } if err := checkConfig(option); err != nil { printErr(err.Error()) os.Exit(1) } InitCLIQuiet(cmd, args) if active, err := sd.IsActive(consumerdUnit); err == nil && !active { if err := startConsumerd(sd); err != nil { printErr(err.Error()) os.Exit(1) } } if sudo { return } cc, err := connectToConsumerd() if err != nil { printErr(err.Error()) os.Exit(1) } if err := setupToolchains(binPath, cc); err != nil { printErr(err.Error()) os.Exit(1) } if err := setupEnv(binPath); err != nil { printErr(err.Error()) os.Exit(1) } }, }
View Source
var StatusCmd = &cobra.Command{ Use: "status", Short: "Show overall cluster status", PersistentPreRun: InitCLI, Run: func(cmd *cobra.Command, args []string) { *CLILog = *zap.NewNop().Sugar() cc, err := servers.Dial(CLIContext, CLIConfig.MonitorAddress, servers.WithTLS(!CLIConfig.DisableTLS)) if err != nil { CLILog.Fatal(err) } client := types.NewMonitorClient(cc) cc2, err := servers.Dial(CLIContext, CLIConfig.SchedulerAddress, servers.WithTLS(!CLIConfig.DisableTLS)) if err != nil { CLILog.Fatal(err) } client2 := types.NewSchedulerClient(cc2) display := ui.NewStatusDisplay(CLIContext, client, client2) display.Run() }, }
StatusCmd represents the status command.
View Source
var TeardownCmd = &cobra.Command{ Use: "teardown", Short: "Remove an existing local kubecc installation", PreRun: sudoPreRun, PostRun: sudoPostRun, Run: func(cmd *cobra.Command, args []string) { system, user := systemdClients() options := map[string]func(){} if active, err := system.IsActive(consumerdUnit); err == nil && active { options["Consumerd service (system)"] = removeSystemConsumerd } else if _, err := os.Stat(systemServiceFilepath); err == nil { options["Consumerd service (system)"] = removeSystemConsumerd } if active, err := user.IsActive(consumerdUnit); err == nil && active { options["Consumerd service (user)"] = removeUserConsumerd } else { path, err := homedir.Expand("~/.config/systemd/user/consumerd.service") if err == nil { if _, err := os.Stat(path); err == nil { options["Consumerd service (user)"] = removeUserConsumerd } } } kubeccHome, err := homedir.Expand("~/.kubecc") if err == nil { for _, f := range configFilenames { if _, err := os.Stat(filepath.Join(kubeccHome, f)); err == nil { options["Local configuration files"] = deleteConfig break } } for _, f := range configFilenames { if _, err := os.Stat(filepath.Join("/etc/kubecc", f)); err == nil { options["System configuration files"] = deleteSystemConfig break } } if _, err := os.Stat(filepath.Join(kubeccHome, "bin")); err == nil { options["Local environment files"] = deleteEnv } else if _, err := os.Stat(filepath.Join(kubeccHome, "env")); err == nil { options["Local environment files"] = deleteEnv } } if binary, err := exec.LookPath("kubecc"); err == nil { if _, err := os.Stat(binary); err == nil { options["Kubecc binary"] = deleteBinary } } if len(options) == 0 { fmt.Println(zapkc.Green.Add("Nothing to do.")) return } keys := []string{} for k := range options { keys = append(keys, k) } selectedOptions := []string{} err = survey.AskOne(&survey.MultiSelect{ Message: "Select the components of Kubecc you would like to remove", Options: keys, }, &selectedOptions) if err != nil { printErr(err.Error()) return } for _, option := range selectedOptions { options[option]() } if entries, err := os.ReadDir(kubeccHome); err == nil { if len(entries) == 0 { os.Remove(kubeccHome) } } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.