Skip to content

Commit 7764bd5

Browse files
authored
Short names for staged policies (#10280)
1 parent 8c8c80b commit 7764bd5

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

apiserver/pkg/registry/projectcalico/rest/storage_calico.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (p RESTStorageProvider) NewV3Storage(
104104
},
105105
p.StorageType,
106106
authorizer,
107-
[]string{},
107+
[]string{"sknp"},
108108
)
109109

110110
stagedpolicyRESTOptions, err := restOptionsGetter.GetRESTOptions(calico.Resource("stagednetworkpolicies"), nil)
@@ -126,7 +126,7 @@ func (p RESTStorageProvider) NewV3Storage(
126126
},
127127
p.StorageType,
128128
authorizer,
129-
[]string{},
129+
[]string{"snp"},
130130
)
131131

132132
networksetRESTOptions, err := restOptionsGetter.GetRESTOptions(calico.Resource("networksets"), nil)
@@ -214,7 +214,7 @@ func (p RESTStorageProvider) NewV3Storage(
214214
},
215215
p.StorageType,
216216
authorizer,
217-
[]string{},
217+
[]string{"sgnp"},
218218
)
219219

220220
gNetworkSetRESTOptions, err := restOptionsGetter.GetRESTOptions(calico.Resource("globalnetworksets"), nil)

apiserver/pkg/registry/projectcalico/stagedglobalnetworkpolicy/storage.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type REST struct {
3939
*genericregistry.Store
4040
rbac.CalicoResourceLister
4141
authorizer authorizer.TierAuthorizer
42+
shortNames []string
4243
}
4344

4445
// EmptyObject returns an empty instance
@@ -102,7 +103,7 @@ func NewREST(scheme *runtime.Scheme, opts server.Options, calicoResourceLister r
102103
DestroyFunc: dFunc,
103104
}
104105

105-
return &REST{store, calicoResourceLister, authorizer.NewTierAuthorizer(opts.Authorizer)}, nil
106+
return &REST{store, calicoResourceLister, authorizer.NewTierAuthorizer(opts.Authorizer), opts.ShortNames}, nil
106107
}
107108

108109
func (r *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
@@ -166,3 +167,7 @@ func (r *REST) Watch(ctx context.Context, options *metainternalversion.ListOptio
166167

167168
return r.Store.Watch(ctx, options)
168169
}
170+
171+
func (r *REST) ShortNames() []string {
172+
return r.shortNames
173+
}

apiserver/pkg/registry/projectcalico/stagedkubernetesnetworkpolicy/storage.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
// rest implements a RESTStorage for API services against etcd
3131
type REST struct {
3232
*genericregistry.Store
33+
shortNames []string
3334
}
3435

3536
// EmptyObject returns an empty instance
@@ -89,5 +90,9 @@ func NewREST(scheme *runtime.Scheme, opts server.Options) (*REST, error) {
8990
DestroyFunc: dFunc,
9091
}
9192

92-
return &REST{store}, nil
93+
return &REST{store, opts.ShortNames}, nil
94+
}
95+
96+
func (r *REST) ShortNames() []string {
97+
return r.shortNames
9398
}

apiserver/pkg/registry/projectcalico/stagednetworkpolicy/storage.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type REST struct {
3939
*genericregistry.Store
4040
rbac.CalicoResourceLister
4141
authorizer authorizer.TierAuthorizer
42+
shortNames []string
4243
}
4344

4445
// EmptyObject returns an empty instance
@@ -98,7 +99,7 @@ func NewREST(scheme *runtime.Scheme, opts server.Options, calicoResourceLister r
9899
DestroyFunc: dFunc,
99100
}
100101

101-
return &REST{store, calicoResourceLister, authorizer.NewTierAuthorizer(opts.Authorizer)}, nil
102+
return &REST{store, calicoResourceLister, authorizer.NewTierAuthorizer(opts.Authorizer), opts.ShortNames}, nil
102103
}
103104

104105
func (r *REST) List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error) {
@@ -162,3 +163,7 @@ func (r *REST) Watch(ctx context.Context, options *metainternalversion.ListOptio
162163

163164
return r.Store.Watch(ctx, options)
164165
}
166+
167+
func (r *REST) ShortNames() []string {
168+
return r.shortNames
169+
}

0 commit comments

Comments
 (0)