diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 4132c1e6f75..130d349b5be 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -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=() } diff --git a/docs/kubectl_update.md b/docs/kubectl_update.md index 6029b2aee2e..84ce14f5f6b 100644 --- a/docs/kubectl_update.md +++ b/docs/kubectl_update.md @@ -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)]() diff --git a/docs/man/man1/kubectl-update.1 b/docs/man/man1/kubectl-update.1 index 2740c025edd..3441a6e09e8 100644 --- a/docs/man/man1/kubectl-update.1 +++ b/docs/man/man1/kubectl-update.1 @@ -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 diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh index 6a81355a00e..77af07c5cc5 100755 --- a/hack/test-cmd.sh +++ b/hack/test-cmd.sh @@ -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 - diff --git a/pkg/kubectl/cmd/update.go b/pkg/kubectl/cmd/update.go index 7898ddce192..52d98baa62c 100644 --- a/pkg/kubectl/cmd/update.go +++ b/pkg/kubectl/cmd/update.go @@ -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() diff --git a/pkg/kubectl/cmd/util/helpers_test.go b/pkg/kubectl/cmd/util/helpers_test.go index 5f3f14b6e63..44b1e36c5c0 100644 --- a/pkg/kubectl/cmd/util/helpers_test.go +++ b/pkg/kubectl/cmd/util/helpers_test.go @@ -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{