mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
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:
@@ -253,7 +253,11 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
||||
}
|
||||
info.Refresh(object, true)
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user