mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Add 'kubectl set image'
This commit is contained in:
@@ -101,7 +101,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
usage := "Filename, directory, or URL to a file identifying the resource to update the labels"
|
||||
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
|
||||
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
|
||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it.")
|
||||
cmdutil.AddDryRunFlag(cmd)
|
||||
cmdutil.AddRecordFlag(cmd)
|
||||
cmdutil.AddInclude3rdPartyFlags(cmd)
|
||||
|
||||
@@ -176,21 +176,9 @@ func labelFunc(obj runtime.Object, overwrite bool, resourceVersion string, label
|
||||
}
|
||||
|
||||
func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string, options *LabelOptions) error {
|
||||
resources, labelArgs := []string{}, []string{}
|
||||
first := true
|
||||
for _, s := range args {
|
||||
isLabel := strings.Contains(s, "=") || strings.HasSuffix(s, "-")
|
||||
switch {
|
||||
case first && isLabel:
|
||||
first = false
|
||||
fallthrough
|
||||
case !first && isLabel:
|
||||
labelArgs = append(labelArgs, s)
|
||||
case first && !isLabel:
|
||||
resources = append(resources, s)
|
||||
case !first && !isLabel:
|
||||
return cmdutil.UsageError(cmd, "all resources must be specified before label changes: %s", s)
|
||||
}
|
||||
resources, labelArgs, err := cmdutil.GetResourcesAndPairs(args, "label")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(resources) < 1 && len(options.Filenames) == 0 {
|
||||
return cmdutil.UsageError(cmd, "one or more resources must be specified as <resource> <name> or <resource>/<name>")
|
||||
@@ -242,7 +230,7 @@ func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
||||
|
||||
var outputObj runtime.Object
|
||||
dataChangeMsg := "not labeled"
|
||||
if cmdutil.GetFlagBool(cmd, "dry-run") {
|
||||
if cmdutil.GetDryRunFlag(cmd) {
|
||||
err = labelFunc(info.Object, overwrite, resourceVersion, lbls, remove)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user