Record kubectl commands

This commit is contained in:
Janet Kuo
2016-01-22 10:33:23 -08:00
parent 210bac10c9
commit 5088d0e147
38 changed files with 277 additions and 11 deletions

View File

@@ -70,6 +70,7 @@ func NewCmdPatch(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringP("patch", "p", "", "The patch to be applied to the resource JSON file.")
cmd.MarkFlagRequired("patch")
cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddRecordFlag(cmd)
usage := "Filename, directory, or URL to a file identifying the resource to update"
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
@@ -124,6 +125,16 @@ func RunPatch(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
if err != nil {
return err
}
if cmdutil.ShouldRecord(cmd, info) {
patchBytes, err = cmdutil.ChangeResourcePatch(info, f.Command())
if err != nil {
return err
}
_, err = helper.Patch(namespace, name, api.StrategicMergePatchType, patchBytes)
if err != nil {
return err
}
}
cmdutil.PrintSuccess(mapper, shortOutput, out, "", name, "patched")
return nil
}