Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make thirdparty codec able to decode DeleteOptions #37328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/registry/extensions/thirdpartyresourcedata/codec.go
Expand Up @@ -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)
}

Expand Down
10 changes: 9 additions & 1 deletion test/e2e/third-party.go
Expand Up @@ -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)
}

Expand Down