mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
allow output patch string in edit command
This commit is contained in:
@@ -52,6 +52,7 @@ type EditOptions struct {
|
||||
resource.FilenameOptions
|
||||
|
||||
Output string
|
||||
OutputPatch bool
|
||||
WindowsLineEndings bool
|
||||
|
||||
cmdutil.ValidateOptions
|
||||
@@ -95,6 +96,10 @@ func (o *EditOptions) Complete(f cmdutil.Factory, out, errOut io.Writer, args []
|
||||
}
|
||||
o.editPrinterOptions = getPrinter(o.Output)
|
||||
|
||||
if o.OutputPatch && o.EditMode != NormalEditMode {
|
||||
return fmt.Errorf("the edit mode doesn't support output the patch")
|
||||
}
|
||||
|
||||
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -452,6 +457,10 @@ func (o *EditOptions) visitToPatch(
|
||||
}
|
||||
}
|
||||
|
||||
if o.OutputPatch {
|
||||
fmt.Fprintf(o.Out, "Patch: %s\n", string(patch))
|
||||
}
|
||||
|
||||
patched, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, patchType, patch)
|
||||
if err != nil {
|
||||
fmt.Fprintln(o.ErrOut, results.addError(err, info))
|
||||
|
||||
Reference in New Issue
Block a user