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

Update etcd stores to use DefaultQualifiedResource #15721

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
8 changes: 4 additions & 4 deletions pkg/authorization/registry/clusterpolicy/etcd/etcd.go
Expand Up @@ -18,10 +18,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ClusterPolicy.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyList{} },
QualifiedResource: authorizationapi.Resource("clusterpolicies"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyList{} },
DefaultQualifiedResource: authorizationapi.Resource("clusterpolicies"),

CreateStrategy: clusterpolicy.Strategy,
UpdateStrategy: clusterpolicy.Strategy,
Expand Down
8 changes: 4 additions & 4 deletions pkg/authorization/registry/clusterpolicybinding/etcd/etcd.go
Expand Up @@ -18,10 +18,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against ClusterPolicyBinding.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBinding{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBindingList{} },
QualifiedResource: authorizationapi.Resource("clusterpolicybindings"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBinding{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyBindingList{} },
DefaultQualifiedResource: authorizationapi.Resource("clusterpolicybindings"),

CreateStrategy: clusterpolicybinding.Strategy,
UpdateStrategy: clusterpolicybinding.Strategy,
Expand Down
8 changes: 4 additions & 4 deletions pkg/authorization/registry/policy/etcd/etcd.go
Expand Up @@ -18,10 +18,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against Policy objects.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.Policy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.PolicyList{} },
QualifiedResource: authorizationapi.Resource("policies"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.Policy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.PolicyList{} },
DefaultQualifiedResource: authorizationapi.Resource("policies"),

CreateStrategy: policy.Strategy,
UpdateStrategy: policy.Strategy,
Expand Down
8 changes: 4 additions & 4 deletions pkg/authorization/registry/policybinding/etcd/etcd.go
Expand Up @@ -22,10 +22,10 @@ type REST struct {
// NewREST returns a RESTStorage object that will work against PolicyBinding objects.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.PolicyBinding{} },
NewListFunc: func() runtime.Object { return &authorizationapi.PolicyBindingList{} },
QualifiedResource: authorizationapi.Resource("policybindings"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.PolicyBinding{} },
NewListFunc: func() runtime.Object { return &authorizationapi.PolicyBindingList{} },
DefaultQualifiedResource: authorizationapi.Resource("policybindings"),

CreateStrategy: policybinding.Strategy,
UpdateStrategy: policybinding.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/authorization/registry/rolebindingrestriction/etcd/etcd.go
Expand Up @@ -21,11 +21,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against nodes.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestriction{} },
NewListFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestrictionList{} },
QualifiedResource: authorizationapi.Resource("rolebindingrestrictions"),
PredicateFunc: rolebindingrestriction.Matcher,
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestriction{} },
NewListFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestrictionList{} },
DefaultQualifiedResource: authorizationapi.Resource("rolebindingrestrictions"),
PredicateFunc: rolebindingrestriction.Matcher,

CreateStrategy: rolebindingrestriction.Strategy,
UpdateStrategy: rolebindingrestriction.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/build/registry/build/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against Build objects.
func NewREST(optsGetter restoptions.Getter) (*REST, *DetailsREST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &buildapi.Build{} },
NewListFunc: func() runtime.Object { return &buildapi.BuildList{} },
PredicateFunc: build.Matcher,
QualifiedResource: buildapi.Resource("builds"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &buildapi.Build{} },
NewListFunc: func() runtime.Object { return &buildapi.BuildList{} },
PredicateFunc: build.Matcher,
DefaultQualifiedResource: buildapi.Resource("builds"),

CreateStrategy: build.Strategy,
UpdateStrategy: build.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/build/registry/buildconfig/etcd/etcd.go
Expand Up @@ -21,11 +21,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against BuildConfig.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &buildapi.BuildConfig{} },
NewListFunc: func() runtime.Object { return &buildapi.BuildConfigList{} },
QualifiedResource: buildapi.Resource("buildconfigs"),
PredicateFunc: buildconfig.Matcher,
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &buildapi.BuildConfig{} },
NewListFunc: func() runtime.Object { return &buildapi.BuildConfigList{} },
DefaultQualifiedResource: buildapi.Resource("buildconfigs"),
PredicateFunc: buildconfig.Matcher,

