Skip to content

Commit

Permalink
don't expose oapi types as 'all'
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Feb 6, 2018
1 parent 284b8b7 commit 06715e2
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 13 deletions.
9 changes: 9 additions & 0 deletions pkg/apps/registry/deployconfig/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,12 @@ func (r *StatusREST) Get(ctx apirequest.Context, name string, options *metav1.Ge
func (r *StatusREST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo)
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}
9 changes: 9 additions & 0 deletions pkg/build/registry/build/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ func (r *DetailsREST) New() runtime.Object {
func (r *DetailsREST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo)
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}
9 changes: 9 additions & 0 deletions pkg/build/registry/buildconfig/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@ func NewREST(optsGetter restoptions.Getter) (*REST, error) {

return &REST{store}, nil
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}
33 changes: 20 additions & 13 deletions pkg/cmd/server/origin/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (

"github.com/openshift/origin/pkg/apps/registry/deployconfig"
deploymentconfigetcd "github.com/openshift/origin/pkg/apps/registry/deployconfig/etcd"
buildetcd "github.com/openshift/origin/pkg/build/registry/build/etcd"
buildconfig "github.com/openshift/origin/pkg/build/registry/buildconfig"
buildconfigetcd "github.com/openshift/origin/pkg/build/registry/buildconfig/etcd"
imagestreametcd "github.com/openshift/origin/pkg/image/registry/imagestream/etcd"
routeregistry "github.com/openshift/origin/pkg/route/registry/route"
routeetcd "github.com/openshift/origin/pkg/route/registry/route/etcd"
)
Expand Down Expand Up @@ -197,24 +199,29 @@ func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[
// Kube only did this for a select few resources which were controller managed and established links
// via a workload controller. In openshift, these will all conform to registry.Store so we
// can actually wrap the "normal" storage here.
switch resource {
case "buildConfigs":
restStorage := s.(*buildconfigetcd.REST)
store := *restStorage.Store
switch storage := s.(type) {
case *buildetcd.REST:
legacyStorage[resource] = &buildetcd.LegacyREST{REST: storage}

case *buildconfigetcd.REST:
store := *storage.Store
store.DeleteStrategy = buildconfig.LegacyStrategy
store.CreateStrategy = buildconfig.LegacyStrategy
legacyStorage[resource] = &buildconfigetcd.REST{Store: &store}
case "deploymentConfigs":
restStorage := s.(*deploymentconfigetcd.REST)
store := *restStorage.Store
legacyStorage[resource] = &buildconfigetcd.LegacyREST{REST: &buildconfigetcd.REST{Store: &store}}

case *deploymentconfigetcd.REST:
store := *storage.Store
store.CreateStrategy = deployconfig.LegacyStrategy
store.DeleteStrategy = deployconfig.LegacyStrategy
legacyStorage[resource] = &deploymentconfigetcd.REST{Store: &store}
case "routes":
restStorage := s.(*routeetcd.REST)
store := *restStorage.Store
legacyStorage[resource] = &deploymentconfigetcd.LegacyREST{REST: &deploymentconfigetcd.REST{Store: &store}}

case *imagestreametcd.REST:
legacyStorage[resource] = &imagestreametcd.LegacyREST{REST: storage}

case *routeetcd.REST:
store := *storage.Store
store.Decorator = routeregistry.DecorateLegacyRouteWithEmptyDestinationCACertificates
legacyStorage[resource] = &routeetcd.REST{Store: &store}
legacyStorage[resource] = &routeetcd.LegacyREST{REST: &routeetcd.REST{Store: &store}}

default:
legacyStorage[resource] = s
Expand Down
9 changes: 9 additions & 0 deletions pkg/image/registry/imagestream/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ func (r *InternalREST) Create(ctx apirequest.Context, obj runtime.Object, _ bool
func (r *InternalREST) Update(ctx apirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo)
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}
9 changes: 9 additions & 0 deletions pkg/route/registry/route/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ func (r *StatusREST) Get(ctx apirequest.Context, name string, options *metav1.Ge
func (r *StatusREST) Update(ctx apirequest.Context, name string, objInfo kapirest.UpdatedObjectInfo) (runtime.Object, bool, error) {
return r.store.Update(ctx, name, objInfo)
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}
9 changes: 9 additions & 0 deletions pkg/security/registry/securitycontextconstraints/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
}
return &REST{store}
}

// LegacyREST allows us to wrap and alter some behavior
type LegacyREST struct {
*REST
}

func (r *LegacyREST) Categories() []string {
return []string{}
}

0 comments on commit 06715e2

Please sign in to comment.