// NewCommandOpenShift creates the standard OpenShift command
func NewCommandOpenShift(name string) *cobra.Command {
in, out, errout := os.Stdin, os.Stdout, os.Stderr
product := "Origin"
switch name {
case "openshift":
product = "OpenShift"
case "atomic-enterprise":
product = "Atomic"
}
root := &cobra.Command{
Use: name,
Short: "Build, deploy, and manage your cloud applications",
Long: fmt.Sprintf(openshiftLong, name, product),
Run: cmdutil.DefaultSubCommandRun(out),
}
startAllInOne, _ := start.NewCommandStartAllInOne(name, out)
root.AddCommand(startAllInOne)
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", out))
root.AddCommand(cli.NewCommandCLI("cli", name+" cli", in, out, errout))
root.AddCommand(cli.NewCmdKubectl("kube", out))
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(version.NewVersionCommand(name))
// 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"),
builder.NewCommandSTIBuilder("sti-build"),
builder.NewCommandDockerBuilder("docker-build"),
)
root.AddCommand(infra)
root.AddCommand(cmd.NewCmdOptions(out))
// TODO: add groups
templates.ActsAsRootCommand(root)
return root
}
// 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
}
开发者ID:mignev,项目名称:origin,代码行数:45,代码来源:admin.go
示例7: NewCmdKubectl
// 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
}
开发者ID:kcbabo,项目名称:origin,代码行数:21,代码来源:cli.go
示例8: NewCmdKubectl
// 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
}
开发者ID:cjnygard,项目名称:origin,代码行数:21,代码来源:cli.go
示例9: NewCommandOpenShift
// NewCommandOpenShift creates the standard OpenShift command
func NewCommandOpenShift(name string) *cobra.Command {
out := os.Stdout
root := &cobra.Command{
Use: name,
Short: "OpenShift helps you build, deploy, and manage your cloud applications",
Long: openshiftLong,
Run: cmdutil.DefaultSubCommandRun(out),
}
startAllInOne, _ := start.NewCommandStartAllInOne(name, out)
root.AddCommand(startAllInOne)
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", out))
root.AddCommand(cli.NewCommandCLI("cli", name+" cli"))
root.AddCommand(cli.NewCmdKubectl("kube", out))
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(version.NewVersionCommand(name))
// 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"),
deployer.NewCommandDeployer("deploy"),
builder.NewCommandSTIBuilder("sti-build"),
builder.NewCommandDockerBuilder("docker-build"),
gitserver.NewCommandGitServer("git-server"),
)
root.AddCommand(infra)
root.AddCommand(cmd.NewCmdOptions(out))
// TODO: add groups
templates.ActsAsRootCommand(root)
return root
}
// 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
}
开发者ID:nikkomega,项目名称:origin,代码行数:24,代码来源:cli.go
示例11: NewCommandAdmin
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
}
请发表评论