Merge pull request #37328 from caesarxuchao/fix-tpr-deleteoptions

Automatic merge from submit-queue (batch tested with PRs 37328, 38102, 37261, 31321, 38146)

Make thirdparty codec able to decode DeleteOptions

Fix #37278. 

Without this PR, the gvk sent to the delegated codec will be the thirdparty one, which is not recognized by the delegated codec (usually api.Codecs).
This commit is contained in:
Kubernetes Submit Queue 2016-12-05 20:16:48 -08:00 committed by GitHub
commit b1dba6cd9f
2 changed files with 13 additions and 1 deletions

View File

@ -370,6 +370,10 @@ func (t *thirdPartyResourceDataDecoder) Decode(data []byte, gvk *schema.GroupVer
}
return o, outGVK, nil
default:
if gvk != nil && registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
// delegate won't recognize a thirdparty group version
gvk = nil
}
return t.delegate.Decode(data, gvk, into)
}

View File

@ -161,7 +161,15 @@ var _ = Describe("ThirdParty resources [Flaky] [Disruptive]", func() {
framework.Failf("expected: %#v, saw in list: %#v", foo, list.Items[0])
}
if _, err := f.ClientSet.Extensions().RESTClient().Delete().AbsPath("/apis/company.com/v1/namespaces/default/foos/foo").DoRaw(); err != nil {
// Need to manually do the serialization because otherwise the
// Content-Type header is set to protobuf, the thirdparty codec in
// the API server side only accepts JSON.
deleteOptionsData, err := json.Marshal(v1.NewDeleteOptions(10))
framework.ExpectNoError(err)
if _, err := f.ClientSet.Core().RESTClient().Delete().
AbsPath("/apis/company.com/v1/namespaces/default/foos/foo").
Body(deleteOptionsData).
DoRaw(); err != nil {
framework.Failf("failed to delete: %v", err)
}