mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #52450 from juanvallejo/jvallejo/misc-err-msg-improvements
Automatic merge from submit-queue (batch tested with PRs 52485, 52443, 52597, 52450, 51971). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Error message / exit code fixes **Release note**: ```release-note NONE ``` Miscellaneous error message tweaks. Makes the error message displayed in `kubectl get` more visible. Returns exit code 1 if a patch fails. Addresses the following downstream bugzillas: - https://bugzilla.redhat.com/show_bug.cgi?id=1311786 - https://bugzilla.redhat.com/show_bug.cgi?id=1414227 cc @fabianofranz @kubernetes/sig-cli-misc
This commit is contained in:
@@ -182,6 +182,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
||||
|
||||
if !options.Local {
|
||||
dataChangedMsg := "not patched"
|
||||
didPatch := false
|
||||
helper := resource.NewHelper(client, mapping)
|
||||
patchedObj, err := helper.Patch(namespace, name, patchType, patchBytes)
|
||||
if err != nil {
|
||||
@@ -212,6 +213,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
||||
return err
|
||||
}
|
||||
if !reflect.DeepEqual(oldData, newData) {
|
||||
didPatch = true
|
||||
dataChangedMsg = "patched"
|
||||
}
|
||||
|
||||
@@ -228,6 +230,12 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
||||
return err
|
||||
}
|
||||
cmdutil.PrintSuccess(mapper, options.OutputFormat == "name", out, info.Mapping.Resource, info.Name, false, dataChangedMsg)
|
||||
|
||||
// if object was not successfully patched, exit with error code 1
|
||||
if !didPatch {
|
||||
return cmdutil.ErrExit
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user