allow output patch string in edit command

This commit is contained in:
xilabao
2017-05-19 17:47:07 +08:00
parent d81da03132
commit fe4afa8643
12 changed files with 197 additions and 1 deletions

View File

@@ -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))