Make generation of the apply annotation optional

This commit is contained in:
Janet Kuo
2015-11-04 13:47:08 -08:00
parent 13e68d2a87
commit a6a64820d7
24 changed files with 158 additions and 41 deletions

View File

@@ -95,6 +95,7 @@ func NewCmdEdit(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringP("output", "o", "yaml", "Output format. One of: yaml|json.")
cmd.Flags().String("output-version", "", "Output the formatted object with the given version (default api-version).")
cmd.Flags().Bool("windows-line-endings", runtime.GOOS == "windows", "Use Windows line-endings (default Unix line-endings)")
cmdutil.AddApplyAnnotationFlags(cmd)
return cmd
}
@@ -220,8 +221,12 @@ func RunEdit(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []strin
return fmt.Errorf("The edited file had a syntax error: %v", err)
}
// annotate the edited object for kubectl apply
if err := kubectl.UpdateApplyAnnotation(updates); err != nil {
// put configuration annotation in "updates"
if err := kubectl.CreateOrUpdateAnnotation(cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag), updates); err != nil {
return preservedFile(err, file, out)
}
// encode updates back to "edited" since we'll only generate patch from "edited"
if edited, err = updates.Mapping.Codec.Encode(updates.Object); err != nil {
return preservedFile(err, file, out)
}