mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
fix kubectl set resource/selector/subject output
This commit is contained in:
parent
2820b45caa
commit
3e5dabbff1
@ -70,7 +70,7 @@ type ResourcesOptions struct {
|
|||||||
Err io.Writer
|
Err io.Writer
|
||||||
Selector string
|
Selector string
|
||||||
ContainerSelector string
|
ContainerSelector string
|
||||||
ShortOutput bool
|
Output string
|
||||||
All bool
|
All bool
|
||||||
Record bool
|
Record bool
|
||||||
ChangeCause string
|
ChangeCause string
|
||||||
@ -129,7 +129,7 @@ func (o *ResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
|||||||
o.Mapper, o.Typer = f.Object()
|
o.Mapper, o.Typer = f.Object()
|
||||||
o.UpdatePodSpecForObject = f.UpdatePodSpecForObject
|
o.UpdatePodSpecForObject = f.UpdatePodSpecForObject
|
||||||
o.Encoder = f.JSONEncoder()
|
o.Encoder = f.JSONEncoder()
|
||||||
o.ShortOutput = cmdutil.GetFlagString(cmd, "output") == "name"
|
o.Output = cmdutil.GetFlagString(cmd, "output")
|
||||||
o.Record = cmdutil.GetRecordFlag(cmd)
|
o.Record = cmdutil.GetRecordFlag(cmd)
|
||||||
o.Local = cmdutil.GetFlagBool(cmd, "local")
|
o.Local = cmdutil.GetFlagBool(cmd, "local")
|
||||||
o.ChangeCause = f.Command(cmd, false)
|
o.ChangeCause = f.Command(cmd, false)
|
||||||
@ -243,7 +243,12 @@ func (o *ResourcesOptions) Run() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
cmdutil.PrintSuccess(o.Mapper, o.ShortOutput, o.Out, info.Mapping.Resource, info.Name, false, "resource requirements updated")
|
|
||||||
|
shortOutput := o.Output == "name"
|
||||||
|
if len(o.Output) > 0 && !shortOutput {
|
||||||
|
return o.PrintObject(o.Cmd, o.Local, o.Mapper, info.Object, o.Out)
|
||||||
|
}
|
||||||
|
cmdutil.PrintSuccess(o.Mapper, shortOutput, o.Out, info.Mapping.Resource, info.Name, false, "resource requirements updated")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ type SelectorOptions struct {
|
|||||||
all bool
|
all bool
|
||||||
record bool
|
record bool
|
||||||
changeCause string
|
changeCause string
|
||||||
|
output string
|
||||||
|
|
||||||
resources []string
|
resources []string
|
||||||
selector *metav1.LabelSelector
|
selector *metav1.LabelSelector
|
||||||
@ -106,6 +107,7 @@ func (o *SelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
|||||||
o.all = cmdutil.GetFlagBool(cmd, "all")
|
o.all = cmdutil.GetFlagBool(cmd, "all")
|
||||||
o.record = cmdutil.GetRecordFlag(cmd)
|
o.record = cmdutil.GetRecordFlag(cmd)
|
||||||
o.dryrun = cmdutil.GetDryRunFlag(cmd)
|
o.dryrun = cmdutil.GetDryRunFlag(cmd)
|
||||||
|
o.output = cmdutil.GetFlagString(cmd, "output")
|
||||||
|
|
||||||
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
|
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -194,7 +196,12 @@ func (o *SelectorOptions) RunSelector() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.Refresh(patched, true)
|
info.Refresh(patched, true)
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, info.Mapping.Resource, info.Name, o.dryrun, "selector updated")
|
|
||||||
|
shortOutput := o.output == "name"
|
||||||
|
if len(o.output) > 0 && !shortOutput {
|
||||||
|
return o.PrintObject(info.Object)
|
||||||
|
}
|
||||||
|
cmdutil.PrintSuccess(o.mapper, shortOutput, o.out, info.Mapping.Resource, info.Name, o.dryrun, "selector updated")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ type SubjectOptions struct {
|
|||||||
Err io.Writer
|
Err io.Writer
|
||||||
Selector string
|
Selector string
|
||||||
ContainerSelector string
|
ContainerSelector string
|
||||||
ShortOutput bool
|
Output string
|
||||||
All bool
|
All bool
|
||||||
DryRun bool
|
DryRun bool
|
||||||
Local bool
|
Local bool
|
||||||
@ -112,7 +112,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
|
|||||||
o.Local = cmdutil.GetFlagBool(cmd, "local")
|
o.Local = cmdutil.GetFlagBool(cmd, "local")
|
||||||
o.Mapper, o.Typer = f.Object()
|
o.Mapper, o.Typer = f.Object()
|
||||||
o.Encoder = f.JSONEncoder()
|
o.Encoder = f.JSONEncoder()
|
||||||
o.ShortOutput = cmdutil.GetFlagString(cmd, "output") == "name"
|
o.Output = cmdutil.GetFlagString(cmd, "output")
|
||||||
o.DryRun = cmdutil.GetDryRunFlag(cmd)
|
o.DryRun = cmdutil.GetDryRunFlag(cmd)
|
||||||
o.PrintObject = func(mapper meta.RESTMapper, obj runtime.Object, out io.Writer) error {
|
o.PrintObject = func(mapper meta.RESTMapper, obj runtime.Object, out io.Writer) error {
|
||||||
return f.PrintObject(cmd, o.Local, mapper, obj, out)
|
return f.PrintObject(cmd, o.Local, mapper, obj, out)
|
||||||
@ -235,7 +235,11 @@ func (o *SubjectOptions) Run(f cmdutil.Factory, fn updateSubjects) error {
|
|||||||
}
|
}
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
|
|
||||||
cmdutil.PrintSuccess(o.Mapper, o.ShortOutput, o.Out, info.Mapping.Resource, info.Name, false, "subjects updated")
|
shortOutput := o.Output == "name"
|
||||||
|
if len(o.Output) > 0 && !shortOutput {
|
||||||
|
return o.PrintObject(o.Mapper, info.Object, o.Out)
|
||||||
|
}
|
||||||
|
cmdutil.PrintSuccess(o.Mapper, shortOutput, o.Out, info.Mapping.Resource, info.Name, false, "subjects updated")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user