mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
error msg fixes
Miscellaneous error message tweaks. Makes the error message displayed in `kubectl get` more visible. Returns exit code 1 if a patch fails.
This commit is contained in:
parent
a416534744
commit
dfef8574cf
@ -239,6 +239,7 @@ __custom_func() {
|
|||||||
* services (aka 'svc')
|
* services (aka 'svc')
|
||||||
* statefulsets
|
* statefulsets
|
||||||
* storageclasses
|
* storageclasses
|
||||||
|
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -183,6 +183,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
|||||||
|
|
||||||
if !options.Local {
|
if !options.Local {
|
||||||
dataChangedMsg := "not patched"
|
dataChangedMsg := "not patched"
|
||||||
|
didPatch := false
|
||||||
helper := resource.NewHelper(client, mapping)
|
helper := resource.NewHelper(client, mapping)
|
||||||
patchedObj, err := helper.Patch(namespace, name, patchType, patchBytes)
|
patchedObj, err := helper.Patch(namespace, name, patchType, patchBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -213,6 +214,7 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(oldData, newData) {
|
if !reflect.DeepEqual(oldData, newData) {
|
||||||
|
didPatch = true
|
||||||
dataChangedMsg = "patched"
|
dataChangedMsg = "patched"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +231,12 @@ func RunPatch(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmdutil.PrintSuccess(mapper, options.OutputFormat == "name", out, info.Mapping.Resource, info.Name, false, dataChangedMsg)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user