mirror of https://github.com/k3s-io/k3s
Merge pull request #8983 from jlowdermilk/update-patch
Disable --patch for kubectl updatepull/6/head
commit
99c9c54c05
|
@ -334,12 +334,10 @@ _kubectl_update()
|
|||
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
|
||||
flags+=("--help")
|
||||
flags+=("-h")
|
||||
flags+=("--patch=")
|
||||
|
||||
must_have_one_flag=()
|
||||
must_have_one_flag+=("--filename=")
|
||||
must_have_one_flag+=("-f")
|
||||
must_have_one_flag+=("--patch=")
|
||||
must_have_one_noun=()
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ $ kubectl update -f pod.json
|
|||
|
||||
// Update a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl update -f -
|
||||
|
||||
// Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified.
|
||||
$ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'
|
||||
```
|
||||
|
||||
### Options
|
||||
|
@ -31,7 +28,6 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState":
|
|||
```
|
||||
-f, --filename=[]: Filename, directory, or URL to file to use to update the resource.
|
||||
-h, --help=false: help for update
|
||||
--patch="": A JSON document to override the existing resource. The resource is downloaded, patched with the JSON, then updated.
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
@ -66,6 +62,6 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState":
|
|||
### SEE ALSO
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.179469636 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-05-29 01:11:24.431126385 +0000 UTC
|
||||
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_update.md?pixel)]()
|
||||
|
|
|
@ -28,10 +28,6 @@ JSON and YAML formats are accepted.
|
|||
\fB\-h\fP, \fB\-\-help\fP=false
|
||||
help for update
|
||||
|
||||
.PP
|
||||
\fB\-\-patch\fP=""
|
||||
A JSON document to override the existing resource. The resource is downloaded, patched with the JSON, then updated.
|
||||
|
||||
|
||||
.SH OPTIONS INHERITED FROM PARENT COMMANDS
|
||||
.PP
|
||||
|
@ -142,9 +138,6 @@ $ kubectl update \-f pod.json
|
|||
// Update a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl update \-f \-
|
||||
|
||||
// Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified.
|
||||
$ kubectl update pods my\-pod \-\-patch='\{ "apiVersion": "v1beta1", "desiredState": \{ "manifest": [\{ "cpu": 100 \}]\}\}'
|
||||
|
||||
.fi
|
||||
.RE
|
||||
|
||||
|
|
|
@ -448,11 +448,6 @@ __EOF__
|
|||
# Post-condition:redis-master-service service is running
|
||||
kube::test::get_object_assert services "{{range.items}}{{$id_field}}:{{end}}" 'kubernetes:kubernetes-ro:redis-master:service-.*-test:'
|
||||
|
||||
# Command
|
||||
kubectl update service "${kube_flags[@]}" service-${version}-test --patch="{\"spec\":{\"selector\":{\"my\":\"test-label\"}},\"apiVersion\":\"v1beta3\"}" --api-version=v1beta3
|
||||
# Post-condition: selector has "test-label" label.
|
||||
kube::test::get_object_assert "service service-${version}-test" "{{range$service_selector_field}}{{.}}{{end}}" "test-label"
|
||||
|
||||
### Identity
|
||||
kubectl get service "${kube_flags[@]}" service-${version}-test -o json | kubectl update "${kube_flags[@]}" -f -
|
||||
|
||||
|
|
|
@ -36,10 +36,7 @@ JSON and YAML formats are accepted.`
|
|||
$ kubectl update -f pod.json
|
||||
|
||||
// Update a pod based on the JSON passed into stdin.
|
||||
$ cat pod.json | kubectl update -f -
|
||||
|
||||
// Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified.
|
||||
$ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'`
|
||||
$ cat pod.json | kubectl update -f -`
|
||||
)
|
||||
|
||||
func NewCmdUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
|
@ -57,8 +54,9 @@ func NewCmdUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||
usage := "Filename, directory, or URL to file to use to update the resource."
|
||||
kubectl.AddJsonFilenameFlag(cmd, &filenames, usage)
|
||||
cmd.MarkFlagRequired("filename")
|
||||
cmd.Flags().String("patch", "", "A JSON document to override the existing resource. The resource is downloaded, patched with the JSON, then updated.")
|
||||
cmd.MarkFlagRequired("patch")
|
||||
// TODO: re-enable --patch and make it use strategic-merge-patch
|
||||
// cmd.Flags().String("patch", "", "A JSON document to override the existing resource. The resource is downloaded, patched with the JSON, then updated.")
|
||||
// cmd.MarkFlagRequired("patch")
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
@ -73,7 +71,7 @@ func RunUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||
return err
|
||||
}
|
||||
|
||||
patch := cmdutil.GetFlagString(cmd, "patch")
|
||||
/* patch := cmdutil.GetFlagString(cmd, "patch")
|
||||
if len(filenames) == 0 && len(patch) == 0 {
|
||||
return cmdutil.UsageError(cmd, "Must specify --filename or --patch to update")
|
||||
}
|
||||
|
@ -89,6 +87,9 @@ func RunUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||
}
|
||||
fmt.Fprintf(out, "%s\n", name)
|
||||
return nil
|
||||
} */
|
||||
if len(filenames) == 0 {
|
||||
return cmdutil.UsageError(cmd, "Must specify --filename to update")
|
||||
}
|
||||
|
||||
mapper, typer := f.Object()
|
||||
|
|
|
@ -54,6 +54,46 @@ func TestMerge(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
/* TODO: uncomment this test once Merge is updated to use
|
||||
strategic-merge-patch. See #844.
|
||||
{
|
||||
kind: "Pod",
|
||||
obj: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
api.Container{
|
||||
Name: "c1",
|
||||
Image: "red-image",
|
||||
},
|
||||
api.Container{
|
||||
Name: "c2",
|
||||
Image: "blue-image",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
fragment: `{ "apiVersion": "v1beta3", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
|
||||
expected: &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
api.Container{
|
||||
Name: "c1",
|
||||
Image: "green-image",
|
||||
},
|
||||
api.Container{
|
||||
Name: "c2",
|
||||
Image: "blue-image",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, */
|
||||
{
|
||||
kind: "Pod",
|
||||
obj: &api.Pod{
|
||||
|
|
Loading…
Reference in New Issue