mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Make generation of the apply annotation optional
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user