diff --git a/pkg/authorization/api/install/apigroup.go b/pkg/authorization/api/install/apigroup.go index 6968e672ac34..f320d85ee779 100644 --- a/pkg/authorization/api/install/apigroup.go +++ b/pkg/authorization/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/authorization/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/authorization/api/install/install.go b/pkg/authorization/api/install/install.go index 25b7e4109eb9..2ac2190ccb03 100644 --- a/pkg/authorization/api/install/install.go +++ b/pkg/authorization/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/build/api/install/apigroup.go b/pkg/build/api/install/apigroup.go index 749124214216..62bc3f40e624 100644 --- a/pkg/build/api/install/apigroup.go +++ b/pkg/build/api/install/apigroup.go @@ -7,7 +7,7 @@ import ( "github.com/openshift/origin/pkg/build/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/build/api/install/install.go b/pkg/build/api/install/install.go index 6db06a066a55..78c5f5ced4c6 100644 --- a/pkg/build/api/install/install.go +++ b/pkg/build/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/deploy/api/install/apigroup.go b/pkg/deploy/api/install/apigroup.go index 99e3b86c4687..48a55ae84f85 100644 --- a/pkg/deploy/api/install/apigroup.go +++ b/pkg/deploy/api/install/apigroup.go @@ -7,7 +7,7 @@ import ( "github.com/openshift/origin/pkg/deploy/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/deploy/api/install/install.go b/pkg/deploy/api/install/install.go index ab04fc139537..b88fd1b358e2 100644 --- a/pkg/deploy/api/install/install.go +++ b/pkg/deploy/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/image/api/install/apigroup.go b/pkg/image/api/install/apigroup.go index 2eb236961436..71faff222285 100644 --- a/pkg/image/api/install/apigroup.go +++ b/pkg/image/api/install/apigroup.go @@ -11,7 +11,7 @@ import ( "github.com/openshift/origin/pkg/image/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/image/api/install/install.go b/pkg/image/api/install/install.go index e122f798e32d..0bc967109413 100644 --- a/pkg/image/api/install/install.go +++ b/pkg/image/api/install/install.go @@ -47,6 +47,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/oauth/api/install/apigroup.go b/pkg/oauth/api/install/apigroup.go index 8b6837e6c15f..030d7f3907d4 100644 --- a/pkg/oauth/api/install/apigroup.go +++ b/pkg/oauth/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/oauth/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/oauth/api/install/install.go b/pkg/oauth/api/install/install.go index 3c81fd357381..5c1eac2708de 100644 --- a/pkg/oauth/api/install/install.go +++ b/pkg/oauth/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/project/api/install/apigroup.go b/pkg/project/api/install/apigroup.go index cc00a3783c79..8cf5f2c476bb 100644 --- a/pkg/project/api/install/apigroup.go +++ b/pkg/project/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/project/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/project/api/install/install.go b/pkg/project/api/install/install.go index cabdca68fa48..2299af6af528 100644 --- a/pkg/project/api/install/install.go +++ b/pkg/project/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/quota/api/install/apigroup.go b/pkg/quota/api/install/apigroup.go index 3b9d05cd4332..7c2a8df54838 100644 --- a/pkg/quota/api/install/apigroup.go +++ b/pkg/quota/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/quota/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/quota/api/install/install.go b/pkg/quota/api/install/install.go index d090eb80b50a..2afda3b989f4 100644 --- a/pkg/quota/api/install/install.go +++ b/pkg/quota/api/install/install.go @@ -45,6 +45,8 @@ func init() { glog.V(4).Infof("%v", err) return } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/route/api/install/apigroup.go b/pkg/route/api/install/apigroup.go index 2fa1dce0df6f..23db227750a9 100644 --- a/pkg/route/api/install/apigroup.go +++ b/pkg/route/api/install/apigroup.go @@ -7,7 +7,7 @@ import ( "github.com/openshift/origin/pkg/route/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/route/api/install/install.go b/pkg/route/api/install/install.go index 1fad8d7b95ea..6fd6be0863bc 100644 --- a/pkg/route/api/install/install.go +++ b/pkg/route/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/sdn/api/install/apigroup.go b/pkg/sdn/api/install/apigroup.go index 57be4d36d6a1..09ef7cf3d655 100644 --- a/pkg/sdn/api/install/apigroup.go +++ b/pkg/sdn/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/sdn/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/sdn/api/install/install.go b/pkg/sdn/api/install/install.go index e3cd43ea8749..af785b20eff2 100644 --- a/pkg/sdn/api/install/install.go +++ b/pkg/sdn/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/security/api/install/apigroup.go b/pkg/security/api/install/apigroup.go index a92caecbfa62..dc7e7cf965d0 100644 --- a/pkg/security/api/install/apigroup.go +++ b/pkg/security/api/install/apigroup.go @@ -7,7 +7,7 @@ import ( "github.com/openshift/origin/pkg/security/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/security/api/install/install.go b/pkg/security/api/install/install.go index c9dcd00f1f43..1672b4a86650 100644 --- a/pkg/security/api/install/install.go +++ b/pkg/security/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/template/api/helpers.go b/pkg/template/api/helpers.go index d7176999a50e..047cd597fd9d 100644 --- a/pkg/template/api/helpers.go +++ b/pkg/template/api/helpers.go @@ -17,21 +17,27 @@ func AddObjectsToTemplate(template *Template, objects []runtime.Object, targetVe return errors.New("cannot add a nil object to a template") } - kind, _, err := kapi.Scheme.ObjectKind(obj) + // We currently add legacy types first to the scheme, followed by the types in the new api + // groups. We have to check all ObjectKinds and not just use the first one returned by + // ObjectKind(). + gvks, _, err := kapi.Scheme.ObjectKinds(obj) if err != nil { return err } var targetVersion *unversioned.GroupVersion + outerLoop: for j := range targetVersions { possibleVersion := targetVersions[j] - if kind.Group == possibleVersion.Group { - targetVersion = &possibleVersion - break + for _, kind := range gvks { + if kind.Group == possibleVersion.Group { + targetVersion = &possibleVersion + break outerLoop + } } } if targetVersion == nil { - return fmt.Errorf("no target version found for object[%d], kind %v in %v", i, kind, targetVersions) + return fmt.Errorf("no target version found for object[%d], gvks %v in %v", i, gvks, targetVersions) } wrappedObject := runtime.NewEncodable(kapi.Codecs.LegacyCodec(*targetVersion), obj) diff --git a/pkg/template/api/install/apigroup.go b/pkg/template/api/install/apigroup.go index d4b7767f9ab3..73aee7c80dea 100644 --- a/pkg/template/api/install/apigroup.go +++ b/pkg/template/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/template/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/template/api/install/install.go b/pkg/template/api/install/install.go index 1282c0b58631..a4323bf67422 100644 --- a/pkg/template/api/install/install.go +++ b/pkg/template/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/pkg/user/api/install/apigroup.go b/pkg/user/api/install/apigroup.go index 688ecd88ffc3..07645e627781 100644 --- a/pkg/user/api/install/apigroup.go +++ b/pkg/user/api/install/apigroup.go @@ -8,7 +8,7 @@ import ( "github.com/openshift/origin/pkg/user/api/v1" ) -func init() { +func installApiGroup() { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: api.GroupName, diff --git a/pkg/user/api/install/install.go b/pkg/user/api/install/install.go index 988f9ff7cd35..4d25844b0b86 100644 --- a/pkg/user/api/install/install.go +++ b/pkg/user/api/install/install.go @@ -43,6 +43,8 @@ func init() { if err := enableVersions(externalVersions); err != nil { panic(err) } + + installApiGroup() } // TODO: enableVersions should be centralized rather than spread in each API diff --git a/test/cmd/newapp.sh b/test/cmd/newapp.sh index c4291646e6cc..477f57feea21 100755 --- a/test/cmd/newapp.sh +++ b/test/cmd/newapp.sh @@ -80,8 +80,8 @@ os::cmd::expect_success 'oc new-app -f test/testdata/template-with-namespaces.js os::cmd::expect_success 'oc delete all -l app=ruby-helloworld-sample' # ensure non-duplicate invalid label errors show up -os::cmd::expect_failure_and_text 'oc new-app nginx -l qwer1345%$$#=self' 'error: ImageStream.image.openshift.io "nginx" is invalid' -os::cmd::expect_failure_and_text 'oc new-app nginx -l qwer1345%$$#=self' 'DeploymentConfig.apps.openshift.io "nginx" is invalid' +os::cmd::expect_failure_and_text 'oc new-app nginx -l qwer1345%$$#=self' 'error: ImageStream "nginx" is invalid' +os::cmd::expect_failure_and_text 'oc new-app nginx -l qwer1345%$$#=self' 'DeploymentConfig "nginx" is invalid' os::cmd::expect_failure_and_text 'oc new-app nginx -l qwer1345%$$#=self' 'Service "nginx" is invalid' # check if we can create from a stored template