本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util.CheckErr函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckErr函数的具体用法?Golang CheckErr怎么用?Golang CheckErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckErr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewCommandCreateBootstrapPolicyFile
func NewCommandCreateBootstrapPolicyFile(commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateBootstrapPolicyFileOptions{}
cmd := &cobra.Command{
Use: commandName,
Short: "Create the default bootstrap policy",
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
if err := options.CreateBootstrapPolicyFile(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
flags := cmd.Flags()
flags.StringVar(&options.File, "filename", DefaultPolicyFile, "The policy template file that will be written with roles and bindings.")
flags.StringVar(&options.OpenShiftSharedResourcesNamespace, "openshift-namespace", "openshift", "Namespace for shared resources.")
// autocompletion hints
cmd.MarkFlagFilename("filename")
return cmd
}
开发者ID:patrykattc,项目名称:origin,代码行数:27,代码来源:create_bootstrappolicy_file.go
示例2: NewCmdWhoCan
// NewCmdWhoCan implements the OpenShift cli who-can command
func NewCmdWhoCan(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := &whoCanOptions{}
cmd := &cobra.Command{
Use: "who-can VERB RESOURCE",
Short: "List who can perform the specified action on a resource",
Long: "List who can perform the specified action on a resource",
Run: func(cmd *cobra.Command, args []string) {
if err := options.complete(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
var err error
if options.client, _, err = f.Clients(); err != nil {
kcmdutil.CheckErr(err)
}
if options.bindingNamespace, err = f.DefaultNamespace(); err != nil {
kcmdutil.CheckErr(err)
}
if err := options.run(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
return cmd
}
开发者ID:mignev,项目名称:origin,代码行数:28,代码来源:who_can.go
示例3: NewCmdAttach
func NewCmdAttach(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
options := &AttachOptions{
In: cmdIn,
Out: cmdOut,
Err: cmdErr,
Attach: &DefaultRemoteAttach{},
}
cmd := &cobra.Command{
Use: "attach POD -c CONTAINER",
Short: "Attach to a running container.",
Long: "Attach to a a process that is already running inside an existing container.",
Example: attach_example,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(options.Complete(f, cmd, args))
cmdutil.CheckErr(options.Validate())
cmdutil.CheckErr(options.Run())
},
}
// TODO support UID
cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name")
cmd.Flags().BoolVarP(&options.Stdin, "stdin", "i", false, "Pass stdin to the container")
cmd.Flags().BoolVarP(&options.TTY, "tty", "t", false, "Stdin is a TTY")
return cmd
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:25,代码来源:attach.go
示例4: NewCmdAddSecret
// NewCmdAddSecret creates a command object for adding a secret reference to a service account
func NewCmdAddSecret(name, fullName string, f *cmdutil.Factory, out io.Writer) *cobra.Command {
o := &AddSecretOptions{Out: out}
var typeFlags util.StringList
cmd := &cobra.Command{
Use: fmt.Sprintf("%s serviceaccounts/sa-name secrets/secret-name [secrets/another-secret-name]...", name),
Short: "Add secrets to a ServiceAccount",
Long: fmt.Sprintf(addSecretLong, fullName),
Run: func(c *cobra.Command, args []string) {
if err := o.Complete(f, args, typeFlags); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(c, err.Error()))
}
if err := o.Validate(); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(c, err.Error()))
}
if err := o.AddSecrets(); err != nil {
cmdutil.CheckErr(err)
}
},
}
forFlag := &pflag.Flag{
Name: "for",
Usage: "type of secret to add: mount or pull",
Value: &typeFlags,
DefValue: "mount",
}
cmd.Flags().AddFlag(forFlag)
return cmd
}
开发者ID:cjnygard,项目名称:origin,代码行数:35,代码来源:add_secret_to_obj.go
示例5: NewCmdStop
func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command {
flags := &struct {
Filenames util.StringList
}{}
cmd := &cobra.Command{
Use: "stop (-f FILENAME | RESOURCE (NAME | -l label | --all))",
Short: "Gracefully shut down a resource by name or filename.",
Long: stop_long,
Example: stop_example,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(cmdutil.ValidateOutputArgs(cmd))
shortOutput := cmdutil.GetFlagString(cmd, "output") == "name"
cmdutil.CheckErr(RunStop(f, cmd, args, flags.Filenames, out, shortOutput))
},
}
usage := "Filename, directory, or URL to file of resource(s) to be stopped."
kubectl.AddJsonFilenameFlag(cmd, &flags.Filenames, usage)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful stop.")
cmd.Flags().Int("grace-period", -1, "Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.")
cmd.Flags().Duration("timeout", 0, "The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object")
cmdutil.AddOutputFlagsForMutation(cmd)
return cmd
}
开发者ID:pat2man,项目名称:kubernetes,代码行数:25,代码来源:stop.go
示例6: NewCmdAddSecret
// NewCmdAddSecret creates a command object for adding a secret reference to a service account
func NewCmdAddSecret(name, fullName string, f *cmdutil.Factory, out io.Writer) *cobra.Command {
o := &AddSecretOptions{Out: out}
typeFlag := "mount"
cmd := &cobra.Command{
Use: fmt.Sprintf("%s serviceaccounts/sa-name secrets/secret-name [secrets/another-secret-name]...", name),
Short: "Add secrets to a ServiceAccount",
Long: fmt.Sprintf(addSecretLong, fullName, fullName),
Run: func(c *cobra.Command, args []string) {
if err := o.Complete(f, args, typeFlag); err != nil {
cmdutil.CheckErr(err)
}
if err := o.Validate(); err != nil {
cmdutil.CheckErr(err)
}
if err := o.AddSecrets(); err != nil {
cmdutil.CheckErr(err)
}
},
}
cmd.Flags().StringVar(&typeFlag, "for", typeFlag, "type of secret to add: mount or pull")
return cmd
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:29,代码来源:addsecret_to_obj.go
示例7: NewCommandCreateKeyPair
func NewCommandCreateKeyPair(commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateKeyPairOptions{Output: out}
cmd := &cobra.Command{
Use: commandName,
Short: "Create a public/private key pair",
Long: fmt.Sprintf(createKeyPairLong, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
err := options.CreateKeyPair()
kcmdutil.CheckErr(err)
},
}
flags := cmd.Flags()
flags.StringVar(&options.PublicKeyFile, "public-key", "", "The public key file.")
flags.StringVar(&options.PrivateKeyFile, "private-key", "", "The private key file.")
flags.BoolVar(&options.Overwrite, "overwrite", false, "Overwrite existing key files if found. If false, either file existing will prevent creation.")
return cmd
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:26,代码来源:create_keypair.go
示例8: NewCommandCreateBootstrapProjectTemplate
func NewCommandCreateBootstrapProjectTemplate(f *clientcmd.Factory, commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateBootstrapProjectTemplateOptions{}
cmd := &cobra.Command{
Use: commandName,
Short: "Create a bootstrap project template",
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}
template, err := options.CreateBootstrapProjectTemplate()
if err != nil {
cmdutil.CheckErr(err)
}
err = f.Factory.PrintObject(cmd, template, out)
if err != nil {
cmdutil.CheckErr(err)
}
},
}
cmd.Flags().StringVar(&options.Name, "name", delegated.DefaultTemplateName, "The name of the template to output.")
cmdutil.AddPrinterFlags(cmd)
// Default to JSON
if flag := cmd.Flags().Lookup("output"); flag != nil {
flag.Value.Set("json")
}
return cmd
}
开发者ID:patrykattc,项目名称:origin,代码行数:33,代码来源:create_bootstrap_project_template.go
示例9: NewCmdNewProject
// NewCmdNewProject implements the OpenShift cli new-project command
func NewCmdNewProject(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := &NewProjectOptions{}
cmd := &cobra.Command{
Use: name + " NAME [--display-name=DISPLAYNAME] [--description=DESCRIPTION]",
Short: "Create a new project",
Long: newProjectLong,
Run: func(cmd *cobra.Command, args []string) {
if err := options.complete(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
var err error
if options.Client, _, err = f.Clients(); err != nil {
kcmdutil.CheckErr(err)
}
// We can't depend on len(options.NodeSelector) > 0 as node-selector="" is valid
// and we want to populate node selector as project annotation only if explicitly set by user
useNodeSelector := cmd.Flag("node-selector").Changed
if err := options.Run(useNodeSelector); err != nil {
kcmdutil.CheckErr(err)
}
},
}
cmd.Flags().StringVar(&options.AdminRole, "admin-role", bootstrappolicy.AdminRoleName, "Project admin role name in the cluster policy")
cmd.Flags().StringVar(&options.AdminUser, "admin", "", "Project admin username")
cmd.Flags().StringVar(&options.DisplayName, "display-name", "", "Project display name")
cmd.Flags().StringVar(&options.Description, "description", "", "Project description")
cmd.Flags().StringVar(&options.NodeSelector, "node-selector", "", "Restrict pods onto nodes matching given label selector. Format: '<key1>=<value1>, <key2>=<value2>...'. Specifying \"\" means any node, not default. If unspecified, cluster default node selector will be used.")
return cmd
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:36,代码来源:new_project.go
示例10: NewCommandCreateClient
func NewCommandCreateClient(commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateClientOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: out}
cmd := &cobra.Command{
Use: commandName,
Short: "Create a config file for connecting to the server as a user",
Long: createClientLong,
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
if err := options.CreateClientFolder(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
flags := cmd.Flags()
BindGetSignerCertOptions(options.GetSignerCertOptions, flags, "")
flags.StringVar(&options.ClientDir, "client-dir", "", "The client data directory.")
flags.StringVar(&options.BaseName, "basename", "", "The base filename to use for the .crt, .key, and .kubeconfig files. Defaults to the username.")
flags.StringVar(&options.User, "user", "", "The scope qualified username.")
flags.Var(&options.Groups, "groups", "The list of groups this user belongs to. Comma delimited list")
flags.StringVar(&options.APIServerURL, "master", "https://localhost:8443", "The API server's URL.")
flags.StringVar(&options.PublicAPIServerURL, "public-master", "", "The API public facing server's URL (if applicable).")
flags.StringVar(&options.APIServerCAFile, "certificate-authority", "openshift.local.config/master/ca.crt", "Path to the API server's CA file.")
return cmd
}
开发者ID:miminar,项目名称:atomic-enterprise,代码行数:34,代码来源:create_client.go
示例11: NewCmdDeploy
// NewCmdDeploy creates a new `deploy` command.
func NewCmdDeploy(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := &DeployOptions{
baseCommandName: fullName,
}
cmd := &cobra.Command{
Use: "deploy DEPLOYMENTCONFIG",
Short: "View, start, cancel, or retry a deployment",
Long: deployLong,
Example: fmt.Sprintf(deployExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Complete(f, args, out); err != nil {
cmdutil.CheckErr(err)
}
if err := options.Validate(args); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}
if err := options.RunDeploy(); err != nil {
cmdutil.CheckErr(err)
}
},
}
cmd.Flags().BoolVar(&options.deployLatest, "latest", false, "Start a new deployment now.")
cmd.Flags().BoolVar(&options.retryDeploy, "retry", false, "Retry the latest failed deployment.")
cmd.Flags().BoolVar(&options.cancelDeploy, "cancel", false, "Cancel the in-progress deployment.")
cmd.Flags().BoolVar(&options.enableTriggers, "enable-triggers", false, "Enables all image triggers for the deployment config.")
return cmd
}
开发者ID:nstrug,项目名称:origin,代码行数:33,代码来源:deploy.go
示例12: NewCommandCreateMasterCerts
func NewCommandCreateMasterCerts(commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateMasterCertsOptions{Output: out}
cmd := &cobra.Command{
Use: commandName,
Short: "Create certificates for an Atomic Enterprise master",
Long: fmt.Sprintf(masterCertLong, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
if err := options.CreateMasterCerts(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
flags := cmd.Flags()
flags.StringVar(&options.CertDir, "cert-dir", "openshift.local.config/master", "The certificate data directory.")
flags.StringVar(&options.SignerName, "signer-name", DefaultSignerName(), "The name to use for the generated signer.")
flags.StringVar(&options.APIServerURL, "master", "https://localhost:8443", "The API server's URL.")
flags.StringVar(&options.PublicAPIServerURL, "public-master", "", "The API public facing server's URL (if applicable).")
flags.Var(&options.Hostnames, "hostnames", "Every hostname or IP that server certs should be valid for (comma-delimited list)")
flags.BoolVar(&options.Overwrite, "overwrite", false, "Overwrite all existing cert/key/config files (WARNING: includes signer/CA)")
return cmd
}
开发者ID:miminar,项目名称:atomic-enterprise,代码行数:30,代码来源:create_mastercerts.go
示例13: NewCmdRollback
// NewCmdRollback creates a CLI rollback command.
func NewCmdRollback(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
opts := &RollbackOptions{}
cmd := &cobra.Command{
Use: "rollback (DEPLOYMENTCONFIG | DEPLOYMENT)",
Short: "Revert part of an application back to a previous deployment",
Long: rollbackLong,
Example: fmt.Sprintf(rollbackExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := opts.Complete(f, args, out); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}
if err := opts.Validate(); err != nil {
cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error()))
}
if err := opts.Run(); err != nil {
cmdutil.CheckErr(err)
}
},
}
cmd.Flags().BoolVar(&opts.IncludeTriggers, "change-triggers", false, "Include the previous deployment's triggers in the rollback")
cmd.Flags().BoolVar(&opts.IncludeStrategy, "change-strategy", false, "Include the previous deployment's strategy in the rollback")
cmd.Flags().BoolVar(&opts.IncludeScalingSettings, "change-scaling-settings", false, "Include the previous deployment's replicationController replica count and selector in the rollback")
cmd.Flags().BoolVarP(&opts.DryRun, "dry-run", "d", false, "Instead of performing the rollback, describe what the rollback will look like in human-readable form")
cmd.Flags().StringVarP(&opts.Format, "output", "o", "", "Instead of performing the rollback, print the updated deployment configuration in the specified format (json|yaml|template|templatefile)")
cmd.Flags().StringVarP(&opts.Template, "template", "t", "", "Template string or path to template file to use when -o=template or -o=templatefile.")
cmd.Flags().IntVar(&opts.DesiredVersion, "to-version", 0, "A config version to rollback to. Specifying version 0 is the same as omitting a version (the version will be auto-detected). This option is ignored when specifying a deployment.")
return cmd
}
开发者ID:nstrug,项目名称:origin,代码行数:33,代码来源:rollback.go
示例14: NewCmdDelete
func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
var filenames util.StringList
cmd := &cobra.Command{
Use: "delete ([-f FILENAME] | (RESOURCE [(NAME | -l label | --all)]",
Short: "Delete a resource by filename, stdin, resource and name, or by resources and label selector.",
Long: delete_long,
Example: delete_example,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(cmdutil.ValidateOutputArgs(cmd))
shortOutput := cmdutil.GetFlagString(cmd, "output") == "name"
err := RunDelete(f, out, cmd, args, filenames, shortOutput)
cmdutil.CheckErr(err)
},
}
usage := "Filename, directory, or URL to a file containing the resource to delete."
kubectl.AddJsonFilenameFlag(cmd, &filenames, usage)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful delete. Defaults to \"true\" when --all is specified.")
cmd.Flags().Bool("cascade", true, "If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.")
cmd.Flags().Int("grace-period", -1, "Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.")
cmd.Flags().Duration("timeout", 0, "The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object")
cmdutil.AddOutputFlagsForMutation(cmd)
return cmd
}
开发者ID:newstatusflowtesting,项目名称:kubernetes,代码行数:25,代码来源:delete.go
示例15: NewCommandOverwriteBootstrapPolicy
func NewCommandOverwriteBootstrapPolicy(commandName string, fullName string, createBootstrapPolicyCommand string, out io.Writer) *cobra.Command {
options := &OverwriteBootstrapPolicyOptions{Out: out}
options.CreateBootstrapPolicyCommand = createBootstrapPolicyCommand
cmd := &cobra.Command{
Use: commandName,
Short: "Reset the policy to the default values",
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
if err := options.OverwriteBootstrapPolicy(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
flags := cmd.Flags()
flags.BoolVarP(&options.Force, "force", "f", false, "You must confirm you really want to reset your policy. This will delete any custom settings you may have.")
flags.StringVar(&options.File, "filename", "", "The policy template file containing roles and bindings. One can be created with '"+createBootstrapPolicyCommand+"'.")
flags.StringVar(&options.MasterConfigFile, "master-config", "openshift.local.config/master/master-config.yaml", "Location of the master configuration file to run from in order to connect to etcd and directly modify the policy.")
// autocompletion hints
cmd.MarkFlagFilename("filename")
cmd.MarkFlagFilename("master-config", "yaml", "yml")
return cmd
}
开发者ID:dustintownsend,项目名称:origin,代码行数:30,代码来源:overwrite_bootstrappolicy.go
示例16: NewCommandCreateServerCert
func NewCommandCreateServerCert(commandName string, fullName string, out io.Writer) *cobra.Command {
options := &CreateServerCertOptions{GetSignerCertOptions: &GetSignerCertOptions{}, Output: out}
cmd := &cobra.Command{
Use: commandName,
Short: "Create a signed server certificate and key",
Long: fmt.Sprintf(createServerLong, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
}
if _, err := options.CreateServerCert(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
flags := cmd.Flags()
BindGetSignerCertOptions(options.GetSignerCertOptions, flags, "")
flags.StringVar(&options.CertFile, "cert", "", "The certificate file. Choose a name that indicates what the service is.")
flags.StringVar(&options.KeyFile, "key", "", "The key file. Choose a name that indicates what the service is.")
flags.Var(&options.Hostnames, "hostnames", "Every hostname or IP you want server certs to be valid for. Comma delimited list")
flags.BoolVar(&options.Overwrite, "overwrite", true, "Overwrite existing cert files if found. If false, any existing file will be left as-is.")
return cmd
}
开发者ID:mignev,项目名称:origin,代码行数:29,代码来源:create_servercert.go
示例17: NewCmdCreateSecret
func NewCmdCreateSecret(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := NewCreateSecretOptions()
options.Out = out
cmd := &cobra.Command{
Use: fmt.Sprintf("%s NAME [KEY=]SOURCE ...", name),
Short: "Create a new secret based on a key file or on files within a directory",
Long: newLong,
Example: fmt.Sprintf(newExamples, fullName),
Run: func(c *cobra.Command, args []string) {
cmdutil.CheckErr(options.Complete(args, f))
cmdutil.CheckErr(options.Validate())
if len(cmdutil.GetFlagString(c, "output")) != 0 {
secret, err := options.BundleSecret()
cmdutil.CheckErr(err)
cmdutil.CheckErr(f.Factory.PrintObject(c, secret, out))
return
}
_, err := options.CreateSecret()
cmdutil.CheckErr(err)
},
}
cmd.Flags().BoolVarP(&options.Quiet, "quiet", "q", options.Quiet, "Suppress warnings")
cmd.Flags().StringVar(&options.SecretTypeName, "type", "", "The type of secret")
cmdutil.AddPrinterFlags(cmd)
return cmd
}
开发者ID:mignev,项目名称:origin,代码行数:32,代码来源:new.go
示例18: NewCmdExec
func NewCmdExec(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
options := &ExecOptions{
In: cmdIn,
Out: cmdOut,
Err: cmdErr,
Executor: &DefaultRemoteExecutor{},
}
cmd := &cobra.Command{
Use: "exec POD -c CONTAINER -- COMMAND [args...]",
Short: "Execute a command in a container.",
Long: "Execute a command in a container.",
Example: exec_example,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(options.Complete(f, cmd, args))
cmdutil.CheckErr(options.Validate())
cmdutil.CheckErr(options.Run())
},
}
cmd.Flags().StringVarP(&options.PodName, "pod", "p", "", "Pod name")
// TODO support UID
cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name")
cmd.Flags().BoolVarP(&options.Stdin, "stdin", "i", false, "Pass stdin to the container")
cmd.Flags().BoolVarP(&options.TTY, "tty", "t", false, "Stdin is a TTY")
return cmd
}
开发者ID:dustintownsend,项目名称:origin,代码行数:26,代码来源:exec.go
示例19: NewCmdLogout
// NewCmdLogout implements the OpenShift cli logout command
func NewCmdLogout(name, fullName, oscLoginFullCommand string, f *osclientcmd.Factory, reader io.Reader, out io.Writer) *cobra.Command {
options := &LogoutOptions{
Out: out,
}
cmds := &cobra.Command{
Use: name,
Short: "End the current server session",
Long: fmt.Sprintf(logoutLong, oscLoginFullCommand),
Example: fmt.Sprintf(logoutExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Complete(f, cmd, args); err != nil {
kcmdutil.CheckErr(err)
}
if err := options.Validate(args); err != nil {
kcmdutil.CheckErr(err)
}
if err := options.RunLogout(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
// TODO: support --all which performs the same logic on all users in your config file.
return cmds
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:31,代码来源:logout.go
示例20: NewCmdRequestProject
func NewCmdRequestProject(name, fullName, oscLoginName, oscProjectName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := &NewProjectOptions{}
options.Out = out
cmd := &cobra.Command{
Use: fmt.Sprintf("%s NAME [--display-name=DISPLAYNAME] [--description=DESCRIPTION]", name),
Short: "Request a new project",
Long: fmt.Sprintf(requestProjectLong, oscLoginName, oscProjectName),
Example: fmt.Sprintf(requestProjectExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.complete(cmd, f); err != nil {
kcmdutil.CheckErr(err)
}
var err error
if options.Client, _, err = f.Clients(); err != nil {
kcmdutil.CheckErr(err)
}
if err := options.Run(); err != nil {
kcmdutil.CheckErr(err)
}
},
}
cmd.Flags().StringVar(&options.DisplayName, "display-name", "", "Project display name")
cmd.Flags().StringVar(&options.Description, "description", "", "Project description")
return cmd
}
开发者ID:miminar,项目名称:atomic-enterprise,代码行数:29,代码来源:request_project.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util.CheckErr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论