Skip to content

Commit af5aadc

Browse files
committed
WIP: standalone registration
1 parent c618703 commit af5aadc

File tree

3 files changed

+57
-27
lines changed

3 files changed

+57
-27
lines changed

pkg/build/api/install/apigroup.go

+57-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package install
22

33
import (
4+
kapi "k8s.io/kubernetes/pkg/api"
5+
"k8s.io/kubernetes/pkg/api/unversioned"
46
"k8s.io/kubernetes/pkg/apimachinery/announced"
7+
"k8s.io/kubernetes/pkg/runtime"
8+
"k8s.io/kubernetes/pkg/watch/versioned"
59

610
"github.com/openshift/origin/pkg/build/api"
711
"github.com/openshift/origin/pkg/build/api/v1"
@@ -12,15 +16,63 @@ const importPrefix = "github.com/openshift/origin/pkg/build/api"
1216
func init() {
1317
if err := announced.NewGroupMetaFactory(
1418
&announced.GroupMetaFactoryArgs{
15-
GroupName: api.GroupName,
16-
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
17-
ImportPrefix: importPrefix,
18-
//AddInternalObjectsToScheme: api.AddToScheme,
19+
GroupName: api.GroupName,
20+
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
21+
ImportPrefix: importPrefix,
22+
AddInternalObjectsToScheme: addKnownInternalTypes,
1923
},
2024
announced.VersionToSchemeFunc{
21-
v1.SchemeGroupVersion.Version: v1.AddToScheme,
25+
v1.SchemeGroupVersion.Version: addKnownExternalTypes,
2226
},
2327
).Announce().RegisterAndEnable(); err != nil {
2428
panic(err)
2529
}
2630
}
31+
32+
func addKnownExternalTypes(scheme *runtime.Scheme) error {
33+
types := []runtime.Object{
34+
&v1.Build{},
35+
&v1.BuildList{},
36+
&v1.BuildConfig{},
37+
&v1.BuildConfigList{},
38+
&v1.BuildLog{},
39+
&v1.BuildRequest{},
40+
&v1.BuildLogOptions{},
41+
&v1.BinaryBuildRequestOptions{},
42+
}
43+
scheme.AddKnownTypes(api.SchemeGroupVersion,
44+
append(types,
45+
&unversioned.Status{},
46+
&kapi.ListOptions{},
47+
&kapi.DeleteOptions{},
48+
&kapi.ExportOptions{},
49+
)...,
50+
)
51+
versioned.AddToGroupVersion(scheme, v1.SchemeGroupVersion)
52+
scheme.AddKnownTypes(v1.SchemeGroupVersion, types...)
53+
return nil
54+
}
55+
56+
func addKnownInternalTypes(scheme *runtime.Scheme) error {
57+
types := []runtime.Object{
58+
&api.Build{},
59+
&api.BuildList{},
60+
&api.BuildConfig{},
61+
&api.BuildConfigList{},
62+
&api.BuildLog{},
63+
&api.BuildRequest{},
64+
&api.BuildLogOptions{},
65+
&api.BinaryBuildRequestOptions{},
66+
}
67+
scheme.AddKnownTypes(api.SchemeGroupVersion,
68+
append(types,
69+
&unversioned.Status{},
70+
&kapi.ListOptions{},
71+
&kapi.DeleteOptions{},
72+
&kapi.ExportOptions{},
73+
)...,
74+
)
75+
versioned.AddToGroupVersion(scheme, api.SchemeGroupVersion)
76+
scheme.AddKnownTypes(api.SchemeGroupVersion, types...)
77+
return nil
78+
}

pkg/build/api/register.go

-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package api
22

33
import (
4-
kapi "k8s.io/kubernetes/pkg/api"
54
"k8s.io/kubernetes/pkg/api/unversioned"
65
"k8s.io/kubernetes/pkg/runtime"
7-
"k8s.io/kubernetes/pkg/watch/versioned"
86
)
97

108
const (
@@ -42,15 +40,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4240
&BuildLogOptions{},
4341
&BinaryBuildRequestOptions{},
4442
}
45-
scheme.AddKnownTypes(SchemeGroupVersion,
46-
append(types,
47-
&unversioned.Status{}, // TODO: revisit in 1.6 when Status is actually registered as unversioned
48-
&kapi.ListOptions{},
49-
&kapi.DeleteOptions{},
50-
&kapi.ExportOptions{},
51-
)...,
52-
)
53-
versioned.AddToGroupVersion(scheme, SchemeGroupVersion)
5443

5544
// legacy: register in core group
5645
scheme.AddKnownTypes(LegacySchemeGroupVersion, types...)

pkg/build/api/v1/register.go

-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package v1
22

33
import (
4-
kapi "k8s.io/kubernetes/pkg/api"
54
"k8s.io/kubernetes/pkg/api/unversioned"
65
"k8s.io/kubernetes/pkg/runtime"
7-
"k8s.io/kubernetes/pkg/watch/versioned"
86
)
97

108
const GroupName = "build.openshift.io"
@@ -30,15 +28,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3028
&BuildLogOptions{},
3129
&BinaryBuildRequestOptions{},
3230
}
33-
scheme.AddKnownTypes(SchemeGroupVersion,
34-
append(types,
35-
&unversioned.Status{}, // TODO: revisit in 1.6 when Status is actually registered as unversioned
36-
&kapi.ListOptions{},
37-
&kapi.DeleteOptions{},
38-
&kapi.ExportOptions{},
39-
)...,
40-
)
41-
versioned.AddToGroupVersion(scheme, SchemeGroupVersion)
4231

4332
// legacy: register in core group
4433
scheme.AddKnownTypes(LegacySchemeGroupVersion, types...)

0 commit comments

Comments
 (0)