From fe3ca9a6eba9b39a305b8cdffc2fbc7a66b812da Mon Sep 17 00:00:00 2001 From: "Steven E. Harris" Date: Tue, 16 May 2017 15:50:40 -0400 Subject: [PATCH 1/2] Copyedit third-party resource registration example --- .../third-party-resources/apis/tpr/v1/register.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go b/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go index 2dd196a4f0a..100484a74b9 100644 --- a/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go +++ b/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go @@ -27,25 +27,25 @@ var ( AddToScheme = SchemeBuilder.AddToScheme ) -// GroupName is the group name use in this package +// GroupName is the group name use in this package. const GroupName = "tpr.client-go.k8s.io" -// SchemeGroupVersion is group version used to register these objects +// SchemeGroupVersion is the group version used to register these objects. var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} -// Resource takes an unqualified resource and returns a Group qualified GroupResource +// Resource takes an unqualified resource and returns a Group-qualified GroupResource. func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } func init() { - // We only register manually written functions here. The registration of the + // 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. SchemeBuilder.Register(addKnownTypes) } -// Adds the list of known types to api.Scheme. +// addKnownTypes adds the set of types defined in this package to the supplied scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Example{}, From 3a8e44bda80f74d674bf2df0b87cb4562a3587a0 Mon Sep 17 00:00:00 2001 From: "Steven E. Harris" Date: Tue, 16 May 2017 15:58:24 -0400 Subject: [PATCH 2/2] Remove redundant third-party type registration Since NewSchemeBuilder registers the supplied Scheme transformation functions synchronously, there's no need for a subsequent call to (*SchemeBuilder).Register against the same instance. --- .../examples/third-party-resources/apis/tpr/v1/register.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go b/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go index 100484a74b9..201310fef46 100644 --- a/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go +++ b/staging/src/k8s.io/client-go/examples/third-party-resources/apis/tpr/v1/register.go @@ -38,13 +38,6 @@ func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } -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. - SchemeBuilder.Register(addKnownTypes) -} - // addKnownTypes adds the set of types defined in this package to the supplied scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion,