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

make config scheme install normal #20471

Merged
merged 2 commits into from
Jul 31, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/openshift-node-config/openshift-node-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func main() {
Kubelet command-line flags.
`),
RunE: func(cmd *cobra.Command, args []string) error {
configapi.AddToScheme(configapi.Scheme)
configapiv1.AddToScheme(configapi.Scheme)
configapi.InstallLegacy(configapi.Scheme)
configapiv1.InstallLegacy(configapi.Scheme)

if len(configFile) == 0 {
return fmt.Errorf("you must specify a --config file to read")
Expand Down
1 change: 0 additions & 1 deletion hack/update-generated-deep-copies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ALL_FQ_APIS=(
github.com/openshift/origin/pkg/build/controller/build/apis/defaults/v1
github.com/openshift/origin/pkg/build/controller/build/apis/overrides
github.com/openshift/origin/pkg/build/controller/build/apis/overrides/v1
github.com/openshift/origin/pkg/build/controller/build/pluginconfig/testing
github.com/openshift/origin/pkg/cmd/server/apis/config
github.com/openshift/origin/pkg/cmd/server/apis/config/v1
github.com/openshift/origin/pkg/cmd/server/apis/config/v1/testing
Expand Down
14 changes: 3 additions & 11 deletions pkg/api/install/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"

configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
configapiv1 "github.com/openshift/origin/pkg/cmd/server/apis/config/v1"
configapiinstall "github.com/openshift/origin/pkg/cmd/server/apis/config/install"
)

func TestDescriptions(t *testing.T) {
Expand Down Expand Up @@ -66,6 +65,7 @@ func TestInternalJsonTags(t *testing.T) {
scheme := runtime.NewScheme()
InstallInternalOpenShift(scheme)
InstallInternalKube(scheme)
configapiinstall.InstallLegacyInternal(scheme)

seen := map[reflect.Type]bool{}
seenGroups := sets.String{}
Expand All @@ -81,10 +81,6 @@ func TestInternalJsonTags(t *testing.T) {
checkInternalJsonTags(apiType, &seen, t)
}
}

for _, apiType := range configapi.Scheme.KnownTypes(configapi.SchemeGroupVersion) {
checkInternalJsonTags(apiType, &seen, t)
}
}

// internalTypesWithAllowedJsonTags is the list of special structs that have a particular need to have json tags on their
Expand Down Expand Up @@ -130,6 +126,7 @@ func TestExternalJsonTags(t *testing.T) {
scheme := runtime.NewScheme()
InstallInternalOpenShift(scheme)
InstallInternalKube(scheme)
configapiinstall.InstallLegacyInternal(scheme)

seen := map[reflect.Type]bool{}

Expand All @@ -138,11 +135,6 @@ func TestExternalJsonTags(t *testing.T) {
checkExternalJsonTags(apiType, &seen, t)
}
}

for _, apiType := range configapi.Scheme.KnownTypes(configapiv1.SchemeGroupVersion) {
checkExternalJsonTags(apiType, &seen, t)
}

}

func checkExternalJsonTags(objType reflect.Type, seen *map[reflect.Type]bool, t *testing.T) {
Expand Down
41 changes: 5 additions & 36 deletions pkg/build/controller/build/apis/defaults/install/install.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package install

import (
"github.com/golang/glog"

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

"github.com/openshift/origin/pkg/build/controller/build/apis/defaults"
"github.com/openshift/origin/pkg/build/controller/build/apis/defaults/v1"
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
)

// availableVersions lists all known external versions for this group from most preferred to least preferred
var availableVersions = []schema.GroupVersion{v1.SchemeGroupVersion}

func init() {
if err := enableVersions(availableVersions); err != nil {
panic(err)
}
}

// TODO: enableVersions should be centralized rather than spread in each API
// group.
// We can combine registered.RegisterVersions, registered.EnableVersions and
// registered.RegisterGroup once we have moved enableVersions there.
func enableVersions(externalVersions []schema.GroupVersion) error {
addVersionsToScheme(externalVersions...)
return nil
}

func addVersionsToScheme(externalVersions ...schema.GroupVersion) {
// add the internal version to Scheme
defaults.AddToScheme(configapi.Scheme)
// add the enabled external versions to Scheme
for _, v := range externalVersions {
switch v {
case v1.SchemeGroupVersion:
v1.AddToScheme(configapi.Scheme)

default:
glog.Errorf("Version %s is not known, so it will not be added to the Scheme.", v)
continue
}
}
func InstallLegacyInternal(scheme *runtime.Scheme) {
utilruntime.Must(defaults.InstallLegacy(scheme))
utilruntime.Must(v1.InstallLegacy(scheme))
}
2 changes: 1 addition & 1 deletion pkg/build/controller/build/apis/defaults/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Resource(resource string) schema.GroupResource {

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
InstallLegacy = SchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
Expand Down
8 changes: 6 additions & 2 deletions pkg/build/controller/build/apis/defaults/v1/register.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"github.com/openshift/origin/pkg/build/controller/build/apis/defaults"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand All @@ -9,8 +10,11 @@ import (
var SchemeGroupVersion = schema.GroupVersion{Group: "", Version: "v1"}

var (
localSchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = localSchemeBuilder.AddToScheme
localSchemeBuilder = runtime.NewSchemeBuilder(
addKnownTypes,
defaults.InstallLegacy,
)
InstallLegacy = localSchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
Expand Down
41 changes: 5 additions & 36 deletions pkg/build/controller/build/apis/overrides/install/install.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package install

import (
"github.com/golang/glog"

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

"github.com/openshift/origin/pkg/build/controller/build/apis/overrides"
"github.com/openshift/origin/pkg/build/controller/build/apis/overrides/v1"
configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
)

// availableVersions lists all known external versions for this group from most preferred to least preferred
var availableVersions = []schema.GroupVersion{v1.SchemeGroupVersion}

func init() {
if err := enableVersions(availableVersions); err != nil {
panic(err)
}
}

// TODO: enableVersions should be centralized rather than spread in each API
// group.
// We can combine registered.RegisterVersions, registered.EnableVersions and
// registered.RegisterGroup once we have moved enableVersions there.
func enableVersions(externalVersions []schema.GroupVersion) error {
addVersionsToScheme(externalVersions...)
return nil
}

func addVersionsToScheme(externalVersions ...schema.GroupVersion) {
// add the internal version to Scheme
overrides.AddToScheme(configapi.Scheme)
// add the enabled external versions to Scheme
for _, v := range externalVersions {
switch v {
case v1.SchemeGroupVersion:
v1.AddToScheme(configapi.Scheme)

default:
glog.Errorf("Version %s is not known, so it will not be added to the Scheme.", v)
continue
}
}
func InstallLegacyInternal(scheme *runtime.Scheme) {
utilruntime.Must(overrides.InstallLegacy(scheme))
utilruntime.Must(v1.InstallLegacy(scheme))
}
2 changes: 1 addition & 1 deletion pkg/build/controller/build/apis/overrides/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Resource(resource string) schema.GroupResource {

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
InstallLegacy = SchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
Expand Down
8 changes: 6 additions & 2 deletions pkg/build/controller/build/apis/overrides/v1/register.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"github.com/openshift/origin/pkg/build/controller/build/apis/overrides"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand All @@ -9,8 +10,11 @@ import (
var SchemeGroupVersion = schema.GroupVersion{Group: "", Version: "v1"}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(
addKnownTypes,
overrides.InstallLegacy,
)
InstallLegacy = SchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
Expand Down
9 changes: 0 additions & 9 deletions pkg/build/controller/build/pluginconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@ import (
"github.com/golang/glog"

"k8s.io/apimachinery/pkg/runtime"
kapiserverinstall "k8s.io/apiserver/pkg/apis/apiserver/install"

configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
"github.com/openshift/origin/pkg/cmd/server/apis/config/latest"
configlatest "github.com/openshift/origin/pkg/cmd/server/apis/config/latest"
)

var (
scheme = runtime.NewScheme()
)

func init() {
kapiserverinstall.Install(scheme)
}

func getPluginConfig(cfg configapi.AdmissionPluginConfig) (string, error) {
obj := cfg.Configuration
if obj == nil {
Expand Down
80 changes: 0 additions & 80 deletions pkg/build/controller/build/pluginconfig/config_test.go

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/build/controller/build/pluginconfig/testing/doc.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/build/controller/build/pluginconfig/testing/types.go

This file was deleted.

Loading