diff --git a/api/v1alpha1/spaceprovisionerconfig_types.go b/api/v1alpha1/spaceprovisionerconfig_types.go new file mode 100644 index 00000000..30b6c62c --- /dev/null +++ b/api/v1alpha1/spaceprovisionerconfig_types.go @@ -0,0 +1,79 @@ +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +const ( + SpaceProvisionerConfigValidConditionType = "Valid" + SpaceProvisionerConfigToolchainClusterNotFoundReason = "ToolchainClusterNotFound" + SpaceProvisionerConfigValidReason = "AllChecksPassed" +) + +// +k8s:openapi-gen=true +type SpaceProvisionerConfigSpec struct { + // ToolchainCluster is the name of the ToolchainCluster CR of the member cluster that this config is for. + ToolchainCluster string `json:"toolchainCluster"` + + // Enabled specifies whether the member cluster is enabled (and therefore can hold spaces) or not. + Enabled bool `json:"enabled"` + + // CapacityThresholds specifies the max capacities allowed in this provisioner + CapacityThresholds SpaceProvisionerCapacityThresholds `json:"capacityThresholds"` + + // PlacementRoles is the list of roles, or flavors, that the provisioner possesses that influence + // the space scheduling decisions. + // +optional + PlacementRoles *[]string `json:"placementRoles,omitempty"` +} + +// SpaceProvisionerCapacityThresholds defines the capacity thresholds of the space provisioner +// +k8s:openapi-gen=true +type SpaceProvisionerCapacityThresholds struct { + // +kubebuilder:validation:Minimum=0 + MaxNumberOfSpaces uint `json:"maxNumberOfSpaces"` + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=100 + MaxMemoryUtilizationPercent uint `json:"maxMemoryUtilizationPercent"` +} + +// +k8s:openapi-gen=true +type SpaceProvisionerConfigStatus struct { + // Conditions describes the state of the configuration (its validity). + // The only known condition type is "Valid". + // +optional + // +listType=map + // +listMapKey=type + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// SpaceProvisionerConfig is the configuration of space provisioning in the member clusters. +// +// Note that these objects are currently NOT used anywhere. +// +// +k8s:openapi-gen=true +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Namespaced +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=`.spec.toolchainCluster` +// +kubebuilder:printcolumn:name="Enabled",type="bool",JSONPath=`.spec.enabled` +// +kubebuilder:validation:XPreserveUnknownFields +// +operator-sdk:gen-csv:customresourcedefinitions.displayName="SpaceProvisionerConfig" +type SpaceProvisionerConfig struct { + Spec SpaceProvisionerConfigSpec `json:"spec,omitempty"` + Status SpaceProvisionerConfigStatus `json:"status,omitempty"` + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` +} + +//+kubebuilder:object:root=true + +// SpaceProvisionerConfigList contains a list of SpaceProvisionerConfig +// +k8s:openapi-gen=true +type SpaceProvisionerConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SpaceProvisionerConfig `json:"items"` +} + +func init() { + SchemeBuilder.Register(&SpaceProvisionerConfig{}, &SpaceProvisionerConfigList{}) +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 1c8f2ccf..420ce542 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -6,6 +6,7 @@ package v1alpha1 import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -2661,6 +2662,127 @@ func (in *SpaceNamespace) DeepCopy() *SpaceNamespace { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpaceProvisionerCapacityThresholds) DeepCopyInto(out *SpaceProvisionerCapacityThresholds) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpaceProvisionerCapacityThresholds. +func (in *SpaceProvisionerCapacityThresholds) DeepCopy() *SpaceProvisionerCapacityThresholds { + if in == nil { + return nil + } + out := new(SpaceProvisionerCapacityThresholds) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpaceProvisionerConfig) DeepCopyInto(out *SpaceProvisionerConfig) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpaceProvisionerConfig. +func (in *SpaceProvisionerConfig) DeepCopy() *SpaceProvisionerConfig { + if in == nil { + return nil + } + out := new(SpaceProvisionerConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpaceProvisionerConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpaceProvisionerConfigList) DeepCopyInto(out *SpaceProvisionerConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SpaceProvisionerConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpaceProvisionerConfigList. +func (in *SpaceProvisionerConfigList) DeepCopy() *SpaceProvisionerConfigList { + if in == nil { + return nil + } + out := new(SpaceProvisionerConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SpaceProvisionerConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpaceProvisionerConfigSpec) DeepCopyInto(out *SpaceProvisionerConfigSpec) { + *out = *in + out.CapacityThresholds = in.CapacityThresholds + if in.PlacementRoles != nil { + in, out := &in.PlacementRoles, &out.PlacementRoles + *out = new([]string) + if **in != nil { + in, out := *in, *out + *out = make([]string, len(*in)) + copy(*out, *in) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpaceProvisionerConfigSpec. +func (in *SpaceProvisionerConfigSpec) DeepCopy() *SpaceProvisionerConfigSpec { + if in == nil { + return nil + } + out := new(SpaceProvisionerConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpaceProvisionerConfigStatus) DeepCopyInto(out *SpaceProvisionerConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpaceProvisionerConfigStatus. +func (in *SpaceProvisionerConfigStatus) DeepCopy() *SpaceProvisionerConfigStatus { + if in == nil { + return nil + } + out := new(SpaceProvisionerConfigStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SpaceRequest) DeepCopyInto(out *SpaceRequest) { *out = *in diff --git a/api/v1alpha1/zz_generated.openapi.go b/api/v1alpha1/zz_generated.openapi.go index c0c71071..f565b81a 100644 --- a/api/v1alpha1/zz_generated.openapi.go +++ b/api/v1alpha1/zz_generated.openapi.go @@ -105,6 +105,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/codeready-toolchain/api/api/v1alpha1.SpaceBindingSpec": schema_codeready_toolchain_api_api_v1alpha1_SpaceBindingSpec(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceBindingStatus": schema_codeready_toolchain_api_api_v1alpha1_SpaceBindingStatus(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceConfig": schema_codeready_toolchain_api_api_v1alpha1_SpaceConfig(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerCapacityThresholds": schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerCapacityThresholds(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfig": schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfig(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigList": schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigList(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigSpec": schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigSpec(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigStatus": schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigStatus(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceRequest": schema_codeready_toolchain_api_api_v1alpha1_SpaceRequest(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceRequestConfig": schema_codeready_toolchain_api_api_v1alpha1_SpaceRequestConfig(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceRequestSpec": schema_codeready_toolchain_api_api_v1alpha1_SpaceRequestSpec(ref), @@ -3673,6 +3678,219 @@ func schema_codeready_toolchain_api_api_v1alpha1_SpaceConfig(ref common.Referenc } } +func schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerCapacityThresholds(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SpaceProvisionerCapacityThresholds defines the capacity thresholds of the space provisioner", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "maxNumberOfSpaces": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + "maxMemoryUtilizationPercent": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"maxNumberOfSpaces", "maxMemoryUtilizationPercent"}, + }, + }, + } +} + +func schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SpaceProvisionerConfig is the configuration of space provisioning in the member clusters.\n\nNote that these objects are currently NOT used anywhere.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigStatus"), + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigSpec", "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfigStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + } +} + +func schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SpaceProvisionerConfigList contains a list of SpaceProvisionerConfig", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfig"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerConfig", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + } +} + +func schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "toolchainCluster": { + SchemaProps: spec.SchemaProps{ + Description: "ToolchainCluster is the name of the ToolchainCluster CR of the member cluster that this config is for.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "enabled": { + SchemaProps: spec.SchemaProps{ + Description: "Enabled specifies whether the member cluster is enabled (and therefore can hold spaces) or not.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "capacityThresholds": { + SchemaProps: spec.SchemaProps{ + Description: "CapacityThresholds specifies the max capacities allowed in this provisioner", + Default: map[string]interface{}{}, + Ref: ref("github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerCapacityThresholds"), + }, + }, + "placementRoles": { + SchemaProps: spec.SchemaProps{ + Description: "PlacementRoles is the list of roles, or flavors, that the provisioner possesses that influence the space scheduling decisions.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"toolchainCluster", "enabled", "capacityThresholds"}, + }, + }, + Dependencies: []string{ + "github.com/codeready-toolchain/api/api/v1alpha1.SpaceProvisionerCapacityThresholds"}, + } +} + +func schema_codeready_toolchain_api_api_v1alpha1_SpaceProvisionerConfigStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Conditions describes the state of the configuration (its validity). The only known condition type is \"Valid\".", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + } +} + func schema_codeready_toolchain_api_api_v1alpha1_SpaceRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/make/generate.mk b/make/generate.mk index d3ee6e4d..c0d166fb 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -5,7 +5,7 @@ API_VERSION:=v1alpha1 # how to dispatch the CRD files per repository (space-separated lists) # !!! IMPORTANT !!! - when there is a new CRD added or an existing one removed or renamed, don't forget to change it also here: https://github.com/codeready-toolchain/toolchain-cicd/blob/master/scripts/add-cluster.sh#L52-L73 -HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates toolchainstatuses toolchainclusters toolchainconfigs usertiers proxyplugins spacerequests spacebindingrequests +HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates toolchainstatuses toolchainclusters toolchainconfigs usertiers proxyplugins spacerequests spacebindingrequests spaceprovisionerconfigs MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchainclusters memberoperatorconfigs spacerequests workspaces spacebindingrequests PATH_TO_CRD_BASES=config/crd/bases