cmd

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 38 Imported by: 21

Documentation

Overview

Package cmd implements clusterctl commands.

Index

Constants

View Source
const (
	// RepositoriesOutputYaml is an option used to print the repository list in yaml format.
	RepositoriesOutputYaml = "yaml"
	// RepositoriesOutputText is an option used to print the repository list in text format.
	RepositoriesOutputText = "text"
)

Variables

View Source
var (
	// RepositoriesOutputs is a list of valid repository list outputs.
	RepositoriesOutputs = []string{RepositoriesOutputYaml, RepositoriesOutputText}
)
View Source
var RootCmd = &cobra.Command{
	Use:          "clusterctl",
	SilenceUsage: true,
	Short:        "clusterctl controls the lifecyle of a Cluster API management cluster",
	Long: LongDesc(`
		Get started with Cluster API using clusterctl to create a management cluster,
		install providers, and create templates for your workload cluster.`),
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		configFolderPath := filepath.Join(homedir.HomeDir(), config.ConfigFolder)
		if _, err := os.Stat(configFolderPath); os.IsNotExist(err) {
			if err := os.MkdirAll(filepath.Dir(configFolderPath), os.ModePerm); err != nil {
				return errors.Wrapf(err, "failed to create the clusterctl config directory: %s", configFolderPath)
			}
		}
		return nil
	},
	PersistentPostRunE: func(cmd *cobra.Command, args []string) error {

		configClient, err := config.New(cfgFile)
		if err != nil {
			return err
		}
		output, err := newVersionChecker(configClient.Variables()).Check()
		if err != nil {
			return errors.Wrap(err, "unable to verify clusterctl version")
		}
		if len(output) != 0 {

			fmt.Fprintf(os.Stderr, "\033[33m%s\033[0m", output)
		}

		downloadConfigFile := filepath.Join(homedir.HomeDir(), config.ConfigFolder, config.DownloadConfigFile)
		if _, err := os.Stat(downloadConfigFile); err == nil {
			if verbosity != nil && *verbosity >= 5 {
				fmt.Fprintf(os.Stdout, "Removing downloaded clusterctl config file: %s\n", config.DownloadConfigFile)
			}
			_ = os.Remove(downloadConfigFile)
		}

		return nil
	},
}

RootCmd is clusterctl root CLI command.

Functions

func Examples added in v0.3.0

func Examples(s string) string

Examples normalizes a command's examples to follow the conventions.

func Execute

func Execute()

Execute executes the root command.

func GetSupportedShells added in v0.3.10

func GetSupportedShells() []string

GetSupportedShells returns a list of supported shells.

func LongDesc added in v0.3.0

func LongDesc(s string) string

LongDesc normalizes a command's long description to follow the conventions.

Types

type ReleaseInfo added in v0.3.9

type ReleaseInfo struct {
	Version string
	URL     string
}

ReleaseInfo stores information about the release.

type Version added in v0.3.0

type Version struct {
	ClientVersion *version.Info `json:"clusterctl"`
}

Version provides the version information of clusterctl.

type VersionState added in v0.3.9

type VersionState struct {
	LastCheck     time.Time
	LatestRelease ReleaseInfo
}

VersionState stores the release info and the last time it was updated.

Directories

Path Synopsis
Package rollout implements the clusterctl rollout command.
Package rollout implements the clusterctl rollout command.

Jump to

Keyboard shortcuts

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