CreateStrategy: buildconfig.GroupStrategy,
UpdateStrategy: buildconfig.GroupStrategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/deploy/registry/deployconfig/etcd/etcd.go
Expand Up @@ -31,11 +31,11 @@ var _ rest.StandardStorage = &REST{}
// and a scaleREST containing the REST storage for the Scale subresources of DeploymentConfigs.
func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &deployapi.DeploymentConfig{} },
NewListFunc: func() runtime.Object { return &deployapi.DeploymentConfigList{} },
PredicateFunc: deployconfig.Matcher,
QualifiedResource: deployapi.Resource("deploymentconfigs"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &deployapi.DeploymentConfig{} },
NewListFunc: func() runtime.Object { return &deployapi.DeploymentConfigList{} },
PredicateFunc: deployconfig.Matcher,
DefaultQualifiedResource: deployapi.Resource("deploymentconfigs"),

CreateStrategy: deployconfig.Strategy,
UpdateStrategy: deployconfig.Strategy,
Expand Down
6 changes: 3 additions & 3 deletions pkg/dockerregistry/server/manifestservice.go
Expand Up @@ -174,9 +174,9 @@ func (m *manifestService) Put(ctx context.Context, manifest distribution.Manifes
}

status := statusErr.ErrStatus
if status.Code != http.StatusNotFound ||
(strings.ToLower(status.Details.Kind) != "imagestream" /*pre-1.2*/ && strings.ToLower(status.Details.Kind) != "imagestreams") ||
status.Details.Name != m.repo.name {
kind := strings.ToLower(status.Details.Kind)
isValidKind := kind == "imagestream" /*pre-1.2*/ || kind == "imagestreams" /*1.2 to 1.6*/ || kind == "imagestreammappings" /*1.7+*/
if !isValidKind || status.Code != http.StatusNotFound || status.Details.Name != m.repo.name {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legionus @mfojtik PTAL

This change is required because in pkg/image/registry/imagestreammapping/rest.go:

// findStreamForMapping retrieves an ImageStream whose DockerImageRepository matches dockerRepo.
func (s *REST) findStreamForMapping(ctx apirequest.Context, mapping *imageapi.ImageStreamMapping) (*imageapi.ImageStream, error) {
	if len(mapping.Name) > 0 {
		// Since ctx is passed through here, this returns a NotFound error for imagestreammappings now
		return s.imageStreamRegistry.GetImageStream(ctx, mapping.Name, &metav1.GetOptions{})
	}
...
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

context.GetLogger(ctx).Errorf("error creating ImageStreamMapping: %s", err)
return "", err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/image/registry/image/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a new REST.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &imageapi.Image{} },
NewListFunc: func() runtime.Object { return &imageapi.ImageList{} },
PredicateFunc: image.Matcher,
QualifiedResource: imageapi.Resource("images"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &imageapi.Image{} },
NewListFunc: func() runtime.Object { return &imageapi.ImageList{} },
PredicateFunc: image.Matcher,
DefaultQualifiedResource: imageapi.Resource("images"),

CreateStrategy: image.Strategy,
UpdateStrategy: image.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/image/registry/imagestream/etcd/etcd.go
Expand Up @@ -27,11 +27,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a new REST.
func NewREST(optsGetter restoptions.Getter, defaultRegistry imageapi.DefaultRegistry, subjectAccessReviewRegistry subjectaccessreview.Registry, limitVerifier imageadmission.LimitVerifier) (*REST, *StatusREST, *InternalREST, error) {
store := registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &imageapi.ImageStream{} },
NewListFunc: func() runtime.Object { return &imageapi.ImageStreamList{} },
PredicateFunc: imagestream.Matcher,
QualifiedResource: imageapi.Resource("imagestreams"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &imageapi.ImageStream{} },
NewListFunc: func() runtime.Object { return &imageapi.ImageStreamList{} },
PredicateFunc: imagestream.Matcher,
DefaultQualifiedResource: imageapi.Resource("imagestreams"),
}

rest := &REST{
Expand Down
10 changes: 5 additions & 5 deletions pkg/oauth/registry/oauthaccesstoken/etcd/etcd.go
Expand Up @@ -28,11 +28,11 @@ var _ rest.StandardStorage = &REST{}
func NewREST(optsGetter restoptions.Getter, clientGetter oauthclient.Getter, backends ...storage.Interface) (*REST, error) {
strategy := oauthaccesstoken.NewStrategy(clientGetter)
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthAccessToken{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthAccessTokenList{} },
PredicateFunc: oauthaccesstoken.Matcher,
QualifiedResource: oauthapi.Resource("oauthaccesstokens"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthAccessToken{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthAccessTokenList{} },
PredicateFunc: oauthaccesstoken.Matcher,
DefaultQualifiedResource: oauthapi.Resource("oauthaccesstokens"),

TTLFunc: func(obj runtime.Object, existing uint64, update bool) (uint64, error) {
token := obj.(*oauthapi.OAuthAccessToken)
Expand Down
10 changes: 5 additions & 5 deletions pkg/oauth/registry/oauthauthorizetoken/etcd/etcd.go
Expand Up @@ -24,11 +24,11 @@ var _ rest.StandardStorage = &REST{}
func NewREST(optsGetter restoptions.Getter, clientGetter oauthclient.Getter) (*REST, error) {
strategy := oauthauthorizetoken.NewStrategy(clientGetter)
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthAuthorizeToken{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthAuthorizeTokenList{} },
PredicateFunc: oauthauthorizetoken.Matcher,
QualifiedResource: oauthapi.Resource("oauthauthorizetokens"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthAuthorizeToken{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthAuthorizeTokenList{} },
PredicateFunc: oauthauthorizetoken.Matcher,
DefaultQualifiedResource: oauthapi.Resource("oauthauthorizetokens"),

TTLFunc: func(obj runtime.Object, existing uint64, update bool) (uint64, error) {
token := obj.(*oauthapi.OAuthAuthorizeToken)
Expand Down
10 changes: 5 additions & 5 deletions pkg/oauth/registry/oauthclient/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against oauth clients
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthClient{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthClientList{} },
PredicateFunc: oauthclient.Matcher,
QualifiedResource: oauthapi.Resource("oauthclients"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthClient{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthClientList{} },
PredicateFunc: oauthclient.Matcher,
DefaultQualifiedResource: oauthapi.Resource("oauthclients"),

CreateStrategy: oauthclient.Strategy,
UpdateStrategy: oauthclient.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/oauth/registry/oauthclientauthorization/etcd/etcd.go
Expand Up @@ -25,11 +25,11 @@ func NewREST(optsGetter restoptions.Getter, clientGetter oauthclient.Getter) (*R
strategy := oauthclientauthorization.NewStrategy(clientGetter)

store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthClientAuthorization{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthClientAuthorizationList{} },
PredicateFunc: oauthclientauthorization.Matcher,
QualifiedResource: oauthapi.Resource("oauthclientauthorizations"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &oauthapi.OAuthClientAuthorization{} },
NewListFunc: func() runtime.Object { return &oauthapi.OAuthClientAuthorizationList{} },
PredicateFunc: oauthclientauthorization.Matcher,
DefaultQualifiedResource: oauthapi.Resource("oauthclientauthorizations"),

CreateStrategy: strategy,
UpdateStrategy: strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/quota/registry/clusterresourcequota/etcd/etcd.go
Expand Up @@ -23,11 +23,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against ClusterResourceQuota objects.
func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &quotaapi.ClusterResourceQuota{} },
NewListFunc: func() runtime.Object { return &quotaapi.ClusterResourceQuotaList{} },
PredicateFunc: clusterresourcequota.Matcher,
QualifiedResource: quotaapi.Resource("clusterresourcequotas"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &quotaapi.ClusterResourceQuota{} },
NewListFunc: func() runtime.Object { return &quotaapi.ClusterResourceQuotaList{} },
PredicateFunc: clusterresourcequota.Matcher,
DefaultQualifiedResource: quotaapi.Resource("clusterresourcequotas"),

CreateStrategy: clusterresourcequota.Strategy,
UpdateStrategy: clusterresourcequota.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/route/registry/route/etcd/etcd.go
Expand Up @@ -27,11 +27,11 @@ func NewREST(optsGetter restoptions.Getter, allocator route.RouteAllocator, sarC
strategy := routeregistry.NewStrategy(allocator, sarClient)

store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &routeapi.Route{} },
NewListFunc: func() runtime.Object { return &routeapi.RouteList{} },
PredicateFunc: routeregistry.Matcher,
QualifiedResource: routeapi.Resource("routes"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &routeapi.Route{} },
NewListFunc: func() runtime.Object { return &routeapi.RouteList{} },
PredicateFunc: routeregistry.Matcher,
DefaultQualifiedResource: routeapi.Resource("routes"),

CreateStrategy: strategy,
UpdateStrategy: strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/sdn/registry/clusternetwork/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against subnets
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.ClusterNetwork{} },
NewListFunc: func() runtime.Object { return &sdnapi.ClusterNetworkList{} },
PredicateFunc: clusternetwork.Matcher,
QualifiedResource: sdnapi.Resource("clusternetworks"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.ClusterNetwork{} },
NewListFunc: func() runtime.Object { return &sdnapi.ClusterNetworkList{} },
PredicateFunc: clusternetwork.Matcher,
DefaultQualifiedResource: sdnapi.Resource("clusternetworks"),

CreateStrategy: clusternetwork.Strategy,
UpdateStrategy: clusternetwork.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/sdn/registry/egressnetworkpolicy/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against egress network policy
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.EgressNetworkPolicy{} },
NewListFunc: func() runtime.Object { return &sdnapi.EgressNetworkPolicyList{} },
PredicateFunc: egressnetworkpolicy.Matcher,
QualifiedResource: sdnapi.Resource("egressnetworkpolicies"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.EgressNetworkPolicy{} },
NewListFunc: func() runtime.Object { return &sdnapi.EgressNetworkPolicyList{} },
PredicateFunc: egressnetworkpolicy.Matcher,
DefaultQualifiedResource: sdnapi.Resource("egressnetworkpolicies"),

CreateStrategy: egressnetworkpolicy.Strategy,
UpdateStrategy: egressnetworkpolicy.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/sdn/registry/hostsubnet/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against subnets
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.HostSubnet{} },
NewListFunc: func() runtime.Object { return &sdnapi.HostSubnetList{} },
PredicateFunc: hostsubnet.Matcher,
QualifiedResource: sdnapi.Resource("hostsubnets"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.HostSubnet{} },
NewListFunc: func() runtime.Object { return &sdnapi.HostSubnetList{} },
PredicateFunc: hostsubnet.Matcher,
DefaultQualifiedResource: sdnapi.Resource("hostsubnets"),

CreateStrategy: hostsubnet.Strategy,
UpdateStrategy: hostsubnet.Strategy,
Expand Down
10 changes: 5 additions & 5 deletions pkg/sdn/registry/netnamespace/etcd/etcd.go
Expand Up @@ -22,11 +22,11 @@ var _ rest.StandardStorage = &REST{}
// NewREST returns a RESTStorage object that will work against netnamespaces
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := &registry.Store{
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.NetNamespace{} },
NewListFunc: func() runtime.Object { return &sdnapi.NetNamespaceList{} },
PredicateFunc: netnamespace.Matcher,
QualifiedResource: sdnapi.Resource("netnamespaces"),
Copier: kapi.Scheme,
NewFunc: func() runtime.Object { return &sdnapi.NetNamespace{} },
NewListFunc: func() runtime.Object { return &sdnapi.NetNamespaceList{} },
PredicateFunc: netnamespace.Matcher,
DefaultQualifiedResource: sdnapi.Resource("netnamespaces"),

CreateStrategy: netnamespace.Strategy,
UpdateStrategy: netnamespace.Strategy,
Expand Down