本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/server/start/kubernetes.NewCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCommand函数的具体用法?Golang NewCommand怎么用?Golang NewCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCommand函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CommandFor
// CommandFor returns the appropriate command for this base name,
// or the global OpenShift command
func CommandFor(basename string) *cobra.Command {
var cmd *cobra.Command
in, out, errout := os.Stdin, os.Stdout, os.Stderr
// Make case-insensitive and strip executable suffix if present
if runtime.GOOS == "windows" {
basename = strings.ToLower(basename)
basename = strings.TrimSuffix(basename, ".exe")
}
switch basename {
case "openshift-router":
cmd = irouter.NewCommandTemplateRouter(basename)
case "openshift-f5-router":
cmd = irouter.NewCommandF5Router(basename)
case "openshift-deploy":
cmd = deployer.NewCommandDeployer(basename)
case "openshift-recycle":
cmd = recycle.NewCommandRecycle(basename, out)
case "openshift-sti-build":
cmd = builder.NewCommandSTIBuilder(basename)
case "openshift-docker-build":
cmd = builder.NewCommandDockerBuilder(basename)
case "oc", "osc":
cmd = cli.NewCommandCLI(basename, basename, in, out, errout)
case "oadm", "osadm":
cmd = admin.NewCommandAdmin(basename, basename, out, errout)
case "kubectl":
cmd = cli.NewCmdKubectl(basename, out)
case "kube-apiserver":
cmd = kubernetes.NewAPIServerCommand(basename, basename, out)
case "kube-controller-manager":
cmd = kubernetes.NewControllersCommand(basename, basename, out)
case "kubelet":
cmd = kubernetes.NewKubeletCommand(basename, basename, out)
case "kube-proxy":
cmd = kubernetes.NewProxyCommand(basename, basename, out)
case "kube-scheduler":
cmd = kubernetes.NewSchedulerCommand(basename, basename, out)
case "kubernetes":
cmd = kubernetes.NewCommand(basename, basename, out)
case "origin", "atomic-enterprise":
cmd = NewCommandOpenShift(basename)
default:
cmd = NewCommandOpenShift("openshift")
}
if cmd.UsageFunc() == nil {
templates.ActsAsRootCommand(cmd, []string{"options"})
}
flagtypes.GLog(cmd.PersistentFlags())
return cmd
}
开发者ID:Xmagicer,项目名称:origin,代码行数:57,代码来源:openshift.go
示例2: NewCommandStartAllInOne
// NewCommandStartAllInOne provides a CLI handler for 'start' command
func NewCommandStartAllInOne(basename string, out io.Writer) (*cobra.Command, *AllInOneOptions) {
options := &AllInOneOptions{Output: out, MasterOptions: &MasterOptions{Output: out}}
options.MasterOptions.DefaultsFromName(basename)
cmds := &cobra.Command{
Use: "start",
Short: "Launch all-in-one server",
Long: fmt.Sprintf(allInOneLong, basename),
Run: func(c *cobra.Command, args []string) {
kcmdutil.CheckErr(options.Complete())
kcmdutil.CheckErr(options.Validate(args))
startProfiler()
if err := options.StartAllInOne(); err != nil {
if kerrors.IsInvalid(err) {
if details := err.(*kerrors.StatusError).ErrStatus.Details; details != nil {
fmt.Fprintf(c.OutOrStderr(), "error: Invalid %s %s\n", details.Kind, details.Name)
for _, cause := range details.Causes {
fmt.Fprintf(c.OutOrStderr(), " %s: %s\n", cause.Field, cause.Message)
}
os.Exit(255)
}
}
glog.Fatalf("Server could not start: %v", err)
}
},
}
cmds.SetOutput(out)
flags := cmds.Flags()
flags.Var(&options.ConfigDir, "write-config", "Directory to write an initial config into. After writing, exit without starting the server.")
flags.StringVar(&options.MasterOptions.ConfigFile, "master-config", "", "Location of the master configuration file to run from. When running from configuration files, all other command-line arguments are ignored.")
flags.StringVar(&options.NodeConfigFile, "node-config", "", "Location of the node configuration file to run from. When running from configuration files, all other command-line arguments are ignored.")
flags.BoolVar(&options.MasterOptions.CreateCertificates, "create-certs", true, "Indicates whether missing certs should be created.")
flags.BoolVar(&options.PrintIP, "print-ip", false, "Print the IP that would be used if no master IP is specified and exit.")
flags.StringVar(&options.ServiceNetworkCIDR, "portal-net", NewDefaultNetworkArgs().ServiceNetworkCIDR, "The CIDR string representing the network that portal/service IPs will be assigned from. This must not overlap with any IP ranges assigned to nodes for pods.")
masterArgs, nodeArgs, listenArg, imageFormatArgs, _ := GetAllInOneArgs()
options.MasterOptions.MasterArgs, options.NodeArgs = masterArgs, nodeArgs
BindMasterArgs(masterArgs, flags, "")
BindNodeArgs(nodeArgs, flags, "", false)
BindListenArg(listenArg, flags, "")
BindImageFormatArgs(imageFormatArgs, flags, "")
startMaster, _ := NewCommandStartMaster(basename, out)
startNode, _ := NewCommandStartNode(basename, out)
startNodeNetwork, _ := NewCommandStartNetwork(basename, out)
startEtcdServer, _ := NewCommandStartEtcdServer(RecommendedStartEtcdServerName, basename, out)
cmds.AddCommand(startMaster)
cmds.AddCommand(startNode)
cmds.AddCommand(startNodeNetwork)
cmds.AddCommand(startEtcdServer)
startKube := kubernetes.NewCommand("kubernetes", basename, out)
cmds.AddCommand(startKube)
// autocompletion hints
cmds.MarkFlagFilename("write-config")
cmds.MarkFlagFilename("master-config", "yaml", "yml")
cmds.MarkFlagFilename("node-config", "yaml", "yml")
return cmds, options
}
开发者ID:abhgupta,项目名称:origin,代码行数:67,代码来源:start_allinone.go
示例3: NewCommandStartAllInOne
// NewCommandStartAllInOne provides a CLI handler for 'start' command
func NewCommandStartAllInOne(fullName string, out io.Writer) (*cobra.Command, *AllInOneOptions) {
options := &AllInOneOptions{Output: out}
cmds := &cobra.Command{
Use: "start",
Short: "Launch OpenShift All-In-One",
Long: allInOneLong,
Run: func(c *cobra.Command, args []string) {
if err := options.Complete(); err != nil {
fmt.Println(kcmdutil.UsageError(c, err.Error()))
return
}
if err := options.Validate(args); err != nil {
fmt.Println(kcmdutil.UsageError(c, err.Error()))
return
}
startProfiler()
if err := options.StartAllInOne(); err != nil {
if kerrors.IsInvalid(err) {
if details := err.(*kerrors.StatusError).ErrStatus.Details; details != nil {
fmt.Fprintf(c.Out(), "Invalid %s %s\n", details.Kind, details.Name)
for _, cause := range details.Causes {
fmt.Fprintln(c.Out(), cause.Message)
}
os.Exit(255)
}
}
glog.Fatalf("OpenShift could not start: %v", err)
}
},
}
cmds.SetOutput(out)
flags := cmds.Flags()
flags.Var(&options.ConfigDir, "write-config", "Directory to write an initial config into. After writing, exit without starting the server.")
flags.StringVar(&options.MasterConfigFile, "master-config", "", "Location of the master configuration file to run from. When running from configuration files, all other command-line arguments are ignored.")
flags.StringVar(&options.NodeConfigFile, "node-config", "", "Location of the node configuration file to run from. When running from configuration files, all other command-line arguments are ignored.")
flags.BoolVar(&options.CreateCerts, "create-certs", true, "Indicates whether missing certs should be created")
masterArgs, nodeArgs, listenArg, imageFormatArgs, _ := GetAllInOneArgs()
options.MasterArgs, options.NodeArgs = masterArgs, nodeArgs
// by default, all-in-ones all disabled docker. Set it here so that if we allow it to be bound later, bindings take precedence
options.NodeArgs.AllowDisabledDocker = true
BindMasterArgs(masterArgs, flags, "")
BindNodeArgs(nodeArgs, flags, "")
BindListenArg(listenArg, flags, "")
BindImageFormatArgs(imageFormatArgs, flags, "")
startMaster, _ := NewCommandStartMaster(out)
startNode, _ := NewCommandStartNode(out)
cmds.AddCommand(startMaster)
cmds.AddCommand(startNode)
startKube := kubernetes.NewCommand("kubernetes", fullName, out)
cmds.AddCommand(startKube)
// autocompletion hints
cmds.MarkFlagFilename("write-config")
cmds.MarkFlagFilename("master-config", "yaml", "yml")
cmds.MarkFlagFilename("node-config", "yaml", "yml")
return cmds, options
}
开发者ID:brandon-adams,项目名称:origin,代码行数:68,代码来源:start_allinone.go
注:本文中的github.com/openshift/origin/pkg/cmd/server/start/kubernetes.NewCommand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论