fix kubectl set resource/selector/subject output

This commit is contained in:
xilabao
2017-05-23 15:49:07 +08:00
committed by Chen Rong
parent 2820b45caa
commit 3e5dabbff1
3 changed files with 23 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ type SelectorOptions struct {
all bool
record bool
changeCause string
output string
resources []string
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.record = cmdutil.GetRecordFlag(cmd)
o.dryrun = cmdutil.GetDryRunFlag(cmd)
o.output = cmdutil.GetFlagString(cmd, "output")
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
@@ -194,7 +196,12 @@ func (o *SelectorOptions) RunSelector() error {
}
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
})
}