Skip to content

Commit 8708fd5

Browse files
committed
collapse onto upstream storage RESTOptions
1 parent b8be8a7 commit 8708fd5

File tree

33 files changed

+56
-104
lines changed

33 files changed

+56
-104
lines changed

pkg/apps/apiserver/registry/deployconfig/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/openshift/origin/pkg/apps/apiserver/registry/deployconfig"
2828
appsutil "github.com/openshift/origin/pkg/apps/util"
2929
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
30-
"github.com/openshift/origin/pkg/util/restoptions"
3130
)
3231

3332
// REST contains the REST storage for DeploymentConfig objects.
@@ -52,7 +51,7 @@ func (r *REST) ShortNames() []string {
5251
// NewREST returns a deploymentConfigREST containing the REST storage for DeploymentConfig objects,
5352
// a statusREST containing the REST storage for changing the status of a DeploymentConfig,
5453
// and a scaleREST containing the REST storage for the Scale subresources of DeploymentConfigs.
55-
func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, error) {
54+
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *ScaleREST, error) {
5655
store := &registry.Store{
5756
NewFunc: func() runtime.Object { return &appsapi.DeploymentConfig{} },
5857
NewListFunc: func() runtime.Object { return &appsapi.DeploymentConfigList{} },

pkg/authorization/apiserver/registry/rolebindingrestriction/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization"
1313
"github.com/openshift/origin/pkg/authorization/apiserver/registry/rolebindingrestriction"
1414
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
15-
"github.com/openshift/origin/pkg/util/restoptions"
1615
)
1716

1817
type REST struct {
@@ -22,7 +21,7 @@ type REST struct {
2221
var _ rest.StandardStorage = &REST{}
2322

2423
// NewREST returns a RESTStorage object that will work against nodes.
25-
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
24+
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
2625
store := &registry.Store{
2726
NewFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestriction{} },
2827
NewListFunc: func() runtime.Object { return &authorizationapi.RoleBindingRestrictionList{} },

pkg/build/apiserver/registry/build/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
buildapi "github.com/openshift/origin/pkg/build/apis/build"
1616
buildregistry "github.com/openshift/origin/pkg/build/apiserver/registry/build"
1717
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
18-
"github.com/openshift/origin/pkg/util/restoptions"
1918
)
2019

2120
type REST struct {
@@ -31,7 +30,7 @@ func (r *REST) Categories() []string {
3130
}
3231

3332
// NewREST returns a RESTStorage object that will work against Build objects.
34-
func NewREST(optsGetter restoptions.Getter) (*REST, *DetailsREST, error) {
33+
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *DetailsREST, error) {
3534
store := &registry.Store{
3635
NewFunc: func() runtime.Object { return &buildapi.Build{} },
3736
NewListFunc: func() runtime.Object { return &buildapi.BuildList{} },

pkg/build/apiserver/registry/buildconfig/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
buildapi "github.com/openshift/origin/pkg/build/apis/build"
1313
"github.com/openshift/origin/pkg/build/apiserver/registry/buildconfig"
1414
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
15-
"github.com/openshift/origin/pkg/util/restoptions"
1615
)
1716

1817
type REST struct {
@@ -34,7 +33,7 @@ func (r *REST) ShortNames() []string {
3433
}
3534

3635
// NewREST returns a RESTStorage object that will work against BuildConfig.
37-
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
36+
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
3837
store := &registry.Store{
3938
NewFunc: func() runtime.Object { return &buildapi.BuildConfig{} },
4039
NewListFunc: func() runtime.Object { return &buildapi.BuildConfigList{} },

pkg/cmd/openshift-apiserver/openshiftapiserver/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/openshift/origin/pkg/image/apiserver/registryhostname"
2929
sccstorage "github.com/openshift/origin/pkg/security/apiserver/registry/securitycontextconstraints/etcd"
3030
usercache "github.com/openshift/origin/pkg/user/cache"
31-
"github.com/openshift/origin/pkg/util/restoptions"
3231
"github.com/openshift/origin/pkg/version"
3332
)
3433

@@ -49,7 +48,7 @@ func NewOpenshiftAPIConfig(openshiftAPIServerConfig *configapi.MasterConfig) (*O
4948
if err != nil {
5049
return nil, err
5150
}
52-
restOptsGetter, err := restoptions.NewConfigGetter(*openshiftAPIServerConfig)
51+
restOptsGetter, err := NewRESTOptionsGetter(*openshiftAPIServerConfig)
5352
if err != nil {
5453
return nil, err
5554
}

pkg/util/restoptions/configgetter.go renamed to pkg/cmd/openshift-apiserver/openshiftapiserver/restoptionsgetter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package restoptions
1+
package openshiftapiserver
22

33
import (
44
"strconv"
55

66
"k8s.io/apimachinery/pkg/runtime/schema"
7+
genericregistry "k8s.io/apiserver/pkg/registry/generic"
78
"k8s.io/apiserver/pkg/server/options"
89
apiserverstorage "k8s.io/apiserver/pkg/server/storage"
910
serverstorage "k8s.io/apiserver/pkg/server/storage"
@@ -14,8 +15,7 @@ import (
1415
)
1516

1617
// NewConfigGetter returns a restoptions.Getter implemented using information from the provided master config.
17-
// TODO: this class should either not need to know about configapi.MasterConfig, or not be in pkg/util
18-
func NewConfigGetter(masterOptions configapi.MasterConfig) (Getter, error) {
18+
func NewRESTOptionsGetter(masterOptions configapi.MasterConfig) (genericregistry.RESTOptionsGetter, error) {
1919
var err error
2020
targetRAMMB := 0
2121
if targetRamString := masterOptions.KubernetesMasterConfig.APIServerArguments["target-ram-mb"]; len(targetRamString) == 1 {

pkg/cmd/server/origin/master_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"k8s.io/apiserver/pkg/admission"
99
admissionmetrics "k8s.io/apiserver/pkg/admission/metrics"
1010
"k8s.io/apiserver/pkg/audit"
11+
genericregistry "k8s.io/apiserver/pkg/registry/generic"
1112
genericapiserver "k8s.io/apiserver/pkg/server"
1213
cacheddiscovery "k8s.io/client-go/discovery/cached"
1314
kinformers "k8s.io/client-go/informers"
@@ -39,7 +40,6 @@ import (
3940
"github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver"
4041
"github.com/openshift/origin/pkg/image/apiserver/registryhostname"
4142
securityinformer "github.com/openshift/origin/pkg/security/generated/informers/internalversion"
42-
"github.com/openshift/origin/pkg/util/restoptions"
4343
)
4444

4545
// MasterConfig defines the required parameters for starting the OpenShift master
@@ -52,7 +52,7 @@ type MasterConfig struct {
5252
additionalPostStartHooks map[string]genericapiserver.PostStartHookFunc
5353

5454
// RESTOptionsGetter provides access to storage and RESTOptions for a particular resource
55-
RESTOptionsGetter restoptions.Getter
55+
RESTOptionsGetter genericregistry.RESTOptionsGetter
5656

5757
RuleResolver rbacregistryvalidation.AuthorizationRuleResolver
5858
SubjectLocator rbacauthorizer.SubjectLocator
@@ -130,7 +130,7 @@ func BuildMasterConfig(
130130
informers = realLoopbackInformers
131131
}
132132

133-
restOptsGetter, err := restoptions.NewConfigGetter(options)
133+
restOptsGetter, err := openshiftapiserver.NewRESTOptionsGetter(options)
134134
if err != nil {
135135
return nil, err
136136
}

pkg/image/apiserver/registry/image/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
imageapi "github.com/openshift/origin/pkg/image/apis/image"
1313
imageregistry "github.com/openshift/origin/pkg/image/apiserver/registry/image"
1414
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
15-
"github.com/openshift/origin/pkg/util/restoptions"
1615
)
1716

1817
// REST implements a RESTStorage for images against etcd.
@@ -23,7 +22,7 @@ type REST struct {
2322
var _ rest.StandardStorage = &REST{}
2423

2524
// NewREST returns a new REST.
26-
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
25+
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
2726
store := &registry.Store{
2827
NewFunc: func() runtime.Object { return &imageapi.Image{} },
2928
NewListFunc: func() runtime.Object { return &imageapi.ImageList{} },

pkg/image/apiserver/registry/image/etcd/etcd_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ import (
99
"k8s.io/apimachinery/pkg/runtime"
1010
"k8s.io/apimachinery/pkg/runtime/schema"
1111
apirequest "k8s.io/apiserver/pkg/endpoints/request"
12+
"k8s.io/apiserver/pkg/registry/generic"
1213
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
1314
"k8s.io/apiserver/pkg/registry/rest"
1415
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
1516
"k8s.io/kubernetes/pkg/api/legacyscheme"
1617

1718
imageapi "github.com/openshift/origin/pkg/image/apis/image"
1819
"github.com/openshift/origin/pkg/image/apiserver/registry/image"
19-
"github.com/openshift/origin/pkg/util/restoptions"
2020
// install all APIs
2121
_ "github.com/openshift/origin/pkg/api/install"
2222
)
2323

2424
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) {
2525
server, etcdStorage := etcdtesting.NewUnsecuredEtcd3TestClientServer(t)
2626
etcdStorage.Codec = legacyscheme.Codecs.LegacyCodec(schema.GroupVersion{Group: "image.openshift.io", Version: "v1"})
27-
storage, err := NewREST(restoptions.NewSimpleGetter(etcdStorage))
27+
imageRESTOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "images"}
28+
storage, err := NewREST(imageRESTOptions)
2829
if err != nil {
2930
t.Fatal(err)
3031
}

pkg/image/apiserver/registry/imagestream/etcd/etcd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/openshift/origin/pkg/image/apiserver/registry/imagestream"
2525
"github.com/openshift/origin/pkg/image/apiserver/registryhostname"
2626
printersinternal "github.com/openshift/origin/pkg/printers/internalversion"
27-
"github.com/openshift/origin/pkg/util/restoptions"
2827
)
2928

3029
// REST implements a RESTStorage for image streams against etcd.
@@ -48,7 +47,7 @@ func (r *REST) ShortNames() []string {
4847

4948
// NewREST returns a new REST.
5049
func NewREST(
51-
optsGetter restoptions.Getter,
50+
optsGetter generic.RESTOptionsGetter,
5251
registryHostname registryhostname.RegistryHostnameRetriever,
5352
subjectAccessReviewRegistry authorizationclient.SubjectAccessReviewInterface,
5453
limitVerifier imageadmission.LimitVerifier,

0 commit comments

Comments
 (0)