func TestKubectlCompatibility(t *testing.T) { f := clientcmd.New(pflag.NewFlagSet("name", pflag.ContinueOnError)) oc := NewCommandCLI("oc", "oc", &bytes.Buffer{}, ioutil.Discard, ioutil.Discard) kubectl := kcmd.NewKubectlCommand(f.Factory, nil, ioutil.Discard, ioutil.Discard) kubectlLoop: for _, kubecmd := range kubectl.Commands() { for _, occmd := range oc.Commands() { if kubecmd.Name() == occmd.Name() { if MissingCommands.Has(kubecmd.Name()) { t.Errorf("%s was supposed to be missing", kubecmd.Name()) continue } if WhitelistedCommands.Has(kubecmd.Name()) { t.Errorf("%s was supposed to be whitelisted", kubecmd.Name()) continue } continue kubectlLoop } } if MissingCommands.Has(kubecmd.Name()) || WhitelistedCommands.Has(kubecmd.Name()) { continue } t.Errorf("missing %q in oc", kubecmd.Name()) } }
func newExperimentalCommand(name, fullName string) *cobra.Command { out := os.Stdout experimental := &cobra.Command{ Use: name, Short: "Experimental commands under active development", Long: "The commands grouped here are under development and may change without notice.", Run: func(c *cobra.Command, args []string) { c.SetOutput(out) c.Help() }, BashCompletionFunction: admin.BashCompletionFunc, } f := clientcmd.New(experimental.PersistentFlags()) experimental.AddCommand(validate.NewCommandValidate(validate.ValidateRecommendedName, fullName+" "+validate.ValidateRecommendedName, out)) experimental.AddCommand(tokens.NewCmdTokens(tokens.TokenRecommendedCommandName, fullName+" "+tokens.TokenRecommendedCommandName, f, out)) experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out)) experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out)) experimental.AddCommand(diagnostics.NewCommandDiagnostics("diagnostics", fullName+" diagnostics", out)) experimental.AddCommand(cmd.NewCmdOptions(out)) // these groups also live under `oadm groups {sync,prune}` and are here only for backwards compatibility experimental.AddCommand(sync.NewCmdSync("sync-groups", fullName+" "+"sync-groups", f, out)) experimental.AddCommand(sync.NewCmdPrune("prune-groups", fullName+" "+"prune-groups", f, out)) return experimental }
// getFactory returns an OpenShift's Factory // It first tries to use the config that is made available when we are running in a cluster // and then fallback to a standard factory (using the default config files) func getFactory() *clientcmd.Factory { factory, err := getFactoryFromCluster() if err != nil { log.Printf("Seems like we are not running in an OpenShift environment (%s), falling back to building a std factory...", err) factory = clientcmd.New(pflag.NewFlagSet("openshift-factory", pflag.ContinueOnError)) } return factory }
// buildNetworkPodDiagnostics builds network Diagnostic objects based on the host environment. // Returns the Diagnostics built, "ok" bool for whether to proceed or abort, and an error if any was encountered during the building of diagnostics. func (o NetworkPodDiagnosticsOptions) buildNetworkPodDiagnostics() ([]types.Diagnostic, bool, []error) { diagnostics := []types.Diagnostic{} err, requestedDiagnostics := util.DetermineRequestedDiagnostics(availableNetworkPodDiagnostics.List(), o.RequestedDiagnostics, o.Logger) if err != nil { return diagnostics, false, []error{err} // don't waste time on discovery } clientFlags := flag.NewFlagSet("client", flag.ContinueOnError) // hide the extensive set of client flags factory := osclientcmd.New(clientFlags) // that would otherwise be added to this command osClient, kubeClient, clientErr := factory.Clients() if clientErr != nil { return diagnostics, false, []error{clientErr} } for _, diagnosticName := range requestedDiagnostics { switch diagnosticName { case networkdiag.CheckNodeNetworkName: diagnostics = append(diagnostics, networkdiag.CheckNodeNetwork{ KubeClient: kubeClient, }) case networkdiag.CheckPodNetworkName: diagnostics = append(diagnostics, networkdiag.CheckPodNetwork{ KubeClient: kubeClient, OSClient: osClient, }) case networkdiag.CheckExternalNetworkName: diagnostics = append(diagnostics, networkdiag.CheckExternalNetwork{}) case networkdiag.CheckServiceNetworkName: diagnostics = append(diagnostics, networkdiag.CheckServiceNetwork{ KubeClient: kubeClient, OSClient: osClient, }) case networkdiag.CollectNetworkInfoName: diagnostics = append(diagnostics, networkdiag.CollectNetworkInfo{ KubeClient: kubeClient, }) default: return diagnostics, false, []error{fmt.Errorf("unknown diagnostic: %v", diagnosticName)} } } return diagnostics, true, nil }
// NewCommandOpenShift creates the standard OpenShift command func NewCommandOpenShift(name string) *cobra.Command { in, out, errout := os.Stdin, term.NewResponsiveWriter(os.Stdout), os.Stderr root := &cobra.Command{ Use: name, Short: "Build, deploy, and manage your cloud applications", Long: fmt.Sprintf(openshiftLong, name, cmdutil.GetPlatformName(name), cmdutil.GetDistributionName(name)), Run: kcmdutil.DefaultSubCommandRun(out), } f := clientcmd.New(pflag.NewFlagSet("", pflag.ContinueOnError)) startAllInOne, _ := start.NewCommandStartAllInOne(name, out, errout) root.AddCommand(startAllInOne) root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", in, out, errout)) root.AddCommand(cli.NewCommandCLI("cli", name+" cli", in, out, errout)) root.AddCommand(cli.NewCmdKubectl("kube", out)) root.AddCommand(newExperimentalCommand("ex", name+" ex")) root.AddCommand(newCompletionCommand("completion", name+" completion")) root.AddCommand(cmd.NewCmdVersion(name, f, out, cmd.VersionOptions{PrintEtcdVersion: true, IsServer: true})) // infra commands are those that are bundled with the binary but not displayed to end users // directly infra := &cobra.Command{ Use: "infra", // Because this command exposes no description, it will not be shown in help } infra.AddCommand( irouter.NewCommandTemplateRouter("router"), irouter.NewCommandF5Router("f5-router"), deployer.NewCommandDeployer("deploy"), recycle.NewCommandRecycle("recycle", out), builder.NewCommandS2IBuilder("sti-build"), builder.NewCommandDockerBuilder("docker-build"), diagnostics.NewCommandPodDiagnostics("diagnostic-pod", out), diagnostics.NewCommandNetworkPodDiagnostics("network-diagnostic-pod", out), ) root.AddCommand(infra) root.AddCommand(cmd.NewCmdOptions(out)) // TODO: add groups templates.ActsAsRootCommand(root, []string{"options"}) return root }
func NewCommandAdmin(name, fullName string, out io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Tools for managing an OpenShift cluster", Long: fmt.Sprintf(adminLong), Run: cmdutil.DefaultSubCommandRun(out), } f := clientcmd.New(cmds.PersistentFlags()) cmds.AddCommand(project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, out)) cmds.AddCommand(policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out)) cmds.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out)) cmds.AddCommand(router.NewCmdRouter(f, fullName, "router", out)) cmds.AddCommand(registry.NewCmdRegistry(f, fullName, "registry", out)) cmds.AddCommand(buildchain.NewCmdBuildChain(f, fullName, "build-chain")) cmds.AddCommand(node.NewCommandManageNode(f, node.ManageNodeCommandName, fullName+" "+node.ManageNodeCommandName, out)) cmds.AddCommand(cmd.NewCmdConfig(fullName, "config")) cmds.AddCommand(prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, out)) // TODO: these probably belong in a sub command cmds.AddCommand(admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, out)) cmds.AddCommand(admin.NewCommandCreateBootstrapPolicyFile(admin.CreateBootstrapPolicyFileCommand, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out)) cmds.AddCommand(admin.NewCommandCreateBootstrapProjectTemplate(f, admin.CreateBootstrapProjectTemplateCommand, fullName+" "+admin.CreateBootstrapProjectTemplateCommand, out)) cmds.AddCommand(admin.NewCommandOverwriteBootstrapPolicy(admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out)) cmds.AddCommand(admin.NewCommandNodeConfig(admin.NodeConfigCommandName, fullName+" "+admin.NodeConfigCommandName, out)) // TODO: these should be rolled up together cmds.AddCommand(admin.NewCommandCreateMasterCerts(admin.CreateMasterCertsCommandName, fullName+" "+admin.CreateMasterCertsCommandName, out)) cmds.AddCommand(admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, out)) cmds.AddCommand(admin.NewCommandCreateKeyPair(admin.CreateKeyPairCommandName, fullName+" "+admin.CreateKeyPairCommandName, out)) cmds.AddCommand(admin.NewCommandCreateServerCert(admin.CreateServerCertCommandName, fullName+" "+admin.CreateServerCertCommandName, out)) cmds.AddCommand(admin.NewCommandCreateSignerCert(admin.CreateSignerCertCommandName, fullName+" "+admin.CreateSignerCertCommandName, out)) // TODO: use groups templates.ActsAsRootCommand(cmds) if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName)) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
// NewCmdDiagnostics is the base command for running any diagnostics. func NewCmdDiagnostics(name string, fullName string, out io.Writer) *cobra.Command { o := &DiagnosticsOptions{ RequestedDiagnostics: []string{}, LogOptions: &log.LoggerOptions{Out: out}, ImageTemplate: variable.NewDefaultImageTemplate(), } cmd := &cobra.Command{ Use: name, Short: "Diagnose common cluster problems", Long: fmt.Sprintf(longDescription, fullName, strings.Join(availableDiagnostics().List(), ", ")), Run: func(c *cobra.Command, args []string) { kcmdutil.CheckErr(o.Complete(args)) kcmdutil.CheckErr(o.Validate()) failed, err, warnCount, errorCount := o.RunDiagnostics() o.Logger.Summary(warnCount, errorCount) kcmdutil.CheckErr(err) if failed { os.Exit(255) } }, } cmd.SetOutput(out) // for output re: usage / help o.ClientFlags = flag.NewFlagSet("client", flag.ContinueOnError) // hide the extensive set of client flags o.Factory = osclientcmd.New(o.ClientFlags) // that would otherwise be added to this command cmd.Flags().AddFlag(o.ClientFlags.Lookup(config.OpenShiftConfigFlagName)) cmd.Flags().AddFlag(o.ClientFlags.Lookup("context")) // TODO: find k8s constant cmd.Flags().StringVar(&o.ClientClusterContext, options.FlagClusterContextName, "", "Client context to use for cluster administrator") cmd.Flags().StringVar(&o.MasterConfigLocation, options.FlagMasterConfigName, "", "Path to master config file (implies --host)") cmd.Flags().StringVar(&o.NodeConfigLocation, options.FlagNodeConfigName, "", "Path to node config file (implies --host)") cmd.Flags().BoolVar(&o.IsHost, options.FlagIsHostName, false, "If true, look for systemd and journald units even without master/node config") cmd.Flags().StringVar(&o.ImageTemplate.Format, options.FlagImageTemplateName, o.ImageTemplate.Format, "Image template for DiagnosticPod to use in creating a pod") cmd.Flags().BoolVar(&o.ImageTemplate.Latest, options.FlagLatestImageName, false, "If true, when expanding the image template, use latest version, not release version") cmd.Flags().BoolVar(&o.PreventModification, options.FlagPreventModificationName, false, "If true, may be set to prevent diagnostics making any changes via the API") cmd.Flags().StringVar(&o.NetworkDiagLogDir, options.FlagNetworkDiagLogDir, netutil.NetworkDiagDefaultLogDir, "Path to store network diagnostic results in case of errors") flagtypes.GLog(cmd.Flags()) options.BindLoggerOptionFlags(cmd.Flags(), o.LogOptions, options.RecommendedLoggerOptionFlags()) return cmd }
func newCompletionCommand(name, fullName string) *cobra.Command { out := os.Stdout completion := &cobra.Command{ Use: "completion SHELL", Short: "Output shell completion code for the given shell (bash or zsh)", Long: completion_long, Example: completion_example, Run: func(cmd *cobra.Command, args []string) { }, } f := clientcmd.New(completion.PersistentFlags()) return cmd.NewCmdCompletion(fullName, f, out) }
// NewCmdKubectl provides exactly the functionality from Kubernetes, // but with support for OpenShift resources func NewCmdKubectl(name string, out io.Writer) *cobra.Command { flags := pflag.NewFlagSet("", pflag.ContinueOnError) f := clientcmd.New(flags) cmds := kubecmd.NewKubectlCommand(f.Factory, os.Stdin, out, os.Stderr) cmds.Aliases = []string{"kubectl"} cmds.Use = name cmds.Short = "Kubernetes cluster management via kubectl" flags.VisitAll(func(flag *pflag.Flag) { if f := cmds.PersistentFlags().Lookup(flag.Name); f == nil { cmds.PersistentFlags().AddFlag(flag) } else { glog.V(5).Infof("already registered flag %s", flag.Name) } }) cmds.PersistentFlags().Var(flags.Lookup("config").Value, "kubeconfig", "Specify a kubeconfig file to define the configuration") templates.ActsAsRootCommand(cmds) cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
// NewCmdKubectl provides exactly the functionality from Kubernetes, // but with support for OpenShift resources func NewCmdKubectl(name string, out io.Writer) *cobra.Command { flags := pflag.NewFlagSet("", pflag.ContinueOnError) f := clientcmd.New(flags) cmds := kubecmd.NewKubectlCommand(f.Factory, os.Stdin, out, os.Stderr) cmds.Aliases = []string{"kubectl"} cmds.Use = name cmds.Short = "Kubernetes cluster management via kubectl" cmds.Long = cmds.Long + "\n\nThis command is provided for direct management of the Kubernetes cluster OpenShift runs on." flags.VisitAll(func(flag *pflag.Flag) { if f := cmds.PersistentFlags().Lookup(flag.Name); f == nil { cmds.PersistentFlags().AddFlag(flag) } else { glog.V(5).Infof("already registered flag %s", flag.Name) } }) templates.ActsAsRootCommand(cmds) cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
// register the tag handlers func init() { RegisterSteps(func(c *Context) { c.Before("@offline", func() { c.setNamespace("offline") c.setFactory(func() *clientcmd.Factory { flags := pflag.NewFlagSet("openshift-factory", pflag.ContinueOnError) return clientcmd.New(flags) }()) }) // @loggedInFromEnvVars performs a login using either server/username/password or server/token from env vars // it sets a factory on the context, ready to be used by other steps c.Before("@loggedInFromEnvVars", func() { server := os.Getenv(OpenShiftServerEnvVarName) username := os.Getenv(OpenShiftUsernameEnvVarName) password := os.Getenv(OpenShiftPasswordEnvVarName) token := os.Getenv(OpenShiftTokenEnvVarName) var config *kclient.Config var err error if len(token) > 0 { config, err = ValidateToken(server, token) if err != nil { log.Fatalf("Could not validate token on server '%s' (from env var '%s') with token '%.10s... [truncated]' (from env var '%s'): %v", server, OpenShiftServerEnvVarName, token, OpenShiftTokenEnvVarName, err) return } } else { config, err = Login(server, username, password) if err != nil { log.Fatalf("Could not login on server '%s' (from env var '%s') with username '%s' (from env var '%s'): %v", server, OpenShiftServerEnvVarName, username, OpenShiftUsernameEnvVarName, err) return } } factory := NewFactory(config) c.setFactory(factory) }) }) }
func newExperimentalCommand(name, fullName string) *cobra.Command { out := os.Stdout experimental := &cobra.Command{ Use: name, Short: "Experimental commands under active development", Long: "The commands grouped here are under development and may change without notice.", Run: func(c *cobra.Command, args []string) { c.SetOutput(out) c.Help() }, } f := clientcmd.New(experimental.PersistentFlags()) experimental.AddCommand(tokens.NewCmdTokens(tokens.TokenRecommendedCommandName, fullName+" "+tokens.TokenRecommendedCommandName, f, out)) experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out)) experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out)) experimental.AddCommand(cmd.NewCmdOptions(out)) return experimental }
// NewCmdKubectl provides exactly the functionality from Kubernetes, // but with support for OpenShift resources func NewCmdKubectl(name string, out io.Writer) *cobra.Command { flags := pflag.NewFlagSet("", pflag.ContinueOnError) f := clientcmd.New(flags) cmds := kubecmd.NewKubectlCommand(f.Factory, os.Stdin, out, os.Stderr) cmds.Aliases = []string{"kubectl"} cmds.Use = name cmds.Short = "Kubernetes cluster management via kubectl" cmds.Long = cmds.Long + ` This command exposes the exact semantics of the Kubernetes command line client with additional support for application lifecycles.` flags.VisitAll(func(flag *pflag.Flag) { if f := cmds.PersistentFlags().Lookup(flag.Name); f == nil { cmds.PersistentFlags().AddFlag(flag) } else { glog.V(5).Infof("already registered flag %s", flag.Name) } }) templates.ActsAsRootCommand(cmds) cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
// NewCommandDiagnostics is the base command for running any diagnostics. func NewCommandDiagnostics(name string, fullName string, out io.Writer) *cobra.Command { o := &DiagnosticsOptions{ RequestedDiagnostics: util.StringList{}, LogOptions: &log.LoggerOptions{Out: out}, } cmd := &cobra.Command{ Use: name, Short: "This utility helps you troubleshoot and diagnose.", Long: fmt.Sprintf(longDescription, fullName), Run: func(c *cobra.Command, args []string) { kcmdutil.CheckErr(o.Complete()) failed, err, warnCount, errorCount := o.RunDiagnostics() o.Logger.Summary(warnCount, errorCount) kcmdutil.CheckErr(err) if failed { os.Exit(255) } }, } cmd.SetOutput(out) // for output re: usage / help o.ClientFlags = flag.NewFlagSet("client", flag.ContinueOnError) // hide the extensive set of client flags o.Factory = osclientcmd.New(o.ClientFlags) // that would otherwise be added to this command cmd.Flags().AddFlag(o.ClientFlags.Lookup(config.OpenShiftConfigFlagName)) cmd.Flags().AddFlag(o.ClientFlags.Lookup("context")) // TODO: find k8s constant cmd.Flags().StringVar(&o.ClientClusterContext, options.FlagClusterContextName, "", "client context to use for cluster administrator") cmd.Flags().StringVar(&o.MasterConfigLocation, options.FlagMasterConfigName, "", "path to master config file (implies --host)") cmd.Flags().StringVar(&o.NodeConfigLocation, options.FlagNodeConfigName, "", "path to node config file (implies --host)") cmd.Flags().BoolVar(&o.IsHost, options.FlagIsHostName, false, "look for systemd and journald units even without master/node config") flagtypes.GLog(cmd.Flags()) options.BindLoggerOptionFlags(cmd.Flags(), o.LogOptions, options.RecommendedLoggerOptionFlags()) options.BindDiagnosticFlag(cmd.Flags(), &o.RequestedDiagnostics, options.NewRecommendedDiagnosticFlag()) return cmd }
// this only checks one level deep for nested commands, but it does ensure that we've gotten several // --validate flags. Based on that we can reasonably assume we got them in the kube commands since they // all share the same registration. func TestValidateDisabled(t *testing.T) { f := clientcmd.New(pflag.NewFlagSet("name", pflag.ContinueOnError)) oc := NewCommandCLI("oc", "oc", &bytes.Buffer{}, ioutil.Discard, ioutil.Discard) kubectl := kcmd.NewKubectlCommand(f.Factory, nil, ioutil.Discard, ioutil.Discard) for _, kubecmd := range kubectl.Commands() { for _, occmd := range oc.Commands() { if kubecmd.Name() == occmd.Name() { ocValidateFlag := occmd.Flags().Lookup("validate") if ocValidateFlag == nil { continue } if ocValidateFlag.Value.String() != "false" { t.Errorf("%s --validate is not defaulting to false", occmd.Name()) } } } } }
func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Command line tools for managing applications", Long: cliLong, Run: func(c *cobra.Command, args []string) { c.SetOutput(out) cmdutil.RequireNoArguments(c, args) fmt.Fprint(out, cliLong) fmt.Fprintf(out, cliExplain, fullName) }, BashCompletionFunction: bashCompletionFunc, } f := clientcmd.New(cmds.PersistentFlags()) loginCmd := login.NewCmdLogin(fullName, f, in, out) secretcmds := secrets.NewCmdSecrets(secrets.SecretsRecommendedName, fullName+" "+secrets.SecretsRecommendedName, f, in, out, fullName+" edit") groups := templates.CommandGroups{ { Message: "Basic Commands:", Commands: []*cobra.Command{ cmd.NewCmdTypes(fullName, f, out), loginCmd, cmd.NewCmdRequestProject(cmd.RequestProjectRecommendedCommandName, fullName, f, out), cmd.NewCmdNewApplication(cmd.NewAppRecommendedCommandName, fullName, f, out), cmd.NewCmdStatus(cmd.StatusRecommendedName, fullName, fullName+" "+cmd.StatusRecommendedName, f, out), cmd.NewCmdProject(fullName+" project", f, out), cmd.NewCmdProjects(fullName, f, out), cmd.NewCmdExplain(fullName, f, out, errout), cluster.NewCmdCluster(cluster.ClusterRecommendedName, fullName+" "+cluster.ClusterRecommendedName, f, out), cmd.NewCmdIdle(fullName, f, out, errout), }, }, { Message: "Build and Deploy Commands:", Commands: []*cobra.Command{ rollout.NewCmdRollout(fullName, f, out), cmd.NewCmdDeploy(fullName, f, out), cmd.NewCmdRollback(fullName, f, out), cmd.NewCmdNewBuild(cmd.NewBuildRecommendedCommandName, fullName, f, in, out), cmd.NewCmdStartBuild(fullName, f, in, out), cmd.NewCmdCancelBuild(cmd.CancelBuildRecommendedCommandName, fullName, f, in, out), cmd.NewCmdImportImage(fullName, f, out, errout), cmd.NewCmdTag(fullName, f, out), }, }, { Message: "Application Management Commands:", Commands: []*cobra.Command{ cmd.NewCmdGet(fullName, f, out, errout), cmd.NewCmdDescribe(fullName, f, out, errout), cmd.NewCmdEdit(fullName, f, out, errout), set.NewCmdSet(fullName, f, in, out, errout), cmd.NewCmdLabel(fullName, f, out), cmd.NewCmdAnnotate(fullName, f, out), cmd.NewCmdExpose(fullName, f, out), cmd.NewCmdDelete(fullName, f, out), cmd.NewCmdScale(fullName, f, out), cmd.NewCmdAutoscale(fullName, f, out), secretcmds, sa.NewCmdServiceAccounts(sa.ServiceAccountsRecommendedName, fullName+" "+sa.ServiceAccountsRecommendedName, f, out), }, }, { Message: "Troubleshooting and Debugging Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogs(cmd.LogsRecommendedCommandName, fullName, f, out), cmd.NewCmdRsh(cmd.RshRecommendedName, fullName, f, in, out, errout), rsync.NewCmdRsync(rsync.RsyncRecommendedName, fullName, f, out, errout), cmd.NewCmdPortForward(fullName, f, out, errout), cmd.NewCmdDebug(fullName, f, in, out, errout), cmd.NewCmdExec(fullName, f, in, out, errout), cmd.NewCmdProxy(fullName, f, out), cmd.NewCmdAttach(fullName, f, in, out, errout), cmd.NewCmdRun(fullName, f, in, out, errout), }, }, { Message: "Advanced Commands:", Commands: []*cobra.Command{ admin.NewCommandAdmin("adm", fullName+" "+"adm", in, out, errout), cmd.NewCmdCreate(fullName, f, out), cmd.NewCmdReplace(fullName, f, out), cmd.NewCmdApply(fullName, f, out), cmd.NewCmdPatch(fullName, f, out), cmd.NewCmdProcess(fullName, f, out), cmd.NewCmdExport(fullName, f, in, out), cmd.NewCmdExtract(fullName, f, in, out, errout), observe.NewCmdObserve(fullName, f, out, errout), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out), cmd.NewCmdConvert(fullName, f, out), importer.NewCmdImport(fullName, f, in, out, errout), }, }, { Message: "Settings Commands:", Commands: []*cobra.Command{ login.NewCmdLogout("logout", fullName+" logout", fullName+" login", f, in, out), cmd.NewCmdConfig(fullName, "config"), cmd.NewCmdWhoAmI(cmd.WhoAmIRecommendedCommandName, fullName+" "+cmd.WhoAmIRecommendedCommandName, f, out), cmd.NewCmdCompletion(fullName, f, out), }, }, } groups.Add(cmds) filters := []string{ "options", // These commands are deprecated and should not appear in help moved(fullName, "set env", cmds, set.NewCmdEnv(fullName, f, in, out)), moved(fullName, "set volume", cmds, set.NewCmdVolume(fullName, f, out, errout)), moved(fullName, "logs", cmds, cmd.NewCmdBuildLogs(fullName, f, out)), moved(fullName, "secrets link", secretcmds, secrets.NewCmdLinkSecret("add", fullName, f.Factory, out)), } changeSharedFlagDefaults(cmds) templates.ActsAsRootCommand(cmds, filters, groups...). ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify", "token") // experimental commands are those that are bundled with the binary but not displayed to end users // directly experimental := &cobra.Command{ Use: "ex", // Because this command exposes no description, it will not be shown in help } experimental.AddCommand( dockerbuild.NewCmdDockerbuild(fullName, f, out, errout), ) cmds.AddCommand(experimental) if name == fullName { cmds.AddCommand(cmd.NewCmdVersion(fullName, f, out, cmd.VersionOptions{PrintClientFeatures: true})) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
func NewCommandAdmin(name, fullName string, in io.Reader, out io.Writer, errout io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Tools for managing a cluster", Long: fmt.Sprintf(adminLong), Run: kcmdutil.DefaultSubCommandRun(out), } f := clientcmd.New(cmds.PersistentFlags()) groups := templates.CommandGroups{ { Message: "Component Installation:", Commands: []*cobra.Command{ router.NewCmdRouter(f, fullName, "router", out, errout), exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout), registry.NewCmdRegistry(f, fullName, "registry", out, errout), }, }, { Message: "Security and Policy:", Commands: []*cobra.Command{ project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, out), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out, errout), groups.NewCmdGroups(groups.GroupsRecommendedName, fullName+" "+groups.GroupsRecommendedName, f, out, errout), cert.NewCmdCert(cert.CertRecommendedName, fullName+" "+cert.CertRecommendedName, out, errout), admin.NewCommandOverwriteBootstrapPolicy(admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), }, }, { Message: "Node Management:", Commands: []*cobra.Command{ admin.NewCommandNodeConfig(admin.NodeConfigCommandName, fullName+" "+admin.NodeConfigCommandName, out), node.NewCommandManageNode(f, node.ManageNodeCommandName, fullName+" "+node.ManageNodeCommandName, out, errout), cmdutil.ReplaceCommandName("kubectl", fullName, templates.Normalize(kubectl.NewCmdCordon(f, out))), cmdutil.ReplaceCommandName("kubectl", fullName, templates.Normalize(kubectl.NewCmdUncordon(f, out))), cmdutil.ReplaceCommandName("kubectl", fullName, templates.Normalize(kubectl.NewCmdDrain(f, out, errout))), cmdutil.ReplaceCommandName("kubectl", fullName, templates.Normalize(kubectl.NewCmdTaint(f, out))), network.NewCmdPodNetwork(network.PodNetworkCommandName, fullName+" "+network.PodNetworkCommandName, f, out, errout), }, }, { Message: "Maintenance:", Commands: []*cobra.Command{ diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out), prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, out, errout), buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out), migrate.NewCommandMigrate( migrate.MigrateRecommendedName, fullName+" "+migrate.MigrateRecommendedName, f, out, errout, // Migration commands migrateimages.NewCmdMigrateImageReferences("image-references", fullName+" "+migrate.MigrateRecommendedName+" image-references", f, in, out, errout), migratestorage.NewCmdMigrateAPIStorage("storage", fullName+" "+migrate.MigrateRecommendedName+" storage", f, in, out, errout), ), top.NewCommandTop(top.TopRecommendedName, fullName+" "+top.TopRecommendedName, f, out, errout), }, }, { Message: "Configuration:", Commands: []*cobra.Command{ admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, out), admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, out), admin.NewCommandCreateBootstrapProjectTemplate(f, admin.CreateBootstrapProjectTemplateCommand, fullName+" "+admin.CreateBootstrapProjectTemplateCommand, out), admin.NewCommandCreateBootstrapPolicyFile(admin.CreateBootstrapPolicyFileCommand, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), admin.NewCommandCreateLoginTemplate(f, admin.CreateLoginTemplateCommand, fullName+" "+admin.CreateLoginTemplateCommand, out), admin.NewCommandCreateProviderSelectionTemplate(f, admin.CreateProviderSelectionTemplateCommand, fullName+" "+admin.CreateProviderSelectionTemplateCommand, out), admin.NewCommandCreateErrorTemplate(f, admin.CreateErrorTemplateCommand, fullName+" "+admin.CreateErrorTemplateCommand, out), }, }, } groups.Add(cmds) templates.ActsAsRootCommand(cmds, []string{"options"}, groups...) // Deprecated commands that are bundled with the binary but not displayed to end users directly deprecatedCommands := []*cobra.Command{ admin.NewCommandCreateMasterCerts(admin.CreateMasterCertsCommandName, fullName+" "+admin.CreateMasterCertsCommandName, out), admin.NewCommandCreateKeyPair(admin.CreateKeyPairCommandName, fullName+" "+admin.CreateKeyPairCommandName, out), admin.NewCommandCreateServerCert(admin.CreateServerCertCommandName, fullName+" "+admin.CreateServerCertCommandName, out), admin.NewCommandCreateSignerCert(admin.CreateSignerCertCommandName, fullName+" "+admin.CreateSignerCertCommandName, out), } for _, cmd := range deprecatedCommands { // Unsetting Short description will not show this command in help cmd.Short = "" cmd.Deprecated = fmt.Sprintf("Use '%s ca' instead.", fullName) cmds.AddCommand(cmd) } cmds.AddCommand( // part of every root command cmd.NewCmdConfig(fullName, "config", out, errout), cmd.NewCmdCompletion(fullName, f, out), // hidden cmd.NewCmdOptions(out), ) if name == fullName { cmds.AddCommand(cmd.NewCmdVersion(fullName, f, out, cmd.VersionOptions{})) } return cmds }
func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Command line tools for managing applications", Long: cliLong, Run: func(c *cobra.Command, args []string) { c.SetOutput(out) cmdutil.RequireNoArguments(c, args) fmt.Fprint(out, cliLong) fmt.Fprintf(out, cliExplain, fullName) }, BashCompletionFunction: bashCompletionFunc, } f := clientcmd.New(cmds.PersistentFlags()) loginCmd := cmd.NewCmdLogin(fullName, f, in, out) groups := templates.CommandGroups{ { Message: "Basic Commands:", Commands: []*cobra.Command{ cmd.NewCmdTypes(fullName, f, out), loginCmd, cmd.NewCmdRequestProject(fullName, "new-project", fullName+" login", fullName+" project", f, out), cmd.NewCmdNewApplication(fullName, f, out), cmd.NewCmdStatus(cmd.StatusRecommendedName, fullName+" "+cmd.StatusRecommendedName, f, out), cmd.NewCmdProject(fullName+" project", f, out), cmd.NewCmdExplain(fullName, f, out), }, }, { Message: "Build and Deploy Commands:", Commands: []*cobra.Command{ cmd.NewCmdDeploy(fullName, f, out), cmd.NewCmdRollback(fullName, f, out), cmd.NewCmdNewBuild(fullName, f, in, out), cmd.NewCmdStartBuild(fullName, f, in, out), cmd.NewCmdCancelBuild(fullName, f, out), cmd.NewCmdImportImage(fullName, f, out), cmd.NewCmdTag(fullName, f, out), }, }, { Message: "Application Management Commands:", Commands: []*cobra.Command{ cmd.NewCmdGet(fullName, f, out), cmd.NewCmdDescribe(fullName, f, out), cmd.NewCmdEdit(fullName, f, out), set.NewCmdSet(fullName, f, in, out, errout), cmd.NewCmdLabel(fullName, f, out), cmd.NewCmdAnnotate(fullName, f, out), cmd.NewCmdExpose(fullName, f, out), cmd.NewCmdDelete(fullName, f, out), cmd.NewCmdScale(fullName, f, out), cmd.NewCmdAutoscale(fullName, f, out), secrets.NewCmdSecrets(secrets.SecretsRecommendedName, fullName+" "+secrets.SecretsRecommendedName, f, in, out, fullName+" edit"), }, }, { Message: "Troubleshooting and Debugging Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogs(cmd.LogsRecommendedName, fullName, f, out), cmd.NewCmdRsh(cmd.RshRecommendedName, fullName, f, in, out, errout), rsync.NewCmdRsync(rsync.RsyncRecommendedName, fullName, f, out, errout), cmd.NewCmdExec(fullName, f, in, out, errout), cmd.NewCmdPortForward(fullName, f), cmd.NewCmdProxy(fullName, f, out), cmd.NewCmdAttach(fullName, f, in, out, errout), cmd.NewCmdRun(fullName, f, in, out, errout), }, }, { Message: "Advanced Commands:", Commands: []*cobra.Command{ admin.NewCommandAdmin("adm", fullName+" "+"adm", out), cmd.NewCmdCreate(fullName, f, out), cmd.NewCmdReplace(fullName, f, out), cmd.NewCmdApply(fullName, f, out), cmd.NewCmdPatch(fullName, f, out), cmd.NewCmdProcess(fullName, f, out), cmd.NewCmdExport(fullName, f, in, out), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out), cmd.NewCmdConvert(fullName, f, out), }, }, { Message: "Settings Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogout("logout", fullName+" logout", fullName+" login", f, in, out), cmd.NewCmdConfig(fullName, "config"), cmd.NewCmdWhoAmI(cmd.WhoAmIRecommendedCommandName, fullName+" "+cmd.WhoAmIRecommendedCommandName, f, out), }, }, } groups.Add(cmds) filters := []string{ "options", // These commands are deprecated and should not appear in help moved(fullName, "set env", cmds, set.NewCmdEnv(fullName, f, in, out)), moved(fullName, "set volume", cmds, set.NewCmdVolume(fullName, f, out, errout)), moved(fullName, "logs", cmds, cmd.NewCmdBuildLogs(fullName, f, out)), } changeSharedFlagDefaults(cmds) templates.ActsAsRootCommand(cmds, filters, groups...). ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify", "token") if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName, false)) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
func NewCommandCLI(name, fullName string) *cobra.Command { in := os.Stdin out := os.Stdout // Main command cmds := &cobra.Command{ Use: name, Short: "Client tools for OpenShift", Long: fmt.Sprintf(cliLong, fullName), Run: cmdutil.DefaultSubCommandRun(out), BashCompletionFunction: bashCompletionFunc, } f := clientcmd.New(cmds.PersistentFlags()) loginCmd := cmd.NewCmdLogin(fullName, f, in, out) groups := templates.CommandGroups{ { Message: "Basic Commands:", Commands: []*cobra.Command{ cmd.NewCmdTypes(fullName, f, out), loginCmd, cmd.NewCmdRequestProject("new-project", fullName+" new-project", fullName+" login", fullName+" project", f, out), cmd.NewCmdNewApplication(fullName, f, out), cmd.NewCmdStatus(fullName, f, out), cmd.NewCmdProject(fullName+" project", f, out), }, }, { Message: "Build and Deploy Commands:", Commands: []*cobra.Command{ cmd.NewCmdStartBuild(fullName, f, out), cmd.NewCmdBuildLogs(fullName, f, out), cmd.NewCmdDeploy(fullName, f, out), cmd.NewCmdRollback(fullName, f, out), cmd.NewCmdNewBuild(fullName, f, out), cmd.NewCmdCancelBuild(fullName, f, out), cmd.NewCmdImportImage(fullName, f, out), cmd.NewCmdScale(fullName, f, out), cmd.NewCmdTag(fullName, f, out), }, }, { Message: "Application Modification Commands:", Commands: []*cobra.Command{ cmd.NewCmdGet(fullName, f, out), cmd.NewCmdDescribe(fullName, f, out), cmd.NewCmdEdit(fullName, f, out), cmd.NewCmdEnv(fullName, f, os.Stdin, out), cmd.NewCmdVolume(fullName, f, out), cmd.NewCmdLabel(fullName, f, out), cmd.NewCmdExpose(fullName, f, out), cmd.NewCmdStop(fullName, f, out), cmd.NewCmdDelete(fullName, f, out), }, }, { Message: "Troubleshooting and Debugging Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogs(fullName, f, out), cmd.NewCmdExec(fullName, f, os.Stdin, out, os.Stderr), cmd.NewCmdPortForward(fullName, f), cmd.NewCmdProxy(fullName, f, out), }, }, { Message: "Advanced Commands:", Commands: []*cobra.Command{ cmd.NewCmdCreate(fullName, f, out), cmd.NewCmdUpdate(fullName, f, out), cmd.NewCmdProcess(fullName, f, out), cmd.NewCmdExport(fullName, f, os.Stdin, out), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out), secrets.NewCmdSecrets(secrets.SecretsRecommendedName, fullName+" "+secrets.SecretsRecommendedName, f, out, fullName+" edit"), }, }, { Message: "Settings Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogout("logout", fullName+" logout", fullName+" login", f, in, out), cmd.NewCmdConfig(fullName, "config"), cmd.NewCmdWhoAmI(cmd.WhoAmIRecommendedCommandName, fullName+" "+cmd.WhoAmIRecommendedCommandName, f, out), }, }, } groups.Add(cmds) templates.ActsAsRootCommand(cmds, groups...). ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify") if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName)) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
func NewCommandAdmin(name, fullName string, out io.Writer, errout io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Tools for managing a cluster", Long: fmt.Sprintf(adminLong), Run: cmdutil.DefaultSubCommandRun(out), } f := clientcmd.New(cmds.PersistentFlags()) groups := templates.CommandGroups{ { Message: "Basic Commands:", Commands: []*cobra.Command{ project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, out), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out, errout), groups.NewCmdGroups(groups.GroupsRecommendedName, fullName+" "+groups.GroupsRecommendedName, f, out), }, }, { Message: "Install Commands:", Commands: []*cobra.Command{ router.NewCmdRouter(f, fullName, "router", out), exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout), registry.NewCmdRegistry(f, fullName, "registry", out), }, }, { Message: "Maintenance Commands:", Commands: []*cobra.Command{ buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out), diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out), node.NewCommandManageNode(f, node.ManageNodeCommandName, fullName+" "+node.ManageNodeCommandName, out, errout), prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, out), }, }, { Message: "Settings Commands:", Commands: []*cobra.Command{ cmd.NewCmdConfig(fullName, "config"), // TODO: these probably belong in a sub command admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, out), admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, out), cmd.NewCmdCompletion(fullName, f, out), }, }, { Message: "Advanced Commands:", Commands: []*cobra.Command{ network.NewCmdPodNetwork(network.PodNetworkCommandName, fullName+" "+network.PodNetworkCommandName, f, out), admin.NewCommandCreateBootstrapProjectTemplate(f, admin.CreateBootstrapProjectTemplateCommand, fullName+" "+admin.CreateBootstrapProjectTemplateCommand, out), admin.NewCommandCreateBootstrapPolicyFile(admin.CreateBootstrapPolicyFileCommand, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), admin.NewCommandCreateLoginTemplate(f, admin.CreateLoginTemplateCommand, fullName+" "+admin.CreateLoginTemplateCommand, out), admin.NewCommandCreateProviderSelectionTemplate(f, admin.CreateProviderSelectionTemplateCommand, fullName+" "+admin.CreateProviderSelectionTemplateCommand, out), admin.NewCommandCreateErrorTemplate(f, admin.CreateErrorTemplateCommand, fullName+" "+admin.CreateErrorTemplateCommand, out), admin.NewCommandOverwriteBootstrapPolicy(admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), admin.NewCommandNodeConfig(admin.NodeConfigCommandName, fullName+" "+admin.NodeConfigCommandName, out), cert.NewCmdCert(cert.CertRecommendedName, fullName+" "+cert.CertRecommendedName, out, errout), }, }, } groups.Add(cmds) templates.ActsAsRootCommand(cmds, []string{"options"}, groups...) // Deprecated commands that are bundled with the binary but not displayed to end users directly deprecatedCommands := []*cobra.Command{ admin.NewCommandCreateMasterCerts(admin.CreateMasterCertsCommandName, fullName+" "+admin.CreateMasterCertsCommandName, out), admin.NewCommandCreateKeyPair(admin.CreateKeyPairCommandName, fullName+" "+admin.CreateKeyPairCommandName, out), admin.NewCommandCreateServerCert(admin.CreateServerCertCommandName, fullName+" "+admin.CreateServerCertCommandName, out), admin.NewCommandCreateSignerCert(admin.CreateSignerCertCommandName, fullName+" "+admin.CreateSignerCertCommandName, out), } for _, cmd := range deprecatedCommands { // Unsetting Short description will not show this command in help cmd.Short = "" cmd.Deprecated = fmt.Sprintf("Use '%s ca' instead.", fullName) cmds.AddCommand(cmd) } if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName, false)) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }
func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *cobra.Command { // Main command cmds := &cobra.Command{ Use: name, Short: "Command line tools for managing applications", Long: fmt.Sprintf(cliLong, fullName), Run: cmdutil.DefaultSubCommandRun(out), BashCompletionFunction: bashCompletionFunc, } f := clientcmd.New(cmds.PersistentFlags()) loginCmd := cmd.NewCmdLogin(fullName, f, in, out) groups := templates.CommandGroups{ { Message: "Basic Commands:", Commands: []*cobra.Command{ cmd.NewCmdTypes(fullName, f, out), loginCmd, cmd.NewCmdRequestProject("new-project", fullName+" new-project", fullName+" login", fullName+" project", f, out), cmd.NewCmdNewApplication(fullName, f, out), cmd.NewCmdStatus(cmd.StatusRecommendedName, fullName+" "+cmd.StatusRecommendedName, f, out), cmd.NewCmdProject(fullName+" project", f, out), }, }, { Message: "Build and Deploy Commands:", Commands: []*cobra.Command{ cmd.NewCmdStartBuild(fullName, f, in, out), cmd.NewCmdBuildLogs(fullName, f, out), cmd.NewCmdDeploy(fullName, f, out), cmd.NewCmdRollback(fullName, f, out), cmd.NewCmdNewBuild(fullName, f, in, out), cmd.NewCmdCancelBuild(fullName, f, out), cmd.NewCmdImportImage(fullName, f, out), cmd.NewCmdScale(fullName, f, out), cmd.NewCmdTag(fullName, f, out), }, }, { Message: "Application Modification Commands:", Commands: []*cobra.Command{ cmd.NewCmdGet(fullName, f, out), cmd.NewCmdDescribe(fullName, f, out), cmd.NewCmdEdit(fullName, f, out), cmd.NewCmdEnv(fullName, f, in, out), cmd.NewCmdVolume(fullName, f, out, errout), cmd.NewCmdLabel(fullName, f, out), cmd.NewCmdAnnotate(fullName, f, out), cmd.NewCmdExpose(fullName, f, out), cmd.NewCmdStop(fullName, f, out), cmd.NewCmdDelete(fullName, f, out), }, }, { Message: "Troubleshooting and Debugging Commands:", Commands: []*cobra.Command{ cmd.NewCmdExplain(fullName, f, out), cmd.NewCmdLogs(fullName, f, out), cmd.NewCmdRsh(cmd.RshRecommendedName, fullName, f, in, out, errout), cmd.NewCmdRsync(cmd.RsyncRecommendedName, fullName, f, out, errout), cmd.NewCmdExec(fullName, f, in, out, errout), cmd.NewCmdPortForward(fullName, f), cmd.NewCmdProxy(fullName, f, out), }, }, { Message: "Advanced Commands:", Commands: []*cobra.Command{ cmd.NewCmdCreate(fullName, f, out), cmd.NewCmdReplace(fullName, f, out), // TODO decide what to do about apply. Its doing unusual things // cmd.NewCmdApply(fullName, f, out), cmd.NewCmdPatch(fullName, f, out), cmd.NewCmdProcess(fullName, f, out), cmd.NewCmdExport(fullName, f, in, out), cmd.NewCmdRun(fullName, f, in, out, errout), cmd.NewCmdAttach(fullName, f, in, out, errout), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out), secrets.NewCmdSecrets(secrets.SecretsRecommendedName, fullName+" "+secrets.SecretsRecommendedName, f, in, out, fullName+" edit"), cmd.NewCmdConvert(fullName, f, out), }, }, { Message: "Settings Commands:", Commands: []*cobra.Command{ cmd.NewCmdLogout("logout", fullName+" logout", fullName+" login", f, in, out), cmd.NewCmdConfig(fullName, "config"), cmd.NewCmdWhoAmI(cmd.WhoAmIRecommendedCommandName, fullName+" "+cmd.WhoAmIRecommendedCommandName, f, out), }, }, } groups.Add(cmds) changeSharedFlagDefaults(cmds) templates.ActsAsRootCommand(cmds, groups...). ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify") if name == fullName { cmds.AddCommand(version.NewVersionCommand(fullName, false)) } cmds.AddCommand(cmd.NewCmdOptions(out)) return cmds }