rename to CustomResourceDefinition
This commit is contained in:
@@ -34,7 +34,7 @@ func main() {
|
|||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := server.NewCommandStartCustomResourcesServer(os.Stdout, os.Stderr, wait.NeverStop)
|
cmd := server.NewCommandStartCustomResourceDefinitionsServer(os.Stdout, os.Stderr, wait.NeverStop)
|
||||||
cmd.Flags().AddGoFlagSet(flag.CommandLine)
|
cmd.Flags().AddGoFlagSet(flag.CommandLine)
|
||||||
if err := cmd.Execute(); err != nil {
|
if err := cmd.Execute(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@@ -30,7 +30,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
|
|||||||
if err := announced.NewGroupMetaFactory(
|
if err := announced.NewGroupMetaFactory(
|
||||||
&announced.GroupMetaFactoryArgs{
|
&announced.GroupMetaFactoryArgs{
|
||||||
GroupName: apiextensions.GroupName,
|
GroupName: apiextensions.GroupName,
|
||||||
RootScopedKinds: sets.NewString("CustomResource"),
|
RootScopedKinds: sets.NewString("CustomResourceDefinition"),
|
||||||
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
|
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
|
||||||
ImportPrefix: "k8s.io/kube-apiextensions-server/pkg/apis/apiextension",
|
ImportPrefix: "k8s.io/kube-apiextensions-server/pkg/apis/apiextension",
|
||||||
AddInternalObjectsToScheme: apiextensions.AddToScheme,
|
AddInternalObjectsToScheme: apiextensions.AddToScheme,
|
||||||
|
@@ -34,7 +34,7 @@ func TestRoundTripTypes(t *testing.T) {
|
|||||||
|
|
||||||
func fuzzerFuncs() []interface{} {
|
func fuzzerFuncs() []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(obj *apiextensions.CustomResourceSpec, c fuzz.Continue) {
|
func(obj *apiextensions.CustomResourceDefinitionSpec, c fuzz.Continue) {
|
||||||
c.FuzzNoCustom(obj)
|
c.FuzzNoCustom(obj)
|
||||||
|
|
||||||
// match our defaulter
|
// match our defaulter
|
||||||
|
@@ -44,8 +44,8 @@ var (
|
|||||||
// Adds the list of known types to api.Scheme.
|
// 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,
|
||||||
&CustomResource{},
|
&CustomResourceDefinition{},
|
||||||
&CustomResourceList{},
|
&CustomResourceDefinitionList{},
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -18,22 +18,22 @@ package apiextensions
|
|||||||
|
|
||||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
// CustomResourceSpec describes how a user wants their resource to appear
|
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
|
||||||
type CustomResourceSpec struct {
|
type CustomResourceDefinitionSpec struct {
|
||||||
// Group is the group this resource belongs in
|
// Group is the group this resource belongs in
|
||||||
Group string
|
Group string
|
||||||
// Version is the version this resource belongs in
|
// Version is the version this resource belongs in
|
||||||
Version string
|
Version string
|
||||||
// Names are the names used to describe this custom resource
|
// Names are the names used to describe this custom resource
|
||||||
Names CustomResourceNames
|
Names CustomResourceDefinitionNames
|
||||||
|
|
||||||
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
|
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
|
||||||
Scope ResourceScope
|
Scope ResourceScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceNames indicates the names to serve this CustomResource
|
// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition
|
||||||
type CustomResourceNames struct {
|
type CustomResourceDefinitionNames struct {
|
||||||
// Plural is the plural name of the resource to serve. It must match the name of the CustomResource-registration
|
// Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration
|
||||||
// too: plural.group and it must be all lowercase.
|
// too: plural.group and it must be all lowercase.
|
||||||
Plural string
|
Plural string
|
||||||
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
|
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
|
||||||
@@ -66,20 +66,20 @@ const (
|
|||||||
ConditionUnknown ConditionStatus = "Unknown"
|
ConditionUnknown ConditionStatus = "Unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceConditionType is a valid value for CustomResourceCondition.Type
|
// CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type
|
||||||
type CustomResourceConditionType string
|
type CustomResourceDefinitionConditionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NameConflict means the names chosen for this CustomResource conflict with others in the group.
|
// NameConflict means the names chosen for this CustomResourceDefinition conflict with others in the group.
|
||||||
NameConflict CustomResourceConditionType = "NameConflict"
|
NameConflict CustomResourceDefinitionConditionType = "NameConflict"
|
||||||
// Terminating means that the CustomResource has been deleted and is cleaning up.
|
// Terminating means that the CustomResourceDefinition has been deleted and is cleaning up.
|
||||||
Terminating CustomResourceConditionType = "Terminating"
|
Terminating CustomResourceDefinitionConditionType = "Terminating"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceCondition contains details for the current condition of this pod.
|
// CustomResourceDefinitionCondition contains details for the current condition of this pod.
|
||||||
type CustomResourceCondition struct {
|
type CustomResourceDefinitionCondition struct {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
Type CustomResourceConditionType
|
Type CustomResourceDefinitionConditionType
|
||||||
// Status is the status of the condition.
|
// Status is the status of the condition.
|
||||||
// Can be True, False, Unknown.
|
// Can be True, False, Unknown.
|
||||||
Status ConditionStatus
|
Status ConditionStatus
|
||||||
@@ -94,36 +94,36 @@ type CustomResourceCondition struct {
|
|||||||
Message string
|
Message string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceStatus indicates the state of the CustomResource
|
// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
|
||||||
type CustomResourceStatus struct {
|
type CustomResourceDefinitionStatus struct {
|
||||||
// Conditions indicate state for particular aspects of a CustomResource
|
// Conditions indicate state for particular aspects of a CustomResourceDefinition
|
||||||
Conditions []CustomResourceCondition
|
Conditions []CustomResourceDefinitionCondition
|
||||||
|
|
||||||
// AcceptedNames are the names that are actually being used to serve discovery
|
// AcceptedNames are the names that are actually being used to serve discovery
|
||||||
// They may be different than the names in spec.
|
// They may be different than the names in spec.
|
||||||
AcceptedNames CustomResourceNames
|
AcceptedNames CustomResourceDefinitionNames
|
||||||
}
|
}
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
// +nonNamespaced=true
|
// +nonNamespaced=true
|
||||||
|
|
||||||
// CustomResource represents a resource that should be exposed on the API server. Its name MUST be in the format
|
// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format
|
||||||
// <.spec.name>.<.spec.group>.
|
// <.spec.name>.<.spec.group>.
|
||||||
type CustomResource struct {
|
type CustomResourceDefinition struct {
|
||||||
metav1.TypeMeta
|
metav1.TypeMeta
|
||||||
metav1.ObjectMeta
|
metav1.ObjectMeta
|
||||||
|
|
||||||
// Spec describes how the user wants the resources to appear
|
// Spec describes how the user wants the resources to appear
|
||||||
Spec CustomResourceSpec
|
Spec CustomResourceDefinitionSpec
|
||||||
// Status indicates the actual state of the CustomResource
|
// Status indicates the actual state of the CustomResourceDefinition
|
||||||
Status CustomResourceStatus
|
Status CustomResourceDefinitionStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceList is a list of CustomResource objects.
|
// CustomResourceDefinitionList is a list of CustomResourceDefinition objects.
|
||||||
type CustomResourceList struct {
|
type CustomResourceDefinitionList struct {
|
||||||
metav1.TypeMeta
|
metav1.TypeMeta
|
||||||
metav1.ListMeta
|
metav1.ListMeta
|
||||||
|
|
||||||
// Items individual CustomResources
|
// Items individual CustomResourceDefinitions
|
||||||
Items []CustomResource
|
Items []CustomResourceDefinition
|
||||||
}
|
}
|
||||||
|
@@ -23,17 +23,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||||
scheme.AddTypeDefaultingFunc(&CustomResource{}, func(obj interface{}) { SetDefaults_CustomResource(obj.(*CustomResource)) })
|
scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) })
|
||||||
// TODO figure out why I can't seem to get my defaulter generated
|
// TODO figure out why I can't seem to get my defaulter generated
|
||||||
// return RegisterDefaults(scheme)
|
// return RegisterDefaults(scheme)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDefaults_CustomResource(obj *CustomResource) {
|
func SetDefaults_CustomResourceDefinition(obj *CustomResourceDefinition) {
|
||||||
SetDefaults_CustomResourceSpec(&obj.Spec)
|
SetDefaults_CustomResourceDefinitionSpec(&obj.Spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDefaults_CustomResourceSpec(obj *CustomResourceSpec) {
|
func SetDefaults_CustomResourceDefinitionSpec(obj *CustomResourceDefinitionSpec) {
|
||||||
if len(obj.Scope) == 0 {
|
if len(obj.Scope) == 0 {
|
||||||
obj.Scope = NamespaceScoped
|
obj.Scope = NamespaceScoped
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@ var (
|
|||||||
// Adds the list of known types to api.Scheme.
|
// 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,
|
||||||
&CustomResource{},
|
&CustomResourceDefinition{},
|
||||||
&CustomResourceList{},
|
&CustomResourceDefinitionList{},
|
||||||
)
|
)
|
||||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||||
return nil
|
return nil
|
||||||
|
@@ -18,22 +18,22 @@ package v1alpha1
|
|||||||
|
|
||||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
// CustomResourceSpec describes how a user wants their resource to appear
|
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
|
||||||
type CustomResourceSpec struct {
|
type CustomResourceDefinitionSpec struct {
|
||||||
// Group is the group this resource belongs in
|
// Group is the group this resource belongs in
|
||||||
Group string `json:"group" protobuf:"bytes,1,opt,name=group"`
|
Group string `json:"group" protobuf:"bytes,1,opt,name=group"`
|
||||||
// Version is the version this resource belongs in
|
// Version is the version this resource belongs in
|
||||||
Version string `json:"version" protobuf:"bytes,2,opt,name=version"`
|
Version string `json:"version" protobuf:"bytes,2,opt,name=version"`
|
||||||
// Names are the names used to describe this custom resource
|
// Names are the names used to describe this custom resource
|
||||||
Names CustomResourceNames `json:"names" protobuf:"bytes,3,opt,name=names"`
|
Names CustomResourceDefinitionNames `json:"names" protobuf:"bytes,3,opt,name=names"`
|
||||||
|
|
||||||
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
|
// Scope indicates whether this resource is cluster or namespace scoped. Default is namespaced
|
||||||
Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"`
|
Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceNames indicates the names to serve this CustomResource
|
// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition
|
||||||
type CustomResourceNames struct {
|
type CustomResourceDefinitionNames struct {
|
||||||
// Plural is the plural name of the resource to serve. It must match the name of the CustomResource-registration
|
// Plural is the plural name of the resource to serve. It must match the name of the CustomResourceDefinition-registration
|
||||||
// too: plural.group and it must be all lowercase.
|
// too: plural.group and it must be all lowercase.
|
||||||
Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"`
|
Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"`
|
||||||
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
|
// Singular is the singular name of the resource. It must be all lowercase Defaults to lowercased <kind>
|
||||||
@@ -66,20 +66,20 @@ const (
|
|||||||
ConditionUnknown ConditionStatus = "Unknown"
|
ConditionUnknown ConditionStatus = "Unknown"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceConditionType is a valid value for CustomResourceCondition.Type
|
// CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type
|
||||||
type CustomResourceConditionType string
|
type CustomResourceDefinitionConditionType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NameConflict means the names chosen for this CustomResource conflict with others in the group.
|
// NameConflict means the names chosen for this CustomResourceDefinition conflict with others in the group.
|
||||||
NameConflict CustomResourceConditionType = "NameConflict"
|
NameConflict CustomResourceDefinitionConditionType = "NameConflict"
|
||||||
// Terminating means that the CustomResource has been deleted and is cleaning up.
|
// Terminating means that the CustomResourceDefinition has been deleted and is cleaning up.
|
||||||
Terminating CustomResourceConditionType = "Terminating"
|
Terminating CustomResourceDefinitionConditionType = "Terminating"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceCondition contains details for the current condition of this pod.
|
// CustomResourceDefinitionCondition contains details for the current condition of this pod.
|
||||||
type CustomResourceCondition struct {
|
type CustomResourceDefinitionCondition struct {
|
||||||
// Type is the type of the condition.
|
// Type is the type of the condition.
|
||||||
Type CustomResourceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceConditionType"`
|
Type CustomResourceDefinitionConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceDefinitionConditionType"`
|
||||||
// Status is the status of the condition.
|
// Status is the status of the condition.
|
||||||
// Can be True, False, Unknown.
|
// Can be True, False, Unknown.
|
||||||
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
|
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
|
||||||
@@ -94,36 +94,36 @@ type CustomResourceCondition struct {
|
|||||||
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
|
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceStatus indicates the state of the CustomResource
|
// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
|
||||||
type CustomResourceStatus struct {
|
type CustomResourceDefinitionStatus struct {
|
||||||
// Conditions indicate state for particular aspects of a CustomResource
|
// Conditions indicate state for particular aspects of a CustomResourceDefinition
|
||||||
Conditions []CustomResourceCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"`
|
Conditions []CustomResourceDefinitionCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"`
|
||||||
|
|
||||||
// AcceptedNames are the names that are actually being used to serve discovery
|
// AcceptedNames are the names that are actually being used to serve discovery
|
||||||
// They may be different than the names in spec.
|
// They may be different than the names in spec.
|
||||||
AcceptedNames CustomResourceNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"`
|
AcceptedNames CustomResourceDefinitionNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
// +nonNamespaced=true
|
// +nonNamespaced=true
|
||||||
|
|
||||||
// CustomResource represents a resource that should be exposed on the API server. Its name MUST be in the format
|
// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format
|
||||||
// <.spec.name>.<.spec.group>.
|
// <.spec.name>.<.spec.group>.
|
||||||
type CustomResource struct {
|
type CustomResourceDefinition struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// Spec describes how the user wants the resources to appear
|
// Spec describes how the user wants the resources to appear
|
||||||
Spec CustomResourceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
Spec CustomResourceDefinitionSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
||||||
// Status indicates the actual state of the CustomResource
|
// Status indicates the actual state of the CustomResourceDefinition
|
||||||
Status CustomResourceStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
|
Status CustomResourceDefinitionStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceList is a list of CustomResource objects.
|
// CustomResourceDefinitionList is a list of CustomResourceDefinition objects.
|
||||||
type CustomResourceList struct {
|
type CustomResourceDefinitionList struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// Items individual CustomResources
|
// Items individual CustomResourceDefinitions
|
||||||
Items []CustomResource `json:"items" protobuf:"bytes,2,rep,name=items"`
|
Items []CustomResourceDefinition `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||||
}
|
}
|
||||||
|
@@ -35,55 +35,55 @@ func init() {
|
|||||||
// Public to allow building arbitrary schemes.
|
// Public to allow building arbitrary schemes.
|
||||||
func RegisterConversions(scheme *runtime.Scheme) error {
|
func RegisterConversions(scheme *runtime.Scheme) error {
|
||||||
return scheme.AddGeneratedConversionFuncs(
|
return scheme.AddGeneratedConversionFuncs(
|
||||||
Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource,
|
Convert_v1alpha1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition,
|
||||||
Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource,
|
Convert_apiextensions_CustomResourceDefinition_To_v1alpha1_CustomResourceDefinition,
|
||||||
Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition,
|
Convert_v1alpha1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition,
|
||||||
Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition,
|
Convert_apiextensions_CustomResourceDefinitionCondition_To_v1alpha1_CustomResourceDefinitionCondition,
|
||||||
Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList,
|
Convert_v1alpha1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList,
|
||||||
Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList,
|
Convert_apiextensions_CustomResourceDefinitionList_To_v1alpha1_CustomResourceDefinitionList,
|
||||||
Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames,
|
Convert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames,
|
||||||
Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames,
|
Convert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames,
|
||||||
Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec,
|
Convert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec,
|
||||||
Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec,
|
Convert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec,
|
||||||
Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus,
|
Convert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus,
|
||||||
Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus,
|
Convert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in *CustomResource, out *apiextensions.CustomResource, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in *CustomResourceDefinition, out *apiextensions.CustomResourceDefinition, s conversion.Scope) error {
|
||||||
out.ObjectMeta = in.ObjectMeta
|
out.ObjectMeta = in.ObjectMeta
|
||||||
if err := Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(&in.Spec, &out.Spec, s); err != nil {
|
if err := Convert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(&in.Status, &out.Status, s); err != nil {
|
if err := Convert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(&in.Status, &out.Status, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in *CustomResource, out *apiextensions.CustomResource, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in *CustomResourceDefinition, out *apiextensions.CustomResourceDefinition, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResource_To_apiextensions_CustomResource(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinition_To_apiextensions_CustomResourceDefinition(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in *apiextensions.CustomResource, out *CustomResource, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinition_To_v1alpha1_CustomResourceDefinition(in *apiextensions.CustomResourceDefinition, out *CustomResourceDefinition, s conversion.Scope) error {
|
||||||
out.ObjectMeta = in.ObjectMeta
|
out.ObjectMeta = in.ObjectMeta
|
||||||
if err := Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(&in.Spec, &out.Spec, s); err != nil {
|
if err := Convert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(&in.Status, &out.Status, s); err != nil {
|
if err := Convert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus(&in.Status, &out.Status, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinition_To_v1alpha1_CustomResourceDefinition is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in *apiextensions.CustomResource, out *CustomResource, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinition_To_v1alpha1_CustomResourceDefinition(in *apiextensions.CustomResourceDefinition, out *CustomResourceDefinition, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResource_To_v1alpha1_CustomResource(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinition_To_v1alpha1_CustomResourceDefinition(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in *CustomResourceCondition, out *apiextensions.CustomResourceCondition, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in *CustomResourceDefinitionCondition, out *apiextensions.CustomResourceDefinitionCondition, s conversion.Scope) error {
|
||||||
out.Type = apiextensions.CustomResourceConditionType(in.Type)
|
out.Type = apiextensions.CustomResourceDefinitionConditionType(in.Type)
|
||||||
out.Status = apiextensions.ConditionStatus(in.Status)
|
out.Status = apiextensions.ConditionStatus(in.Status)
|
||||||
out.LastTransitionTime = in.LastTransitionTime
|
out.LastTransitionTime = in.LastTransitionTime
|
||||||
out.Reason = in.Reason
|
out.Reason = in.Reason
|
||||||
@@ -91,13 +91,13 @@ func autoConvert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in *CustomResourceCondition, out *apiextensions.CustomResourceCondition, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in *CustomResourceDefinitionCondition, out *apiextensions.CustomResourceDefinitionCondition, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResourceCondition_To_apiextensions_CustomResourceCondition(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinitionCondition_To_apiextensions_CustomResourceDefinitionCondition(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in *apiextensions.CustomResourceCondition, out *CustomResourceCondition, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinitionCondition_To_v1alpha1_CustomResourceDefinitionCondition(in *apiextensions.CustomResourceDefinitionCondition, out *CustomResourceDefinitionCondition, s conversion.Scope) error {
|
||||||
out.Type = CustomResourceConditionType(in.Type)
|
out.Type = CustomResourceDefinitionConditionType(in.Type)
|
||||||
out.Status = ConditionStatus(in.Status)
|
out.Status = ConditionStatus(in.Status)
|
||||||
out.LastTransitionTime = in.LastTransitionTime
|
out.LastTransitionTime = in.LastTransitionTime
|
||||||
out.Reason = in.Reason
|
out.Reason = in.Reason
|
||||||
@@ -105,38 +105,38 @@ func autoConvert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinitionCondition_To_v1alpha1_CustomResourceDefinitionCondition is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in *apiextensions.CustomResourceCondition, out *CustomResourceCondition, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinitionCondition_To_v1alpha1_CustomResourceDefinitionCondition(in *apiextensions.CustomResourceDefinitionCondition, out *CustomResourceDefinitionCondition, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResourceCondition_To_v1alpha1_CustomResourceCondition(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinitionCondition_To_v1alpha1_CustomResourceDefinitionCondition(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in *CustomResourceList, out *apiextensions.CustomResourceList, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in *CustomResourceDefinitionList, out *apiextensions.CustomResourceDefinitionList, s conversion.Scope) error {
|
||||||
out.ListMeta = in.ListMeta
|
out.ListMeta = in.ListMeta
|
||||||
out.Items = *(*[]apiextensions.CustomResource)(unsafe.Pointer(&in.Items))
|
out.Items = *(*[]apiextensions.CustomResourceDefinition)(unsafe.Pointer(&in.Items))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in *CustomResourceList, out *apiextensions.CustomResourceList, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in *CustomResourceDefinitionList, out *apiextensions.CustomResourceDefinitionList, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResourceList_To_apiextensions_CustomResourceList(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinitionList_To_apiextensions_CustomResourceDefinitionList(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in *apiextensions.CustomResourceList, out *CustomResourceList, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinitionList_To_v1alpha1_CustomResourceDefinitionList(in *apiextensions.CustomResourceDefinitionList, out *CustomResourceDefinitionList, s conversion.Scope) error {
|
||||||
out.ListMeta = in.ListMeta
|
out.ListMeta = in.ListMeta
|
||||||
if in.Items == nil {
|
if in.Items == nil {
|
||||||
out.Items = make([]CustomResource, 0)
|
out.Items = make([]CustomResourceDefinition, 0)
|
||||||
} else {
|
} else {
|
||||||
out.Items = *(*[]CustomResource)(unsafe.Pointer(&in.Items))
|
out.Items = *(*[]CustomResourceDefinition)(unsafe.Pointer(&in.Items))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinitionList_To_v1alpha1_CustomResourceDefinitionList is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in *apiextensions.CustomResourceList, out *CustomResourceList, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinitionList_To_v1alpha1_CustomResourceDefinitionList(in *apiextensions.CustomResourceDefinitionList, out *CustomResourceDefinitionList, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResourceList_To_v1alpha1_CustomResourceList(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinitionList_To_v1alpha1_CustomResourceDefinitionList(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in *CustomResourceNames, out *apiextensions.CustomResourceNames, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in *CustomResourceDefinitionNames, out *apiextensions.CustomResourceDefinitionNames, s conversion.Scope) error {
|
||||||
out.Plural = in.Plural
|
out.Plural = in.Plural
|
||||||
out.Singular = in.Singular
|
out.Singular = in.Singular
|
||||||
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
|
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
|
||||||
@@ -145,12 +145,12 @@ func autoConvert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNam
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in *CustomResourceNames, out *apiextensions.CustomResourceNames, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in *CustomResourceDefinitionNames, out *apiextensions.CustomResourceDefinitionNames, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in *apiextensions.CustomResourceNames, out *CustomResourceNames, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames(in *apiextensions.CustomResourceDefinitionNames, out *CustomResourceDefinitionNames, s conversion.Scope) error {
|
||||||
out.Plural = in.Plural
|
out.Plural = in.Plural
|
||||||
out.Singular = in.Singular
|
out.Singular = in.Singular
|
||||||
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
|
out.ShortNames = *(*[]string)(unsafe.Pointer(&in.ShortNames))
|
||||||
@@ -159,67 +159,67 @@ func autoConvert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNam
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in *apiextensions.CustomResourceNames, out *CustomResourceNames, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames(in *apiextensions.CustomResourceDefinitionNames, out *CustomResourceDefinitionNames, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in *CustomResourceSpec, out *apiextensions.CustomResourceSpec, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in *CustomResourceDefinitionSpec, out *apiextensions.CustomResourceDefinitionSpec, s conversion.Scope) error {
|
||||||
out.Group = in.Group
|
out.Group = in.Group
|
||||||
out.Version = in.Version
|
out.Version = in.Version
|
||||||
if err := Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(&in.Names, &out.Names, s); err != nil {
|
if err := Convert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(&in.Names, &out.Names, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Scope = apiextensions.ResourceScope(in.Scope)
|
out.Scope = apiextensions.ResourceScope(in.Scope)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in *CustomResourceSpec, out *apiextensions.CustomResourceSpec, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in *CustomResourceDefinitionSpec, out *apiextensions.CustomResourceDefinitionSpec, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResourceSpec_To_apiextensions_CustomResourceSpec(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinitionSpec_To_apiextensions_CustomResourceDefinitionSpec(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in *apiextensions.CustomResourceSpec, out *CustomResourceSpec, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec(in *apiextensions.CustomResourceDefinitionSpec, out *CustomResourceDefinitionSpec, s conversion.Scope) error {
|
||||||
out.Group = in.Group
|
out.Group = in.Group
|
||||||
out.Version = in.Version
|
out.Version = in.Version
|
||||||
if err := Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(&in.Names, &out.Names, s); err != nil {
|
if err := Convert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames(&in.Names, &out.Names, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Scope = ResourceScope(in.Scope)
|
out.Scope = ResourceScope(in.Scope)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in *apiextensions.CustomResourceSpec, out *CustomResourceSpec, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec(in *apiextensions.CustomResourceDefinitionSpec, out *CustomResourceDefinitionSpec, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResourceSpec_To_v1alpha1_CustomResourceSpec(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinitionSpec_To_v1alpha1_CustomResourceDefinitionSpec(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in *CustomResourceStatus, out *apiextensions.CustomResourceStatus, s conversion.Scope) error {
|
func autoConvert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in *CustomResourceDefinitionStatus, out *apiextensions.CustomResourceDefinitionStatus, s conversion.Scope) error {
|
||||||
out.Conditions = *(*[]apiextensions.CustomResourceCondition)(unsafe.Pointer(&in.Conditions))
|
out.Conditions = *(*[]apiextensions.CustomResourceDefinitionCondition)(unsafe.Pointer(&in.Conditions))
|
||||||
if err := Convert_v1alpha1_CustomResourceNames_To_apiextensions_CustomResourceNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
|
if err := Convert_v1alpha1_CustomResourceDefinitionNames_To_apiextensions_CustomResourceDefinitionNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus is an autogenerated conversion function.
|
// Convert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus is an autogenerated conversion function.
|
||||||
func Convert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in *CustomResourceStatus, out *apiextensions.CustomResourceStatus, s conversion.Scope) error {
|
func Convert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in *CustomResourceDefinitionStatus, out *apiextensions.CustomResourceDefinitionStatus, s conversion.Scope) error {
|
||||||
return autoConvert_v1alpha1_CustomResourceStatus_To_apiextensions_CustomResourceStatus(in, out, s)
|
return autoConvert_v1alpha1_CustomResourceDefinitionStatus_To_apiextensions_CustomResourceDefinitionStatus(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in *apiextensions.CustomResourceStatus, out *CustomResourceStatus, s conversion.Scope) error {
|
func autoConvert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus(in *apiextensions.CustomResourceDefinitionStatus, out *CustomResourceDefinitionStatus, s conversion.Scope) error {
|
||||||
if in.Conditions == nil {
|
if in.Conditions == nil {
|
||||||
out.Conditions = make([]CustomResourceCondition, 0)
|
out.Conditions = make([]CustomResourceDefinitionCondition, 0)
|
||||||
} else {
|
} else {
|
||||||
out.Conditions = *(*[]CustomResourceCondition)(unsafe.Pointer(&in.Conditions))
|
out.Conditions = *(*[]CustomResourceDefinitionCondition)(unsafe.Pointer(&in.Conditions))
|
||||||
}
|
}
|
||||||
if err := Convert_apiextensions_CustomResourceNames_To_v1alpha1_CustomResourceNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
|
if err := Convert_apiextensions_CustomResourceDefinitionNames_To_v1alpha1_CustomResourceDefinitionNames(&in.AcceptedNames, &out.AcceptedNames, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus is an autogenerated conversion function.
|
// Convert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus is an autogenerated conversion function.
|
||||||
func Convert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in *apiextensions.CustomResourceStatus, out *CustomResourceStatus, s conversion.Scope) error {
|
func Convert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus(in *apiextensions.CustomResourceDefinitionStatus, out *CustomResourceDefinitionStatus, s conversion.Scope) error {
|
||||||
return autoConvert_apiextensions_CustomResourceStatus_To_v1alpha1_CustomResourceStatus(in, out, s)
|
return autoConvert_apiextensions_CustomResourceDefinitionStatus_To_v1alpha1_CustomResourceDefinitionStatus(in, out, s)
|
||||||
}
|
}
|
||||||
|
@@ -35,19 +35,19 @@ func init() {
|
|||||||
// to allow building arbitrary schemes.
|
// to allow building arbitrary schemes.
|
||||||
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
||||||
return scheme.AddGeneratedDeepCopyFuncs(
|
return scheme.AddGeneratedDeepCopyFuncs(
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResource, InType: reflect.TypeOf(&CustomResource{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinition, InType: reflect.TypeOf(&CustomResourceDefinition{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceCondition, InType: reflect.TypeOf(&CustomResourceCondition{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinitionCondition, InType: reflect.TypeOf(&CustomResourceDefinitionCondition{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceList, InType: reflect.TypeOf(&CustomResourceList{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinitionList, InType: reflect.TypeOf(&CustomResourceDefinitionList{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceNames, InType: reflect.TypeOf(&CustomResourceNames{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinitionNames, InType: reflect.TypeOf(&CustomResourceDefinitionNames{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceSpec, InType: reflect.TypeOf(&CustomResourceSpec{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinitionSpec, InType: reflect.TypeOf(&CustomResourceDefinitionSpec{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceStatus, InType: reflect.TypeOf(&CustomResourceStatus{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1alpha1_CustomResourceDefinitionStatus, InType: reflect.TypeOf(&CustomResourceDefinitionStatus{})},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResource(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResource)
|
in := in.(*CustomResourceDefinition)
|
||||||
out := out.(*CustomResource)
|
out := out.(*CustomResourceDefinition)
|
||||||
*out = *in
|
*out = *in
|
||||||
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
|
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -57,40 +57,40 @@ func DeepCopy_v1alpha1_CustomResource(in interface{}, out interface{}, c *conver
|
|||||||
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
|
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Spec = *newVal.(*CustomResourceSpec)
|
out.Spec = *newVal.(*CustomResourceDefinitionSpec)
|
||||||
}
|
}
|
||||||
if newVal, err := c.DeepCopy(&in.Status); err != nil {
|
if newVal, err := c.DeepCopy(&in.Status); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Status = *newVal.(*CustomResourceStatus)
|
out.Status = *newVal.(*CustomResourceDefinitionStatus)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResourceCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinitionCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceCondition)
|
in := in.(*CustomResourceDefinitionCondition)
|
||||||
out := out.(*CustomResourceCondition)
|
out := out.(*CustomResourceDefinitionCondition)
|
||||||
*out = *in
|
*out = *in
|
||||||
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
|
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResourceList(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinitionList(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceList)
|
in := in.(*CustomResourceDefinitionList)
|
||||||
out := out.(*CustomResourceList)
|
out := out.(*CustomResourceDefinitionList)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Items != nil {
|
if in.Items != nil {
|
||||||
in, out := &in.Items, &out.Items
|
in, out := &in.Items, &out.Items
|
||||||
*out = make([]CustomResource, len(*in))
|
*out = make([]CustomResourceDefinition, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
(*out)[i] = *newVal.(*CustomResource)
|
(*out)[i] = *newVal.(*CustomResourceDefinition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ func DeepCopy_v1alpha1_CustomResourceList(in interface{}, out interface{}, c *co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResourceNames(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinitionNames(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceNames)
|
in := in.(*CustomResourceDefinitionNames)
|
||||||
out := out.(*CustomResourceNames)
|
out := out.(*CustomResourceDefinitionNames)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.ShortNames != nil {
|
if in.ShortNames != nil {
|
||||||
in, out := &in.ShortNames, &out.ShortNames
|
in, out := &in.ShortNames, &out.ShortNames
|
||||||
@@ -112,40 +112,40 @@ func DeepCopy_v1alpha1_CustomResourceNames(in interface{}, out interface{}, c *c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResourceSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinitionSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceSpec)
|
in := in.(*CustomResourceDefinitionSpec)
|
||||||
out := out.(*CustomResourceSpec)
|
out := out.(*CustomResourceDefinitionSpec)
|
||||||
*out = *in
|
*out = *in
|
||||||
if newVal, err := c.DeepCopy(&in.Names); err != nil {
|
if newVal, err := c.DeepCopy(&in.Names); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Names = *newVal.(*CustomResourceNames)
|
out.Names = *newVal.(*CustomResourceDefinitionNames)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_v1alpha1_CustomResourceStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_v1alpha1_CustomResourceDefinitionStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceStatus)
|
in := in.(*CustomResourceDefinitionStatus)
|
||||||
out := out.(*CustomResourceStatus)
|
out := out.(*CustomResourceDefinitionStatus)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Conditions != nil {
|
if in.Conditions != nil {
|
||||||
in, out := &in.Conditions, &out.Conditions
|
in, out := &in.Conditions, &out.Conditions
|
||||||
*out = make([]CustomResourceCondition, len(*in))
|
*out = make([]CustomResourceDefinitionCondition, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
(*out)[i] = *newVal.(*CustomResourceCondition)
|
(*out)[i] = *newVal.(*CustomResourceDefinitionCondition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
|
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.AcceptedNames = *newVal.(*CustomResourceNames)
|
out.AcceptedNames = *newVal.(*CustomResourceDefinitionNames)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,8 @@ import (
|
|||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidateCustomResource statically validates
|
// ValidateCustomResourceDefinition statically validates
|
||||||
func ValidateCustomResource(obj *apiextensions.CustomResource) field.ErrorList {
|
func ValidateCustomResourceDefinition(obj *apiextensions.CustomResourceDefinition) field.ErrorList {
|
||||||
nameValidationFn := func(name string, prefix bool) []string {
|
nameValidationFn := func(name string, prefix bool) []string {
|
||||||
ret := genericvalidation.NameIsDNSSubdomain(name, prefix)
|
ret := genericvalidation.NameIsDNSSubdomain(name, prefix)
|
||||||
requiredName := obj.Spec.Names.Plural + "." + obj.Spec.Group
|
requiredName := obj.Spec.Names.Plural + "." + obj.Spec.Group
|
||||||
@@ -38,28 +38,28 @@ func ValidateCustomResource(obj *apiextensions.CustomResource) field.ErrorList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allErrs := genericvalidation.ValidateObjectMeta(&obj.ObjectMeta, false, nameValidationFn, field.NewPath("metadata"))
|
allErrs := genericvalidation.ValidateObjectMeta(&obj.ObjectMeta, false, nameValidationFn, field.NewPath("metadata"))
|
||||||
allErrs = append(allErrs, ValidateCustomResourceSpec(&obj.Spec, field.NewPath("spec"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionSpec(&obj.Spec, field.NewPath("spec"))...)
|
||||||
allErrs = append(allErrs, ValidateCustomResourceStatus(&obj.Status, field.NewPath("status"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCustomResourceUpdate statically validates
|
// ValidateCustomResourceDefinitionUpdate statically validates
|
||||||
func ValidateCustomResourceUpdate(obj, oldObj *apiextensions.CustomResource) field.ErrorList {
|
func ValidateCustomResourceDefinitionUpdate(obj, oldObj *apiextensions.CustomResourceDefinition) field.ErrorList {
|
||||||
allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata"))
|
allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata"))
|
||||||
allErrs = append(allErrs, ValidateCustomResourceSpecUpdate(&obj.Spec, &oldObj.Spec, field.NewPath("spec"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionSpecUpdate(&obj.Spec, &oldObj.Spec, field.NewPath("spec"))...)
|
||||||
allErrs = append(allErrs, ValidateCustomResourceStatus(&obj.Status, field.NewPath("status"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateUpdateCustomResourceStatus statically validates
|
// ValidateUpdateCustomResourceDefinitionStatus statically validates
|
||||||
func ValidateUpdateCustomResourceStatus(obj, oldObj *apiextensions.CustomResource) field.ErrorList {
|
func ValidateUpdateCustomResourceDefinitionStatus(obj, oldObj *apiextensions.CustomResourceDefinition) field.ErrorList {
|
||||||
allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata"))
|
allErrs := genericvalidation.ValidateObjectMetaUpdate(&obj.ObjectMeta, &oldObj.ObjectMeta, field.NewPath("metadata"))
|
||||||
allErrs = append(allErrs, ValidateCustomResourceStatus(&obj.Status, field.NewPath("status"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionStatus(&obj.Status, field.NewPath("status"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCustomResourceSpec statically validates
|
// ValidateCustomResourceDefinitionSpec statically validates
|
||||||
func ValidateCustomResourceSpec(spec *apiextensions.CustomResourceSpec, fldPath *field.Path) field.ErrorList {
|
func ValidateCustomResourceDefinitionSpec(spec *apiextensions.CustomResourceDefinitionSpec, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
|
|
||||||
if len(spec.Group) == 0 {
|
if len(spec.Group) == 0 {
|
||||||
@@ -99,14 +99,14 @@ func ValidateCustomResourceSpec(spec *apiextensions.CustomResourceSpec, fldPath
|
|||||||
allErrs = append(allErrs, field.Required(fldPath.Child("names", "listKind"), ""))
|
allErrs = append(allErrs, field.Required(fldPath.Child("names", "listKind"), ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
allErrs = append(allErrs, ValidateCustomResourceNames(&spec.Names, fldPath.Child("names"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionNames(&spec.Names, fldPath.Child("names"))...)
|
||||||
|
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCustomResourceSpecUpdate statically validates
|
// ValidateCustomResourceDefinitionSpecUpdate statically validates
|
||||||
func ValidateCustomResourceSpecUpdate(spec, oldSpec *apiextensions.CustomResourceSpec, fldPath *field.Path) field.ErrorList {
|
func ValidateCustomResourceDefinitionSpecUpdate(spec, oldSpec *apiextensions.CustomResourceDefinitionSpec, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := ValidateCustomResourceSpec(spec, fldPath)
|
allErrs := ValidateCustomResourceDefinitionSpec(spec, fldPath)
|
||||||
|
|
||||||
// these all affect the storage, so you can't change them
|
// these all affect the storage, so you can't change them
|
||||||
genericvalidation.ValidateImmutableField(spec.Group, oldSpec.Group, fldPath.Child("group"))
|
genericvalidation.ValidateImmutableField(spec.Group, oldSpec.Group, fldPath.Child("group"))
|
||||||
@@ -120,15 +120,15 @@ func ValidateCustomResourceSpecUpdate(spec, oldSpec *apiextensions.CustomResourc
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCustomResourceStatus statically validates
|
// ValidateCustomResourceDefinitionStatus statically validates
|
||||||
func ValidateCustomResourceStatus(status *apiextensions.CustomResourceStatus, fldPath *field.Path) field.ErrorList {
|
func ValidateCustomResourceDefinitionStatus(status *apiextensions.CustomResourceDefinitionStatus, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
allErrs = append(allErrs, ValidateCustomResourceNames(&status.AcceptedNames, fldPath.Child("acceptedNames"))...)
|
allErrs = append(allErrs, ValidateCustomResourceDefinitionNames(&status.AcceptedNames, fldPath.Child("acceptedNames"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateCustomResourceNames statically validates
|
// ValidateCustomResourceDefinitionNames statically validates
|
||||||
func ValidateCustomResourceNames(names *apiextensions.CustomResourceNames, fldPath *field.Path) field.ErrorList {
|
func ValidateCustomResourceDefinitionNames(names *apiextensions.CustomResourceDefinitionNames, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
if errs := validationutil.IsDNS1035Label(names.Plural); len(names.Plural) > 0 && len(errs) > 0 {
|
if errs := validationutil.IsDNS1035Label(names.Plural); len(names.Plural) > 0 && len(errs) > 0 {
|
||||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("plural"), names.Plural, strings.Join(errs, ",")))
|
allErrs = append(allErrs, field.Invalid(fldPath.Child("plural"), names.Plural, strings.Join(errs, ",")))
|
||||||
|
@@ -40,19 +40,19 @@ func (v validationMatch) matches(err *field.Error) bool {
|
|||||||
return err.Type == v.errorType && err.Field == v.path.String()
|
return err.Type == v.errorType && err.Field == v.path.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCustomResource(t *testing.T) {
|
func TestValidateCustomResourceDefinition(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
resource *apiextensions.CustomResource
|
resource *apiextensions.CustomResourceDefinition
|
||||||
errors []validationMatch
|
errors []validationMatch
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "mismatched name",
|
name: "mismatched name",
|
||||||
resource: &apiextensions.CustomResource{
|
resource: &apiextensions.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "plural.not.group.com"},
|
ObjectMeta: metav1.ObjectMeta{Name: "plural.not.group.com"},
|
||||||
Spec: apiextensions.CustomResourceSpec{
|
Spec: apiextensions.CustomResourceDefinitionSpec{
|
||||||
Group: "group.com",
|
Group: "group.com",
|
||||||
Names: apiextensions.CustomResourceNames{
|
Names: apiextensions.CustomResourceDefinitionNames{
|
||||||
Plural: "plural",
|
Plural: "plural",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ func TestValidateCustomResource(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "missing values",
|
name: "missing values",
|
||||||
resource: &apiextensions.CustomResource{
|
resource: &apiextensions.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"},
|
ObjectMeta: metav1.ObjectMeta{Name: "plural.group.com"},
|
||||||
},
|
},
|
||||||
errors: []validationMatch{
|
errors: []validationMatch{
|
||||||
@@ -78,21 +78,21 @@ func TestValidateCustomResource(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bad names 01",
|
name: "bad names 01",
|
||||||
resource: &apiextensions.CustomResource{
|
resource: &apiextensions.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "plural.group"},
|
ObjectMeta: metav1.ObjectMeta{Name: "plural.group"},
|
||||||
Spec: apiextensions.CustomResourceSpec{
|
Spec: apiextensions.CustomResourceDefinitionSpec{
|
||||||
Group: "group",
|
Group: "group",
|
||||||
Version: "ve()*rsion",
|
Version: "ve()*rsion",
|
||||||
Scope: apiextensions.ResourceScope("foo"),
|
Scope: apiextensions.ResourceScope("foo"),
|
||||||
Names: apiextensions.CustomResourceNames{
|
Names: apiextensions.CustomResourceDefinitionNames{
|
||||||
Plural: "pl()*ural",
|
Plural: "pl()*ural",
|
||||||
Singular: "value()*a",
|
Singular: "value()*a",
|
||||||
Kind: "value()*a",
|
Kind: "value()*a",
|
||||||
ListKind: "value()*a",
|
ListKind: "value()*a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: apiextensions.CustomResourceStatus{
|
Status: apiextensions.CustomResourceDefinitionStatus{
|
||||||
AcceptedNames: apiextensions.CustomResourceNames{
|
AcceptedNames: apiextensions.CustomResourceDefinitionNames{
|
||||||
Plural: "pl()*ural",
|
Plural: "pl()*ural",
|
||||||
Singular: "value()*a",
|
Singular: "value()*a",
|
||||||
Kind: "value()*a",
|
Kind: "value()*a",
|
||||||
@@ -116,20 +116,20 @@ func TestValidateCustomResource(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bad names 02",
|
name: "bad names 02",
|
||||||
resource: &apiextensions.CustomResource{
|
resource: &apiextensions.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "plural.group"},
|
ObjectMeta: metav1.ObjectMeta{Name: "plural.group"},
|
||||||
Spec: apiextensions.CustomResourceSpec{
|
Spec: apiextensions.CustomResourceDefinitionSpec{
|
||||||
Group: "group.c(*&om",
|
Group: "group.c(*&om",
|
||||||
Version: "version",
|
Version: "version",
|
||||||
Names: apiextensions.CustomResourceNames{
|
Names: apiextensions.CustomResourceDefinitionNames{
|
||||||
Plural: "plural",
|
Plural: "plural",
|
||||||
Singular: "singular",
|
Singular: "singular",
|
||||||
Kind: "matching",
|
Kind: "matching",
|
||||||
ListKind: "matching",
|
ListKind: "matching",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: apiextensions.CustomResourceStatus{
|
Status: apiextensions.CustomResourceDefinitionStatus{
|
||||||
AcceptedNames: apiextensions.CustomResourceNames{
|
AcceptedNames: apiextensions.CustomResourceDefinitionNames{
|
||||||
Plural: "plural",
|
Plural: "plural",
|
||||||
Singular: "singular",
|
Singular: "singular",
|
||||||
Kind: "matching",
|
Kind: "matching",
|
||||||
@@ -146,7 +146,7 @@ func TestValidateCustomResource(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
errs := ValidateCustomResource(tc.resource)
|
errs := ValidateCustomResourceDefinition(tc.resource)
|
||||||
|
|
||||||
for _, expectedError := range tc.errors {
|
for _, expectedError := range tc.errors {
|
||||||
found := false
|
found := false
|
||||||
|
@@ -35,19 +35,19 @@ func init() {
|
|||||||
// to allow building arbitrary schemes.
|
// to allow building arbitrary schemes.
|
||||||
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
func RegisterDeepCopies(scheme *runtime.Scheme) error {
|
||||||
return scheme.AddGeneratedDeepCopyFuncs(
|
return scheme.AddGeneratedDeepCopyFuncs(
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResource, InType: reflect.TypeOf(&CustomResource{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinition, InType: reflect.TypeOf(&CustomResourceDefinition{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceCondition, InType: reflect.TypeOf(&CustomResourceCondition{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinitionCondition, InType: reflect.TypeOf(&CustomResourceDefinitionCondition{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceList, InType: reflect.TypeOf(&CustomResourceList{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinitionList, InType: reflect.TypeOf(&CustomResourceDefinitionList{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceNames, InType: reflect.TypeOf(&CustomResourceNames{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinitionNames, InType: reflect.TypeOf(&CustomResourceDefinitionNames{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceSpec, InType: reflect.TypeOf(&CustomResourceSpec{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinitionSpec, InType: reflect.TypeOf(&CustomResourceDefinitionSpec{})},
|
||||||
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceStatus, InType: reflect.TypeOf(&CustomResourceStatus{})},
|
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_apiextensions_CustomResourceDefinitionStatus, InType: reflect.TypeOf(&CustomResourceDefinitionStatus{})},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResource(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResource)
|
in := in.(*CustomResourceDefinition)
|
||||||
out := out.(*CustomResource)
|
out := out.(*CustomResourceDefinition)
|
||||||
*out = *in
|
*out = *in
|
||||||
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
|
if newVal, err := c.DeepCopy(&in.ObjectMeta); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -57,40 +57,40 @@ func DeepCopy_apiextensions_CustomResource(in interface{}, out interface{}, c *c
|
|||||||
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
|
if newVal, err := c.DeepCopy(&in.Spec); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Spec = *newVal.(*CustomResourceSpec)
|
out.Spec = *newVal.(*CustomResourceDefinitionSpec)
|
||||||
}
|
}
|
||||||
if newVal, err := c.DeepCopy(&in.Status); err != nil {
|
if newVal, err := c.DeepCopy(&in.Status); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Status = *newVal.(*CustomResourceStatus)
|
out.Status = *newVal.(*CustomResourceDefinitionStatus)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResourceCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinitionCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceCondition)
|
in := in.(*CustomResourceDefinitionCondition)
|
||||||
out := out.(*CustomResourceCondition)
|
out := out.(*CustomResourceDefinitionCondition)
|
||||||
*out = *in
|
*out = *in
|
||||||
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
|
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResourceList(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinitionList(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceList)
|
in := in.(*CustomResourceDefinitionList)
|
||||||
out := out.(*CustomResourceList)
|
out := out.(*CustomResourceDefinitionList)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Items != nil {
|
if in.Items != nil {
|
||||||
in, out := &in.Items, &out.Items
|
in, out := &in.Items, &out.Items
|
||||||
*out = make([]CustomResource, len(*in))
|
*out = make([]CustomResourceDefinition, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
(*out)[i] = *newVal.(*CustomResource)
|
(*out)[i] = *newVal.(*CustomResourceDefinition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ func DeepCopy_apiextensions_CustomResourceList(in interface{}, out interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResourceNames(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinitionNames(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceNames)
|
in := in.(*CustomResourceDefinitionNames)
|
||||||
out := out.(*CustomResourceNames)
|
out := out.(*CustomResourceDefinitionNames)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.ShortNames != nil {
|
if in.ShortNames != nil {
|
||||||
in, out := &in.ShortNames, &out.ShortNames
|
in, out := &in.ShortNames, &out.ShortNames
|
||||||
@@ -112,40 +112,40 @@ func DeepCopy_apiextensions_CustomResourceNames(in interface{}, out interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResourceSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinitionSpec(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceSpec)
|
in := in.(*CustomResourceDefinitionSpec)
|
||||||
out := out.(*CustomResourceSpec)
|
out := out.(*CustomResourceDefinitionSpec)
|
||||||
*out = *in
|
*out = *in
|
||||||
if newVal, err := c.DeepCopy(&in.Names); err != nil {
|
if newVal, err := c.DeepCopy(&in.Names); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.Names = *newVal.(*CustomResourceNames)
|
out.Names = *newVal.(*CustomResourceDefinitionNames)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeepCopy_apiextensions_CustomResourceStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
|
func DeepCopy_apiextensions_CustomResourceDefinitionStatus(in interface{}, out interface{}, c *conversion.Cloner) error {
|
||||||
{
|
{
|
||||||
in := in.(*CustomResourceStatus)
|
in := in.(*CustomResourceDefinitionStatus)
|
||||||
out := out.(*CustomResourceStatus)
|
out := out.(*CustomResourceDefinitionStatus)
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Conditions != nil {
|
if in.Conditions != nil {
|
||||||
in, out := &in.Conditions, &out.Conditions
|
in, out := &in.Conditions, &out.Conditions
|
||||||
*out = make([]CustomResourceCondition, len(*in))
|
*out = make([]CustomResourceDefinitionCondition, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
if newVal, err := c.DeepCopy(&(*in)[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
(*out)[i] = *newVal.(*CustomResourceCondition)
|
(*out)[i] = *newVal.(*CustomResourceDefinitionCondition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
|
if newVal, err := c.DeepCopy(&in.AcceptedNames); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
out.AcceptedNames = *newVal.(*CustomResourceNames)
|
out.AcceptedNames = *newVal.(*CustomResourceDefinitionNames)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,6 @@ go_library(
|
|||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions/internalversion:go_default_library",
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion/apiextensions/internalversion:go_default_library",
|
||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion:go_default_library",
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion:go_default_library",
|
||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/registry/customresource:go_default_library",
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/registry/customresource:go_default_library",
|
||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/registry/customresourcestorage:go_default_library",
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/registry/customresourcedefinition:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -37,7 +37,7 @@ import (
|
|||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
||||||
"k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
|
"k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset"
|
||||||
internalinformers "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion"
|
internalinformers "k8s.io/kube-apiextensions-server/pkg/client/informers/internalversion"
|
||||||
"k8s.io/kube-apiextensions-server/pkg/registry/customresource"
|
"k8s.io/kube-apiextensions-server/pkg/registry/customresourcedefinition"
|
||||||
|
|
||||||
// make sure the generated client works
|
// make sure the generated client works
|
||||||
_ "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
|
_ "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
|
||||||
@@ -71,10 +71,10 @@ func init() {
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
GenericConfig *genericapiserver.Config
|
GenericConfig *genericapiserver.Config
|
||||||
|
|
||||||
CustomResourceRESTOptionsGetter genericregistry.RESTOptionsGetter
|
CustomResourceDefinitionRESTOptionsGetter genericregistry.RESTOptionsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomResources struct {
|
type CustomResourceDefinitions struct {
|
||||||
GenericAPIServer *genericapiserver.GenericAPIServer
|
GenericAPIServer *genericapiserver.GenericAPIServer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,32 +100,32 @@ func (c *Config) SkipComplete() completedConfig {
|
|||||||
return completedConfig{c}
|
return completedConfig{c}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new instance of CustomResources from the given config.
|
// New returns a new instance of CustomResourceDefinitions from the given config.
|
||||||
func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget) (*CustomResources, error) {
|
func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget) (*CustomResourceDefinitions, error) {
|
||||||
genericServer, err := c.Config.GenericConfig.SkipComplete().New(genericapiserver.EmptyDelegate) // completion is done in Complete, no need for a second time
|
genericServer, err := c.Config.GenericConfig.SkipComplete().New(genericapiserver.EmptyDelegate) // completion is done in Complete, no need for a second time
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
s := &CustomResources{
|
s := &CustomResourceDefinitions{
|
||||||
GenericAPIServer: genericServer,
|
GenericAPIServer: genericServer,
|
||||||
}
|
}
|
||||||
|
|
||||||
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiextensions.GroupName, registry, Scheme, metav1.ParameterCodec, Codecs)
|
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiextensions.GroupName, registry, Scheme, metav1.ParameterCodec, Codecs)
|
||||||
apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion
|
apiGroupInfo.GroupMeta.GroupVersion = v1alpha1.SchemeGroupVersion
|
||||||
v1alpha1storage := map[string]rest.Storage{}
|
v1alpha1storage := map[string]rest.Storage{}
|
||||||
v1alpha1storage["customresources"] = customresource.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)
|
v1alpha1storage["customresourcedefinitions"] = customresourcedefinition.NewREST(Scheme, c.GenericConfig.RESTOptionsGetter)
|
||||||
apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage
|
apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] = v1alpha1storage
|
||||||
|
|
||||||
if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil {
|
if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
customResourceClient, err := internalclientset.NewForConfig(s.GenericAPIServer.LoopbackClientConfig)
|
customResourceDefinitionClient, err := internalclientset.NewForConfig(s.GenericAPIServer.LoopbackClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
customResourceInformers := internalinformers.NewSharedInformerFactory(customResourceClient, 5*time.Minute)
|
customResourceDefinitionInformers := internalinformers.NewSharedInformerFactory(customResourceDefinitionClient, 5*time.Minute)
|
||||||
|
|
||||||
delegateHandler := delegationTarget.UnprotectedHandler()
|
delegateHandler := delegationTarget.UnprotectedHandler()
|
||||||
if delegateHandler == nil {
|
if delegateHandler == nil {
|
||||||
@@ -140,26 +140,26 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
|||||||
discovery: map[string]*discovery.APIGroupHandler{},
|
discovery: map[string]*discovery.APIGroupHandler{},
|
||||||
delegate: delegateHandler,
|
delegate: delegateHandler,
|
||||||
}
|
}
|
||||||
customResourceHandler := NewCustomResourceHandler(
|
customResourceDefinitionHandler := NewCustomResourceDefinitionHandler(
|
||||||
versionDiscoveryHandler,
|
versionDiscoveryHandler,
|
||||||
groupDiscoveryHandler,
|
groupDiscoveryHandler,
|
||||||
s.GenericAPIServer.RequestContextMapper(),
|
s.GenericAPIServer.RequestContextMapper(),
|
||||||
customResourceInformers.Apiextensions().InternalVersion().CustomResources().Lister(),
|
customResourceDefinitionInformers.Apiextensions().InternalVersion().CustomResourceDefinitions().Lister(),
|
||||||
delegateHandler,
|
delegateHandler,
|
||||||
c.CustomResourceRESTOptionsGetter,
|
c.CustomResourceDefinitionRESTOptionsGetter,
|
||||||
c.GenericConfig.AdmissionControl,
|
c.GenericConfig.AdmissionControl,
|
||||||
)
|
)
|
||||||
s.GenericAPIServer.Handler.PostGoRestfulMux.Handle("/apis", customResourceHandler)
|
s.GenericAPIServer.Handler.PostGoRestfulMux.Handle("/apis", customResourceDefinitionHandler)
|
||||||
s.GenericAPIServer.Handler.PostGoRestfulMux.HandlePrefix("/apis/", customResourceHandler)
|
s.GenericAPIServer.Handler.PostGoRestfulMux.HandlePrefix("/apis/", customResourceDefinitionHandler)
|
||||||
|
|
||||||
customResourceController := NewDiscoveryController(customResourceInformers.Apiextensions().InternalVersion().CustomResources(), versionDiscoveryHandler, groupDiscoveryHandler)
|
customResourceDefinitionController := NewDiscoveryController(customResourceDefinitionInformers.Apiextensions().InternalVersion().CustomResourceDefinitions(), versionDiscoveryHandler, groupDiscoveryHandler)
|
||||||
|
|
||||||
s.GenericAPIServer.AddPostStartHook("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error {
|
s.GenericAPIServer.AddPostStartHook("start-apiextensions-informers", func(context genericapiserver.PostStartHookContext) error {
|
||||||
customResourceInformers.Start(context.StopCh)
|
customResourceDefinitionInformers.Start(context.StopCh)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
s.GenericAPIServer.AddPostStartHook("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error {
|
s.GenericAPIServer.AddPostStartHook("start-apiextensions-controllers", func(context genericapiserver.PostStartHookContext) error {
|
||||||
go customResourceController.Run(context.StopCh)
|
go customResourceDefinitionController.Run(context.StopCh)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -40,8 +40,8 @@ type DiscoveryController struct {
|
|||||||
versionHandler *versionDiscoveryHandler
|
versionHandler *versionDiscoveryHandler
|
||||||
groupHandler *groupDiscoveryHandler
|
groupHandler *groupDiscoveryHandler
|
||||||
|
|
||||||
customResourceLister listers.CustomResourceLister
|
customResourceDefinitionLister listers.CustomResourceDefinitionLister
|
||||||
customResourcesSynced cache.InformerSynced
|
customResourceDefinitionsSynced cache.InformerSynced
|
||||||
|
|
||||||
// To allow injection for testing.
|
// To allow injection for testing.
|
||||||
syncFn func(version schema.GroupVersion) error
|
syncFn func(version schema.GroupVersion) error
|
||||||
@@ -49,20 +49,20 @@ type DiscoveryController struct {
|
|||||||
queue workqueue.RateLimitingInterface
|
queue workqueue.RateLimitingInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDiscoveryController(customResourceInformer informers.CustomResourceInformer, versionHandler *versionDiscoveryHandler, groupHandler *groupDiscoveryHandler) *DiscoveryController {
|
func NewDiscoveryController(customResourceDefinitionInformer informers.CustomResourceDefinitionInformer, versionHandler *versionDiscoveryHandler, groupHandler *groupDiscoveryHandler) *DiscoveryController {
|
||||||
c := &DiscoveryController{
|
c := &DiscoveryController{
|
||||||
versionHandler: versionHandler,
|
versionHandler: versionHandler,
|
||||||
groupHandler: groupHandler,
|
groupHandler: groupHandler,
|
||||||
customResourceLister: customResourceInformer.Lister(),
|
customResourceDefinitionLister: customResourceDefinitionInformer.Lister(),
|
||||||
customResourcesSynced: customResourceInformer.Informer().HasSynced,
|
customResourceDefinitionsSynced: customResourceDefinitionInformer.Informer().HasSynced,
|
||||||
|
|
||||||
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "DiscoveryController"),
|
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "DiscoveryController"),
|
||||||
}
|
}
|
||||||
|
|
||||||
customResourceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
customResourceDefinitionInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: c.addCustomResource,
|
AddFunc: c.addCustomResourceDefinition,
|
||||||
UpdateFunc: c.updateCustomResource,
|
UpdateFunc: c.updateCustomResourceDefinition,
|
||||||
DeleteFunc: c.deleteCustomResource,
|
DeleteFunc: c.deleteCustomResourceDefinition,
|
||||||
})
|
})
|
||||||
|
|
||||||
c.syncFn = c.sync
|
c.syncFn = c.sync
|
||||||
@@ -75,36 +75,36 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
|
|||||||
apiVersionsForDiscovery := []metav1.GroupVersionForDiscovery{}
|
apiVersionsForDiscovery := []metav1.GroupVersionForDiscovery{}
|
||||||
apiResourcesForDiscovery := []metav1.APIResource{}
|
apiResourcesForDiscovery := []metav1.APIResource{}
|
||||||
|
|
||||||
customResources, err := c.customResourceLister.List(labels.Everything())
|
customResourceDefinitions, err := c.customResourceDefinitionLister.List(labels.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
foundVersion := false
|
foundVersion := false
|
||||||
foundGroup := false
|
foundGroup := false
|
||||||
for _, customResource := range customResources {
|
for _, customResourceDefinition := range customResourceDefinitions {
|
||||||
// TODO add status checking
|
// TODO add status checking
|
||||||
|
|
||||||
if customResource.Spec.Group != version.Group {
|
if customResourceDefinition.Spec.Group != version.Group {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
foundGroup = true
|
foundGroup = true
|
||||||
apiVersionsForDiscovery = append(apiVersionsForDiscovery, metav1.GroupVersionForDiscovery{
|
apiVersionsForDiscovery = append(apiVersionsForDiscovery, metav1.GroupVersionForDiscovery{
|
||||||
GroupVersion: customResource.Spec.Group + "/" + customResource.Spec.Version,
|
GroupVersion: customResourceDefinition.Spec.Group + "/" + customResourceDefinition.Spec.Version,
|
||||||
Version: customResource.Spec.Version,
|
Version: customResourceDefinition.Spec.Version,
|
||||||
})
|
})
|
||||||
|
|
||||||
if customResource.Spec.Version != version.Version {
|
if customResourceDefinition.Spec.Version != version.Version {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
foundVersion = true
|
foundVersion = true
|
||||||
|
|
||||||
apiResourcesForDiscovery = append(apiResourcesForDiscovery, metav1.APIResource{
|
apiResourcesForDiscovery = append(apiResourcesForDiscovery, metav1.APIResource{
|
||||||
Name: customResource.Spec.Names.Plural,
|
Name: customResourceDefinition.Spec.Names.Plural,
|
||||||
SingularName: customResource.Spec.Names.Singular,
|
SingularName: customResourceDefinition.Spec.Names.Singular,
|
||||||
Namespaced: customResource.Spec.Scope == apiextensions.NamespaceScoped,
|
Namespaced: customResourceDefinition.Spec.Scope == apiextensions.NamespaceScoped,
|
||||||
Kind: customResource.Spec.Names.Kind,
|
Kind: customResourceDefinition.Spec.Names.Kind,
|
||||||
Verbs: metav1.Verbs([]string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}),
|
Verbs: metav1.Verbs([]string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}),
|
||||||
ShortNames: customResource.Spec.Names.ShortNames,
|
ShortNames: customResourceDefinition.Spec.Names.ShortNames,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ func (c *DiscoveryController) Run(stopCh <-chan struct{}) {
|
|||||||
|
|
||||||
glog.Infof("Starting DiscoveryController")
|
glog.Infof("Starting DiscoveryController")
|
||||||
|
|
||||||
if !cache.WaitForCacheSync(stopCh, c.customResourcesSynced) {
|
if !cache.WaitForCacheSync(stopCh, c.customResourceDefinitionsSynced) {
|
||||||
utilruntime.HandleError(fmt.Errorf("timed out waiting for caches to sync"))
|
utilruntime.HandleError(fmt.Errorf("timed out waiting for caches to sync"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -176,36 +176,36 @@ func (c *DiscoveryController) processNextWorkItem() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DiscoveryController) enqueue(obj *apiextensions.CustomResource) {
|
func (c *DiscoveryController) enqueue(obj *apiextensions.CustomResourceDefinition) {
|
||||||
c.queue.Add(schema.GroupVersion{Group: obj.Spec.Group, Version: obj.Spec.Version})
|
c.queue.Add(schema.GroupVersion{Group: obj.Spec.Group, Version: obj.Spec.Version})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DiscoveryController) addCustomResource(obj interface{}) {
|
func (c *DiscoveryController) addCustomResourceDefinition(obj interface{}) {
|
||||||
castObj := obj.(*apiextensions.CustomResource)
|
castObj := obj.(*apiextensions.CustomResourceDefinition)
|
||||||
glog.V(4).Infof("Adding customresource %s", castObj.Name)
|
glog.V(4).Infof("Adding customresourcedefinition %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DiscoveryController) updateCustomResource(obj, _ interface{}) {
|
func (c *DiscoveryController) updateCustomResourceDefinition(obj, _ interface{}) {
|
||||||
castObj := obj.(*apiextensions.CustomResource)
|
castObj := obj.(*apiextensions.CustomResourceDefinition)
|
||||||
glog.V(4).Infof("Updating customresource %s", castObj.Name)
|
glog.V(4).Infof("Updating customresourcedefinition %s", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DiscoveryController) deleteCustomResource(obj interface{}) {
|
func (c *DiscoveryController) deleteCustomResourceDefinition(obj interface{}) {
|
||||||
castObj, ok := obj.(*apiextensions.CustomResource)
|
castObj, ok := obj.(*apiextensions.CustomResourceDefinition)
|
||||||
if !ok {
|
if !ok {
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("Couldn't get object from tombstone %#v", obj)
|
glog.Errorf("Couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
castObj, ok = tombstone.Obj.(*apiextensions.CustomResource)
|
castObj, ok = tombstone.Obj.(*apiextensions.CustomResourceDefinition)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
glog.Errorf("Tombstone contained object that is not expected %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Deleting customresource %q", castObj.Name)
|
glog.V(4).Infof("Deleting customresourcedefinition %q", castObj.Name)
|
||||||
c.enqueue(castObj)
|
c.enqueue(castObj)
|
||||||
}
|
}
|
||||||
|
@@ -44,61 +44,61 @@ import (
|
|||||||
|
|
||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
listers "k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion"
|
listers "k8s.io/kube-apiextensions-server/pkg/client/listers/apiextensions/internalversion"
|
||||||
"k8s.io/kube-apiextensions-server/pkg/registry/customresourcestorage"
|
"k8s.io/kube-apiextensions-server/pkg/registry/customresource"
|
||||||
)
|
)
|
||||||
|
|
||||||
// customResourceHandler serves the `/apis` endpoint.
|
// customResourceDefinitionHandler serves the `/apis` endpoint.
|
||||||
// This is registered as a filter so that it never collides with any explictly registered endpoints
|
// This is registered as a filter so that it never collides with any explictly registered endpoints
|
||||||
type customResourceHandler struct {
|
type customResourceDefinitionHandler struct {
|
||||||
versionDiscoveryHandler *versionDiscoveryHandler
|
versionDiscoveryHandler *versionDiscoveryHandler
|
||||||
groupDiscoveryHandler *groupDiscoveryHandler
|
groupDiscoveryHandler *groupDiscoveryHandler
|
||||||
|
|
||||||
customStorageLock sync.Mutex
|
customStorageLock sync.Mutex
|
||||||
// customStorage contains a customResourceStorageMap
|
// customStorage contains a customResourceDefinitionStorageMap
|
||||||
customStorage atomic.Value
|
customStorage atomic.Value
|
||||||
|
|
||||||
requestContextMapper apirequest.RequestContextMapper
|
requestContextMapper apirequest.RequestContextMapper
|
||||||
|
|
||||||
customResourceLister listers.CustomResourceLister
|
customResourceDefinitionLister listers.CustomResourceDefinitionLister
|
||||||
|
|
||||||
delegate http.Handler
|
delegate http.Handler
|
||||||
restOptionsGetter generic.RESTOptionsGetter
|
restOptionsGetter generic.RESTOptionsGetter
|
||||||
admission admission.Interface
|
admission admission.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// customResourceInfo stores enough information to serve the storage for the custom resource
|
// customResourceDefinitionInfo stores enough information to serve the storage for the custom resource
|
||||||
type customResourceInfo struct {
|
type customResourceDefinitionInfo struct {
|
||||||
storage *customresourcestorage.REST
|
storage *customresource.REST
|
||||||
requestScope handlers.RequestScope
|
requestScope handlers.RequestScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// customResourceStorageMap goes from customresource to its storage
|
// customResourceDefinitionStorageMap goes from customresourcedefinition to its storage
|
||||||
type customResourceStorageMap map[types.UID]*customResourceInfo
|
type customResourceDefinitionStorageMap map[types.UID]*customResourceDefinitionInfo
|
||||||
|
|
||||||
func NewCustomResourceHandler(
|
func NewCustomResourceDefinitionHandler(
|
||||||
versionDiscoveryHandler *versionDiscoveryHandler,
|
versionDiscoveryHandler *versionDiscoveryHandler,
|
||||||
groupDiscoveryHandler *groupDiscoveryHandler,
|
groupDiscoveryHandler *groupDiscoveryHandler,
|
||||||
requestContextMapper apirequest.RequestContextMapper,
|
requestContextMapper apirequest.RequestContextMapper,
|
||||||
customResourceLister listers.CustomResourceLister,
|
customResourceDefinitionLister listers.CustomResourceDefinitionLister,
|
||||||
delegate http.Handler,
|
delegate http.Handler,
|
||||||
restOptionsGetter generic.RESTOptionsGetter,
|
restOptionsGetter generic.RESTOptionsGetter,
|
||||||
admission admission.Interface) *customResourceHandler {
|
admission admission.Interface) *customResourceDefinitionHandler {
|
||||||
ret := &customResourceHandler{
|
ret := &customResourceDefinitionHandler{
|
||||||
versionDiscoveryHandler: versionDiscoveryHandler,
|
versionDiscoveryHandler: versionDiscoveryHandler,
|
||||||
groupDiscoveryHandler: groupDiscoveryHandler,
|
groupDiscoveryHandler: groupDiscoveryHandler,
|
||||||
customStorage: atomic.Value{},
|
customStorage: atomic.Value{},
|
||||||
requestContextMapper: requestContextMapper,
|
requestContextMapper: requestContextMapper,
|
||||||
customResourceLister: customResourceLister,
|
customResourceDefinitionLister: customResourceDefinitionLister,
|
||||||
delegate: delegate,
|
delegate: delegate,
|
||||||
restOptionsGetter: restOptionsGetter,
|
restOptionsGetter: restOptionsGetter,
|
||||||
admission: admission,
|
admission: admission,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.customStorage.Store(customResourceStorageMap{})
|
ret.customStorage.Store(customResourceDefinitionStorageMap{})
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *customResourceHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (r *customResourceDefinitionHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx, ok := r.requestContextMapper.Get(req)
|
ctx, ok := r.requestContextMapper.Get(req)
|
||||||
if !ok {
|
if !ok {
|
||||||
// programmer error
|
// programmer error
|
||||||
@@ -133,8 +133,8 @@ func (r *customResourceHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
customResourceName := requestInfo.Resource + "." + requestInfo.APIGroup
|
customResourceDefinitionName := requestInfo.Resource + "." + requestInfo.APIGroup
|
||||||
customResource, err := r.customResourceLister.Get(customResourceName)
|
customResourceDefinition, err := r.customResourceDefinitionLister.Get(customResourceDefinitionName)
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
r.delegate.ServeHTTP(w, req)
|
r.delegate.ServeHTTP(w, req)
|
||||||
return
|
return
|
||||||
@@ -143,15 +143,15 @@ func (r *customResourceHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
|
|||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if customResource.Spec.Version != requestInfo.APIVersion {
|
if customResourceDefinition.Spec.Version != requestInfo.APIVersion {
|
||||||
r.delegate.ServeHTTP(w, req)
|
r.delegate.ServeHTTP(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO this is the point to do the condition checks
|
// TODO this is the point to do the condition checks
|
||||||
|
|
||||||
customResourceInfo := r.getServingInfoFor(customResource)
|
customResourceDefinitionInfo := r.getServingInfoFor(customResourceDefinition)
|
||||||
storage := customResourceInfo.storage
|
storage := customResourceDefinitionInfo.storage
|
||||||
requestScope := customResourceInfo.requestScope
|
requestScope := customResourceDefinitionInfo.requestScope
|
||||||
minRequestTimeout := 1 * time.Minute
|
minRequestTimeout := 1 * time.Minute
|
||||||
|
|
||||||
switch requestInfo.Verb {
|
switch requestInfo.Verb {
|
||||||
@@ -194,12 +194,12 @@ func (r *customResourceHandler) ServeHTTP(w http.ResponseWriter, req *http.Reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
// removeDeadStorage removes REST storage that isn't being used
|
// removeDeadStorage removes REST storage that isn't being used
|
||||||
func (r *customResourceHandler) removeDeadStorage() {
|
func (r *customResourceDefinitionHandler) removeDeadStorage() {
|
||||||
// these don't have to be live. A snapshot is fine
|
// these don't have to be live. A snapshot is fine
|
||||||
// if we wrongly delete, that's ok. The rest storage will be recreated on the next request
|
// if we wrongly delete, that's ok. The rest storage will be recreated on the next request
|
||||||
// if we wrongly miss one, that's ok. We'll get it next time
|
// if we wrongly miss one, that's ok. We'll get it next time
|
||||||
storageMap := r.customStorage.Load().(customResourceStorageMap)
|
storageMap := r.customStorage.Load().(customResourceDefinitionStorageMap)
|
||||||
allCustomResources, err := r.customResourceLister.List(labels.Everything())
|
allCustomResourceDefinitions, err := r.customResourceDefinitionLister.List(labels.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utilruntime.HandleError(err)
|
utilruntime.HandleError(err)
|
||||||
return
|
return
|
||||||
@@ -207,8 +207,8 @@ func (r *customResourceHandler) removeDeadStorage() {
|
|||||||
|
|
||||||
for uid := range storageMap {
|
for uid := range storageMap {
|
||||||
found := false
|
found := false
|
||||||
for _, customResource := range allCustomResources {
|
for _, customResourceDefinition := range allCustomResourceDefinitions {
|
||||||
if customResource.UID == uid {
|
if customResourceDefinition.UID == uid {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -224,9 +224,9 @@ func (r *customResourceHandler) removeDeadStorage() {
|
|||||||
r.customStorage.Store(storageMap)
|
r.customStorage.Store(storageMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *customResourceHandler) getServingInfoFor(customResource *apiextensions.CustomResource) *customResourceInfo {
|
func (r *customResourceDefinitionHandler) getServingInfoFor(customResourceDefinition *apiextensions.CustomResourceDefinition) *customResourceDefinitionInfo {
|
||||||
storageMap := r.customStorage.Load().(customResourceStorageMap)
|
storageMap := r.customStorage.Load().(customResourceDefinitionStorageMap)
|
||||||
ret, ok := storageMap[customResource.UID]
|
ret, ok := storageMap[customResourceDefinition.UID]
|
||||||
if ok {
|
if ok {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -234,21 +234,21 @@ func (r *customResourceHandler) getServingInfoFor(customResource *apiextensions.
|
|||||||
r.customStorageLock.Lock()
|
r.customStorageLock.Lock()
|
||||||
defer r.customStorageLock.Unlock()
|
defer r.customStorageLock.Unlock()
|
||||||
|
|
||||||
ret, ok = storageMap[customResource.UID]
|
ret, ok = storageMap[customResourceDefinition.UID]
|
||||||
if ok {
|
if ok {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
storage := customresourcestorage.NewREST(
|
storage := customresource.NewREST(
|
||||||
schema.GroupResource{Group: customResource.Spec.Group, Resource: customResource.Spec.Names.Plural},
|
schema.GroupResource{Group: customResourceDefinition.Spec.Group, Resource: customResourceDefinition.Spec.Names.Plural},
|
||||||
schema.GroupVersionKind{Group: customResource.Spec.Group, Version: customResource.Spec.Version, Kind: customResource.Spec.Names.ListKind},
|
schema.GroupVersionKind{Group: customResourceDefinition.Spec.Group, Version: customResourceDefinition.Spec.Version, Kind: customResourceDefinition.Spec.Names.ListKind},
|
||||||
UnstructuredCopier{},
|
UnstructuredCopier{},
|
||||||
customresourcestorage.NewStrategy(discovery.NewUnstructuredObjectTyper(nil), customResource.Spec.Scope == apiextensions.NamespaceScoped),
|
customresource.NewStrategy(discovery.NewUnstructuredObjectTyper(nil), customResourceDefinition.Spec.Scope == apiextensions.NamespaceScoped),
|
||||||
r.restOptionsGetter,
|
r.restOptionsGetter,
|
||||||
)
|
)
|
||||||
|
|
||||||
parameterScheme := runtime.NewScheme()
|
parameterScheme := runtime.NewScheme()
|
||||||
parameterScheme.AddUnversionedTypes(schema.GroupVersion{Group: customResource.Spec.Group, Version: customResource.Spec.Version},
|
parameterScheme.AddUnversionedTypes(schema.GroupVersion{Group: customResourceDefinition.Spec.Group, Version: customResourceDefinition.Spec.Version},
|
||||||
&metav1.ListOptions{},
|
&metav1.ListOptions{},
|
||||||
&metav1.ExportOptions{},
|
&metav1.ExportOptions{},
|
||||||
&metav1.GetOptions{},
|
&metav1.GetOptions{},
|
||||||
@@ -264,7 +264,7 @@ func (r *customResourceHandler) getServingInfoFor(customResource *apiextensions.
|
|||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
SelfLinker: meta.NewAccessor(),
|
SelfLinker: meta.NewAccessor(),
|
||||||
ClusterScoped: customResource.Spec.Scope == apiextensions.ClusterScoped,
|
ClusterScoped: customResourceDefinition.Spec.Scope == apiextensions.ClusterScoped,
|
||||||
},
|
},
|
||||||
ContextFunc: func(req *http.Request) apirequest.Context {
|
ContextFunc: func(req *http.Request) apirequest.Context {
|
||||||
ret, _ := r.requestContextMapper.Get(req)
|
ret, _ := r.requestContextMapper.Get(req)
|
||||||
@@ -281,18 +281,18 @@ func (r *customResourceHandler) getServingInfoFor(customResource *apiextensions.
|
|||||||
Typer: discovery.NewUnstructuredObjectTyper(nil),
|
Typer: discovery.NewUnstructuredObjectTyper(nil),
|
||||||
UnsafeConvertor: unstructured.UnstructuredObjectConverter{},
|
UnsafeConvertor: unstructured.UnstructuredObjectConverter{},
|
||||||
|
|
||||||
Resource: schema.GroupVersionResource{Group: customResource.Spec.Group, Version: customResource.Spec.Version, Resource: customResource.Spec.Names.Plural},
|
Resource: schema.GroupVersionResource{Group: customResourceDefinition.Spec.Group, Version: customResourceDefinition.Spec.Version, Resource: customResourceDefinition.Spec.Names.Plural},
|
||||||
Kind: schema.GroupVersionKind{Group: customResource.Spec.Group, Version: customResource.Spec.Version, Kind: customResource.Spec.Names.Kind},
|
Kind: schema.GroupVersionKind{Group: customResourceDefinition.Spec.Group, Version: customResourceDefinition.Spec.Version, Kind: customResourceDefinition.Spec.Names.Kind},
|
||||||
Subresource: "",
|
Subresource: "",
|
||||||
|
|
||||||
MetaGroupVersion: metav1.SchemeGroupVersion,
|
MetaGroupVersion: metav1.SchemeGroupVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = &customResourceInfo{
|
ret = &customResourceDefinitionInfo{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
requestScope: requestScope,
|
requestScope: requestScope,
|
||||||
}
|
}
|
||||||
storageMap[customResource.UID] = ret
|
storageMap[customResourceDefinition.UID] = ret
|
||||||
r.customStorage.Store(storageMap)
|
r.customStorage.Store(storageMap)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -349,7 +349,7 @@ type UnstructuredDefaulter struct{}
|
|||||||
|
|
||||||
func (UnstructuredDefaulter) Default(in runtime.Object) {}
|
func (UnstructuredDefaulter) Default(in runtime.Object) {}
|
||||||
|
|
||||||
type CustomResourceRESTOptionsGetter struct {
|
type CustomResourceDefinitionRESTOptionsGetter struct {
|
||||||
StorageConfig storagebackend.Config
|
StorageConfig storagebackend.Config
|
||||||
StoragePrefix string
|
StoragePrefix string
|
||||||
EnableWatchCache bool
|
EnableWatchCache bool
|
||||||
@@ -358,7 +358,7 @@ type CustomResourceRESTOptionsGetter struct {
|
|||||||
DeleteCollectionWorkers int
|
DeleteCollectionWorkers int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t CustomResourceRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error) {
|
func (t CustomResourceDefinitionRESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error) {
|
||||||
ret := generic.RESTOptions{
|
ret := generic.RESTOptions{
|
||||||
StorageConfig: &t.StorageConfig,
|
StorageConfig: &t.StorageConfig,
|
||||||
Decorator: generic.UndecoratedStorage,
|
Decorator: generic.UndecoratedStorage,
|
||||||
|
@@ -11,7 +11,7 @@ go_library(
|
|||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"apiextensions_client.go",
|
"apiextensions_client.go",
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"generated_expansion.go",
|
"generated_expansion.go",
|
||||||
],
|
],
|
||||||
|
@@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
type ApiextensionsV1alpha1Interface interface {
|
type ApiextensionsV1alpha1Interface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() rest.Interface
|
||||||
CustomResourcesGetter
|
CustomResourceDefinitionsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiextensionsV1alpha1Client is used to interact with features provided by the apiextensions.k8s.io group.
|
// ApiextensionsV1alpha1Client is used to interact with features provided by the apiextensions.k8s.io group.
|
||||||
@@ -33,8 +33,8 @@ type ApiextensionsV1alpha1Client struct {
|
|||||||
restClient rest.Interface
|
restClient rest.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApiextensionsV1alpha1Client) CustomResources() CustomResourceInterface {
|
func (c *ApiextensionsV1alpha1Client) CustomResourceDefinitions() CustomResourceDefinitionInterface {
|
||||||
return newCustomResources(c)
|
return newCustomResourceDefinitions(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewForConfig creates a new ApiextensionsV1alpha1Client for the given config.
|
// NewForConfig creates a new ApiextensionsV1alpha1Client for the given config.
|
||||||
|
@@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
|
||||||
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/scheme"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CustomResourcesGetter has a method to return a CustomResourceInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type CustomResourcesGetter interface {
|
|
||||||
CustomResources() CustomResourceInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// CustomResourceInterface has methods to work with CustomResource resources.
|
|
||||||
type CustomResourceInterface interface {
|
|
||||||
Create(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
|
|
||||||
Update(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
|
|
||||||
UpdateStatus(*v1alpha1.CustomResource) (*v1alpha1.CustomResource, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string, options v1.GetOptions) (*v1alpha1.CustomResource, error)
|
|
||||||
List(opts v1.ListOptions) (*v1alpha1.CustomResourceList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error)
|
|
||||||
CustomResourceExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// customResources implements CustomResourceInterface
|
|
||||||
type customResources struct {
|
|
||||||
client rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
// newCustomResources returns a CustomResources
|
|
||||||
func newCustomResources(c *ApiextensionsV1alpha1Client) *customResources {
|
|
||||||
return &customResources{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a customResource and creates it. Returns the server's representation of the customResource, and an error, if there is any.
|
|
||||||
func (c *customResources) Create(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
result = &v1alpha1.CustomResource{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Resource("customresources").
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a customResource and updates it. Returns the server's representation of the customResource, and an error, if there is any.
|
|
||||||
func (c *customResources) Update(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
result = &v1alpha1.CustomResource{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(customResource.Name).
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateStatus was generated because the type contains a Status member.
|
|
||||||
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
|
|
||||||
|
|
||||||
func (c *customResources) UpdateStatus(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
result = &v1alpha1.CustomResource{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(customResource.Name).
|
|
||||||
SubResource("status").
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the customResource and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *customResources) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *customResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the customResource, and returns the corresponding customResource object, and an error if there is any.
|
|
||||||
func (c *customResources) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
result = &v1alpha1.CustomResource{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(name).
|
|
||||||
VersionedParams(&options, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of CustomResources that match those selectors.
|
|
||||||
func (c *customResources) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceList, err error) {
|
|
||||||
result = &v1alpha1.CustomResourceList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested customResources.
|
|
||||||
func (c *customResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
opts.Watch = true
|
|
||||||
return c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched customResource.
|
|
||||||
func (c *customResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
result = &v1alpha1.CustomResource{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Resource("customresources").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
@@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
|
rest "k8s.io/client-go/rest"
|
||||||
|
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
||||||
|
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset/scheme"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface.
|
||||||
|
// A group's client should implement this interface.
|
||||||
|
type CustomResourceDefinitionsGetter interface {
|
||||||
|
CustomResourceDefinitions() CustomResourceDefinitionInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomResourceDefinitionInterface has methods to work with CustomResourceDefinition resources.
|
||||||
|
type CustomResourceDefinitionInterface interface {
|
||||||
|
Create(*v1alpha1.CustomResourceDefinition) (*v1alpha1.CustomResourceDefinition, error)
|
||||||
|
Update(*v1alpha1.CustomResourceDefinition) (*v1alpha1.CustomResourceDefinition, error)
|
||||||
|
UpdateStatus(*v1alpha1.CustomResourceDefinition) (*v1alpha1.CustomResourceDefinition, error)
|
||||||
|
Delete(name string, options *v1.DeleteOptions) error
|
||||||
|
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||||
|
Get(name string, options v1.GetOptions) (*v1alpha1.CustomResourceDefinition, error)
|
||||||
|
List(opts v1.ListOptions) (*v1alpha1.CustomResourceDefinitionList, error)
|
||||||
|
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||||
|
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResourceDefinition, err error)
|
||||||
|
CustomResourceDefinitionExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// customResourceDefinitions implements CustomResourceDefinitionInterface
|
||||||
|
type customResourceDefinitions struct {
|
||||||
|
client rest.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCustomResourceDefinitions returns a CustomResourceDefinitions
|
||||||
|
func newCustomResourceDefinitions(c *ApiextensionsV1alpha1Client) *customResourceDefinitions {
|
||||||
|
return &customResourceDefinitions{
|
||||||
|
client: c.RESTClient(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any.
|
||||||
|
func (c *customResourceDefinitions) Create(customResourceDefinition *v1alpha1.CustomResourceDefinition) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinition{}
|
||||||
|
err = c.client.Post().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any.
|
||||||
|
func (c *customResourceDefinitions) Update(customResourceDefinition *v1alpha1.CustomResourceDefinition) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinition{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(customResourceDefinition.Name).
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatus was generated because the type contains a Status member.
|
||||||
|
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
|
||||||
|
|
||||||
|
func (c *customResourceDefinitions) UpdateStatus(customResourceDefinition *v1alpha1.CustomResourceDefinition) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinition{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(customResourceDefinition.Name).
|
||||||
|
SubResource("status").
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs.
|
||||||
|
func (c *customResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(name).
|
||||||
|
Body(options).
|
||||||
|
Do().
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCollection deletes a collection of objects.
|
||||||
|
func (c *customResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||||
|
Body(options).
|
||||||
|
Do().
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any.
|
||||||
|
func (c *customResourceDefinitions) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinition{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(name).
|
||||||
|
VersionedParams(&options, scheme.ParameterCodec).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors.
|
||||||
|
func (c *customResourceDefinitions) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceDefinitionList, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinitionList{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested customResourceDefinitions.
|
||||||
|
func (c *customResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||||
|
opts.Watch = true
|
||||||
|
return c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Watch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched customResourceDefinition.
|
||||||
|
func (c *customResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
result = &v1alpha1.CustomResourceDefinition{}
|
||||||
|
err = c.client.Patch(pt).
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
SubResource(subresources...).
|
||||||
|
Name(name).
|
||||||
|
Body(data).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
@@ -12,7 +12,7 @@ go_library(
|
|||||||
srcs = [
|
srcs = [
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"fake_apiextensions_client.go",
|
"fake_apiextensions_client.go",
|
||||||
"fake_customresource.go",
|
"fake_customresourcedefinition.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
|
@@ -26,8 +26,8 @@ type FakeApiextensionsV1alpha1 struct {
|
|||||||
*testing.Fake
|
*testing.Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeApiextensionsV1alpha1) CustomResources() v1alpha1.CustomResourceInterface {
|
func (c *FakeApiextensionsV1alpha1) CustomResourceDefinitions() v1alpha1.CustomResourceDefinitionInterface {
|
||||||
return &FakeCustomResources{c}
|
return &FakeCustomResourceDefinitions{c}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
// RESTClient returns a RESTClient that is used to communicate
|
||||||
|
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
labels "k8s.io/apimachinery/pkg/labels"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakeCustomResources implements CustomResourceInterface
|
|
||||||
type FakeCustomResources struct {
|
|
||||||
Fake *FakeApiextensionsV1alpha1
|
|
||||||
}
|
|
||||||
|
|
||||||
var customresourcesResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1alpha1", Resource: "customresources"}
|
|
||||||
|
|
||||||
var customresourcesKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1alpha1", Kind: "CustomResource"}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Create(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootCreateAction(customresourcesResource, customResource), &v1alpha1.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Update(customResource *v1alpha1.CustomResource) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateAction(customresourcesResource, customResource), &v1alpha1.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) UpdateStatus(customResource *v1alpha1.CustomResource) (*v1alpha1.CustomResource, error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateSubresourceAction(customresourcesResource, "status", customResource), &v1alpha1.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootDeleteAction(customresourcesResource, name), &v1alpha1.CustomResource{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewRootDeleteCollectionAction(customresourcesResource, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &v1alpha1.CustomResourceList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootGetAction(customresourcesResource, name), &v1alpha1.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootListAction(customresourcesResource, customresourcesKind, opts), &v1alpha1.CustomResourceList{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &v1alpha1.CustomResourceList{}
|
|
||||||
for _, item := range obj.(*v1alpha1.CustomResourceList).Items {
|
|
||||||
if label.Matches(labels.Set(item.Labels)) {
|
|
||||||
list.Items = append(list.Items, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested customResources.
|
|
||||||
func (c *FakeCustomResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewRootWatchAction(customresourcesResource, opts))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched customResource.
|
|
||||||
func (c *FakeCustomResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootPatchSubresourceAction(customresourcesResource, name, data, subresources...), &v1alpha1.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), err
|
|
||||||
}
|
|
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package fake
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
labels "k8s.io/apimachinery/pkg/labels"
|
||||||
|
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
|
testing "k8s.io/client-go/testing"
|
||||||
|
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface
|
||||||
|
type FakeCustomResourceDefinitions struct {
|
||||||
|
Fake *FakeApiextensionsV1alpha1
|
||||||
|
}
|
||||||
|
|
||||||
|
var customresourcedefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1alpha1", Resource: "customresourcedefinitions"}
|
||||||
|
|
||||||
|
var customresourcedefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1alpha1", Kind: "CustomResourceDefinition"}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Create(customResourceDefinition *v1alpha1.CustomResourceDefinition) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootCreateAction(customresourcedefinitionsResource, customResourceDefinition), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Update(customResourceDefinition *v1alpha1.CustomResourceDefinition) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootUpdateAction(customresourcedefinitionsResource, customResourceDefinition), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) UpdateStatus(customResourceDefinition *v1alpha1.CustomResourceDefinition) (*v1alpha1.CustomResourceDefinition, error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootUpdateSubresourceAction(customresourcedefinitionsResource, "status", customResourceDefinition), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error {
|
||||||
|
_, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootDeleteAction(customresourcedefinitionsResource, name), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||||
|
action := testing.NewRootDeleteCollectionAction(customresourcedefinitionsResource, listOptions)
|
||||||
|
|
||||||
|
_, err := c.Fake.Invokes(action, &v1alpha1.CustomResourceDefinitionList{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Get(name string, options v1.GetOptions) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootGetAction(customresourcedefinitionsResource, name), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) List(opts v1.ListOptions) (result *v1alpha1.CustomResourceDefinitionList, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootListAction(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), &v1alpha1.CustomResourceDefinitionList{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||||
|
if label == nil {
|
||||||
|
label = labels.Everything()
|
||||||
|
}
|
||||||
|
list := &v1alpha1.CustomResourceDefinitionList{}
|
||||||
|
for _, item := range obj.(*v1alpha1.CustomResourceDefinitionList).Items {
|
||||||
|
if label.Matches(labels.Set(item.Labels)) {
|
||||||
|
list.Items = append(list.Items, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested customResourceDefinitions.
|
||||||
|
func (c *FakeCustomResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||||
|
return c.Fake.
|
||||||
|
InvokesWatch(testing.NewRootWatchAction(customresourcedefinitionsResource, opts))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched customResourceDefinition.
|
||||||
|
func (c *FakeCustomResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootPatchSubresourceAction(customresourcedefinitionsResource, name, data, subresources...), &v1alpha1.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), err
|
||||||
|
}
|
@@ -16,4 +16,4 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
type CustomResourceExpansion interface{}
|
type CustomResourceDefinitionExpansion interface{}
|
||||||
|
@@ -11,7 +11,7 @@ go_library(
|
|||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"apiextensions_client.go",
|
"apiextensions_client.go",
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"generated_expansion.go",
|
"generated_expansion.go",
|
||||||
],
|
],
|
||||||
|
@@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
type ApiextensionsInterface interface {
|
type ApiextensionsInterface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() rest.Interface
|
||||||
CustomResourcesGetter
|
CustomResourceDefinitionsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiextensionsClient is used to interact with features provided by the apiextensions.k8s.io group.
|
// ApiextensionsClient is used to interact with features provided by the apiextensions.k8s.io group.
|
||||||
@@ -31,8 +31,8 @@ type ApiextensionsClient struct {
|
|||||||
restClient rest.Interface
|
restClient rest.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApiextensionsClient) CustomResources() CustomResourceInterface {
|
func (c *ApiextensionsClient) CustomResourceDefinitions() CustomResourceDefinitionInterface {
|
||||||
return newCustomResources(c)
|
return newCustomResourceDefinitions(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewForConfig creates a new ApiextensionsClient for the given config.
|
// NewForConfig creates a new ApiextensionsClient for the given config.
|
||||||
|
@@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
|
||||||
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/scheme"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CustomResourcesGetter has a method to return a CustomResourceInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type CustomResourcesGetter interface {
|
|
||||||
CustomResources() CustomResourceInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// CustomResourceInterface has methods to work with CustomResource resources.
|
|
||||||
type CustomResourceInterface interface {
|
|
||||||
Create(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
|
|
||||||
Update(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
|
|
||||||
UpdateStatus(*apiextensions.CustomResource) (*apiextensions.CustomResource, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string, options v1.GetOptions) (*apiextensions.CustomResource, error)
|
|
||||||
List(opts v1.ListOptions) (*apiextensions.CustomResourceList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error)
|
|
||||||
CustomResourceExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// customResources implements CustomResourceInterface
|
|
||||||
type customResources struct {
|
|
||||||
client rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
// newCustomResources returns a CustomResources
|
|
||||||
func newCustomResources(c *ApiextensionsClient) *customResources {
|
|
||||||
return &customResources{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a customResource and creates it. Returns the server's representation of the customResource, and an error, if there is any.
|
|
||||||
func (c *customResources) Create(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
|
|
||||||
result = &apiextensions.CustomResource{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Resource("customresources").
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a customResource and updates it. Returns the server's representation of the customResource, and an error, if there is any.
|
|
||||||
func (c *customResources) Update(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
|
|
||||||
result = &apiextensions.CustomResource{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(customResource.Name).
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateStatus was generated because the type contains a Status member.
|
|
||||||
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
|
|
||||||
|
|
||||||
func (c *customResources) UpdateStatus(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
|
|
||||||
result = &apiextensions.CustomResource{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(customResource.Name).
|
|
||||||
SubResource("status").
|
|
||||||
Body(customResource).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the customResource and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *customResources) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *customResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the customResource, and returns the corresponding customResource object, and an error if there is any.
|
|
||||||
func (c *customResources) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResource, err error) {
|
|
||||||
result = &apiextensions.CustomResource{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
Name(name).
|
|
||||||
VersionedParams(&options, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of CustomResources that match those selectors.
|
|
||||||
func (c *customResources) List(opts v1.ListOptions) (result *apiextensions.CustomResourceList, err error) {
|
|
||||||
result = &apiextensions.CustomResourceList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested customResources.
|
|
||||||
func (c *customResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
opts.Watch = true
|
|
||||||
return c.client.Get().
|
|
||||||
Resource("customresources").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched customResource.
|
|
||||||
func (c *customResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error) {
|
|
||||||
result = &apiextensions.CustomResource{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Resource("customresources").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
@@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package internalversion
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
|
rest "k8s.io/client-go/rest"
|
||||||
|
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
|
scheme "k8s.io/kube-apiextensions-server/pkg/client/clientset/internalclientset/scheme"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface.
|
||||||
|
// A group's client should implement this interface.
|
||||||
|
type CustomResourceDefinitionsGetter interface {
|
||||||
|
CustomResourceDefinitions() CustomResourceDefinitionInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomResourceDefinitionInterface has methods to work with CustomResourceDefinition resources.
|
||||||
|
type CustomResourceDefinitionInterface interface {
|
||||||
|
Create(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error)
|
||||||
|
Update(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error)
|
||||||
|
UpdateStatus(*apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error)
|
||||||
|
Delete(name string, options *v1.DeleteOptions) error
|
||||||
|
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||||
|
Get(name string, options v1.GetOptions) (*apiextensions.CustomResourceDefinition, error)
|
||||||
|
List(opts v1.ListOptions) (*apiextensions.CustomResourceDefinitionList, error)
|
||||||
|
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||||
|
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error)
|
||||||
|
CustomResourceDefinitionExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// customResourceDefinitions implements CustomResourceDefinitionInterface
|
||||||
|
type customResourceDefinitions struct {
|
||||||
|
client rest.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
// newCustomResourceDefinitions returns a CustomResourceDefinitions
|
||||||
|
func newCustomResourceDefinitions(c *ApiextensionsClient) *customResourceDefinitions {
|
||||||
|
return &customResourceDefinitions{
|
||||||
|
client: c.RESTClient(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create takes the representation of a customResourceDefinition and creates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any.
|
||||||
|
func (c *customResourceDefinitions) Create(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinition{}
|
||||||
|
err = c.client.Post().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update takes the representation of a customResourceDefinition and updates it. Returns the server's representation of the customResourceDefinition, and an error, if there is any.
|
||||||
|
func (c *customResourceDefinitions) Update(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinition{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(customResourceDefinition.Name).
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatus was generated because the type contains a Status member.
|
||||||
|
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
|
||||||
|
|
||||||
|
func (c *customResourceDefinitions) UpdateStatus(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinition{}
|
||||||
|
err = c.client.Put().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(customResourceDefinition.Name).
|
||||||
|
SubResource("status").
|
||||||
|
Body(customResourceDefinition).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete takes name of the customResourceDefinition and deletes it. Returns an error if one occurs.
|
||||||
|
func (c *customResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(name).
|
||||||
|
Body(options).
|
||||||
|
Do().
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteCollection deletes a collection of objects.
|
||||||
|
func (c *customResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||||
|
return c.client.Delete().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||||
|
Body(options).
|
||||||
|
Do().
|
||||||
|
Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get takes name of the customResourceDefinition, and returns the corresponding customResourceDefinition object, and an error if there is any.
|
||||||
|
func (c *customResourceDefinitions) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinition{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
Name(name).
|
||||||
|
VersionedParams(&options, scheme.ParameterCodec).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors.
|
||||||
|
func (c *customResourceDefinitions) List(opts v1.ListOptions) (result *apiextensions.CustomResourceDefinitionList, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinitionList{}
|
||||||
|
err = c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested customResourceDefinitions.
|
||||||
|
func (c *customResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||||
|
opts.Watch = true
|
||||||
|
return c.client.Get().
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
|
Watch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched customResourceDefinition.
|
||||||
|
func (c *customResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
result = &apiextensions.CustomResourceDefinition{}
|
||||||
|
err = c.client.Patch(pt).
|
||||||
|
Resource("customresourcedefinitions").
|
||||||
|
SubResource(subresources...).
|
||||||
|
Name(name).
|
||||||
|
Body(data).
|
||||||
|
Do().
|
||||||
|
Into(result)
|
||||||
|
return
|
||||||
|
}
|
@@ -12,7 +12,7 @@ go_library(
|
|||||||
srcs = [
|
srcs = [
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"fake_apiextensions_client.go",
|
"fake_apiextensions_client.go",
|
||||||
"fake_customresource.go",
|
"fake_customresourcedefinition.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
|
@@ -26,8 +26,8 @@ type FakeApiextensions struct {
|
|||||||
*testing.Fake
|
*testing.Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeApiextensions) CustomResources() internalversion.CustomResourceInterface {
|
func (c *FakeApiextensions) CustomResourceDefinitions() internalversion.CustomResourceDefinitionInterface {
|
||||||
return &FakeCustomResources{c}
|
return &FakeCustomResourceDefinitions{c}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
// RESTClient returns a RESTClient that is used to communicate
|
||||||
|
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
labels "k8s.io/apimachinery/pkg/labels"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakeCustomResources implements CustomResourceInterface
|
|
||||||
type FakeCustomResources struct {
|
|
||||||
Fake *FakeApiextensions
|
|
||||||
}
|
|
||||||
|
|
||||||
var customresourcesResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "", Resource: "customresources"}
|
|
||||||
|
|
||||||
var customresourcesKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "", Kind: "CustomResource"}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Create(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootCreateAction(customresourcesResource, customResource), &apiextensions.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Update(customResource *apiextensions.CustomResource) (result *apiextensions.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateAction(customresourcesResource, customResource), &apiextensions.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) UpdateStatus(customResource *apiextensions.CustomResource) (*apiextensions.CustomResource, error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateSubresourceAction(customresourcesResource, "status", customResource), &apiextensions.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootDeleteAction(customresourcesResource, name), &apiextensions.CustomResource{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewRootDeleteCollectionAction(customresourcesResource, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &apiextensions.CustomResourceList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootGetAction(customresourcesResource, name), &apiextensions.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeCustomResources) List(opts v1.ListOptions) (result *apiextensions.CustomResourceList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootListAction(customresourcesResource, customresourcesKind, opts), &apiextensions.CustomResourceList{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &apiextensions.CustomResourceList{}
|
|
||||||
for _, item := range obj.(*apiextensions.CustomResourceList).Items {
|
|
||||||
if label.Matches(labels.Set(item.Labels)) {
|
|
||||||
list.Items = append(list.Items, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested customResources.
|
|
||||||
func (c *FakeCustomResources) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewRootWatchAction(customresourcesResource, opts))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched customResource.
|
|
||||||
func (c *FakeCustomResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResource, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootPatchSubresourceAction(customresourcesResource, name, data, subresources...), &apiextensions.CustomResource{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), err
|
|
||||||
}
|
|
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package fake
|
||||||
|
|
||||||
|
import (
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
labels "k8s.io/apimachinery/pkg/labels"
|
||||||
|
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
|
watch "k8s.io/apimachinery/pkg/watch"
|
||||||
|
testing "k8s.io/client-go/testing"
|
||||||
|
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FakeCustomResourceDefinitions implements CustomResourceDefinitionInterface
|
||||||
|
type FakeCustomResourceDefinitions struct {
|
||||||
|
Fake *FakeApiextensions
|
||||||
|
}
|
||||||
|
|
||||||
|
var customresourcedefinitionsResource = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "", Resource: "customresourcedefinitions"}
|
||||||
|
|
||||||
|
var customresourcedefinitionsKind = schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "", Kind: "CustomResourceDefinition"}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Create(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootCreateAction(customresourcedefinitionsResource, customResourceDefinition), &apiextensions.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Update(customResourceDefinition *apiextensions.CustomResourceDefinition) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootUpdateAction(customresourcedefinitionsResource, customResourceDefinition), &apiextensions.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) UpdateStatus(customResourceDefinition *apiextensions.CustomResourceDefinition) (*apiextensions.CustomResourceDefinition, error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootUpdateSubresourceAction(customresourcedefinitionsResource, "status", customResourceDefinition), &apiextensions.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Delete(name string, options *v1.DeleteOptions) error {
|
||||||
|
_, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootDeleteAction(customresourcedefinitionsResource, name), &apiextensions.CustomResourceDefinition{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||||
|
action := testing.NewRootDeleteCollectionAction(customresourcedefinitionsResource, listOptions)
|
||||||
|
|
||||||
|
_, err := c.Fake.Invokes(action, &apiextensions.CustomResourceDefinitionList{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) Get(name string, options v1.GetOptions) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootGetAction(customresourcedefinitionsResource, name), &apiextensions.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FakeCustomResourceDefinitions) List(opts v1.ListOptions) (result *apiextensions.CustomResourceDefinitionList, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootListAction(customresourcedefinitionsResource, customresourcedefinitionsKind, opts), &apiextensions.CustomResourceDefinitionList{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||||
|
if label == nil {
|
||||||
|
label = labels.Everything()
|
||||||
|
}
|
||||||
|
list := &apiextensions.CustomResourceDefinitionList{}
|
||||||
|
for _, item := range obj.(*apiextensions.CustomResourceDefinitionList).Items {
|
||||||
|
if label.Matches(labels.Set(item.Labels)) {
|
||||||
|
list.Items = append(list.Items, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch returns a watch.Interface that watches the requested customResourceDefinitions.
|
||||||
|
func (c *FakeCustomResourceDefinitions) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||||
|
return c.Fake.
|
||||||
|
InvokesWatch(testing.NewRootWatchAction(customresourcedefinitionsResource, opts))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched customResourceDefinition.
|
||||||
|
func (c *FakeCustomResourceDefinitions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
obj, err := c.Fake.
|
||||||
|
Invokes(testing.NewRootPatchSubresourceAction(customresourcedefinitionsResource, name, data, subresources...), &apiextensions.CustomResourceDefinition{})
|
||||||
|
if obj == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), err
|
||||||
|
}
|
@@ -16,4 +16,4 @@ limitations under the License.
|
|||||||
|
|
||||||
package internalversion
|
package internalversion
|
||||||
|
|
||||||
type CustomResourceExpansion interface{}
|
type CustomResourceDefinitionExpansion interface{}
|
||||||
|
@@ -10,7 +10,7 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"interface.go",
|
"interface.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
@@ -30,28 +30,28 @@ import (
|
|||||||
time "time"
|
time "time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceInformer provides access to a shared informer and lister for
|
// CustomResourceDefinitionInformer provides access to a shared informer and lister for
|
||||||
// CustomResources.
|
// CustomResourceDefinitions.
|
||||||
type CustomResourceInformer interface {
|
type CustomResourceDefinitionInformer interface {
|
||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
Lister() v1alpha1.CustomResourceLister
|
Lister() v1alpha1.CustomResourceDefinitionLister
|
||||||
}
|
}
|
||||||
|
|
||||||
type customResourceInformer struct {
|
type customResourceDefinitionInformer struct {
|
||||||
factory internalinterfaces.SharedInformerFactory
|
factory internalinterfaces.SharedInformerFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCustomResourceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
func newCustomResourceDefinitionInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||||
return client.ApiextensionsV1alpha1().CustomResources().List(options)
|
return client.ApiextensionsV1alpha1().CustomResourceDefinitions().List(options)
|
||||||
},
|
},
|
||||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
return client.ApiextensionsV1alpha1().CustomResources().Watch(options)
|
return client.ApiextensionsV1alpha1().CustomResourceDefinitions().Watch(options)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&apiextensions_v1alpha1.CustomResource{},
|
&apiextensions_v1alpha1.CustomResourceDefinition{},
|
||||||
resyncPeriod,
|
resyncPeriod,
|
||||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||||
)
|
)
|
||||||
@@ -59,10 +59,10 @@ func newCustomResourceInformer(client clientset.Interface, resyncPeriod time.Dur
|
|||||||
return sharedIndexInformer
|
return sharedIndexInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *customResourceInformer) Informer() cache.SharedIndexInformer {
|
func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer {
|
||||||
return f.factory.InformerFor(&apiextensions_v1alpha1.CustomResource{}, newCustomResourceInformer)
|
return f.factory.InformerFor(&apiextensions_v1alpha1.CustomResourceDefinition{}, newCustomResourceDefinitionInformer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *customResourceInformer) Lister() v1alpha1.CustomResourceLister {
|
func (f *customResourceDefinitionInformer) Lister() v1alpha1.CustomResourceDefinitionLister {
|
||||||
return v1alpha1.NewCustomResourceLister(f.Informer().GetIndexer())
|
return v1alpha1.NewCustomResourceDefinitionLister(f.Informer().GetIndexer())
|
||||||
}
|
}
|
@@ -24,8 +24,8 @@ import (
|
|||||||
|
|
||||||
// Interface provides access to all the informers in this group version.
|
// Interface provides access to all the informers in this group version.
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
// CustomResources returns a CustomResourceInformer.
|
// CustomResourceDefinitions returns a CustomResourceDefinitionInformer.
|
||||||
CustomResources() CustomResourceInformer
|
CustomResourceDefinitions() CustomResourceDefinitionInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
type version struct {
|
type version struct {
|
||||||
@@ -37,7 +37,7 @@ func New(f internalinterfaces.SharedInformerFactory) Interface {
|
|||||||
return &version{f}
|
return &version{f}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResources returns a CustomResourceInformer.
|
// CustomResourceDefinitions returns a CustomResourceDefinitionInformer.
|
||||||
func (v *version) CustomResources() CustomResourceInformer {
|
func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer {
|
||||||
return &customResourceInformer{factory: v.SharedInformerFactory}
|
return &customResourceDefinitionInformer{factory: v.SharedInformerFactory}
|
||||||
}
|
}
|
||||||
|
@@ -52,8 +52,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
|
|||||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
||||||
switch resource {
|
switch resource {
|
||||||
// Group=Apiextensions, Version=V1alpha1
|
// Group=Apiextensions, Version=V1alpha1
|
||||||
case v1alpha1.SchemeGroupVersion.WithResource("customresources"):
|
case v1alpha1.SchemeGroupVersion.WithResource("customresourcedefinitions"):
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1alpha1().CustomResources().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().V1alpha1().CustomResourceDefinitions().Informer()}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"interface.go",
|
"interface.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
@@ -30,28 +30,28 @@ import (
|
|||||||
time "time"
|
time "time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomResourceInformer provides access to a shared informer and lister for
|
// CustomResourceDefinitionInformer provides access to a shared informer and lister for
|
||||||
// CustomResources.
|
// CustomResourceDefinitions.
|
||||||
type CustomResourceInformer interface {
|
type CustomResourceDefinitionInformer interface {
|
||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
Lister() internalversion.CustomResourceLister
|
Lister() internalversion.CustomResourceDefinitionLister
|
||||||
}
|
}
|
||||||
|
|
||||||
type customResourceInformer struct {
|
type customResourceDefinitionInformer struct {
|
||||||
factory internalinterfaces.SharedInformerFactory
|
factory internalinterfaces.SharedInformerFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCustomResourceInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
func newCustomResourceDefinitionInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||||
return client.Apiextensions().CustomResources().List(options)
|
return client.Apiextensions().CustomResourceDefinitions().List(options)
|
||||||
},
|
},
|
||||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||||
return client.Apiextensions().CustomResources().Watch(options)
|
return client.Apiextensions().CustomResourceDefinitions().Watch(options)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&apiextensions.CustomResource{},
|
&apiextensions.CustomResourceDefinition{},
|
||||||
resyncPeriod,
|
resyncPeriod,
|
||||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||||
)
|
)
|
||||||
@@ -59,10 +59,10 @@ func newCustomResourceInformer(client internalclientset.Interface, resyncPeriod
|
|||||||
return sharedIndexInformer
|
return sharedIndexInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *customResourceInformer) Informer() cache.SharedIndexInformer {
|
func (f *customResourceDefinitionInformer) Informer() cache.SharedIndexInformer {
|
||||||
return f.factory.InformerFor(&apiextensions.CustomResource{}, newCustomResourceInformer)
|
return f.factory.InformerFor(&apiextensions.CustomResourceDefinition{}, newCustomResourceDefinitionInformer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *customResourceInformer) Lister() internalversion.CustomResourceLister {
|
func (f *customResourceDefinitionInformer) Lister() internalversion.CustomResourceDefinitionLister {
|
||||||
return internalversion.NewCustomResourceLister(f.Informer().GetIndexer())
|
return internalversion.NewCustomResourceDefinitionLister(f.Informer().GetIndexer())
|
||||||
}
|
}
|
@@ -24,8 +24,8 @@ import (
|
|||||||
|
|
||||||
// Interface provides access to all the informers in this group version.
|
// Interface provides access to all the informers in this group version.
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
// CustomResources returns a CustomResourceInformer.
|
// CustomResourceDefinitions returns a CustomResourceDefinitionInformer.
|
||||||
CustomResources() CustomResourceInformer
|
CustomResourceDefinitions() CustomResourceDefinitionInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
type version struct {
|
type version struct {
|
||||||
@@ -37,7 +37,7 @@ func New(f internalinterfaces.SharedInformerFactory) Interface {
|
|||||||
return &version{f}
|
return &version{f}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResources returns a CustomResourceInformer.
|
// CustomResourceDefinitions returns a CustomResourceDefinitionInformer.
|
||||||
func (v *version) CustomResources() CustomResourceInformer {
|
func (v *version) CustomResourceDefinitions() CustomResourceDefinitionInformer {
|
||||||
return &customResourceInformer{factory: v.SharedInformerFactory}
|
return &customResourceDefinitionInformer{factory: v.SharedInformerFactory}
|
||||||
}
|
}
|
||||||
|
@@ -52,8 +52,8 @@ func (f *genericInformer) Lister() cache.GenericLister {
|
|||||||
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
|
||||||
switch resource {
|
switch resource {
|
||||||
// Group=Apiextensions, Version=InternalVersion
|
// Group=Apiextensions, Version=InternalVersion
|
||||||
case apiextensions.SchemeGroupVersion.WithResource("customresources"):
|
case apiextensions.SchemeGroupVersion.WithResource("customresourcedefinitions"):
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().InternalVersion().CustomResources().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Apiextensions().InternalVersion().CustomResourceDefinitions().Informer()}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"expansion_generated.go",
|
"expansion_generated.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This file was automatically generated by lister-gen
|
|
||||||
|
|
||||||
package internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
|
||||||
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CustomResourceLister helps list CustomResources.
|
|
||||||
type CustomResourceLister interface {
|
|
||||||
// List lists all CustomResources in the indexer.
|
|
||||||
List(selector labels.Selector) (ret []*apiextensions.CustomResource, err error)
|
|
||||||
// Get retrieves the CustomResource from the index for a given name.
|
|
||||||
Get(name string) (*apiextensions.CustomResource, error)
|
|
||||||
CustomResourceListerExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// customResourceLister implements the CustomResourceLister interface.
|
|
||||||
type customResourceLister struct {
|
|
||||||
indexer cache.Indexer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCustomResourceLister returns a new CustomResourceLister.
|
|
||||||
func NewCustomResourceLister(indexer cache.Indexer) CustomResourceLister {
|
|
||||||
return &customResourceLister{indexer: indexer}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List lists all CustomResources in the indexer.
|
|
||||||
func (s *customResourceLister) List(selector labels.Selector) (ret []*apiextensions.CustomResource, err error) {
|
|
||||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
|
||||||
ret = append(ret, m.(*apiextensions.CustomResource))
|
|
||||||
})
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the CustomResource from the index for a given name.
|
|
||||||
func (s *customResourceLister) Get(name string) (*apiextensions.CustomResource, error) {
|
|
||||||
key := &apiextensions.CustomResource{ObjectMeta: v1.ObjectMeta{Name: name}}
|
|
||||||
obj, exists, err := s.indexer.Get(key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
return nil, errors.NewNotFound(apiextensions.Resource("customresource"), name)
|
|
||||||
}
|
|
||||||
return obj.(*apiextensions.CustomResource), nil
|
|
||||||
}
|
|
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This file was automatically generated by lister-gen
|
||||||
|
|
||||||
|
package internalversion
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/client-go/tools/cache"
|
||||||
|
apiextensions "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomResourceDefinitionLister helps list CustomResourceDefinitions.
|
||||||
|
type CustomResourceDefinitionLister interface {
|
||||||
|
// List lists all CustomResourceDefinitions in the indexer.
|
||||||
|
List(selector labels.Selector) (ret []*apiextensions.CustomResourceDefinition, err error)
|
||||||
|
// Get retrieves the CustomResourceDefinition from the index for a given name.
|
||||||
|
Get(name string) (*apiextensions.CustomResourceDefinition, error)
|
||||||
|
CustomResourceDefinitionListerExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// customResourceDefinitionLister implements the CustomResourceDefinitionLister interface.
|
||||||
|
type customResourceDefinitionLister struct {
|
||||||
|
indexer cache.Indexer
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister.
|
||||||
|
func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister {
|
||||||
|
return &customResourceDefinitionLister{indexer: indexer}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all CustomResourceDefinitions in the indexer.
|
||||||
|
func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*apiextensions.CustomResourceDefinition, err error) {
|
||||||
|
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||||
|
ret = append(ret, m.(*apiextensions.CustomResourceDefinition))
|
||||||
|
})
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves the CustomResourceDefinition from the index for a given name.
|
||||||
|
func (s *customResourceDefinitionLister) Get(name string) (*apiextensions.CustomResourceDefinition, error) {
|
||||||
|
key := &apiextensions.CustomResourceDefinition{ObjectMeta: v1.ObjectMeta{Name: name}}
|
||||||
|
obj, exists, err := s.indexer.Get(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
return nil, errors.NewNotFound(apiextensions.Resource("customresourcedefinition"), name)
|
||||||
|
}
|
||||||
|
return obj.(*apiextensions.CustomResourceDefinition), nil
|
||||||
|
}
|
@@ -18,6 +18,6 @@ limitations under the License.
|
|||||||
|
|
||||||
package internalversion
|
package internalversion
|
||||||
|
|
||||||
// CustomResourceListerExpansion allows custom methods to be added to
|
// CustomResourceDefinitionListerExpansion allows custom methods to be added to
|
||||||
// CustomResourceLister.
|
// CustomResourceDefinitionLister.
|
||||||
type CustomResourceListerExpansion interface{}
|
type CustomResourceDefinitionListerExpansion interface{}
|
||||||
|
@@ -10,7 +10,7 @@ load(
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = [
|
||||||
"customresource.go",
|
"customresourcedefinition.go",
|
||||||
"expansion_generated.go",
|
"expansion_generated.go",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This file was automatically generated by lister-gen
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
|
||||||
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CustomResourceLister helps list CustomResources.
|
|
||||||
type CustomResourceLister interface {
|
|
||||||
// List lists all CustomResources in the indexer.
|
|
||||||
List(selector labels.Selector) (ret []*v1alpha1.CustomResource, err error)
|
|
||||||
// Get retrieves the CustomResource from the index for a given name.
|
|
||||||
Get(name string) (*v1alpha1.CustomResource, error)
|
|
||||||
CustomResourceListerExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// customResourceLister implements the CustomResourceLister interface.
|
|
||||||
type customResourceLister struct {
|
|
||||||
indexer cache.Indexer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCustomResourceLister returns a new CustomResourceLister.
|
|
||||||
func NewCustomResourceLister(indexer cache.Indexer) CustomResourceLister {
|
|
||||||
return &customResourceLister{indexer: indexer}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List lists all CustomResources in the indexer.
|
|
||||||
func (s *customResourceLister) List(selector labels.Selector) (ret []*v1alpha1.CustomResource, err error) {
|
|
||||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
|
||||||
ret = append(ret, m.(*v1alpha1.CustomResource))
|
|
||||||
})
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the CustomResource from the index for a given name.
|
|
||||||
func (s *customResourceLister) Get(name string) (*v1alpha1.CustomResource, error) {
|
|
||||||
key := &v1alpha1.CustomResource{ObjectMeta: v1.ObjectMeta{Name: name}}
|
|
||||||
obj, exists, err := s.indexer.Get(key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
return nil, errors.NewNotFound(v1alpha1.Resource("customresource"), name)
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.CustomResource), nil
|
|
||||||
}
|
|
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This file was automatically generated by lister-gen
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/client-go/tools/cache"
|
||||||
|
v1alpha1 "k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomResourceDefinitionLister helps list CustomResourceDefinitions.
|
||||||
|
type CustomResourceDefinitionLister interface {
|
||||||
|
// List lists all CustomResourceDefinitions in the indexer.
|
||||||
|
List(selector labels.Selector) (ret []*v1alpha1.CustomResourceDefinition, err error)
|
||||||
|
// Get retrieves the CustomResourceDefinition from the index for a given name.
|
||||||
|
Get(name string) (*v1alpha1.CustomResourceDefinition, error)
|
||||||
|
CustomResourceDefinitionListerExpansion
|
||||||
|
}
|
||||||
|
|
||||||
|
// customResourceDefinitionLister implements the CustomResourceDefinitionLister interface.
|
||||||
|
type customResourceDefinitionLister struct {
|
||||||
|
indexer cache.Indexer
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCustomResourceDefinitionLister returns a new CustomResourceDefinitionLister.
|
||||||
|
func NewCustomResourceDefinitionLister(indexer cache.Indexer) CustomResourceDefinitionLister {
|
||||||
|
return &customResourceDefinitionLister{indexer: indexer}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all CustomResourceDefinitions in the indexer.
|
||||||
|
func (s *customResourceDefinitionLister) List(selector labels.Selector) (ret []*v1alpha1.CustomResourceDefinition, err error) {
|
||||||
|
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||||
|
ret = append(ret, m.(*v1alpha1.CustomResourceDefinition))
|
||||||
|
})
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves the CustomResourceDefinition from the index for a given name.
|
||||||
|
func (s *customResourceDefinitionLister) Get(name string) (*v1alpha1.CustomResourceDefinition, error) {
|
||||||
|
key := &v1alpha1.CustomResourceDefinition{ObjectMeta: v1.ObjectMeta{Name: name}}
|
||||||
|
obj, exists, err := s.indexer.Get(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
return nil, errors.NewNotFound(v1alpha1.Resource("customresourcedefinition"), name)
|
||||||
|
}
|
||||||
|
return obj.(*v1alpha1.CustomResourceDefinition), nil
|
||||||
|
}
|
@@ -18,6 +18,6 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1alpha1
|
package v1alpha1
|
||||||
|
|
||||||
// CustomResourceListerExpansion allows custom methods to be added to
|
// CustomResourceDefinitionListerExpansion allows custom methods to be added to
|
||||||
// CustomResourceLister.
|
// CustomResourceDefinitionLister.
|
||||||
type CustomResourceListerExpansion interface{}
|
type CustomResourceDefinitionListerExpansion interface{}
|
||||||
|
@@ -32,15 +32,15 @@ import (
|
|||||||
|
|
||||||
const defaultEtcdPathPrefix = "/registry/apiextensions.kubernetes.io"
|
const defaultEtcdPathPrefix = "/registry/apiextensions.kubernetes.io"
|
||||||
|
|
||||||
type CustomResourcesServerOptions struct {
|
type CustomResourceDefinitionsServerOptions struct {
|
||||||
RecommendedOptions *genericoptions.RecommendedOptions
|
RecommendedOptions *genericoptions.RecommendedOptions
|
||||||
|
|
||||||
StdOut io.Writer
|
StdOut io.Writer
|
||||||
StdErr io.Writer
|
StdErr io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCustomResourcesServerOptions(out, errOut io.Writer) *CustomResourcesServerOptions {
|
func NewCustomResourceDefinitionsServerOptions(out, errOut io.Writer) *CustomResourceDefinitionsServerOptions {
|
||||||
o := &CustomResourcesServerOptions{
|
o := &CustomResourceDefinitionsServerOptions{
|
||||||
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, apiserver.Scheme, apiserver.Codecs.LegacyCodec(v1alpha1.SchemeGroupVersion)),
|
RecommendedOptions: genericoptions.NewRecommendedOptions(defaultEtcdPathPrefix, apiserver.Scheme, apiserver.Codecs.LegacyCodec(v1alpha1.SchemeGroupVersion)),
|
||||||
|
|
||||||
StdOut: out,
|
StdOut: out,
|
||||||
@@ -50,8 +50,8 @@ func NewCustomResourcesServerOptions(out, errOut io.Writer) *CustomResourcesServ
|
|||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommandStartCustomResourcesServer(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
|
func NewCommandStartCustomResourceDefinitionsServer(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
|
||||||
o := NewCustomResourcesServerOptions(out, errOut)
|
o := NewCustomResourceDefinitionsServerOptions(out, errOut)
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Short: "Launch an API extensions API server",
|
Short: "Launch an API extensions API server",
|
||||||
@@ -63,7 +63,7 @@ func NewCommandStartCustomResourcesServer(out, errOut io.Writer, stopCh <-chan s
|
|||||||
if err := o.Validate(args); err != nil {
|
if err := o.Validate(args); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := o.RunCustomResourcesServer(stopCh); err != nil {
|
if err := o.RunCustomResourceDefinitionsServer(stopCh); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -76,15 +76,15 @@ func NewCommandStartCustomResourcesServer(out, errOut io.Writer, stopCh <-chan s
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o CustomResourcesServerOptions) Validate(args []string) error {
|
func (o CustomResourceDefinitionsServerOptions) Validate(args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CustomResourcesServerOptions) Complete() error {
|
func (o *CustomResourceDefinitionsServerOptions) Complete() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o CustomResourcesServerOptions) Config() (*apiserver.Config, error) {
|
func (o CustomResourceDefinitionsServerOptions) Config() (*apiserver.Config, error) {
|
||||||
// TODO have a "real" external address
|
// TODO have a "real" external address
|
||||||
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
|
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
|
||||||
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
|
return nil, fmt.Errorf("error creating self-signed certificates: %v", err)
|
||||||
@@ -95,7 +95,7 @@ func (o CustomResourcesServerOptions) Config() (*apiserver.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
customResourceRESTOptionsGetter := apiserver.CustomResourceRESTOptionsGetter{
|
customResourceDefinitionRESTOptionsGetter := apiserver.CustomResourceDefinitionRESTOptionsGetter{
|
||||||
StorageConfig: o.RecommendedOptions.Etcd.StorageConfig,
|
StorageConfig: o.RecommendedOptions.Etcd.StorageConfig,
|
||||||
StoragePrefix: o.RecommendedOptions.Etcd.StorageConfig.Prefix,
|
StoragePrefix: o.RecommendedOptions.Etcd.StorageConfig.Prefix,
|
||||||
EnableWatchCache: o.RecommendedOptions.Etcd.EnableWatchCache,
|
EnableWatchCache: o.RecommendedOptions.Etcd.EnableWatchCache,
|
||||||
@@ -103,17 +103,17 @@ func (o CustomResourcesServerOptions) Config() (*apiserver.Config, error) {
|
|||||||
EnableGarbageCollection: o.RecommendedOptions.Etcd.EnableGarbageCollection,
|
EnableGarbageCollection: o.RecommendedOptions.Etcd.EnableGarbageCollection,
|
||||||
DeleteCollectionWorkers: o.RecommendedOptions.Etcd.DeleteCollectionWorkers,
|
DeleteCollectionWorkers: o.RecommendedOptions.Etcd.DeleteCollectionWorkers,
|
||||||
}
|
}
|
||||||
customResourceRESTOptionsGetter.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
|
customResourceDefinitionRESTOptionsGetter.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
|
||||||
customResourceRESTOptionsGetter.StorageConfig.Copier = apiserver.UnstructuredCopier{}
|
customResourceDefinitionRESTOptionsGetter.StorageConfig.Copier = apiserver.UnstructuredCopier{}
|
||||||
|
|
||||||
config := &apiserver.Config{
|
config := &apiserver.Config{
|
||||||
GenericConfig: serverConfig,
|
GenericConfig: serverConfig,
|
||||||
CustomResourceRESTOptionsGetter: customResourceRESTOptionsGetter,
|
CustomResourceDefinitionRESTOptionsGetter: customResourceDefinitionRESTOptionsGetter,
|
||||||
}
|
}
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o CustomResourcesServerOptions) RunCustomResourcesServer(stopCh <-chan struct{}) error {
|
func (o CustomResourceDefinitionsServerOptions) RunCustomResourceDefinitionsServer(stopCh <-chan struct{}) error {
|
||||||
config, err := o.Config()
|
config, err := o.Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@@ -15,16 +15,19 @@ go_library(
|
|||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/api/validation:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
|
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
|
|
||||||
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/validation:go_default_library",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -17,10 +17,12 @@ limitations under the License.
|
|||||||
package customresource
|
package customresource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// rest implements a RESTStorage for API services against etcd
|
// rest implements a RESTStorage for API services against etcd
|
||||||
@@ -29,24 +31,31 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against API services.
|
// NewREST returns a RESTStorage object that will work against API services.
|
||||||
func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST {
|
func NewREST(resource schema.GroupResource, listKind schema.GroupVersionKind, copier runtime.ObjectCopier, strategy CustomResourceDefinitionStorageStrategy, optsGetter generic.RESTOptionsGetter) *REST {
|
||||||
strategy := NewStrategy(scheme)
|
|
||||||
|
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
Copier: scheme,
|
Copier: copier,
|
||||||
NewFunc: func() runtime.Object { return &apiextensions.CustomResource{} },
|
NewFunc: func() runtime.Object { return &unstructured.Unstructured{} },
|
||||||
NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceList{} },
|
NewListFunc: func() runtime.Object {
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
// lists are never stored, only manufactured, so stomp in the right kind
|
||||||
return obj.(*apiextensions.CustomResource).Name, nil
|
ret := &unstructured.UnstructuredList{}
|
||||||
|
ret.SetGroupVersionKind(listKind)
|
||||||
|
return ret
|
||||||
},
|
},
|
||||||
PredicateFunc: MatchCustomResource,
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
QualifiedResource: apiextensions.Resource("customresources"),
|
accessor, err := meta.Accessor(obj)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return accessor.GetName(), nil
|
||||||
|
},
|
||||||
|
PredicateFunc: strategy.MatchCustomResourceDefinitionStorage,
|
||||||
|
QualifiedResource: resource,
|
||||||
|
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
DeleteStrategy: strategy,
|
DeleteStrategy: strategy,
|
||||||
}
|
}
|
||||||
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs}
|
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: strategy.GetAttrs}
|
||||||
if err := store.CompleteWithOptions(options); err != nil {
|
if err := store.CompleteWithOptions(options); err != nil {
|
||||||
panic(err) // TODO: Propagate error up
|
panic(err) // TODO: Propagate error up
|
||||||
}
|
}
|
||||||
|
@@ -17,78 +17,99 @@ limitations under the License.
|
|||||||
package customresource
|
package customresource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
"k8s.io/apimachinery/pkg/api/validation"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
|
|
||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
|
||||||
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/validation"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type apiServerStrategy struct {
|
type CustomResourceDefinitionStorageStrategy struct {
|
||||||
runtime.ObjectTyper
|
runtime.ObjectTyper
|
||||||
names.NameGenerator
|
names.NameGenerator
|
||||||
|
|
||||||
|
namespaceScoped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStrategy(typer runtime.ObjectTyper) apiServerStrategy {
|
func NewStrategy(typer runtime.ObjectTyper, namespaceScoped bool) CustomResourceDefinitionStorageStrategy {
|
||||||
return apiServerStrategy{typer, names.SimpleNameGenerator}
|
return CustomResourceDefinitionStorageStrategy{typer, names.SimpleNameGenerator, namespaceScoped}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiServerStrategy) NamespaceScoped() bool {
|
func (a CustomResourceDefinitionStorageStrategy) NamespaceScoped() bool {
|
||||||
return false
|
return a.namespaceScoped
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
func (CustomResourceDefinitionStorageStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiServerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
func (CustomResourceDefinitionStorageStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (apiServerStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
|
func (a CustomResourceDefinitionStorageStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
|
||||||
return validation.ValidateCustomResource(obj.(*apiextensions.CustomResource))
|
accessor, err := meta.Accessor(obj)
|
||||||
}
|
if err != nil {
|
||||||
|
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
||||||
func (apiServerStrategy) AllowCreateOnUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (apiServerStrategy) AllowUnconditionalUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (apiServerStrategy) Canonicalize(obj runtime.Object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (apiServerStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
|
|
||||||
return validation.ValidateCustomResourceUpdate(obj.(*apiextensions.CustomResource), old.(*apiextensions.CustomResource))
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
|
||||||
apiserver, ok := obj.(*apiextensions.CustomResource)
|
|
||||||
if !ok {
|
|
||||||
return nil, nil, fmt.Errorf("given object is not a CustomResource.")
|
|
||||||
}
|
}
|
||||||
return labels.Set(apiserver.ObjectMeta.Labels), CustomResourceToSelectableFields(apiserver), nil
|
|
||||||
|
return validation.ValidateObjectMetaAccessor(accessor, a.namespaceScoped, validation.NameIsDNSSubdomain, field.NewPath("metadata"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchCustomResource is the filter used by the generic etcd backend to watch events
|
func (CustomResourceDefinitionStorageStrategy) AllowCreateOnUpdate() bool {
|
||||||
// from etcd to clients of the apiserver only interested in specific labels/fields.
|
return false
|
||||||
func MatchCustomResource(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
}
|
||||||
|
|
||||||
|
func (CustomResourceDefinitionStorageStrategy) AllowUnconditionalUpdate() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (CustomResourceDefinitionStorageStrategy) Canonicalize(obj runtime.Object) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (CustomResourceDefinitionStorageStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
|
objAccessor, err := meta.Accessor(obj)
|
||||||
|
if err != nil {
|
||||||
|
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
||||||
|
}
|
||||||
|
oldAccessor, err := meta.Accessor(old)
|
||||||
|
if err != nil {
|
||||||
|
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
||||||
|
}
|
||||||
|
|
||||||
|
return validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata"))
|
||||||
|
|
||||||
|
return field.ErrorList{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a CustomResourceDefinitionStorageStrategy) GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
|
accessor, err := meta.Accessor(obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return labels.Set(accessor.GetLabels()), objectMetaFieldsSet(accessor, a.namespaceScoped), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// objectMetaFieldsSet returns a fields that represent the ObjectMeta.
|
||||||
|
func objectMetaFieldsSet(objectMeta metav1.Object, namespaceScoped bool) fields.Set {
|
||||||
|
if namespaceScoped {
|
||||||
|
return fields.Set{
|
||||||
|
"metadata.name": objectMeta.GetName(),
|
||||||
|
"metadata.namespace": objectMeta.GetNamespace(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fields.Set{
|
||||||
|
"metadata.name": objectMeta.GetName(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a CustomResourceDefinitionStorageStrategy) MatchCustomResourceDefinitionStorage(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
||||||
return storage.SelectionPredicate{
|
return storage.SelectionPredicate{
|
||||||
Label: label,
|
Label: label,
|
||||||
Field: field,
|
Field: field,
|
||||||
GetAttrs: GetAttrs,
|
GetAttrs: a.GetAttrs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomResourceToSelectableFields returns a field set that represents the object.
|
|
||||||
func CustomResourceToSelectableFields(obj *apiextensions.CustomResource) fields.Set {
|
|
||||||
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
|
|
||||||
}
|
|
||||||
|
@@ -15,19 +15,16 @@ go_library(
|
|||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/validation:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
||||||
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions:go_default_library",
|
||||||
|
"//vendor/k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/validation:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
@@ -14,15 +14,13 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package customresourcestorage
|
package customresourcedefinition
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// rest implements a RESTStorage for API services against etcd
|
// rest implements a RESTStorage for API services against etcd
|
||||||
@@ -31,31 +29,24 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against API services.
|
// NewREST returns a RESTStorage object that will work against API services.
|
||||||
func NewREST(resource schema.GroupResource, listKind schema.GroupVersionKind, copier runtime.ObjectCopier, strategy CustomResourceStorageStrategy, optsGetter generic.RESTOptionsGetter) *REST {
|
func NewREST(scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) *REST {
|
||||||
|
strategy := NewStrategy(scheme)
|
||||||
|
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
Copier: copier,
|
Copier: scheme,
|
||||||
NewFunc: func() runtime.Object { return &unstructured.Unstructured{} },
|
NewFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinition{} },
|
||||||
NewListFunc: func() runtime.Object {
|
NewListFunc: func() runtime.Object { return &apiextensions.CustomResourceDefinitionList{} },
|
||||||
// lists are never stored, only manufactured, so stomp in the right kind
|
|
||||||
ret := &unstructured.UnstructuredList{}
|
|
||||||
ret.SetGroupVersionKind(listKind)
|
|
||||||
return ret
|
|
||||||
},
|
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||||
accessor, err := meta.Accessor(obj)
|
return obj.(*apiextensions.CustomResourceDefinition).Name, nil
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return accessor.GetName(), nil
|
|
||||||
},
|
},
|
||||||
PredicateFunc: strategy.MatchCustomResourceStorage,
|
PredicateFunc: MatchCustomResourceDefinition,
|
||||||
QualifiedResource: resource,
|
QualifiedResource: apiextensions.Resource("customresourcedefinitions"),
|
||||||
|
|
||||||
CreateStrategy: strategy,
|
CreateStrategy: strategy,
|
||||||
UpdateStrategy: strategy,
|
UpdateStrategy: strategy,
|
||||||
DeleteStrategy: strategy,
|
DeleteStrategy: strategy,
|
||||||
}
|
}
|
||||||
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: strategy.GetAttrs}
|
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: GetAttrs}
|
||||||
if err := store.CompleteWithOptions(options); err != nil {
|
if err := store.CompleteWithOptions(options); err != nil {
|
||||||
panic(err) // TODO: Propagate error up
|
panic(err) // TODO: Propagate error up
|
||||||
}
|
}
|
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package customresourcedefinition
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
|
"k8s.io/apiserver/pkg/storage"
|
||||||
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
|
|
||||||
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions"
|
||||||
|
"k8s.io/kube-apiextensions-server/pkg/apis/apiextensions/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
type apiServerStrategy struct {
|
||||||
|
runtime.ObjectTyper
|
||||||
|
names.NameGenerator
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewStrategy(typer runtime.ObjectTyper) apiServerStrategy {
|
||||||
|
return apiServerStrategy{typer, names.SimpleNameGenerator}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) NamespaceScoped() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
|
||||||
|
return validation.ValidateCustomResourceDefinition(obj.(*apiextensions.CustomResourceDefinition))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) AllowCreateOnUpdate() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) AllowUnconditionalUpdate() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) Canonicalize(obj runtime.Object) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (apiServerStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
|
return validation.ValidateCustomResourceDefinitionUpdate(obj.(*apiextensions.CustomResourceDefinition), old.(*apiextensions.CustomResourceDefinition))
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
|
apiserver, ok := obj.(*apiextensions.CustomResourceDefinition)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, fmt.Errorf("given object is not a CustomResourceDefinition.")
|
||||||
|
}
|
||||||
|
return labels.Set(apiserver.ObjectMeta.Labels), CustomResourceDefinitionToSelectableFields(apiserver), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MatchCustomResourceDefinition is the filter used by the generic etcd backend to watch events
|
||||||
|
// from etcd to clients of the apiserver only interested in specific labels/fields.
|
||||||
|
func MatchCustomResourceDefinition(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
||||||
|
return storage.SelectionPredicate{
|
||||||
|
Label: label,
|
||||||
|
Field: field,
|
||||||
|
GetAttrs: GetAttrs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomResourceDefinitionToSelectableFields returns a field set that represents the object.
|
||||||
|
func CustomResourceDefinitionToSelectableFields(obj *apiextensions.CustomResourceDefinition) fields.Set {
|
||||||
|
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
|
||||||
|
}
|
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package customresourcestorage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
|
||||||
"k8s.io/apimachinery/pkg/api/validation"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
|
||||||
"k8s.io/apiserver/pkg/storage"
|
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CustomResourceStorageStrategy struct {
|
|
||||||
runtime.ObjectTyper
|
|
||||||
names.NameGenerator
|
|
||||||
|
|
||||||
namespaceScoped bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewStrategy(typer runtime.ObjectTyper, namespaceScoped bool) CustomResourceStorageStrategy {
|
|
||||||
return CustomResourceStorageStrategy{typer, names.SimpleNameGenerator, namespaceScoped}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a CustomResourceStorageStrategy) NamespaceScoped() bool {
|
|
||||||
return a.namespaceScoped
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a CustomResourceStorageStrategy) Validate(ctx genericapirequest.Context, obj runtime.Object) field.ErrorList {
|
|
||||||
accessor, err := meta.Accessor(obj)
|
|
||||||
if err != nil {
|
|
||||||
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
|
||||||
}
|
|
||||||
|
|
||||||
return validation.ValidateObjectMetaAccessor(accessor, a.namespaceScoped, validation.NameIsDNSSubdomain, field.NewPath("metadata"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) AllowCreateOnUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) AllowUnconditionalUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) Canonicalize(obj runtime.Object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (CustomResourceStorageStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
|
|
||||||
objAccessor, err := meta.Accessor(obj)
|
|
||||||
if err != nil {
|
|
||||||
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
|
||||||
}
|
|
||||||
oldAccessor, err := meta.Accessor(old)
|
|
||||||
if err != nil {
|
|
||||||
return field.ErrorList{field.Invalid(field.NewPath("metadata"), nil, err.Error())}
|
|
||||||
}
|
|
||||||
|
|
||||||
return validation.ValidateObjectMetaAccessorUpdate(objAccessor, oldAccessor, field.NewPath("metadata"))
|
|
||||||
|
|
||||||
return field.ErrorList{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a CustomResourceStorageStrategy) GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
|
||||||
accessor, err := meta.Accessor(obj)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
return labels.Set(accessor.GetLabels()), objectMetaFieldsSet(accessor, a.namespaceScoped), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// objectMetaFieldsSet returns a fields that represent the ObjectMeta.
|
|
||||||
func objectMetaFieldsSet(objectMeta metav1.Object, namespaceScoped bool) fields.Set {
|
|
||||||
if namespaceScoped {
|
|
||||||
return fields.Set{
|
|
||||||
"metadata.name": objectMeta.GetName(),
|
|
||||||
"metadata.namespace": objectMeta.GetNamespace(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fields.Set{
|
|
||||||
"metadata.name": objectMeta.GetName(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a CustomResourceStorageStrategy) MatchCustomResourceStorage(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
|
||||||
return storage.SelectionPredicate{
|
|
||||||
Label: label,
|
|
||||||
Field: field,
|
|
||||||
GetAttrs: a.GetAttrs,
|
|
||||||
}
|
|
||||||
}
|
|
@@ -30,7 +30,7 @@ import (
|
|||||||
"k8s.io/kube-apiextensions-server/test/integration/testserver"
|
"k8s.io/kube-apiextensions-server/test/integration/testserver"
|
||||||
)
|
)
|
||||||
|
|
||||||
func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unstructured, client *dynamic.ResourceClient, definition *apiextensionsv1alpha1.CustomResource) (*unstructured.Unstructured, error) {
|
func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unstructured, client *dynamic.ResourceClient, definition *apiextensionsv1alpha1.CustomResourceDefinition) (*unstructured.Unstructured, error) {
|
||||||
createdInstance, err := client.Create(instanceToCreate)
|
createdInstance, err := client.Create(instanceToCreate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("%#v", createdInstance)
|
t.Logf("%#v", createdInstance)
|
||||||
@@ -57,7 +57,7 @@ func instantiateCustomResource(t *testing.T, instanceToCreate *unstructured.Unst
|
|||||||
return createdInstance, nil
|
return createdInstance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNamespacedCustomResourceClient(ns string, client *dynamic.Client, definition *apiextensionsv1alpha1.CustomResource) *dynamic.ResourceClient {
|
func NewNamespacedCustomResourceClient(ns string, client *dynamic.Client, definition *apiextensionsv1alpha1.CustomResourceDefinition) *dynamic.ResourceClient {
|
||||||
return client.Resource(&metav1.APIResource{
|
return client.Resource(&metav1.APIResource{
|
||||||
Name: definition.Spec.Names.Plural,
|
Name: definition.Spec.Names.Plural,
|
||||||
Namespaced: definition.Spec.Scope == apiextensionsv1alpha1.NamespaceScoped,
|
Namespaced: definition.Spec.Scope == apiextensionsv1alpha1.NamespaceScoped,
|
||||||
|
@@ -28,13 +28,13 @@ import (
|
|||||||
"k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
|
"k8s.io/kube-apiextensions-server/pkg/client/clientset/clientset"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewNoxuCustomResourceDefinition() *apiextensionsv1alpha1.CustomResource {
|
func NewNoxuCustomResourceDefinition() *apiextensionsv1alpha1.CustomResourceDefinition {
|
||||||
return &apiextensionsv1alpha1.CustomResource{
|
return &apiextensionsv1alpha1.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"},
|
ObjectMeta: metav1.ObjectMeta{Name: "noxus.mygroup.example.com"},
|
||||||
Spec: apiextensionsv1alpha1.CustomResourceSpec{
|
Spec: apiextensionsv1alpha1.CustomResourceDefinitionSpec{
|
||||||
Group: "mygroup.example.com",
|
Group: "mygroup.example.com",
|
||||||
Version: "v1alpha1",
|
Version: "v1alpha1",
|
||||||
Names: apiextensionsv1alpha1.CustomResourceNames{
|
Names: apiextensionsv1alpha1.CustomResourceDefinitionNames{
|
||||||
Plural: "noxus",
|
Plural: "noxus",
|
||||||
Singular: "nonenglishnoxu",
|
Singular: "nonenglishnoxu",
|
||||||
Kind: "WishIHadChosenNoxu",
|
Kind: "WishIHadChosenNoxu",
|
||||||
@@ -61,13 +61,13 @@ func NewNoxuInstance(namespace, name string) *unstructured.Unstructured {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCurletCustomResourceDefinition() *apiextensionsv1alpha1.CustomResource {
|
func NewCurletCustomResourceDefinition() *apiextensionsv1alpha1.CustomResourceDefinition {
|
||||||
return &apiextensionsv1alpha1.CustomResource{
|
return &apiextensionsv1alpha1.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "curlets.mygroup.example.com"},
|
ObjectMeta: metav1.ObjectMeta{Name: "curlets.mygroup.example.com"},
|
||||||
Spec: apiextensionsv1alpha1.CustomResourceSpec{
|
Spec: apiextensionsv1alpha1.CustomResourceDefinitionSpec{
|
||||||
Group: "mygroup.example.com",
|
Group: "mygroup.example.com",
|
||||||
Version: "v1alpha1",
|
Version: "v1alpha1",
|
||||||
Names: apiextensionsv1alpha1.CustomResourceNames{
|
Names: apiextensionsv1alpha1.CustomResourceDefinitionNames{
|
||||||
Plural: "curlets",
|
Plural: "curlets",
|
||||||
Singular: "curlet",
|
Singular: "curlet",
|
||||||
Kind: "Curlet",
|
Kind: "Curlet",
|
||||||
@@ -94,20 +94,20 @@ func NewCurletInstance(namespace, name string) *unstructured.Unstructured {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateNewCustomResourceDefinition(customResource *apiextensionsv1alpha1.CustomResource, apiExtensionsClient clientset.Interface, clientPool dynamic.ClientPool) (*dynamic.Client, error) {
|
func CreateNewCustomResourceDefinition(customResourceDefinition *apiextensionsv1alpha1.CustomResourceDefinition, apiExtensionsClient clientset.Interface, clientPool dynamic.ClientPool) (*dynamic.Client, error) {
|
||||||
_, err := apiExtensionsClient.Apiextensions().CustomResources().Create(customResource)
|
_, err := apiExtensionsClient.Apiextensions().CustomResourceDefinitions().Create(customResourceDefinition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until the resource appears in discovery
|
// wait until the resource appears in discovery
|
||||||
err = wait.PollImmediate(30*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.PollImmediate(30*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
resourceList, err := apiExtensionsClient.Discovery().ServerResourcesForGroupVersion(customResource.Spec.Group + "/" + customResource.Spec.Version)
|
resourceList, err := apiExtensionsClient.Discovery().ServerResourcesForGroupVersion(customResourceDefinition.Spec.Group + "/" + customResourceDefinition.Spec.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
for _, resource := range resourceList.APIResources {
|
for _, resource := range resourceList.APIResources {
|
||||||
if resource.Name == customResource.Spec.Names.Plural {
|
if resource.Name == customResourceDefinition.Spec.Names.Plural {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ func CreateNewCustomResourceDefinition(customResource *apiextensionsv1alpha1.Cus
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamicClient, err := clientPool.ClientForGroupVersionResource(schema.GroupVersionResource{Group: customResource.Spec.Group, Version: customResource.Spec.Version, Resource: customResource.Spec.Names.Plural})
|
dynamicClient, err := clientPool.ClientForGroupVersionResource(schema.GroupVersionResource{Group: customResourceDefinition.Spec.Group, Version: customResourceDefinition.Spec.Version, Resource: customResourceDefinition.Spec.Names.Plural})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ func DefaultServerConfig() (*extensionsapiserver.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
options := server.NewCustomResourcesServerOptions(os.Stdout, os.Stderr)
|
options := server.NewCustomResourceDefinitionsServerOptions(os.Stdout, os.Stderr)
|
||||||
options.RecommendedOptions.Audit.Path = "-"
|
options.RecommendedOptions.Audit.Path = "-"
|
||||||
options.RecommendedOptions.SecureServing.BindPort = port
|
options.RecommendedOptions.SecureServing.BindPort = port
|
||||||
options.RecommendedOptions.Authentication.SkipInClusterLookup = true
|
options.RecommendedOptions.Authentication.SkipInClusterLookup = true
|
||||||
@@ -76,7 +76,7 @@ func DefaultServerConfig() (*extensionsapiserver.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
customResourceRESTOptionsGetter := extensionsapiserver.CustomResourceRESTOptionsGetter{
|
customResourceDefinitionRESTOptionsGetter := extensionsapiserver.CustomResourceDefinitionRESTOptionsGetter{
|
||||||
StorageConfig: options.RecommendedOptions.Etcd.StorageConfig,
|
StorageConfig: options.RecommendedOptions.Etcd.StorageConfig,
|
||||||
StoragePrefix: options.RecommendedOptions.Etcd.StorageConfig.Prefix,
|
StoragePrefix: options.RecommendedOptions.Etcd.StorageConfig.Prefix,
|
||||||
EnableWatchCache: options.RecommendedOptions.Etcd.EnableWatchCache,
|
EnableWatchCache: options.RecommendedOptions.Etcd.EnableWatchCache,
|
||||||
@@ -84,12 +84,12 @@ func DefaultServerConfig() (*extensionsapiserver.Config, error) {
|
|||||||
EnableGarbageCollection: options.RecommendedOptions.Etcd.EnableGarbageCollection,
|
EnableGarbageCollection: options.RecommendedOptions.Etcd.EnableGarbageCollection,
|
||||||
DeleteCollectionWorkers: options.RecommendedOptions.Etcd.DeleteCollectionWorkers,
|
DeleteCollectionWorkers: options.RecommendedOptions.Etcd.DeleteCollectionWorkers,
|
||||||
}
|
}
|
||||||
customResourceRESTOptionsGetter.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
|
customResourceDefinitionRESTOptionsGetter.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
|
||||||
customResourceRESTOptionsGetter.StorageConfig.Copier = extensionsapiserver.UnstructuredCopier{}
|
customResourceDefinitionRESTOptionsGetter.StorageConfig.Copier = extensionsapiserver.UnstructuredCopier{}
|
||||||
|
|
||||||
config := &extensionsapiserver.Config{
|
config := &extensionsapiserver.Config{
|
||||||
GenericConfig: genericConfig,
|
GenericConfig: genericConfig,
|
||||||
CustomResourceRESTOptionsGetter: customResourceRESTOptionsGetter,
|
CustomResourceDefinitionRESTOptionsGetter: customResourceDefinitionRESTOptionsGetter,
|
||||||
}
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
|
Reference in New Issue
Block a user