From eaab325fad67f8ac9bb3e4e583f5fffd28e98f08 Mon Sep 17 00:00:00 2001 From: Nikhita Raghunath Date: Wed, 25 Oct 2017 12:45:59 +0530 Subject: [PATCH] typed client: add tags and script for code generation Kubernetes-commit: 355279c86677efe1efbba32cccc0719548fc3c87 --- .../samplecontroller/v1alpha1/register.go | 22 +++++++------------ pkg/apis/samplecontroller/v1alpha1/types.go | 2 -- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pkg/apis/samplecontroller/v1alpha1/register.go b/pkg/apis/samplecontroller/v1alpha1/register.go index e72b4034..babd488d 100644 --- a/pkg/apis/samplecontroller/v1alpha1/register.go +++ b/pkg/apis/samplecontroller/v1alpha1/register.go @@ -17,7 +17,6 @@ limitations under the License. package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -27,31 +26,26 @@ import ( // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = schema.GroupVersion{Group: samplecontroller.GroupName, Version: "v1alpha1"} +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } var ( - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.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) -} - -// Adds the list of known types to api.Scheme. +// Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Foo{}, &FooList{}, ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil } diff --git a/pkg/apis/samplecontroller/v1alpha1/types.go b/pkg/apis/samplecontroller/v1alpha1/types.go index 8f071033..1f6eb1f9 100644 --- a/pkg/apis/samplecontroller/v1alpha1/types.go +++ b/pkg/apis/samplecontroller/v1alpha1/types.go @@ -23,7 +23,6 @@ import ( // +genclient // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +resource:path=foo // Foo is a specification for a Foo resource type Foo struct { @@ -46,7 +45,6 @@ type FooStatus struct { } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +resource:path=foos // FooList is a list of Foo resources type FooList struct {