diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4cc13107..2afd7fd9 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -50,9 +50,13 @@ "ImportPath": "github.com/docker/spdystream/spdy", "Rev": "449fdfce4d962303d702fec724ef0ad181c92528" }, + { + "ImportPath": "github.com/evanphx/json-patch", + "Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4" + }, { "ImportPath": "github.com/ghodss/yaml", - "Rev": "c7ce16629ff4cd059ed96ed06419dd3856fd3577" + "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" }, { "ImportPath": "github.com/gogo/protobuf/proto", @@ -268,339 +272,339 @@ }, { "ImportPath": "gopkg.in/yaml.v2", - "Rev": "5420a8b6744d3b0345ab293f6fcba19c978f1183" + "Rev": "670d4cfef0544295bc27a114dbac37980d83185a" }, { "ImportPath": "k8s.io/api/admissionregistration/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/admissionregistration/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/apps/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/apps/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/apps/v1beta2", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/authentication/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/authentication/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/authorization/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/authorization/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/autoscaling/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/autoscaling/v2beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/autoscaling/v2beta2", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/batch/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/batch/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/batch/v2alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/certificates/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/coordination/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/core/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/events/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/extensions/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/imagepolicy/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/networking/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/policy/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/rbac/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/rbac/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/rbac/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/scheduling/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/scheduling/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/settings/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/storage/v1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/storage/v1alpha1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/api/storage/v1beta1", - "Rev": "bbf5c193d86c33256702fc781833463a7bca7849" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/equality", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/errors", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/meta", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/resource", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/conversion", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/fields", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/labels", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/selection", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/types", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/cache", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/clock", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/diff", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/errors", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/framer", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/intstr", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/json", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/naming", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/net", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/runtime", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/sets", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/validation", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/wait", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/util/yaml", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/version", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/pkg/watch", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", - "Rev": "dcb88206cd7f3654b224cbfc244e41126f52a13b" + "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", diff --git a/dynamic/fake/simple.go b/dynamic/fake/simple.go index c04b7883..eec3cfbc 100644 --- a/dynamic/fake/simple.go +++ b/dynamic/fake/simple.go @@ -331,25 +331,26 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface, panic("math broke") } +// TODO: opts are currently ignored. func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { var uncastRet runtime.Object var err error switch { case len(c.namespace) == 0 && len(subresources) == 0: uncastRet, err = c.client.Fake. - Invokes(testing.NewRootPatchAction(c.resource, name, data), &metav1.Status{Status: "dynamic patch fail"}) + Invokes(testing.NewRootPatchAction(c.resource, name, pt, data), &metav1.Status{Status: "dynamic patch fail"}) case len(c.namespace) == 0 && len(subresources) > 0: uncastRet, err = c.client.Fake. - Invokes(testing.NewRootPatchSubresourceAction(c.resource, name, data, subresources...), &metav1.Status{Status: "dynamic patch fail"}) + Invokes(testing.NewRootPatchSubresourceAction(c.resource, name, pt, data, subresources...), &metav1.Status{Status: "dynamic patch fail"}) case len(c.namespace) > 0 && len(subresources) == 0: uncastRet, err = c.client.Fake. - Invokes(testing.NewPatchAction(c.resource, c.namespace, name, data), &metav1.Status{Status: "dynamic patch fail"}) + Invokes(testing.NewPatchAction(c.resource, c.namespace, name, pt, data), &metav1.Status{Status: "dynamic patch fail"}) case len(c.namespace) > 0 && len(subresources) > 0: uncastRet, err = c.client.Fake. - Invokes(testing.NewPatchSubresourceAction(c.resource, c.namespace, name, data, subresources...), &metav1.Status{Status: "dynamic patch fail"}) + Invokes(testing.NewPatchSubresourceAction(c.resource, c.namespace, name, pt, data, subresources...), &metav1.Status{Status: "dynamic patch fail"}) } diff --git a/dynamic/fake/simple_test.go b/dynamic/fake/simple_test.go index cb79c30b..f0991956 100644 --- a/dynamic/fake/simple_test.go +++ b/dynamic/fake/simple_test.go @@ -17,6 +17,7 @@ limitations under the License. package fake import ( + "fmt" "testing" "k8s.io/apimachinery/pkg/api/equality" @@ -24,9 +25,20 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/diff" ) +const ( + testGroup = "testgroup" + testVersion = "testversion" + testResource = "testkinds" + testNamespace = "testns" + testName = "testname" + testKind = "TestKind" + testAPIVersion = "testgroup/testversion" +) + func newUnstructured(apiVersion, kind, namespace, name string) *unstructured.Unstructured { return &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -40,6 +52,12 @@ func newUnstructured(apiVersion, kind, namespace, name string) *unstructured.Uns } } +func newUnstructuredWithSpec(spec map[string]interface{}) *unstructured.Unstructured { + u := newUnstructured(testAPIVersion, testKind, testNamespace, testName) + u.Object["spec"] = spec + return u +} + func TestList(t *testing.T) { scheme := runtime.NewScheme() @@ -64,3 +82,116 @@ func TestList(t *testing.T) { t.Fatal(diff.ObjectGoPrintDiff(expected, listFirst.Items)) } } + +type patchTestCase struct { + name string + object runtime.Object + patchType types.PatchType + patchBytes []byte + wantErrMsg string + expectedPatchedObject runtime.Object +} + +func (tc *patchTestCase) runner(t *testing.T) { + client := NewSimpleDynamicClient(runtime.NewScheme(), tc.object) + resourceInterface := client.Resource(schema.GroupVersionResource{Group: testGroup, Version: testVersion, Resource: testResource}).Namespace(testNamespace) + + got, recErr := resourceInterface.Patch(testName, tc.patchType, tc.patchBytes, metav1.UpdateOptions{}) + + if err := tc.verifyErr(recErr); err != nil { + t.Error(err) + } + + if err := tc.verifyResult(got); err != nil { + t.Error(err) + } + +} + +// verifyErr verifies that the given error returned from Patch is the error +// expected by the test case. +func (tc *patchTestCase) verifyErr(err error) error { + if tc.wantErrMsg != "" && err == nil { + return fmt.Errorf("want error, got nil") + } + + if tc.wantErrMsg == "" && err != nil { + return fmt.Errorf("want no error, got %v", err) + } + + if err != nil { + if want, got := tc.wantErrMsg, err.Error(); want != got { + return fmt.Errorf("incorrect error: want: %q got: %q", want, got) + } + } + return nil +} + +func (tc *patchTestCase) verifyResult(result *unstructured.Unstructured) error { + if tc.expectedPatchedObject == nil && result == nil { + return nil + } + if !equality.Semantic.DeepEqual(result, tc.expectedPatchedObject) { + return fmt.Errorf("unexpected diff in received object: %s", diff.ObjectGoPrintDiff(tc.expectedPatchedObject, result)) + } + return nil +} + +func TestPatch(t *testing.T) { + testCases := []patchTestCase{ + { + name: "jsonpatch fails with merge type", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + patchType: types.StrategicMergePatchType, + patchBytes: []byte(`[]`), + wantErrMsg: "invalid JSON document", + }, { + name: "jsonpatch works with empty patch", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + patchType: types.JSONPatchType, + // No-op + patchBytes: []byte(`[]`), + expectedPatchedObject: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + }, { + name: "jsonpatch works with simple change patch", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + patchType: types.JSONPatchType, + // change spec.foo from bar to foobar + patchBytes: []byte(`[{"op": "replace", "path": "/spec/foo", "value": "foobar"}]`), + expectedPatchedObject: newUnstructuredWithSpec(map[string]interface{}{"foo": "foobar"}), + }, { + name: "jsonpatch works with simple addition", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + patchType: types.JSONPatchType, + // add spec.newvalue = dummy + patchBytes: []byte(`[{"op": "add", "path": "/spec/newvalue", "value": "dummy"}]`), + expectedPatchedObject: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar", "newvalue": "dummy"}), + }, { + name: "jsonpatch works with simple deletion", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar", "toremove": "shouldnotbehere"}), + patchType: types.JSONPatchType, + // remove spec.newvalue = dummy + patchBytes: []byte(`[{"op": "remove", "path": "/spec/toremove"}]`), + expectedPatchedObject: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + }, { + name: "strategic merge patch fails with JSONPatch", + object: newUnstructuredWithSpec(map[string]interface{}{"foo": "bar"}), + patchType: types.StrategicMergePatchType, + // add spec.newvalue = dummy + patchBytes: []byte(`[{"op": "add", "path": "/spec/newvalue", "value": "dummy"}]`), + wantErrMsg: "invalid JSON document", + }, { + name: "merge patch fails as unsupported", + object: newUnstructured(testAPIVersion, testKind, testNamespace, testName), + patchType: types.MergePatchType, + patchBytes: []byte(`{}`), + wantErrMsg: "PatchType is not supported", + }, + // TODO: Add tests for strategic merge using v1.Pod for example to ensure the test cases + // demonstrate expected use cases. + } + + for _, tc := range testCases { + t.Run(tc.name, tc.runner) + } +} diff --git a/kubernetes/typed/admissionregistration/v1alpha1/fake/fake_initializerconfiguration.go b/kubernetes/typed/admissionregistration/v1alpha1/fake/fake_initializerconfiguration.go index b927dae2..4baee661 100644 --- a/kubernetes/typed/admissionregistration/v1alpha1/fake/fake_initializerconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1alpha1/fake/fake_initializerconfiguration.go @@ -112,7 +112,7 @@ func (c *FakeInitializerConfigurations) DeleteCollection(options *v1.DeleteOptio // Patch applies the patch and returns the patched initializerConfiguration. func (c *FakeInitializerConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.InitializerConfiguration, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(initializerconfigurationsResource, name, data, subresources...), &v1alpha1.InitializerConfiguration{}) + Invokes(testing.NewRootPatchSubresourceAction(initializerconfigurationsResource, name, pt, data, subresources...), &v1alpha1.InitializerConfiguration{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/fake_mutatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/fake/fake_mutatingwebhookconfiguration.go index e06888cc..d2177bad 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/fake_mutatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/fake_mutatingwebhookconfiguration.go @@ -112,7 +112,7 @@ func (c *FakeMutatingWebhookConfigurations) DeleteCollection(options *v1.DeleteO // Patch applies the patch and returns the patched mutatingWebhookConfiguration. func (c *FakeMutatingWebhookConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MutatingWebhookConfiguration, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(mutatingwebhookconfigurationsResource, name, data, subresources...), &v1beta1.MutatingWebhookConfiguration{}) + Invokes(testing.NewRootPatchSubresourceAction(mutatingwebhookconfigurationsResource, name, pt, data, subresources...), &v1beta1.MutatingWebhookConfiguration{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/admissionregistration/v1beta1/fake/fake_validatingwebhookconfiguration.go b/kubernetes/typed/admissionregistration/v1beta1/fake/fake_validatingwebhookconfiguration.go index 1069634e..6be2b393 100644 --- a/kubernetes/typed/admissionregistration/v1beta1/fake/fake_validatingwebhookconfiguration.go +++ b/kubernetes/typed/admissionregistration/v1beta1/fake/fake_validatingwebhookconfiguration.go @@ -112,7 +112,7 @@ func (c *FakeValidatingWebhookConfigurations) DeleteCollection(options *v1.Delet // Patch applies the patch and returns the patched validatingWebhookConfiguration. func (c *FakeValidatingWebhookConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ValidatingWebhookConfiguration, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(validatingwebhookconfigurationsResource, name, data, subresources...), &v1beta1.ValidatingWebhookConfiguration{}) + Invokes(testing.NewRootPatchSubresourceAction(validatingwebhookconfigurationsResource, name, pt, data, subresources...), &v1beta1.ValidatingWebhookConfiguration{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/apps/v1/fake/fake_controllerrevision.go b/kubernetes/typed/apps/v1/fake/fake_controllerrevision.go index fc2808da..eb38bca4 100644 --- a/kubernetes/typed/apps/v1/fake/fake_controllerrevision.go +++ b/kubernetes/typed/apps/v1/fake/fake_controllerrevision.go @@ -119,7 +119,7 @@ func (c *FakeControllerRevisions) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched controllerRevision. func (c *FakeControllerRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsv1.ControllerRevision, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, data, subresources...), &appsv1.ControllerRevision{}) + Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, pt, data, subresources...), &appsv1.ControllerRevision{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1/fake/fake_daemonset.go b/kubernetes/typed/apps/v1/fake/fake_daemonset.go index 89e72ebd..c06336e9 100644 --- a/kubernetes/typed/apps/v1/fake/fake_daemonset.go +++ b/kubernetes/typed/apps/v1/fake/fake_daemonset.go @@ -131,7 +131,7 @@ func (c *FakeDaemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched daemonSet. func (c *FakeDaemonSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsv1.DaemonSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, data, subresources...), &appsv1.DaemonSet{}) + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, pt, data, subresources...), &appsv1.DaemonSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1/fake/fake_deployment.go b/kubernetes/typed/apps/v1/fake/fake_deployment.go index 2fbd82d6..a5786fd5 100644 --- a/kubernetes/typed/apps/v1/fake/fake_deployment.go +++ b/kubernetes/typed/apps/v1/fake/fake_deployment.go @@ -131,7 +131,7 @@ func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched deployment. func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsv1.Deployment, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &appsv1.Deployment{}) + Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, pt, data, subresources...), &appsv1.Deployment{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1/fake/fake_replicaset.go b/kubernetes/typed/apps/v1/fake/fake_replicaset.go index 7b882c86..d6a7c059 100644 --- a/kubernetes/typed/apps/v1/fake/fake_replicaset.go +++ b/kubernetes/typed/apps/v1/fake/fake_replicaset.go @@ -131,7 +131,7 @@ func (c *FakeReplicaSets) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched replicaSet. func (c *FakeReplicaSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsv1.ReplicaSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, data, subresources...), &appsv1.ReplicaSet{}) + Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, pt, data, subresources...), &appsv1.ReplicaSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1/fake/fake_statefulset.go b/kubernetes/typed/apps/v1/fake/fake_statefulset.go index 3cd643a5..0682a999 100644 --- a/kubernetes/typed/apps/v1/fake/fake_statefulset.go +++ b/kubernetes/typed/apps/v1/fake/fake_statefulset.go @@ -131,7 +131,7 @@ func (c *FakeStatefulSets) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched statefulSet. func (c *FakeStatefulSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsv1.StatefulSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, data, subresources...), &appsv1.StatefulSet{}) + Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, pt, data, subresources...), &appsv1.StatefulSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta1/fake/fake_controllerrevision.go b/kubernetes/typed/apps/v1beta1/fake/fake_controllerrevision.go index 92419489..8e339d78 100644 --- a/kubernetes/typed/apps/v1beta1/fake/fake_controllerrevision.go +++ b/kubernetes/typed/apps/v1beta1/fake/fake_controllerrevision.go @@ -119,7 +119,7 @@ func (c *FakeControllerRevisions) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched controllerRevision. func (c *FakeControllerRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ControllerRevision, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, data, subresources...), &v1beta1.ControllerRevision{}) + Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, pt, data, subresources...), &v1beta1.ControllerRevision{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta1/fake/fake_deployment.go b/kubernetes/typed/apps/v1beta1/fake/fake_deployment.go index c4749c52..c33baba5 100644 --- a/kubernetes/typed/apps/v1beta1/fake/fake_deployment.go +++ b/kubernetes/typed/apps/v1beta1/fake/fake_deployment.go @@ -131,7 +131,7 @@ func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched deployment. func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &v1beta1.Deployment{}) + Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, pt, data, subresources...), &v1beta1.Deployment{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go b/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go index b0f194a7..754da5fb 100644 --- a/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go +++ b/kubernetes/typed/apps/v1beta1/fake/fake_statefulset.go @@ -131,7 +131,7 @@ func (c *FakeStatefulSets) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched statefulSet. func (c *FakeStatefulSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.StatefulSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, data, subresources...), &v1beta1.StatefulSet{}) + Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, pt, data, subresources...), &v1beta1.StatefulSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta2/fake/fake_controllerrevision.go b/kubernetes/typed/apps/v1beta2/fake/fake_controllerrevision.go index 954ac35d..197f190c 100644 --- a/kubernetes/typed/apps/v1beta2/fake/fake_controllerrevision.go +++ b/kubernetes/typed/apps/v1beta2/fake/fake_controllerrevision.go @@ -119,7 +119,7 @@ func (c *FakeControllerRevisions) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched controllerRevision. func (c *FakeControllerRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.ControllerRevision, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, data, subresources...), &v1beta2.ControllerRevision{}) + Invokes(testing.NewPatchSubresourceAction(controllerrevisionsResource, c.ns, name, pt, data, subresources...), &v1beta2.ControllerRevision{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta2/fake/fake_daemonset.go b/kubernetes/typed/apps/v1beta2/fake/fake_daemonset.go index 38a14755..b50747fd 100644 --- a/kubernetes/typed/apps/v1beta2/fake/fake_daemonset.go +++ b/kubernetes/typed/apps/v1beta2/fake/fake_daemonset.go @@ -131,7 +131,7 @@ func (c *FakeDaemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched daemonSet. func (c *FakeDaemonSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.DaemonSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, data, subresources...), &v1beta2.DaemonSet{}) + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, pt, data, subresources...), &v1beta2.DaemonSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta2/fake/fake_deployment.go b/kubernetes/typed/apps/v1beta2/fake/fake_deployment.go index cae23224..b74d24ed 100644 --- a/kubernetes/typed/apps/v1beta2/fake/fake_deployment.go +++ b/kubernetes/typed/apps/v1beta2/fake/fake_deployment.go @@ -131,7 +131,7 @@ func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched deployment. func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.Deployment, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &v1beta2.Deployment{}) + Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, pt, data, subresources...), &v1beta2.Deployment{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta2/fake/fake_replicaset.go b/kubernetes/typed/apps/v1beta2/fake/fake_replicaset.go index 05fa7893..ba1de33e 100644 --- a/kubernetes/typed/apps/v1beta2/fake/fake_replicaset.go +++ b/kubernetes/typed/apps/v1beta2/fake/fake_replicaset.go @@ -131,7 +131,7 @@ func (c *FakeReplicaSets) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched replicaSet. func (c *FakeReplicaSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.ReplicaSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, data, subresources...), &v1beta2.ReplicaSet{}) + Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, pt, data, subresources...), &v1beta2.ReplicaSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/apps/v1beta2/fake/fake_statefulset.go b/kubernetes/typed/apps/v1beta2/fake/fake_statefulset.go index fe785128..652c7cbc 100644 --- a/kubernetes/typed/apps/v1beta2/fake/fake_statefulset.go +++ b/kubernetes/typed/apps/v1beta2/fake/fake_statefulset.go @@ -131,7 +131,7 @@ func (c *FakeStatefulSets) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched statefulSet. func (c *FakeStatefulSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta2.StatefulSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, data, subresources...), &v1beta2.StatefulSet{}) + Invokes(testing.NewPatchSubresourceAction(statefulsetsResource, c.ns, name, pt, data, subresources...), &v1beta2.StatefulSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/autoscaling/v1/fake/fake_horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v1/fake/fake_horizontalpodautoscaler.go index 7df83437..6a4bf988 100644 --- a/kubernetes/typed/autoscaling/v1/fake/fake_horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v1/fake/fake_horizontalpodautoscaler.go @@ -131,7 +131,7 @@ func (c *FakeHorizontalPodAutoscalers) DeleteCollection(options *v1.DeleteOption // Patch applies the patch and returns the patched horizontalPodAutoscaler. func (c *FakeHorizontalPodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *autoscalingv1.HorizontalPodAutoscaler, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, data, subresources...), &autoscalingv1.HorizontalPodAutoscaler{}) + Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, pt, data, subresources...), &autoscalingv1.HorizontalPodAutoscaler{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/autoscaling/v2beta1/fake/fake_horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta1/fake/fake_horizontalpodautoscaler.go index 2d860341..514a787c 100644 --- a/kubernetes/typed/autoscaling/v2beta1/fake/fake_horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta1/fake/fake_horizontalpodautoscaler.go @@ -131,7 +131,7 @@ func (c *FakeHorizontalPodAutoscalers) DeleteCollection(options *v1.DeleteOption // Patch applies the patch and returns the patched horizontalPodAutoscaler. func (c *FakeHorizontalPodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2beta1.HorizontalPodAutoscaler, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, data, subresources...), &v2beta1.HorizontalPodAutoscaler{}) + Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v2beta1.HorizontalPodAutoscaler{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/autoscaling/v2beta2/fake/fake_horizontalpodautoscaler.go b/kubernetes/typed/autoscaling/v2beta2/fake/fake_horizontalpodautoscaler.go index a19b86e2..c0569f00 100644 --- a/kubernetes/typed/autoscaling/v2beta2/fake/fake_horizontalpodautoscaler.go +++ b/kubernetes/typed/autoscaling/v2beta2/fake/fake_horizontalpodautoscaler.go @@ -131,7 +131,7 @@ func (c *FakeHorizontalPodAutoscalers) DeleteCollection(options *v1.DeleteOption // Patch applies the patch and returns the patched horizontalPodAutoscaler. func (c *FakeHorizontalPodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2beta2.HorizontalPodAutoscaler, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, data, subresources...), &v2beta2.HorizontalPodAutoscaler{}) + Invokes(testing.NewPatchSubresourceAction(horizontalpodautoscalersResource, c.ns, name, pt, data, subresources...), &v2beta2.HorizontalPodAutoscaler{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/batch/v1/fake/fake_job.go b/kubernetes/typed/batch/v1/fake/fake_job.go index f12619bb..06dc25c6 100644 --- a/kubernetes/typed/batch/v1/fake/fake_job.go +++ b/kubernetes/typed/batch/v1/fake/fake_job.go @@ -131,7 +131,7 @@ func (c *FakeJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li // Patch applies the patch and returns the patched job. func (c *FakeJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *batchv1.Job, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, name, data, subresources...), &batchv1.Job{}) + Invokes(testing.NewPatchSubresourceAction(jobsResource, c.ns, name, pt, data, subresources...), &batchv1.Job{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/batch/v1beta1/fake/fake_cronjob.go b/kubernetes/typed/batch/v1beta1/fake/fake_cronjob.go index d80ef5e6..3985c403 100644 --- a/kubernetes/typed/batch/v1beta1/fake/fake_cronjob.go +++ b/kubernetes/typed/batch/v1beta1/fake/fake_cronjob.go @@ -131,7 +131,7 @@ func (c *FakeCronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v // Patch applies the patch and returns the patched cronJob. func (c *FakeCronJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CronJob, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, name, data, subresources...), &v1beta1.CronJob{}) + Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, name, pt, data, subresources...), &v1beta1.CronJob{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/batch/v2alpha1/fake/fake_cronjob.go b/kubernetes/typed/batch/v2alpha1/fake/fake_cronjob.go index 75c0b173..2195027d 100644 --- a/kubernetes/typed/batch/v2alpha1/fake/fake_cronjob.go +++ b/kubernetes/typed/batch/v2alpha1/fake/fake_cronjob.go @@ -131,7 +131,7 @@ func (c *FakeCronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v // Patch applies the patch and returns the patched cronJob. func (c *FakeCronJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2alpha1.CronJob, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, name, data, subresources...), &v2alpha1.CronJob{}) + Invokes(testing.NewPatchSubresourceAction(cronjobsResource, c.ns, name, pt, data, subresources...), &v2alpha1.CronJob{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest.go b/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest.go index dfd51719..aa45c880 100644 --- a/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest.go +++ b/kubernetes/typed/certificates/v1beta1/fake/fake_certificatesigningrequest.go @@ -123,7 +123,7 @@ func (c *FakeCertificateSigningRequests) DeleteCollection(options *v1.DeleteOpti // Patch applies the patch and returns the patched certificateSigningRequest. func (c *FakeCertificateSigningRequests) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CertificateSigningRequest, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(certificatesigningrequestsResource, name, data, subresources...), &v1beta1.CertificateSigningRequest{}) + Invokes(testing.NewRootPatchSubresourceAction(certificatesigningrequestsResource, name, pt, data, subresources...), &v1beta1.CertificateSigningRequest{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/coordination/v1beta1/fake/fake_lease.go b/kubernetes/typed/coordination/v1beta1/fake/fake_lease.go index 3204e029..0ebf3bff 100644 --- a/kubernetes/typed/coordination/v1beta1/fake/fake_lease.go +++ b/kubernetes/typed/coordination/v1beta1/fake/fake_lease.go @@ -119,7 +119,7 @@ func (c *FakeLeases) DeleteCollection(options *v1.DeleteOptions, listOptions v1. // Patch applies the patch and returns the patched lease. func (c *FakeLeases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Lease, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(leasesResource, c.ns, name, data, subresources...), &v1beta1.Lease{}) + Invokes(testing.NewPatchSubresourceAction(leasesResource, c.ns, name, pt, data, subresources...), &v1beta1.Lease{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_componentstatus.go b/kubernetes/typed/core/v1/fake/fake_componentstatus.go index d06023d4..18beedc2 100644 --- a/kubernetes/typed/core/v1/fake/fake_componentstatus.go +++ b/kubernetes/typed/core/v1/fake/fake_componentstatus.go @@ -112,7 +112,7 @@ func (c *FakeComponentStatuses) DeleteCollection(options *v1.DeleteOptions, list // Patch applies the patch and returns the patched componentStatus. func (c *FakeComponentStatuses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.ComponentStatus, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(componentstatusesResource, name, data, subresources...), &corev1.ComponentStatus{}) + Invokes(testing.NewRootPatchSubresourceAction(componentstatusesResource, name, pt, data, subresources...), &corev1.ComponentStatus{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/core/v1/fake/fake_configmap.go b/kubernetes/typed/core/v1/fake/fake_configmap.go index b491661f..2361ac3f 100644 --- a/kubernetes/typed/core/v1/fake/fake_configmap.go +++ b/kubernetes/typed/core/v1/fake/fake_configmap.go @@ -119,7 +119,7 @@ func (c *FakeConfigMaps) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched configMap. func (c *FakeConfigMaps) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.ConfigMap, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(configmapsResource, c.ns, name, data, subresources...), &corev1.ConfigMap{}) + Invokes(testing.NewPatchSubresourceAction(configmapsResource, c.ns, name, pt, data, subresources...), &corev1.ConfigMap{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_endpoints.go b/kubernetes/typed/core/v1/fake/fake_endpoints.go index 2c9f0de0..d521af40 100644 --- a/kubernetes/typed/core/v1/fake/fake_endpoints.go +++ b/kubernetes/typed/core/v1/fake/fake_endpoints.go @@ -119,7 +119,7 @@ func (c *FakeEndpoints) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched endpoints. func (c *FakeEndpoints) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Endpoints, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(endpointsResource, c.ns, name, data, subresources...), &corev1.Endpoints{}) + Invokes(testing.NewPatchSubresourceAction(endpointsResource, c.ns, name, pt, data, subresources...), &corev1.Endpoints{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_event.go b/kubernetes/typed/core/v1/fake/fake_event.go index 68405a54..3444f4be 100644 --- a/kubernetes/typed/core/v1/fake/fake_event.go +++ b/kubernetes/typed/core/v1/fake/fake_event.go @@ -119,7 +119,7 @@ func (c *FakeEvents) DeleteCollection(options *v1.DeleteOptions, listOptions v1. // Patch applies the patch and returns the patched event. func (c *FakeEvents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Event, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(eventsResource, c.ns, name, data, subresources...), &corev1.Event{}) + Invokes(testing.NewPatchSubresourceAction(eventsResource, c.ns, name, pt, data, subresources...), &corev1.Event{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_event_expansion.go b/kubernetes/typed/core/v1/fake/fake_event_expansion.go index dd3fb839..4b4c90d7 100644 --- a/kubernetes/typed/core/v1/fake/fake_event_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_event_expansion.go @@ -21,6 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" + types "k8s.io/apimachinery/pkg/types" core "k8s.io/client-go/testing" ) @@ -52,10 +53,13 @@ func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error } // PatchWithEventNamespace patches an existing event. Returns the copy of the event the server returns, or an error. +// TODO: Should take a PatchType as an argument probably. func (c *FakeEvents) PatchWithEventNamespace(event *v1.Event, data []byte) (*v1.Event, error) { - action := core.NewRootPatchAction(eventsResource, event.Name, data) + // TODO: Should be configurable to support additional patch strategies. + pt := types.StrategicMergePatchType + action := core.NewRootPatchAction(eventsResource, event.Name, pt, data) if c.ns != "" { - action = core.NewPatchAction(eventsResource, c.ns, event.Name, data) + action = core.NewPatchAction(eventsResource, c.ns, event.Name, pt, data) } obj, err := c.Fake.Invokes(action, event) if obj == nil { diff --git a/kubernetes/typed/core/v1/fake/fake_limitrange.go b/kubernetes/typed/core/v1/fake/fake_limitrange.go index 03c03c5d..d110031f 100644 --- a/kubernetes/typed/core/v1/fake/fake_limitrange.go +++ b/kubernetes/typed/core/v1/fake/fake_limitrange.go @@ -119,7 +119,7 @@ func (c *FakeLimitRanges) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched limitRange. func (c *FakeLimitRanges) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.LimitRange, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(limitrangesResource, c.ns, name, data, subresources...), &corev1.LimitRange{}) + Invokes(testing.NewPatchSubresourceAction(limitrangesResource, c.ns, name, pt, data, subresources...), &corev1.LimitRange{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_namespace.go b/kubernetes/typed/core/v1/fake/fake_namespace.go index 12b918af..21387b5e 100644 --- a/kubernetes/typed/core/v1/fake/fake_namespace.go +++ b/kubernetes/typed/core/v1/fake/fake_namespace.go @@ -115,7 +115,7 @@ func (c *FakeNamespaces) Delete(name string, options *v1.DeleteOptions) error { // Patch applies the patch and returns the patched namespace. func (c *FakeNamespaces) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Namespace, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(namespacesResource, name, data, subresources...), &corev1.Namespace{}) + Invokes(testing.NewRootPatchSubresourceAction(namespacesResource, name, pt, data, subresources...), &corev1.Namespace{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/core/v1/fake/fake_node.go b/kubernetes/typed/core/v1/fake/fake_node.go index a2bc97b2..bcde116a 100644 --- a/kubernetes/typed/core/v1/fake/fake_node.go +++ b/kubernetes/typed/core/v1/fake/fake_node.go @@ -123,7 +123,7 @@ func (c *FakeNodes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L // Patch applies the patch and returns the patched node. func (c *FakeNodes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Node, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(nodesResource, name, data, subresources...), &corev1.Node{}) + Invokes(testing.NewRootPatchSubresourceAction(nodesResource, name, pt, data, subresources...), &corev1.Node{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/core/v1/fake/fake_node_expansion.go b/kubernetes/typed/core/v1/fake/fake_node_expansion.go index eb684fd2..a39022c8 100644 --- a/kubernetes/typed/core/v1/fake/fake_node_expansion.go +++ b/kubernetes/typed/core/v1/fake/fake_node_expansion.go @@ -18,12 +18,16 @@ package fake import ( "k8s.io/api/core/v1" + types "k8s.io/apimachinery/pkg/types" core "k8s.io/client-go/testing" ) +// TODO: Should take a PatchType as an argument probably. func (c *FakeNodes) PatchStatus(nodeName string, data []byte) (*v1.Node, error) { + // TODO: Should be configurable to support additional patch strategies. + pt := types.StrategicMergePatchType obj, err := c.Fake.Invokes( - core.NewRootPatchSubresourceAction(nodesResource, nodeName, data, "status"), &v1.Node{}) + core.NewRootPatchSubresourceAction(nodesResource, nodeName, pt, data, "status"), &v1.Node{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/core/v1/fake/fake_persistentvolume.go b/kubernetes/typed/core/v1/fake/fake_persistentvolume.go index 71e2f2dc..843f3230 100644 --- a/kubernetes/typed/core/v1/fake/fake_persistentvolume.go +++ b/kubernetes/typed/core/v1/fake/fake_persistentvolume.go @@ -123,7 +123,7 @@ func (c *FakePersistentVolumes) DeleteCollection(options *v1.DeleteOptions, list // Patch applies the patch and returns the patched persistentVolume. func (c *FakePersistentVolumes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.PersistentVolume, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(persistentvolumesResource, name, data, subresources...), &corev1.PersistentVolume{}) + Invokes(testing.NewRootPatchSubresourceAction(persistentvolumesResource, name, pt, data, subresources...), &corev1.PersistentVolume{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go b/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go index a06eca81..d2557c4c 100644 --- a/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go +++ b/kubernetes/typed/core/v1/fake/fake_persistentvolumeclaim.go @@ -131,7 +131,7 @@ func (c *FakePersistentVolumeClaims) DeleteCollection(options *v1.DeleteOptions, // Patch applies the patch and returns the patched persistentVolumeClaim. func (c *FakePersistentVolumeClaims) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.PersistentVolumeClaim, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(persistentvolumeclaimsResource, c.ns, name, data, subresources...), &corev1.PersistentVolumeClaim{}) + Invokes(testing.NewPatchSubresourceAction(persistentvolumeclaimsResource, c.ns, name, pt, data, subresources...), &corev1.PersistentVolumeClaim{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_pod.go b/kubernetes/typed/core/v1/fake/fake_pod.go index bbf39eaf..2dbecbba 100644 --- a/kubernetes/typed/core/v1/fake/fake_pod.go +++ b/kubernetes/typed/core/v1/fake/fake_pod.go @@ -131,7 +131,7 @@ func (c *FakePods) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li // Patch applies the patch and returns the patched pod. func (c *FakePods) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Pod, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(podsResource, c.ns, name, data, subresources...), &corev1.Pod{}) + Invokes(testing.NewPatchSubresourceAction(podsResource, c.ns, name, pt, data, subresources...), &corev1.Pod{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_podtemplate.go b/kubernetes/typed/core/v1/fake/fake_podtemplate.go index ff242f16..307f3059 100644 --- a/kubernetes/typed/core/v1/fake/fake_podtemplate.go +++ b/kubernetes/typed/core/v1/fake/fake_podtemplate.go @@ -119,7 +119,7 @@ func (c *FakePodTemplates) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched podTemplate. func (c *FakePodTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.PodTemplate, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(podtemplatesResource, c.ns, name, data, subresources...), &corev1.PodTemplate{}) + Invokes(testing.NewPatchSubresourceAction(podtemplatesResource, c.ns, name, pt, data, subresources...), &corev1.PodTemplate{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go b/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go index 64fde0b6..f830d7da 100644 --- a/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go +++ b/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go @@ -132,7 +132,7 @@ func (c *FakeReplicationControllers) DeleteCollection(options *v1.DeleteOptions, // Patch applies the patch and returns the patched replicationController. func (c *FakeReplicationControllers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.ReplicationController, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(replicationcontrollersResource, c.ns, name, data, subresources...), &corev1.ReplicationController{}) + Invokes(testing.NewPatchSubresourceAction(replicationcontrollersResource, c.ns, name, pt, data, subresources...), &corev1.ReplicationController{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_resourcequota.go b/kubernetes/typed/core/v1/fake/fake_resourcequota.go index 069749cc..b521f712 100644 --- a/kubernetes/typed/core/v1/fake/fake_resourcequota.go +++ b/kubernetes/typed/core/v1/fake/fake_resourcequota.go @@ -131,7 +131,7 @@ func (c *FakeResourceQuotas) DeleteCollection(options *v1.DeleteOptions, listOpt // Patch applies the patch and returns the patched resourceQuota. func (c *FakeResourceQuotas) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.ResourceQuota, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(resourcequotasResource, c.ns, name, data, subresources...), &corev1.ResourceQuota{}) + Invokes(testing.NewPatchSubresourceAction(resourcequotasResource, c.ns, name, pt, data, subresources...), &corev1.ResourceQuota{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_secret.go b/kubernetes/typed/core/v1/fake/fake_secret.go index f59ba40b..47dba9ef 100644 --- a/kubernetes/typed/core/v1/fake/fake_secret.go +++ b/kubernetes/typed/core/v1/fake/fake_secret.go @@ -119,7 +119,7 @@ func (c *FakeSecrets) DeleteCollection(options *v1.DeleteOptions, listOptions v1 // Patch applies the patch and returns the patched secret. func (c *FakeSecrets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Secret, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(secretsResource, c.ns, name, data, subresources...), &corev1.Secret{}) + Invokes(testing.NewPatchSubresourceAction(secretsResource, c.ns, name, pt, data, subresources...), &corev1.Secret{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_service.go b/kubernetes/typed/core/v1/fake/fake_service.go index 2ffcdff7..a65de499 100644 --- a/kubernetes/typed/core/v1/fake/fake_service.go +++ b/kubernetes/typed/core/v1/fake/fake_service.go @@ -123,7 +123,7 @@ func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { // Patch applies the patch and returns the patched service. func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.Service, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, data, subresources...), &corev1.Service{}) + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, pt, data, subresources...), &corev1.Service{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/core/v1/fake/fake_serviceaccount.go b/kubernetes/typed/core/v1/fake/fake_serviceaccount.go index 2b2c5a7b..5b6d8f8b 100644 --- a/kubernetes/typed/core/v1/fake/fake_serviceaccount.go +++ b/kubernetes/typed/core/v1/fake/fake_serviceaccount.go @@ -119,7 +119,7 @@ func (c *FakeServiceAccounts) DeleteCollection(options *v1.DeleteOptions, listOp // Patch applies the patch and returns the patched serviceAccount. func (c *FakeServiceAccounts) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *corev1.ServiceAccount, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serviceaccountsResource, c.ns, name, data, subresources...), &corev1.ServiceAccount{}) + Invokes(testing.NewPatchSubresourceAction(serviceaccountsResource, c.ns, name, pt, data, subresources...), &corev1.ServiceAccount{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/events/v1beta1/fake/fake_event.go b/kubernetes/typed/events/v1beta1/fake/fake_event.go index b210e40a..ef76ec13 100644 --- a/kubernetes/typed/events/v1beta1/fake/fake_event.go +++ b/kubernetes/typed/events/v1beta1/fake/fake_event.go @@ -119,7 +119,7 @@ func (c *FakeEvents) DeleteCollection(options *v1.DeleteOptions, listOptions v1. // Patch applies the patch and returns the patched event. func (c *FakeEvents) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Event, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(eventsResource, c.ns, name, data, subresources...), &v1beta1.Event{}) + Invokes(testing.NewPatchSubresourceAction(eventsResource, c.ns, name, pt, data, subresources...), &v1beta1.Event{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_daemonset.go b/kubernetes/typed/extensions/v1beta1/fake/fake_daemonset.go index 3a760b31..4c986606 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_daemonset.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_daemonset.go @@ -131,7 +131,7 @@ func (c *FakeDaemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched daemonSet. func (c *FakeDaemonSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.DaemonSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, data, subresources...), &v1beta1.DaemonSet{}) + Invokes(testing.NewPatchSubresourceAction(daemonsetsResource, c.ns, name, pt, data, subresources...), &v1beta1.DaemonSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_deployment.go b/kubernetes/typed/extensions/v1beta1/fake/fake_deployment.go index f032a556..7b7df45c 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_deployment.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_deployment.go @@ -131,7 +131,7 @@ func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched deployment. func (c *FakeDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, data, subresources...), &v1beta1.Deployment{}) + Invokes(testing.NewPatchSubresourceAction(deploymentsResource, c.ns, name, pt, data, subresources...), &v1beta1.Deployment{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_ingress.go b/kubernetes/typed/extensions/v1beta1/fake/fake_ingress.go index 55257a88..01c25214 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_ingress.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_ingress.go @@ -131,7 +131,7 @@ func (c *FakeIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched ingress. func (c *FakeIngresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Ingress, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(ingressesResource, c.ns, name, data, subresources...), &v1beta1.Ingress{}) + Invokes(testing.NewPatchSubresourceAction(ingressesResource, c.ns, name, pt, data, subresources...), &v1beta1.Ingress{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_podsecuritypolicy.go b/kubernetes/typed/extensions/v1beta1/fake/fake_podsecuritypolicy.go index 70b5dac2..b97a3441 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_podsecuritypolicy.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_podsecuritypolicy.go @@ -112,7 +112,7 @@ func (c *FakePodSecurityPolicies) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched podSecurityPolicy. func (c *FakePodSecurityPolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PodSecurityPolicy, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(podsecuritypoliciesResource, name, data, subresources...), &v1beta1.PodSecurityPolicy{}) + Invokes(testing.NewRootPatchSubresourceAction(podsecuritypoliciesResource, name, pt, data, subresources...), &v1beta1.PodSecurityPolicy{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/extensions/v1beta1/fake/fake_replicaset.go b/kubernetes/typed/extensions/v1beta1/fake/fake_replicaset.go index 2ab8f244..7ed16af9 100644 --- a/kubernetes/typed/extensions/v1beta1/fake/fake_replicaset.go +++ b/kubernetes/typed/extensions/v1beta1/fake/fake_replicaset.go @@ -131,7 +131,7 @@ func (c *FakeReplicaSets) DeleteCollection(options *v1.DeleteOptions, listOption // Patch applies the patch and returns the patched replicaSet. func (c *FakeReplicaSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ReplicaSet, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, data, subresources...), &v1beta1.ReplicaSet{}) + Invokes(testing.NewPatchSubresourceAction(replicasetsResource, c.ns, name, pt, data, subresources...), &v1beta1.ReplicaSet{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/networking/v1/fake/fake_networkpolicy.go b/kubernetes/typed/networking/v1/fake/fake_networkpolicy.go index 7be20229..58667c48 100644 --- a/kubernetes/typed/networking/v1/fake/fake_networkpolicy.go +++ b/kubernetes/typed/networking/v1/fake/fake_networkpolicy.go @@ -119,7 +119,7 @@ func (c *FakeNetworkPolicies) DeleteCollection(options *v1.DeleteOptions, listOp // Patch applies the patch and returns the patched networkPolicy. func (c *FakeNetworkPolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *networkingv1.NetworkPolicy, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(networkpoliciesResource, c.ns, name, data, subresources...), &networkingv1.NetworkPolicy{}) + Invokes(testing.NewPatchSubresourceAction(networkpoliciesResource, c.ns, name, pt, data, subresources...), &networkingv1.NetworkPolicy{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/policy/v1beta1/fake/fake_poddisruptionbudget.go b/kubernetes/typed/policy/v1beta1/fake/fake_poddisruptionbudget.go index 3f2e78b3..5bfbbca4 100644 --- a/kubernetes/typed/policy/v1beta1/fake/fake_poddisruptionbudget.go +++ b/kubernetes/typed/policy/v1beta1/fake/fake_poddisruptionbudget.go @@ -131,7 +131,7 @@ func (c *FakePodDisruptionBudgets) DeleteCollection(options *v1.DeleteOptions, l // Patch applies the patch and returns the patched podDisruptionBudget. func (c *FakePodDisruptionBudgets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PodDisruptionBudget, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(poddisruptionbudgetsResource, c.ns, name, data, subresources...), &v1beta1.PodDisruptionBudget{}) + Invokes(testing.NewPatchSubresourceAction(poddisruptionbudgetsResource, c.ns, name, pt, data, subresources...), &v1beta1.PodDisruptionBudget{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/policy/v1beta1/fake/fake_podsecuritypolicy.go b/kubernetes/typed/policy/v1beta1/fake/fake_podsecuritypolicy.go index 0df9aa15..32d1989f 100644 --- a/kubernetes/typed/policy/v1beta1/fake/fake_podsecuritypolicy.go +++ b/kubernetes/typed/policy/v1beta1/fake/fake_podsecuritypolicy.go @@ -112,7 +112,7 @@ func (c *FakePodSecurityPolicies) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched podSecurityPolicy. func (c *FakePodSecurityPolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PodSecurityPolicy, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(podsecuritypoliciesResource, name, data, subresources...), &v1beta1.PodSecurityPolicy{}) + Invokes(testing.NewRootPatchSubresourceAction(podsecuritypoliciesResource, name, pt, data, subresources...), &v1beta1.PodSecurityPolicy{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1/fake/fake_clusterrole.go b/kubernetes/typed/rbac/v1/fake/fake_clusterrole.go index d93ac829..d57f3393 100644 --- a/kubernetes/typed/rbac/v1/fake/fake_clusterrole.go +++ b/kubernetes/typed/rbac/v1/fake/fake_clusterrole.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoles) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched clusterRole. func (c *FakeClusterRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *rbacv1.ClusterRole, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, data, subresources...), &rbacv1.ClusterRole{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, pt, data, subresources...), &rbacv1.ClusterRole{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1/fake/fake_clusterrolebinding.go b/kubernetes/typed/rbac/v1/fake/fake_clusterrolebinding.go index a8b2b57f..878473ef 100644 --- a/kubernetes/typed/rbac/v1/fake/fake_clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1/fake/fake_clusterrolebinding.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoleBindings) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched clusterRoleBinding. func (c *FakeClusterRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *rbacv1.ClusterRoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, data, subresources...), &rbacv1.ClusterRoleBinding{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, pt, data, subresources...), &rbacv1.ClusterRoleBinding{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1/fake/fake_role.go b/kubernetes/typed/rbac/v1/fake/fake_role.go index f048bbdf..78ef3192 100644 --- a/kubernetes/typed/rbac/v1/fake/fake_role.go +++ b/kubernetes/typed/rbac/v1/fake/fake_role.go @@ -119,7 +119,7 @@ func (c *FakeRoles) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L // Patch applies the patch and returns the patched role. func (c *FakeRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *rbacv1.Role, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, data, subresources...), &rbacv1.Role{}) + Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, pt, data, subresources...), &rbacv1.Role{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/rbac/v1/fake/fake_rolebinding.go b/kubernetes/typed/rbac/v1/fake/fake_rolebinding.go index c71635fc..6c344cad 100644 --- a/kubernetes/typed/rbac/v1/fake/fake_rolebinding.go +++ b/kubernetes/typed/rbac/v1/fake/fake_rolebinding.go @@ -119,7 +119,7 @@ func (c *FakeRoleBindings) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched roleBinding. func (c *FakeRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *rbacv1.RoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, data, subresources...), &rbacv1.RoleBinding{}) + Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, pt, data, subresources...), &rbacv1.RoleBinding{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go b/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go index 13fbce4e..d2d1b1c7 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoles) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched clusterRole. func (c *FakeClusterRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRole, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, data, subresources...), &v1alpha1.ClusterRole{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, pt, data, subresources...), &v1alpha1.ClusterRole{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go b/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go index 5076543d..3e23e5f6 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoleBindings) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched clusterRoleBinding. func (c *FakeClusterRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, data, subresources...), &v1alpha1.ClusterRoleBinding{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, pt, data, subresources...), &v1alpha1.ClusterRoleBinding{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go b/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go index 24d8efee..7bd52373 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go @@ -119,7 +119,7 @@ func (c *FakeRoles) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L // Patch applies the patch and returns the patched role. func (c *FakeRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Role, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, data, subresources...), &v1alpha1.Role{}) + Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Role{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go b/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go index cb01ef99..01505031 100644 --- a/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go +++ b/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go @@ -119,7 +119,7 @@ func (c *FakeRoleBindings) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched roleBinding. func (c *FakeRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, data, subresources...), &v1alpha1.RoleBinding{}) + Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.RoleBinding{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrole.go b/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrole.go index 62a83219..2dbc3f61 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrole.go +++ b/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrole.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoles) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched clusterRole. func (c *FakeClusterRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ClusterRole, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, data, subresources...), &v1beta1.ClusterRole{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, pt, data, subresources...), &v1beta1.ClusterRole{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrolebinding.go b/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrolebinding.go index c9ab4726..14e20bc2 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/fake/fake_clusterrolebinding.go @@ -112,7 +112,7 @@ func (c *FakeClusterRoleBindings) DeleteCollection(options *v1.DeleteOptions, li // Patch applies the patch and returns the patched clusterRoleBinding. func (c *FakeClusterRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.ClusterRoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, data, subresources...), &v1beta1.ClusterRoleBinding{}) + Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, pt, data, subresources...), &v1beta1.ClusterRoleBinding{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/rbac/v1beta1/fake/fake_role.go b/kubernetes/typed/rbac/v1beta1/fake/fake_role.go index 45b07a00..e31768e4 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/fake_role.go +++ b/kubernetes/typed/rbac/v1beta1/fake/fake_role.go @@ -119,7 +119,7 @@ func (c *FakeRoles) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L // Patch applies the patch and returns the patched role. func (c *FakeRoles) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Role, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, data, subresources...), &v1beta1.Role{}) + Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, pt, data, subresources...), &v1beta1.Role{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/rbac/v1beta1/fake/fake_rolebinding.go b/kubernetes/typed/rbac/v1beta1/fake/fake_rolebinding.go index 1efd4000..06b93c93 100644 --- a/kubernetes/typed/rbac/v1beta1/fake/fake_rolebinding.go +++ b/kubernetes/typed/rbac/v1beta1/fake/fake_rolebinding.go @@ -119,7 +119,7 @@ func (c *FakeRoleBindings) DeleteCollection(options *v1.DeleteOptions, listOptio // Patch applies the patch and returns the patched roleBinding. func (c *FakeRoleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.RoleBinding, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, data, subresources...), &v1beta1.RoleBinding{}) + Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, pt, data, subresources...), &v1beta1.RoleBinding{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/scheduling/v1alpha1/fake/fake_priorityclass.go b/kubernetes/typed/scheduling/v1alpha1/fake/fake_priorityclass.go index 8ab4421a..e592ed13 100644 --- a/kubernetes/typed/scheduling/v1alpha1/fake/fake_priorityclass.go +++ b/kubernetes/typed/scheduling/v1alpha1/fake/fake_priorityclass.go @@ -112,7 +112,7 @@ func (c *FakePriorityClasses) DeleteCollection(options *v1.DeleteOptions, listOp // Patch applies the patch and returns the patched priorityClass. func (c *FakePriorityClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PriorityClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, name, data, subresources...), &v1alpha1.PriorityClass{}) + Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, name, pt, data, subresources...), &v1alpha1.PriorityClass{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/scheduling/v1beta1/fake/fake_priorityclass.go b/kubernetes/typed/scheduling/v1beta1/fake/fake_priorityclass.go index e234fec6..44ce64b5 100644 --- a/kubernetes/typed/scheduling/v1beta1/fake/fake_priorityclass.go +++ b/kubernetes/typed/scheduling/v1beta1/fake/fake_priorityclass.go @@ -112,7 +112,7 @@ func (c *FakePriorityClasses) DeleteCollection(options *v1.DeleteOptions, listOp // Patch applies the patch and returns the patched priorityClass. func (c *FakePriorityClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.PriorityClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, name, data, subresources...), &v1beta1.PriorityClass{}) + Invokes(testing.NewRootPatchSubresourceAction(priorityclassesResource, name, pt, data, subresources...), &v1beta1.PriorityClass{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/settings/v1alpha1/fake/fake_podpreset.go b/kubernetes/typed/settings/v1alpha1/fake/fake_podpreset.go index 90eaccec..273a027f 100644 --- a/kubernetes/typed/settings/v1alpha1/fake/fake_podpreset.go +++ b/kubernetes/typed/settings/v1alpha1/fake/fake_podpreset.go @@ -119,7 +119,7 @@ func (c *FakePodPresets) DeleteCollection(options *v1.DeleteOptions, listOptions // Patch applies the patch and returns the patched podPreset. func (c *FakePodPresets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodPreset, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(podpresetsResource, c.ns, name, data, subresources...), &v1alpha1.PodPreset{}) + Invokes(testing.NewPatchSubresourceAction(podpresetsResource, c.ns, name, pt, data, subresources...), &v1alpha1.PodPreset{}) if obj == nil { return nil, err diff --git a/kubernetes/typed/storage/v1/fake/fake_storageclass.go b/kubernetes/typed/storage/v1/fake/fake_storageclass.go index 37488a2d..c7531d87 100644 --- a/kubernetes/typed/storage/v1/fake/fake_storageclass.go +++ b/kubernetes/typed/storage/v1/fake/fake_storageclass.go @@ -112,7 +112,7 @@ func (c *FakeStorageClasses) DeleteCollection(options *v1.DeleteOptions, listOpt // Patch applies the patch and returns the patched storageClass. func (c *FakeStorageClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *storagev1.StorageClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(storageclassesResource, name, data, subresources...), &storagev1.StorageClass{}) + Invokes(testing.NewRootPatchSubresourceAction(storageclassesResource, name, pt, data, subresources...), &storagev1.StorageClass{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/storage/v1alpha1/fake/fake_volumeattachment.go b/kubernetes/typed/storage/v1alpha1/fake/fake_volumeattachment.go index af04b681..86f53e2d 100644 --- a/kubernetes/typed/storage/v1alpha1/fake/fake_volumeattachment.go +++ b/kubernetes/typed/storage/v1alpha1/fake/fake_volumeattachment.go @@ -123,7 +123,7 @@ func (c *FakeVolumeAttachments) DeleteCollection(options *v1.DeleteOptions, list // Patch applies the patch and returns the patched volumeAttachment. func (c *FakeVolumeAttachments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.VolumeAttachment, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumeattachmentsResource, name, data, subresources...), &v1alpha1.VolumeAttachment{}) + Invokes(testing.NewRootPatchSubresourceAction(volumeattachmentsResource, name, pt, data, subresources...), &v1alpha1.VolumeAttachment{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go b/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go index cbfbab1a..9fc8ca99 100644 --- a/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go +++ b/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go @@ -112,7 +112,7 @@ func (c *FakeStorageClasses) DeleteCollection(options *v1.DeleteOptions, listOpt // Patch applies the patch and returns the patched storageClass. func (c *FakeStorageClasses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.StorageClass, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(storageclassesResource, name, data, subresources...), &v1beta1.StorageClass{}) + Invokes(testing.NewRootPatchSubresourceAction(storageclassesResource, name, pt, data, subresources...), &v1beta1.StorageClass{}) if obj == nil { return nil, err } diff --git a/kubernetes/typed/storage/v1beta1/fake/fake_volumeattachment.go b/kubernetes/typed/storage/v1beta1/fake/fake_volumeattachment.go index 04c0c463..043098f4 100644 --- a/kubernetes/typed/storage/v1beta1/fake/fake_volumeattachment.go +++ b/kubernetes/typed/storage/v1beta1/fake/fake_volumeattachment.go @@ -123,7 +123,7 @@ func (c *FakeVolumeAttachments) DeleteCollection(options *v1.DeleteOptions, list // Patch applies the patch and returns the patched volumeAttachment. func (c *FakeVolumeAttachments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VolumeAttachment, err error) { obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(volumeattachmentsResource, name, data, subresources...), &v1beta1.VolumeAttachment{}) + Invokes(testing.NewRootPatchSubresourceAction(volumeattachmentsResource, name, pt, data, subresources...), &v1beta1.VolumeAttachment{}) if obj == nil { return nil, err } diff --git a/testing/actions.go b/testing/actions.go index b99f231c..e6db578e 100644 --- a/testing/actions.go +++ b/testing/actions.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" ) func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl { @@ -152,45 +153,49 @@ func NewUpdateAction(resource schema.GroupVersionResource, namespace string, obj return action } -func NewRootPatchAction(resource schema.GroupVersionResource, name string, patch []byte) PatchActionImpl { +func NewRootPatchAction(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte) PatchActionImpl { action := PatchActionImpl{} action.Verb = "patch" action.Resource = resource action.Name = name + action.PatchType = pt action.Patch = patch return action } -func NewPatchAction(resource schema.GroupVersionResource, namespace string, name string, patch []byte) PatchActionImpl { +func NewPatchAction(resource schema.GroupVersionResource, namespace string, name string, pt types.PatchType, patch []byte) PatchActionImpl { action := PatchActionImpl{} action.Verb = "patch" action.Resource = resource action.Namespace = namespace action.Name = name + action.PatchType = pt action.Patch = patch return action } -func NewRootPatchSubresourceAction(resource schema.GroupVersionResource, name string, patch []byte, subresources ...string) PatchActionImpl { +func NewRootPatchSubresourceAction(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte, subresources ...string) PatchActionImpl { action := PatchActionImpl{} action.Verb = "patch" action.Resource = resource action.Subresource = path.Join(subresources...) action.Name = name + action.PatchType = pt action.Patch = patch return action } -func NewPatchSubresourceAction(resource schema.GroupVersionResource, namespace, name string, patch []byte, subresources ...string) PatchActionImpl { +func NewPatchSubresourceAction(resource schema.GroupVersionResource, namespace, name string, pt types.PatchType, patch []byte, subresources ...string) PatchActionImpl { action := PatchActionImpl{} action.Verb = "patch" action.Resource = resource action.Subresource = path.Join(subresources...) action.Namespace = namespace action.Name = name + action.PatchType = pt action.Patch = patch return action @@ -396,6 +401,7 @@ type DeleteCollectionAction interface { type PatchAction interface { Action GetName() string + GetPatchType() types.PatchType GetPatch() []byte } @@ -537,8 +543,9 @@ func (a UpdateActionImpl) DeepCopy() Action { type PatchActionImpl struct { ActionImpl - Name string - Patch []byte + Name string + PatchType types.PatchType + Patch []byte } func (a PatchActionImpl) GetName() string { @@ -549,12 +556,17 @@ func (a PatchActionImpl) GetPatch() []byte { return a.Patch } +func (a PatchActionImpl) GetPatchType() types.PatchType { + return a.PatchType +} + func (a PatchActionImpl) DeepCopy() Action { patch := make([]byte, len(a.Patch)) copy(patch, a.Patch) return PatchActionImpl{ ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), Name: a.Name, + PatchType: a.PatchType, Patch: patch, } } diff --git a/testing/fixture.go b/testing/fixture.go index 00c4c49f..90f16f56 100644 --- a/testing/fixture.go +++ b/testing/fixture.go @@ -20,11 +20,13 @@ import ( "fmt" "sync" + "github.com/evanphx/json-patch" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/watch" @@ -137,15 +139,30 @@ func ObjectReaction(tracker ObjectTracker) ReactionFunc { if err != nil { return true, nil, err } - // Only supports strategic merge patch - // TODO: Add support for other Patch types - mergedByte, err := strategicpatch.StrategicMergePatch(old, action.GetPatch(), obj) - if err != nil { - return true, nil, err - } - - if err = json.Unmarshal(mergedByte, obj); err != nil { - return true, nil, err + // Only supports strategic merge patch and JSONPatch as coded. + switch action.GetPatchType() { + case types.JSONPatchType: + patch, err := jsonpatch.DecodePatch(action.GetPatch()) + if err != nil { + return true, nil, err + } + modified, err := patch.Apply(old) + if err != nil { + return true, nil, err + } + if err = json.Unmarshal(modified, obj); err != nil { + return true, nil, err + } + case types.StrategicMergePatchType: + mergedByte, err := strategicpatch.StrategicMergePatch(old, action.GetPatch(), obj) + if err != nil { + return true, nil, err + } + if err = json.Unmarshal(mergedByte, obj); err != nil { + return true, nil, err + } + default: + return true, nil, fmt.Errorf("PatchType is not supported") } if err = tracker.Update(gvr, obj, ns); err != nil {