diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 5e17923a..a02a4f06 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -188,7 +188,7 @@ }, { "ImportPath": "k8s.io/api", - "Rev": "db0771252981" + "Rev": "e4e27c96b39a" }, { "ImportPath": "k8s.io/apimachinery", diff --git a/go.mod b/go.mod index 97fd411a..22b3d626 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a golang.org/x/time v0.0.0-20161028155119-f51c12702a4d google.golang.org/appengine v1.5.0 // indirect - k8s.io/api v0.0.0-20190612125737-db0771252981 + k8s.io/api v0.0.0-20190614205929-e4e27c96b39a k8s.io/apimachinery v0.0.0-20190612125636-6a5db36e93ad k8s.io/klog v0.3.1 k8s.io/utils v0.0.0-20190221042446-c2654d5206da @@ -37,6 +37,6 @@ replace ( golang.org/x/sync => golang.org/x/sync v0.0.0-20181108010431-42b317875d0f golang.org/x/sys => golang.org/x/sys v0.0.0-20190209173611-3b5209105503 golang.org/x/tools => golang.org/x/tools v0.0.0-20190313210603-aa82965741a9 - k8s.io/api => k8s.io/api v0.0.0-20190612125737-db0771252981 + k8s.io/api => k8s.io/api v0.0.0-20190614205929-e4e27c96b39a k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190612125636-6a5db36e93ad ) diff --git a/go.sum b/go.sum index 064841fc..3e6de351 100644 --- a/go.sum +++ b/go.sum @@ -91,7 +91,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/api v0.0.0-20190612125737-db0771252981/go.mod h1:SR4nMi8IQTDnEi4768MsMCoZ9DyfRls7wy+TbRrFicA= +k8s.io/api v0.0.0-20190614205929-e4e27c96b39a/go.mod h1:SR4nMi8IQTDnEi4768MsMCoZ9DyfRls7wy+TbRrFicA= k8s.io/apimachinery v0.0.0-20190612125636-6a5db36e93ad/go.mod h1:I4A+glKBHiTgiEjQiCCQfCAIcIMFGt291SmsvcrFzJA= k8s.io/klog v0.3.1 h1:RVgyDHY/kFKtLqh67NvEWIgkMneNoIrdkN0CxDSQc68= k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= diff --git a/testing/fixture.go b/testing/fixture.go index 993fcf6a..b3ace307 100644 --- a/testing/fixture.go +++ b/testing/fixture.go @@ -18,9 +18,11 @@ package testing import ( "fmt" + "reflect" "sync" jsonpatch "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" @@ -139,6 +141,11 @@ func ObjectReaction(tracker ObjectTracker) ReactionFunc { return true, nil, err } + // reset the object in preparation to unmarshal, since unmarshal does not guarantee that fields + // in obj that are removed by patch are cleared + value := reflect.ValueOf(obj) + value.Elem().Set(reflect.New(value.Type().Elem()).Elem()) + switch action.GetPatchType() { case types.JSONPatchType: patch, err := jsonpatch.DecodePatch(action.GetPatch()) @@ -149,6 +156,7 @@ func ObjectReaction(tracker ObjectTracker) ReactionFunc { if err != nil { return true, nil, err } + if err = json.Unmarshal(modified, obj); err != nil { return true, nil, err }