Skip to content

Commit

Permalink
minor integration test fixes and more singular resource
Browse files Browse the repository at this point in the history
  • Loading branch information
ardaguclu committed Nov 18, 2022
1 parent 23e2899 commit 1f54f61
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 26 deletions.
Expand Up @@ -47,7 +47,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter, authorizer authorizer.Authori
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.ValidatingAdmissionPolicy).Name, nil
},
DefaultQualifiedResource: groupResource,
DefaultQualifiedResource: groupResource,
SingularQualifiedResource: admissionregistration.Resource("validatingadmissionpolicy"),

CreateStrategy: strategy,
UpdateStrategy: strategy,
Expand Down
Expand Up @@ -50,7 +50,8 @@ func NewREST(optsGetter generic.RESTOptionsGetter, authorizer authorizer.Authori
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.ValidatingAdmissionPolicyBinding).Name, nil
},
DefaultQualifiedResource: groupResource,
DefaultQualifiedResource: groupResource,
SingularQualifiedResource: admissionregistration.Resource("validatingadmissionpolicybinding"),

CreateStrategy: strategy,
UpdateStrategy: strategy,
Expand Down
2 changes: 2 additions & 0 deletions pkg/registry/authentication/selfsubjectreview/rest.go
Expand Up @@ -94,6 +94,8 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
return selfSAR, nil
}

var _ rest.SingularNameProvider = &REST{}

