mirror of
https://github.com/kubernetes/sample-controller.git
synced 2025-02-22 00:32:59 +08:00
Merge pull request #54535 from nikhita/apiextensions-typed-client
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. apiextensions/examples: add typed client It was discussed in https://github.com/kubernetes/kubernetes/pull/52753#issuecomment-337840762 to add a typed client example to apiextensions-apiserver and remove the controller part. For an example controller, we have [`k8s.io/sample-controller`](https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/sample-controller) now. **Release note**: ```release-note NONE ``` Kubernetes-commit: 175af4c3c4797786c5344d334de400f640a9e509
This commit is contained in:
commit
93d63d51fb
1888
Godeps/Godeps.json
generated
1888
Godeps/Godeps.json
generated
File diff suppressed because it is too large
Load Diff
@ -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