Skip to content

Commit

Permalink
unify register.go formats:
Browse files Browse the repository at this point in the history
networking/v1/register.go
staging/src/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1/register.go
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1/register.go
staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1 register.go
  • Loading branch information
Chao Xu committed Jun 22, 2017
1 parent bad65b4 commit 94e8bb6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
14 changes: 12 additions & 2 deletions pkg/apis/networking/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ func Resource(resource string) schema.GroupResource {
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs, addConversionFuncs)
AddToScheme = SchemeBuilder.AddToScheme
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs, addConversionFuncs)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ func Resource(resource string) schema.GroupResource {
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs)
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func Resource(resource string) schema.GroupResource {
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func Resource(resource string) schema.GroupResource {
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
Expand Down

0 comments on commit 94e8bb6

Please sign in to comment.