From bc9afc4554b1565b20350b0eaf70ccceaaaee64a Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Wed, 10 May 2023 14:12:38 -0700 Subject: [PATCH] Aggregated API endpoints now must implement rest.SingularNameProvider This was a change in the interface requirements introduced in Kube 1.27. --- internal/registry/clientsecretrequest/rest.go | 7 +++- .../registry/clientsecretrequest/rest_test.go | 3 +- internal/registry/credentialrequest/rest.go | 7 +++- .../registry/credentialrequest/rest_test.go | 3 +- internal/registry/whoamirequest/rest.go | 7 +++- internal/registry/whoamirequest/rest_test.go | 3 +- test/integration/kube_api_discovery_test.go | 33 ++++++++++--------- 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/internal/registry/clientsecretrequest/rest.go b/internal/registry/clientsecretrequest/rest.go index 026809a8..aa817457 100644 --- a/internal/registry/clientsecretrequest/rest.go +++ b/internal/registry/clientsecretrequest/rest.go @@ -1,4 +1,4 @@ -// Copyright 2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2022-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Package clientsecretrequest provides REST functionality for the CredentialRequest resource. @@ -77,6 +77,7 @@ var _ interface { rest.Scoper rest.Storage rest.CategoriesProvider + rest.SingularNameProvider rest.Lister rest.TableConvertor } = (*REST)(nil) @@ -114,6 +115,10 @@ func (*REST) Categories() []string { return []string{"pinniped"} } +func (*REST) GetSingularName() string { + return "oidcclientsecretrequest" +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { t := trace.FromContext(ctx).Nest("create", trace.Field{Key: "kind", Value: "OIDCClientSecretRequest"}, diff --git a/internal/registry/clientsecretrequest/rest_test.go b/internal/registry/clientsecretrequest/rest_test.go index 986c6d18..af604c93 100644 --- a/internal/registry/clientsecretrequest/rest_test.go +++ b/internal/registry/clientsecretrequest/rest_test.go @@ -1,4 +1,4 @@ -// Copyright 2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2022-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package clientsecretrequest @@ -50,6 +50,7 @@ func TestNew(t *testing.T) { require.NotNil(t, r) require.True(t, r.NamespaceScoped()) require.Equal(t, []string{"pinniped"}, r.Categories()) + require.Equal(t, "oidcclientsecretrequest", r.GetSingularName()) require.IsType(t, &clientsecretapi.OIDCClientSecretRequest{}, r.New()) require.IsType(t, &clientsecretapi.OIDCClientSecretRequestList{}, r.NewList()) diff --git a/internal/registry/credentialrequest/rest.go b/internal/registry/credentialrequest/rest.go index b8b89ef7..4e272266 100644 --- a/internal/registry/credentialrequest/rest.go +++ b/internal/registry/credentialrequest/rest.go @@ -1,4 +1,4 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Package credentialrequest provides REST functionality for the CredentialRequest resource. @@ -52,6 +52,7 @@ var _ interface { rest.Scoper rest.Storage rest.CategoriesProvider + rest.SingularNameProvider rest.Lister } = (*REST)(nil) @@ -86,6 +87,10 @@ func (*REST) Categories() []string { return []string{"pinniped"} } +func (*REST) GetSingularName() string { + return "tokencredentialrequest" +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { t := trace.FromContext(ctx).Nest("create", trace.Field{ Key: "kind", diff --git a/internal/registry/credentialrequest/rest_test.go b/internal/registry/credentialrequest/rest_test.go index 29ada189..8b60e182 100644 --- a/internal/registry/credentialrequest/rest_test.go +++ b/internal/registry/credentialrequest/rest_test.go @@ -1,4 +1,4 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package credentialrequest @@ -36,6 +36,7 @@ func TestNew(t *testing.T) { require.NotNil(t, r) require.False(t, r.NamespaceScoped()) require.Equal(t, []string{"pinniped"}, r.Categories()) + require.Equal(t, "tokencredentialrequest", r.GetSingularName()) require.IsType(t, &loginapi.TokenCredentialRequest{}, r.New()) require.IsType(t, &loginapi.TokenCredentialRequestList{}, r.NewList()) diff --git a/internal/registry/whoamirequest/rest.go b/internal/registry/whoamirequest/rest.go index 5468c3c2..96c72667 100644 --- a/internal/registry/whoamirequest/rest.go +++ b/internal/registry/whoamirequest/rest.go @@ -1,4 +1,4 @@ -// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package whoamirequest @@ -38,6 +38,7 @@ var _ interface { rest.Scoper rest.Storage rest.CategoriesProvider + rest.SingularNameProvider rest.Lister } = (*REST)(nil) @@ -72,6 +73,10 @@ func (*REST) Categories() []string { return []string{"pinniped"} } +func (*REST) GetSingularName() string { + return "whoamirequest" +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { whoAmIRequest, ok := obj.(*identityapi.WhoAmIRequest) if !ok { diff --git a/internal/registry/whoamirequest/rest_test.go b/internal/registry/whoamirequest/rest_test.go index 28b65041..c840479c 100644 --- a/internal/registry/whoamirequest/rest_test.go +++ b/internal/registry/whoamirequest/rest_test.go @@ -1,4 +1,4 @@ -// Copyright 2021 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package whoamirequest @@ -25,6 +25,7 @@ func TestNew(t *testing.T) { require.NotNil(t, r) require.False(t, r.NamespaceScoped()) require.Equal(t, []string{"pinniped"}, r.Categories()) + require.Equal(t, "whoamirequest", r.GetSingularName()) require.IsType(t, &identityapi.WhoAmIRequest{}, r.New()) require.IsType(t, &identityapi.WhoAmIRequestList{}, r.NewList()) diff --git a/test/integration/kube_api_discovery_test.go b/test/integration/kube_api_discovery_test.go index 71b8219d..060a51a8 100644 --- a/test/integration/kube_api_discovery_test.go +++ b/test/integration/kube_api_discovery_test.go @@ -79,11 +79,12 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr resourceByVersion: map[string][]metav1.APIResource{ loginConciergeGV.String(): { { - Name: "tokencredentialrequests", - Kind: "TokenCredentialRequest", - Verbs: []string{"create", "list"}, - Namespaced: false, - Categories: []string{"pinniped"}, + Name: "tokencredentialrequests", + SingularName: "tokencredentialrequest", + Kind: "TokenCredentialRequest", + Verbs: []string{"create", "list"}, + Namespaced: false, + Categories: []string{"pinniped"}, }, }, }, @@ -105,11 +106,12 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr resourceByVersion: map[string][]metav1.APIResource{ identityConciergeGV.String(): { { - Name: "whoamirequests", - Kind: "WhoAmIRequest", - Verbs: []string{"create", "list"}, - Namespaced: false, - Categories: []string{"pinniped"}, + Name: "whoamirequests", + SingularName: "whoamirequest", + Kind: "WhoAmIRequest", + Verbs: []string{"create", "list"}, + Namespaced: false, + Categories: []string{"pinniped"}, }, }, }, @@ -131,11 +133,12 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr resourceByVersion: map[string][]metav1.APIResource{ clientSecretSupervisorGV.String(): { { - Name: "oidcclientsecretrequests", - Kind: "OIDCClientSecretRequest", - Verbs: []string{"create", "list"}, - Namespaced: true, - Categories: []string{"pinniped"}, + Name: "oidcclientsecretrequests", + SingularName: "oidcclientsecretrequest", + Kind: "OIDCClientSecretRequest", + Verbs: []string{"create", "list"}, + Namespaced: true, + Categories: []string{"pinniped"}, }, }, },