func NewCommand()

in kinder/cmd/kinder/do/do.go [50:132]


func NewCommand() *cobra.Command {
	flags := &flagpole{
		Discovery: string(actions.TokenDiscovery),
	}
	cmd := &cobra.Command{
		Args: cobra.ExactArgs(1),
		Use: "do [flags] ACTION\n\n" +
			"Args:\n" +
			fmt.Sprintf("  ACTION is one of %s", actions.KnownActions()),
		Short: "Executes actions (tasks/sequence of commands) on a cluster",
		Long: "Action define a set of tasks/sequence of commands to be executed on a cluster. Usage of actions allows \n" +
			"to automate repetitive operations.",
		RunE: func(cmd *cobra.Command, args []string) error {
			return runE(flags, cmd, args)
		},
	}

	cmd.Flags().StringVar(
		&flags.Name,
		"name", constants.DefaultClusterName, "cluster name",
	)
	cmd.Flags().StringVar(&flags.OnlyNode,
		"only-node",
		"", "exec the action only on the selected node",
	)
	cmd.Flags().BoolVar(
		&flags.DryRun,
		"dry-run", false,
		"only prints workflow commands, without executing them",
	)
	cmd.Flags().BoolVar(
		&flags.UsePhases, "use-phases",
		false, "use the kubeadm phases subcommands instead of the kubeadm top-level commands",
	)
	cmd.Flags().StringVar(
		&flags.UpgradeVersion,
		"upgrade-version", "",
		"defines the target upgrade version (it should match the version of upgrades binaries)",
	)
	cmd.Flags().StringVar(
		&flags.CopyCerts,
		"copy-certs", string(actions.CopyCertsModeManual),
		fmt.Sprintf("mode to copy certs when joining new control-plane nodes; use one of %s", actions.KnownCopyCertsMode()),
	)
	cmd.Flags().StringVar(
		&flags.Discovery,
		"discovery-mode", flags.Discovery,
		fmt.Sprintf("the discovery mode to be used for join; use one of %s", actions.KnownDiscoveryMode()),
	)
	cmd.Flags().DurationVar(
		&flags.Wait,
		"wait", time.Duration(5*time.Minute),
		"Wait for cluster state to converge after action",
	)
	cmd.Flags().IntVarP(
		&flags.VLevel,
		"kubeadm-verbosity", "v", 0,
		"Number for the log level verbosity for the kubeadm commands",
	)
	cmd.Flags().StringVar(
		&flags.PatchesDir,
		"patches", flags.PatchesDir,
		"the patches directory to be used for init, join and upgrade",
	)
	cmd.Flags().StringVar(
		&flags.IgnorePreflightErrors,
		"ignore-preflight-errors", constants.KubeadmIgnorePreflightErrors,
		"list of kubeadm preflight errors to skip",
	)
	cmd.Flags().StringVar(
		&flags.KubeadmConfigVersion,
		"kubeadm-config-version", flags.KubeadmConfigVersion,
		"the kubeadm config version to be used for init, join and upgrade. "+
			"If not set, kubeadm will automatically choose the kubeadm config version "+
			"according to the Kubernetes version in use",
	)
	cmd.Flags().StringVar(
		&flags.FeatureGate,
		"kubeadm-feature-gate", "",
		"a single kubeadm feature-gate to be used for init, join and upgrade",
	)
	return cmd
}