mirror of
https://github.com/kubernetes/sample-controller.git
synced 2025-01-19 16:12:52 +08:00
typed client: add tags and script for code generation
Kubernetes-commit: 355279c86677efe1efbba32cccc0719548fc3c87
This commit is contained in:
parent
745637cf02
commit
eaab325fad
@ -17,7 +17,6 @@ limitations under the License.
|
|||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
@ -27,31 +26,26 @@ import (
|
|||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: samplecontroller.GroupName, Version: "v1alpha1"}
|
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
|
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||||
func Resource(resource string) schema.GroupResource {
|
func Resource(resource string) schema.GroupResource {
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
SchemeBuilder runtime.SchemeBuilder
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
localSchemeBuilder = &SchemeBuilder
|
|
||||||
AddToScheme = localSchemeBuilder.AddToScheme
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
// Adds the list of known types to Scheme.
|
||||||
// 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.
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&Foo{},
|
&Foo{},
|
||||||
&FooList{},
|
&FooList{},
|
||||||
)
|
)
|
||||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
// +genclient
|
// +genclient
|
||||||
// +genclient:noStatus
|
// +genclient:noStatus
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
// +resource:path=foo
|
|
||||||
|
|
||||||
// Foo is a specification for a Foo resource
|
// Foo is a specification for a Foo resource
|
||||||
type Foo struct {
|
type Foo struct {
|
||||||
@ -46,7 +45,6 @@ type FooStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
// +resource:path=foos
|
|
||||||
|
|
||||||
// FooList is a list of Foo resources
|
// FooList is a list of Foo resources
|
||||||
type FooList struct {
|
type FooList struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user