Merge pull request #4213 from smarterclayton/use_name_from_server
Use name from server when displaying create/update
This commit is contained in:
@@ -43,7 +43,7 @@ Examples:
|
||||
|
||||
$ cat pod.json | kubectl update -f -
|
||||
<update a pod based on the json passed into stdin>
|
||||
|
||||
|
||||
$ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'
|
||||
<update a pod by downloading it, applying the patch, then updating, requires apiVersion be specified>`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
@@ -68,29 +68,32 @@ Examples:
|
||||
if len(flags.Filenames) != 0 && len(patch) != 0 {
|
||||
usageError(cmd, "Can not specify both --filename and --patch")
|
||||
}
|
||||
if len(flags.Filenames) > 0 {
|
||||
err := r.Visit(func(info *resource.Info) error {
|
||||
data, err := info.Mapping.Codec.Encode(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := schema.ValidateBytes(data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := resource.NewHelper(info.Client, info.Mapping).
|
||||
Update(info.Namespace, info.Name, true, data); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", info.Name)
|
||||
return nil
|
||||
})
|
||||
checkErr(err)
|
||||
} else {
|
||||
// TODO: Make patching work with -f, updating with patched JSON input files
|
||||
|
||||
// TODO: Make patching work with -f, updating with patched JSON input files
|
||||
if len(flags.Filenames) == 0 {
|
||||
name := updateWithPatch(cmd, args, f, patch)
|
||||
fmt.Fprintf(out, "%s\n", name)
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Visit(func(info *resource.Info) error {
|
||||
data, err := info.Mapping.Codec.Encode(info.Object)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := schema.ValidateBytes(data); err != nil {
|
||||
return err
|
||||
}
|
||||
obj, err := resource.NewHelper(info.Client, info.Mapping).Update(info.Namespace, info.Name, true, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info.Refresh(obj, true)
|
||||
fmt.Fprintf(out, "%s\n", info.Name)
|
||||
return nil
|
||||
})
|
||||
checkErr(err)
|
||||
|
||||
},
|
||||
}
|
||||
cmd.Flags().VarP(&flags.Filenames, "filename", "f", "Filename, directory, or URL to file to use to update the resource")
|
||||
@@ -116,7 +119,7 @@ func updateWithPatch(cmd *cobra.Command, args []string, f *Factory, patch string
|
||||
data, err := helper.Codec.Encode(obj)
|
||||
checkErr(err)
|
||||
|
||||
err = helper.Update(namespace, name, true, data)
|
||||
obj, err = helper.Update(namespace, name, true, data)
|
||||
checkErr(err)
|
||||
return name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user