Aggregated API endpoints now must implement rest.SingularNameProvider

This was a change in the interface requirements introduced in Kube 1.27.
This commit is contained in:
Ryan Richard 2023-05-10 14:12:38 -07:00
parent 8c3395481b
commit bc9afc4554
7 changed files with 42 additions and 21 deletions

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
// Package clientsecretrequest provides REST functionality for the CredentialRequest resource. // Package clientsecretrequest provides REST functionality for the CredentialRequest resource.
@ -77,6 +77,7 @@ var _ interface {
rest.Scoper rest.Scoper
rest.Storage rest.Storage
rest.CategoriesProvider rest.CategoriesProvider
rest.SingularNameProvider
rest.Lister rest.Lister
rest.TableConvertor rest.TableConvertor
} = (*REST)(nil) } = (*REST)(nil)
@ -114,6 +115,10 @@ func (*REST) Categories() []string {
return []string{"pinniped"} 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) { 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", t := trace.FromContext(ctx).Nest("create",
trace.Field{Key: "kind", Value: "OIDCClientSecretRequest"}, trace.Field{Key: "kind", Value: "OIDCClientSecretRequest"},

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
package clientsecretrequest package clientsecretrequest
@ -50,6 +50,7 @@ func TestNew(t *testing.T) {
require.NotNil(t, r) require.NotNil(t, r)
require.True(t, r.NamespaceScoped()) require.True(t, r.NamespaceScoped())
require.Equal(t, []string{"pinniped"}, r.Categories()) require.Equal(t, []string{"pinniped"}, r.Categories())
require.Equal(t, "oidcclientsecretrequest", r.GetSingularName())
require.IsType(t, &clientsecretapi.OIDCClientSecretRequest{}, r.New()) require.IsType(t, &clientsecretapi.OIDCClientSecretRequest{}, r.New())
require.IsType(t, &clientsecretapi.OIDCClientSecretRequestList{}, r.NewList()) require.IsType(t, &clientsecretapi.OIDCClientSecretRequestList{}, r.NewList())

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
// Package credentialrequest provides REST functionality for the CredentialRequest resource. // Package credentialrequest provides REST functionality for the CredentialRequest resource.
@ -52,6 +52,7 @@ var _ interface {
rest.Scoper rest.Scoper
rest.Storage rest.Storage
rest.CategoriesProvider rest.CategoriesProvider
rest.SingularNameProvider
rest.Lister rest.Lister
} = (*REST)(nil) } = (*REST)(nil)
@ -86,6 +87,10 @@ func (*REST) Categories() []string {
return []string{"pinniped"} 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) { 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{ t := trace.FromContext(ctx).Nest("create", trace.Field{
Key: "kind", Key: "kind",

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
package credentialrequest package credentialrequest
@ -36,6 +36,7 @@ func TestNew(t *testing.T) {
require.NotNil(t, r) require.NotNil(t, r)
require.False(t, r.NamespaceScoped()) require.False(t, r.NamespaceScoped())
require.Equal(t, []string{"pinniped"}, r.Categories()) require.Equal(t, []string{"pinniped"}, r.Categories())
require.Equal(t, "tokencredentialrequest", r.GetSingularName())
require.IsType(t, &loginapi.TokenCredentialRequest{}, r.New()) require.IsType(t, &loginapi.TokenCredentialRequest{}, r.New())
require.IsType(t, &loginapi.TokenCredentialRequestList{}, r.NewList()) require.IsType(t, &loginapi.TokenCredentialRequestList{}, r.NewList())

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
package whoamirequest package whoamirequest
@ -38,6 +38,7 @@ var _ interface {
rest.Scoper rest.Scoper
rest.Storage rest.Storage
rest.CategoriesProvider rest.CategoriesProvider
rest.SingularNameProvider
rest.Lister rest.Lister
} = (*REST)(nil) } = (*REST)(nil)
@ -72,6 +73,10 @@ func (*REST) Categories() []string {
return []string{"pinniped"} 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) { func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
whoAmIRequest, ok := obj.(*identityapi.WhoAmIRequest) whoAmIRequest, ok := obj.(*identityapi.WhoAmIRequest)
if !ok { if !ok {

View File

@ -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 // SPDX-License-Identifier: Apache-2.0
package whoamirequest package whoamirequest
@ -25,6 +25,7 @@ func TestNew(t *testing.T) {
require.NotNil(t, r) require.NotNil(t, r)
require.False(t, r.NamespaceScoped()) require.False(t, r.NamespaceScoped())
require.Equal(t, []string{"pinniped"}, r.Categories()) require.Equal(t, []string{"pinniped"}, r.Categories())
require.Equal(t, "whoamirequest", r.GetSingularName())
require.IsType(t, &identityapi.WhoAmIRequest{}, r.New()) require.IsType(t, &identityapi.WhoAmIRequest{}, r.New())
require.IsType(t, &identityapi.WhoAmIRequestList{}, r.NewList()) require.IsType(t, &identityapi.WhoAmIRequestList{}, r.NewList())

View File

@ -79,11 +79,12 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr
resourceByVersion: map[string][]metav1.APIResource{ resourceByVersion: map[string][]metav1.APIResource{
loginConciergeGV.String(): { loginConciergeGV.String(): {
{ {
Name: "tokencredentialrequests", Name: "tokencredentialrequests",
Kind: "TokenCredentialRequest", SingularName: "tokencredentialrequest",
Verbs: []string{"create", "list"}, Kind: "TokenCredentialRequest",
Namespaced: false, Verbs: []string{"create", "list"},
Categories: []string{"pinniped"}, 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{ resourceByVersion: map[string][]metav1.APIResource{
identityConciergeGV.String(): { identityConciergeGV.String(): {
{ {
Name: "whoamirequests", Name: "whoamirequests",
Kind: "WhoAmIRequest", SingularName: "whoamirequest",
Verbs: []string{"create", "list"}, Kind: "WhoAmIRequest",
Namespaced: false, Verbs: []string{"create", "list"},
Categories: []string{"pinniped"}, 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{ resourceByVersion: map[string][]metav1.APIResource{
clientSecretSupervisorGV.String(): { clientSecretSupervisorGV.String(): {
{ {
Name: "oidcclientsecretrequests", Name: "oidcclientsecretrequests",
Kind: "OIDCClientSecretRequest", SingularName: "oidcclientsecretrequest",
Verbs: []string{"create", "list"}, Kind: "OIDCClientSecretRequest",
Namespaced: true, Verbs: []string{"create", "list"},
Categories: []string{"pinniped"}, Namespaced: true,
Categories: []string{"pinniped"},
}, },
}, },
}, },