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
// 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"},

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
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())

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
// 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",

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
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())

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
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 {

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
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())

View File

@ -80,6 +80,7 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr
loginConciergeGV.String(): {
{
Name: "tokencredentialrequests",
SingularName: "tokencredentialrequest",
Kind: "TokenCredentialRequest",
Verbs: []string{"create", "list"},
Namespaced: false,
@ -106,6 +107,7 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr
identityConciergeGV.String(): {
{
Name: "whoamirequests",
SingularName: "whoamirequest",
Kind: "WhoAmIRequest",
Verbs: []string{"create", "list"},
Namespaced: false,
@ -132,6 +134,7 @@ func TestGetAPIResourceList(t *testing.T) { //nolint:gocyclo // each t.Run is pr
clientSecretSupervisorGV.String(): {
{
Name: "oidcclientsecretrequests",
SingularName: "oidcclientsecretrequest",
Kind: "OIDCClientSecretRequest",
Verbs: []string{"create", "list"},
Namespaced: true,