本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/util.StringList類的典型用法代碼示例。如果您正苦於以下問題:Golang StringList類的具體用法?Golang StringList怎麽用?Golang StringList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了StringList類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddLabelsToColumnsFlag
// AddLabelsToColumnsFlag added a user flag to print resource labels into columns. Currently used in kubectl get command
func AddLabelsToColumnsFlag(cmd *cobra.Command, value *util.StringList, usage string) {
flag := &pflag.Flag{
Name: "label-columns",
Shorthand: "L",
Usage: usage,
Value: value,
DefValue: value.String(),
}
cmd.Flags().AddFlag(flag)
}
示例2: AddJsonFilenameFlag
func AddJsonFilenameFlag(cmd *cobra.Command, value *util.StringList, usage string) {
annotations := []string{"json", "yaml", "yml"}
annotation := make(map[string][]string)
annotation[cobra.BashCompFilenameExt] = annotations
flag := &pflag.Flag{
Name: "filename",
Shorthand: "f",
Usage: usage,
Value: value,
DefValue: value.String(),
Annotations: annotation,
}
cmd.Flags().AddFlag(flag)
}
示例3: injectUserVars
// injectUserVars injects user specified variables into the Template
func injectUserVars(cmd *cobra.Command, t *api.Template) {
values := util.StringList{}
values.Set(kcmdutil.GetFlagString(cmd, "value"))
for _, keypair := range values {
p := strings.SplitN(keypair, "=", 2)
if len(p) != 2 {
fmt.Fprintf(cmd.Out(), "invalid parameter assignment in %q: %q\n", t.Name, keypair)
continue
}
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
fmt.Fprintf(cmd.Out(), "unknown parameter name %q\n", p[0])
}
}
}