func (r *REST) GetSingularName() string {
return "selfsubjectrulesreview"
}
4 changes: 2 additions & 2 deletions pkg/registry/rbac/clusterrole/policybased/storage.go
Expand Up @@ -128,9 +128,9 @@ func hasAggregationRule(clusterRole *rbac.ClusterRole) bool {
var _ rest.SingularNameProvider = &Storage{}

func (s *Storage) GetSingularName() string {
svp, ok := s.StandardStorage.(rest.SingularNameProvider)
snp, ok := s.StandardStorage.(rest.SingularNameProvider)
if !ok {
return ""
}
return svp.GetSingularName()
return snp.GetSingularName()
}
4 changes: 2 additions & 2 deletions pkg/registry/rbac/clusterrolebinding/policybased/storage.go
Expand Up @@ -131,9 +131,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
var _ rest.SingularNameProvider = &Storage{}

func (s *Storage) GetSingularName() string {
svp, ok := s.StandardStorage.(rest.SingularNameProvider)
snp, ok := s.StandardStorage.(rest.SingularNameProvider)
if !ok {
return ""
}
return svp.GetSingularName()
return snp.GetSingularName()
}
4 changes: 2 additions & 2 deletions pkg/registry/rbac/role/policybased/storage.go
Expand Up @@ -103,9 +103,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
var _ rest.SingularNameProvider = &Storage{}

func (s *Storage) GetSingularName() string {
svp, ok := s.StandardStorage.(rest.SingularNameProvider)
snp, ok := s.StandardStorage.(rest.SingularNameProvider)
if !ok {
return ""
}
return svp.GetSingularName()
return snp.GetSingularName()
}
4 changes: 2 additions & 2 deletions pkg/registry/rbac/rolebinding/policybased/storage.go
Expand Up @@ -146,9 +146,9 @@ func (s *Storage) Update(ctx context.Context, name string, obj rest.UpdatedObjec
var _ rest.SingularNameProvider = &Storage{}

func (s *Storage) GetSingularName() string {
svp, ok := s.StandardStorage.(rest.SingularNameProvider)
snp, ok := s.StandardStorage.(rest.SingularNameProvider)
if !ok {
return ""
}
return svp.GetSingularName()
return snp.GetSingularName()
}
9 changes: 5 additions & 4 deletions pkg/registry/resource/podscheduling/storage/storage.go
Expand Up @@ -40,10 +40,11 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against PodSchedulings.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.PodScheduling{} },
NewListFunc: func() runtime.Object { return &resource.PodSchedulingList{} },
PredicateFunc: podscheduling.Match,
DefaultQualifiedResource: resource.Resource("podschedulings"),
NewFunc: func() runtime.Object { return &resource.PodScheduling{} },
NewListFunc: func() runtime.Object { return &resource.PodSchedulingList{} },
PredicateFunc: podscheduling.Match,
DefaultQualifiedResource: resource.Resource("podschedulings"),
SingularQualifiedResource: resource.Resource("podscheduling"),

CreateStrategy: podscheduling.Strategy,
UpdateStrategy: podscheduling.Strategy,
Expand Down
9 changes: 5 additions & 4 deletions pkg/registry/resource/resourceclaim/storage/storage.go
Expand Up @@ -40,10 +40,11 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ResourceClaims.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.ResourceClaim{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClaimList{} },
PredicateFunc: resourceclaim.Match,
DefaultQualifiedResource: resource.Resource("resourceclaims"),
NewFunc: func() runtime.Object { return &resource.ResourceClaim{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClaimList{} },
PredicateFunc: resourceclaim.Match,
DefaultQualifiedResource: resource.Resource("resourceclaims"),
SingularQualifiedResource: resource.Resource("resourceclaim"),

CreateStrategy: resourceclaim.Strategy,
UpdateStrategy: resourceclaim.Strategy,
Expand Down
Expand Up @@ -35,9 +35,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ResourceClass.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.ResourceClaimTemplate{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClaimTemplateList{} },
DefaultQualifiedResource: resource.Resource("resourceclaimtemplates"),
NewFunc: func() runtime.Object { return &resource.ResourceClaimTemplate{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClaimTemplateList{} },
DefaultQualifiedResource: resource.Resource("resourceclaimtemplates"),
SingularQualifiedResource: resource.Resource("resourceclaimtemplate"),

CreateStrategy: resourceclaimtemplate.Strategy,
UpdateStrategy: resourceclaimtemplate.Strategy,
Expand Down
7 changes: 4 additions & 3 deletions pkg/registry/resource/resourceclass/storage/storage.go
Expand Up @@ -35,9 +35,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ResourceClass.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.ResourceClass{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClassList{} },
DefaultQualifiedResource: resource.Resource("resourceclasses"),
NewFunc: func() runtime.Object { return &resource.ResourceClass{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClassList{} },
DefaultQualifiedResource: resource.Resource("resourceclasses"),
SingularQualifiedResource: resource.Resource("resourceclass"),

CreateStrategy: resourceclass.Strategy,
UpdateStrategy: resourceclass.Strategy,
Expand Down
4 changes: 2 additions & 2 deletions test/cmd/discovery.sh
Expand Up @@ -91,7 +91,7 @@ spec:
__EOF__

# Test that we can list this new custom resource
kube::test::wait_object_assert customresourcedefinitions "{{range.items}}{{if eq ${id_field:?} \\\"examples.test.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'examples.test.com:'
kube::test::wait_object_assert customresourcedefinitions "{{range.items}}{{if eq ${id_field:?} \"examples.test.com\"}}{{$id_field}}:{{end}}{{end}}" 'examples.test.com:'

kubectl create -f - << __EOF__
apiVersion: test.com/v1
Expand Down Expand Up @@ -169,7 +169,7 @@ spec:
__EOF__

# Test that we can list this new custom resource
kube::test::wait_object_assert customresourcedefinitions "{{range.items}}{{if eq ${id_field:?} \\\"examples.test.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'examples.test.com:'
kube::test::wait_object_assert customresourcedefinitions "{{range.items}}{{if eq ${id_field:?} \"examples.test.com\"}}{{$id_field}}:{{end}}{{end}}" 'examples.test.com:'

kubectl create -f - << __EOF__
apiVersion: test.com/v1
Expand Down

0 comments on commit 1f54f61

Please sign in to comment.