本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/cli/cmd.NewCmdPortForward函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCmdPortForward函数的具体用法?Golang NewCmdPortForward怎么用?Golang NewCmdPortForward使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCmdPortForward函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewCommandCLI
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
}
示例2: NewCommandCLI
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
//.........这里部分代码省略.........
示例3: NewCommandCLI
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))
}
//.........这里部分代码省略.........
示例4: NewCommandCLI
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{
//.........这里部分代码省略.........