Merge pull request #31276 from juanvallejo/jvallejo_update-dry-run-create
Automatic merge from submit-queue Update kubectl create message when using --dry-run `kubectl create <resource> <name> --dry-run` provides a misleading success message. When commands such as `kubectl new-app node` are run with a `--dry-run` flag, they make this clear by appending a "(DRY RUN)" string to the final output. `kubectl create <resource> <name> --dry-run` does not do this, providing a potentially misleading output. This patch appends a "(DRY RUN)" string to the end of a successful message of `kubectl create` subcommands that support the `--dry-run` flag. `kubectl create quota quota --dry-run` ``` resourcequota "quota" created ``` `kubectl create quota quota --dry-run` ``` resourcequota "quota" created (DRY RUN) ``` **Release note**: ```release-note release-note-none ```
This commit is contained in:
commit
ea688f5e44
@ -256,7 +256,7 @@ func (o AnnotateOptions) RunAnnotate() error {
|
|||||||
return o.f.PrintObject(o.cmd, mapper, outputObj, o.out)
|
return o.f.PrintObject(o.cmd, mapper, outputObj, o.out)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdutil.PrintSuccess(mapper, false, o.out, info.Mapping.Resource, info.Name, "annotated")
|
cmdutil.PrintSuccess(mapper, false, o.out, info.Mapping.Resource, info.Name, false, "annotated")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func RunApply(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *re
|
|||||||
return cmdutil.AddSourceToErr("creating", info.Source, err)
|
return cmdutil.AddSourceToErr("creating", info.Source, err)
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "created")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "created")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ func RunApply(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *re
|
|||||||
}
|
}
|
||||||
|
|
||||||
count++
|
count++
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "configured")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "configured")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func RunAutoscale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
|
|||||||
return f.PrintObject(cmd, mapper, object, out)
|
return f.PrintObject(cmd, mapper, object, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "autoscaled")
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, cmdutil.GetDryRunFlag(cmd), "autoscaled")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,7 +140,7 @@ func RunCreate(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, options *r
|
|||||||
if !shortOutput {
|
if !shortOutput {
|
||||||
f.PrintObjectSpecificMessage(info.Object, out)
|
f.PrintObjectSpecificMessage(info.Object, out)
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "created")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "created")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -226,7 +226,7 @@ func RunCreateSubcommand(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if useShortOutput := options.OutputFormat == "name"; useShortOutput || len(options.OutputFormat) == 0 {
|
if useShortOutput := options.OutputFormat == "name"; useShortOutput || len(options.OutputFormat) == 0 {
|
||||||
cmdutil.PrintSuccess(mapper, useShortOutput, out, mapping.Resource, options.Name, "created")
|
cmdutil.PrintSuccess(mapper, useShortOutput, out, mapping.Resource, options.Name, options.DryRun, "created")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ func ReapResult(r *resource.Result, f *cmdutil.Factory, out io.Writer, isDefault
|
|||||||
return cmdutil.AddSourceToErr("stopping", info.Source, err)
|
return cmdutil.AddSourceToErr("stopping", info.Source, err)
|
||||||
}
|
}
|
||||||
if !quiet {
|
if !quiet {
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "deleted")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "deleted")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -222,6 +222,6 @@ func deleteResource(info *resource.Info, out io.Writer, shortOutput bool, mapper
|
|||||||
if err := resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name); err != nil {
|
if err := resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name); err != nil {
|
||||||
return cmdutil.AddSourceToErr("deleting", info.Source, err)
|
return cmdutil.AddSourceToErr("deleting", info.Source, err)
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "deleted")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "deleted")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ func (o *DrainOptions) RunDrain() error {
|
|||||||
if err = o.deletePods(pods); err != nil {
|
if err = o.deletePods(pods); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, "node", o.nodeInfo.Name, "drained")
|
cmdutil.PrintSuccess(o.mapper, false, o.out, "node", o.nodeInfo.Name, false, "drained")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ func (o *DrainOptions) deletePods(pods []api.Pod) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, "pod", pod.Name, "deleted")
|
cmdutil.PrintSuccess(o.mapper, false, o.out, "pod", pod.Name, false, "deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -408,7 +408,7 @@ func (o *DrainOptions) RunCordonOrUncordon(desired bool) error {
|
|||||||
if o.nodeInfo.Mapping.GroupVersionKind.Kind == "Node" {
|
if o.nodeInfo.Mapping.GroupVersionKind.Kind == "Node" {
|
||||||
unsched := reflect.ValueOf(o.nodeInfo.Object).Elem().FieldByName("Spec").FieldByName("Unschedulable")
|
unsched := reflect.ValueOf(o.nodeInfo.Object).Elem().FieldByName("Spec").FieldByName("Unschedulable")
|
||||||
if unsched.Bool() == desired {
|
if unsched.Bool() == desired {
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, already(desired))
|
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, false, already(desired))
|
||||||
} else {
|
} else {
|
||||||
helper := resource.NewHelper(o.restClient, o.nodeInfo.Mapping)
|
helper := resource.NewHelper(o.restClient, o.nodeInfo.Mapping)
|
||||||
unsched.SetBool(desired)
|
unsched.SetBool(desired)
|
||||||
@ -416,10 +416,10 @@ func (o *DrainOptions) RunCordonOrUncordon(desired bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, changed(desired))
|
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, false, changed(desired))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, "skipped")
|
cmdutil.PrintSuccess(o.mapper, false, o.out, o.nodeInfo.Mapping.Resource, o.nodeInfo.Name, false, "skipped")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -379,7 +379,7 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
|
|||||||
|
|
||||||
if reflect.DeepEqual(originalJS, editedJS) {
|
if reflect.DeepEqual(originalJS, editedJS) {
|
||||||
// no edit, so just skip it.
|
// no edit, so just skip it.
|
||||||
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "skipped")
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, false, "skipped")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ func RunEdit(f *cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
info.Refresh(patched, true)
|
info.Refresh(patched, true)
|
||||||
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "edited")
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, false, "edited")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -253,7 +253,11 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||||||
}
|
}
|
||||||
info.Refresh(object, true)
|
info.Refresh(object, true)
|
||||||
if cmdutil.GetDryRunFlag(cmd) {
|
if cmdutil.GetDryRunFlag(cmd) {
|
||||||
return f.PrintObject(cmd, mapper, object, out)
|
if len(cmdutil.GetFlagString(cmd, "output")) > 0 {
|
||||||
|
return f.PrintObject(cmd, mapper, object, out)
|
||||||
|
}
|
||||||
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, true, "exposed")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if err := kubectl.CreateOrUpdateAnnotation(cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag), info, f.JSONEncoder()); err != nil {
|
if err := kubectl.CreateOrUpdateAnnotation(cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag), info, f.JSONEncoder()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -269,7 +273,7 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||||||
return f.PrintObject(cmd, mapper, object, out)
|
return f.PrintObject(cmd, mapper, object, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, "exposed")
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, false, "exposed")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,6 +18,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -464,7 +465,7 @@ func TestRunExposeService(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
test.expected = buf.String()
|
test.expected = fmt.Sprintf("service %q exposed (dry run)", test.flags["name"])
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(out, test.expected) {
|
if !strings.Contains(out, test.expected) {
|
||||||
|
@ -294,7 +294,7 @@ func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
|||||||
if outputFormat != "" {
|
if outputFormat != "" {
|
||||||
return f.PrintObject(cmd, mapper, outputObj, out)
|
return f.PrintObject(cmd, mapper, outputObj, out)
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, dataChangeMsg)
|
cmdutil.PrintSuccess(mapper, false, out, info.Mapping.Resource, info.Name, cmdutil.GetDryRunFlag(cmd), dataChangeMsg)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ func RunPatch(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
|||||||
count++
|
count++
|
||||||
|
|
||||||
if options.OutputFormat == "name" || len(options.OutputFormat) == 0 {
|
if options.OutputFormat == "name" || len(options.OutputFormat) == 0 {
|
||||||
cmdutil.PrintSuccess(mapper, options.OutputFormat == "name", out, "", name, "patched")
|
cmdutil.PrintSuccess(mapper, options.OutputFormat == "name", out, "", name, false, "patched")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
|
|||||||
|
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
f.PrintObjectSpecificMessage(obj, out)
|
f.PrintObjectSpecificMessage(obj, out)
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "replaced")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "replaced")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ func forceReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
|
|||||||
count++
|
count++
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
f.PrintObjectSpecificMessage(obj, out)
|
f.PrintObjectSpecificMessage(obj, out)
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "replaced")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "replaced")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -388,7 +388,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, res := meta.KindToResource(kinds[0])
|
_, res := meta.KindToResource(kinds[0])
|
||||||
cmdutil.PrintSuccess(mapper, false, out, res.Resource, oldName, message)
|
cmdutil.PrintSuccess(mapper, false, out, res.Resource, oldName, dryrun, message)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,10 +133,10 @@ func (o PauseConfig) RunPause() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if isAlreadyPaused {
|
if isAlreadyPaused {
|
||||||
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, "already paused")
|
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "already paused")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, "paused")
|
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "paused")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
@ -137,10 +137,10 @@ func (o ResumeConfig) RunResume() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if isAlreadyResumed {
|
if isAlreadyResumed {
|
||||||
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, "already resumed")
|
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "already resumed")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, "resumed")
|
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "resumed")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (o *UndoOptions) RunUndo() error {
|
|||||||
allErrs = append(allErrs, cmdutil.AddSourceToErr("undoing", info.Source, err))
|
allErrs = append(allErrs, cmdutil.AddSourceToErr("undoing", info.Source, err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, result)
|
cmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, result)
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ func Run(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cob
|
|||||||
if outputFormat != "" || cmdutil.GetDryRunFlag(cmd) {
|
if outputFormat != "" || cmdutil.GetDryRunFlag(cmd) {
|
||||||
return f.PrintObject(cmd, mapper, obj, cmdOut)
|
return f.PrintObject(cmd, mapper, obj, cmdOut)
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, false, cmdOut, mapping.Resource, args[0], "created")
|
cmdutil.PrintSuccess(mapper, false, cmdOut, mapping.Resource, args[0], cmdutil.GetDryRunFlag(cmd), "created")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ func generateService(f *cmdutil.Factory, cmd *cobra.Command, args []string, serv
|
|||||||
if cmdutil.GetFlagString(cmd, "output") != "" || cmdutil.GetDryRunFlag(cmd) {
|
if cmdutil.GetFlagString(cmd, "output") != "" || cmdutil.GetDryRunFlag(cmd) {
|
||||||
return f.PrintObject(cmd, mapper, obj, out)
|
return f.PrintObject(cmd, mapper, obj, out)
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, false, out, mapping.Resource, args[0], "created")
|
cmdutil.PrintSuccess(mapper, false, out, mapping.Resource, args[0], cmdutil.GetDryRunFlag(cmd), "created")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ func RunScale(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
counter++
|
counter++
|
||||||
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "scaled")
|
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, false, "scaled")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -219,7 +219,7 @@ func (o *ImageOptions) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.Refresh(obj, true)
|
info.Refresh(obj, true)
|
||||||
cmdutil.PrintSuccess(o.Mapper, o.ShortOutput, o.Out, info.Mapping.Resource, info.Name, "image updated")
|
cmdutil.PrintSuccess(o.Mapper, o.ShortOutput, o.Out, info.Mapping.Resource, info.Name, false, "image updated")
|
||||||
}
|
}
|
||||||
return utilerrors.NewAggregate(allErrs)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ func (o TaintOptions) RunTaint() error {
|
|||||||
return o.f.PrintObject(o.cmd, mapper, outputObj, o.out)
|
return o.f.PrintObject(o.cmd, mapper, outputObj, o.out)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdutil.PrintSuccess(mapper, false, o.out, info.Mapping.Resource, info.Name, "tainted")
|
cmdutil.PrintSuccess(mapper, false, o.out, info.Mapping.Resource, info.Name, false, "tainted")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,12 @@ func AddNoHeadersFlags(cmd *cobra.Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PrintSuccess prints message after finishing mutating operations
|
// PrintSuccess prints message after finishing mutating operations
|
||||||
func PrintSuccess(mapper meta.RESTMapper, shortOutput bool, out io.Writer, resource string, name string, operation string) {
|
func PrintSuccess(mapper meta.RESTMapper, shortOutput bool, out io.Writer, resource string, name string, dryRun bool, operation string) {
|
||||||
resource, _ = mapper.ResourceSingularizer(resource)
|
resource, _ = mapper.ResourceSingularizer(resource)
|
||||||
|
dryRunMsg := ""
|
||||||
|
if dryRun {
|
||||||
|
dryRunMsg = " (dry run)"
|
||||||
|
}
|
||||||
if shortOutput {
|
if shortOutput {
|
||||||
// -o name: prints resource/name
|
// -o name: prints resource/name
|
||||||
if len(resource) > 0 {
|
if len(resource) > 0 {
|
||||||
@ -68,9 +72,9 @@ func PrintSuccess(mapper meta.RESTMapper, shortOutput bool, out io.Writer, resou
|
|||||||
} else {
|
} else {
|
||||||
// understandable output by default
|
// understandable output by default
|
||||||
if len(resource) > 0 {
|
if len(resource) > 0 {
|
||||||
fmt.Fprintf(out, "%s \"%s\" %s\n", resource, name, operation)
|
fmt.Fprintf(out, "%s \"%s\" %s%s\n", resource, name, operation, dryRunMsg)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(out, "\"%s\" %s\n", name, operation)
|
fmt.Fprintf(out, "\"%s\" %s%s\n", name, operation, dryRunMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user