add api registration

Signed-off-by: Kevin Wang <kevinwzf0126@gmail.com>
This commit is contained in:
Kevin Wang 2020-11-10 22:59:10 +08:00
parent 79dd1ee177
commit 5f14717035
3 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,6 @@
package propagationstrategy
// GroupName is the group name used in this package
const (
GroupName = "propagationstrategy.karmada.io"
)

View File

@ -0,0 +1,5 @@
// +k8s:deepcopy-gen=package
// +groupName=propagationstrategy.karmada.io
// Package v1alpha1 is the v1alpha1 version of the API.
package v1alpha1

View File

@ -0,0 +1,43 @@
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/huawei-cloudnative/karmada/pkg/apis/propagationstrategy"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: propagationstrategy.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 (
// SchemeBuilder initializes a scheme builder
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
//&PropagationPolicy{},
//&PropagationPolicyList{},
&PropagationBinding{},
&PropagationBindingList{},
&PropagationWork{},
&PropagationWorkList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}