From b5bfcb3cb1b03a3b1af53429f66952ab531391a1 Mon Sep 17 00:00:00 2001 From: Francisc Munteanu Date: Fri, 27 Sep 2024 12:43:25 +0200 Subject: [PATCH] feat: Add new TierTemplateRevision CRD (#446) * add new tiertemplaterevision API --------- Co-authored-by: Devtools --- api/v1alpha1/docs/apiref.adoc | 73 ++++++++++++++++++++ api/v1alpha1/tiertemplaterevision_types.go | 45 ++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 80 ++++++++++++++++++++++ api/v1alpha1/zz_generated.openapi.go | 35 ++++++++++ make/generate.mk | 3 +- 5 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 api/v1alpha1/tiertemplaterevision_types.go diff --git a/api/v1alpha1/docs/apiref.adoc b/api/v1alpha1/docs/apiref.adoc index 1120ece0..ec66d323 100644 --- a/api/v1alpha1/docs/apiref.adoc +++ b/api/v1alpha1/docs/apiref.adoc @@ -46,6 +46,8 @@ Package v1alpha1 contains API Schema definitions for the toolchain.dev.openshift - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-spacerequestlist[$$SpaceRequestList$$] - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplate[$$TierTemplate$$] - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplatelist[$$TierTemplateList$$] +- xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevision[$$TierTemplateRevision$$] +- xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevisionlist[$$TierTemplateRevisionList$$] - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-toolchaincluster[$$ToolchainCluster$$] - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-toolchainclusterlist[$$ToolchainClusterList$$] - xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-toolchainconfig[$$ToolchainConfig$$] @@ -3126,6 +3128,77 @@ TierTemplateList contains a list of TierTemplate |=== +[id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevision"] +==== TierTemplateRevision + + + +TierTemplateRevision is the Schema for the tiertemplaterevisions API + +.Validation: +- XPreserveUnknownFields: {} + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevisionlist[$$TierTemplateRevisionList$$] +**** + +[cols="20a,50a,15a,15a", options="header"] +|=== +| Field | Description | Default | Validation +| *`apiVersion`* __string__ | `toolchain.dev.openshift.com/v1alpha1` | | +| *`kind`* __string__ | `TierTemplateRevision` | | +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.2/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + | | +| *`spec`* __xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevisionspec[$$TierTemplateRevisionSpec$$]__ | | | +|=== + + +[id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevisionlist"] +==== TierTemplateRevisionList + + + +TierTemplateRevisionList contains a list of TierTemplateRevisions + + + + + +[cols="20a,50a,15a,15a", options="header"] +|=== +| Field | Description | Default | Validation +| *`apiVersion`* __string__ | `toolchain.dev.openshift.com/v1alpha1` | | +| *`kind`* __string__ | `TierTemplateRevisionList` | | +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.2/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + | | +| *`items`* __xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevision[$$TierTemplateRevision$$] array__ | | | XPreserveUnknownFields: {} + + +|=== + + +[id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevisionspec"] +==== TierTemplateRevisionSpec + + + +TierTemplateRevisionSpec defines the desired state of TierTemplateRevision + + + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplaterevision[$$TierTemplateRevision$$] +**** + +[cols="20a,50a,15a,15a", options="header"] +|=== +| Field | Description | Default | Validation +| *`templateObjects`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.2/#rawextension-runtime-pkg[$$RawExtension$$] array__ | TemplateObjects contains list of Unstructured Objects that can be parsed at runtime and will be applied as part of the tier provisioning. + +The template parameters values will be defined in the NSTemplateTier CRD. + | | +|=== + + [id="{anchor_prefix}-github-com-codeready-toolchain-api-api-v1alpha1-tiertemplatespec"] ==== TierTemplateSpec diff --git a/api/v1alpha1/tiertemplaterevision_types.go b/api/v1alpha1/tiertemplaterevision_types.go new file mode 100644 index 00000000..b490b60d --- /dev/null +++ b/api/v1alpha1/tiertemplaterevision_types.go @@ -0,0 +1,45 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// TierTemplateRevision is the Schema for the tiertemplaterevisions API +// +kubebuilder:resource:path=tiertemplaterevisions,scope=Namespaced +// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=`.spec.type` +// +kubebuilder:validation:XPreserveUnknownFields +// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Template Tier Revision" +type TierTemplateRevision struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TierTemplateRevisionSpec `json:"spec,omitempty"` +} + +// TierTemplateRevisionSpec defines the desired state of TierTemplateRevision +// +k8s:openapi-gen=true +type TierTemplateRevisionSpec struct { + // TemplateObjects contains list of Unstructured Objects that can be parsed at runtime and will be applied as part of the tier provisioning. + // The template parameters values will be defined in the NSTemplateTier CRD. + // +optional + // +listType=atomic + // +kubebuilder:pruning:PreserveUnknownFields + TemplateObjects []runtime.RawExtension `json:"templateObjects,omitempty" protobuf:"bytes,3,opt,name=templateObjects"` +} + +//+kubebuilder:object:root=true + +// TierTemplateRevisionList contains a list of TierTemplateRevisions +type TierTemplateRevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []TierTemplateRevision `json:"items"` +} + +func init() { + SchemeBuilder.Register(&TierTemplateRevision{}, &TierTemplateRevisionList{}) +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 91655c33..5df3a56c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -3061,6 +3061,86 @@ func (in *TierTemplateList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TierTemplateRevision) DeepCopyInto(out *TierTemplateRevision) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TierTemplateRevision. +func (in *TierTemplateRevision) DeepCopy() *TierTemplateRevision { + if in == nil { + return nil + } + out := new(TierTemplateRevision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TierTemplateRevision) 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 *TierTemplateRevisionList) DeepCopyInto(out *TierTemplateRevisionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TierTemplateRevision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TierTemplateRevisionList. +func (in *TierTemplateRevisionList) DeepCopy() *TierTemplateRevisionList { + if in == nil { + return nil + } + out := new(TierTemplateRevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TierTemplateRevisionList) 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 *TierTemplateRevisionSpec) DeepCopyInto(out *TierTemplateRevisionSpec) { + *out = *in + if in.TemplateObjects != nil { + in, out := &in.TemplateObjects, &out.TemplateObjects + *out = make([]runtime.RawExtension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TierTemplateRevisionSpec. +func (in *TierTemplateRevisionSpec) DeepCopy() *TierTemplateRevisionSpec { + if in == nil { + return nil + } + out := new(TierTemplateRevisionSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TierTemplateSpec) DeepCopyInto(out *TierTemplateSpec) { *out = *in diff --git a/api/v1alpha1/zz_generated.openapi.go b/api/v1alpha1/zz_generated.openapi.go index a76577df..9ef0afce 100644 --- a/api/v1alpha1/zz_generated.openapi.go +++ b/api/v1alpha1/zz_generated.openapi.go @@ -117,6 +117,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/codeready-toolchain/api/api/v1alpha1.SpaceRequestStatus": schema_codeready_toolchain_api_api_v1alpha1_SpaceRequestStatus(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceSpec": schema_codeready_toolchain_api_api_v1alpha1_SpaceSpec(ref), "github.com/codeready-toolchain/api/api/v1alpha1.SpaceStatus": schema_codeready_toolchain_api_api_v1alpha1_SpaceStatus(ref), + "github.com/codeready-toolchain/api/api/v1alpha1.TierTemplateRevisionSpec": schema_codeready_toolchain_api_api_v1alpha1_TierTemplateRevisionSpec(ref), "github.com/codeready-toolchain/api/api/v1alpha1.TierTemplateSpec": schema_codeready_toolchain_api_api_v1alpha1_TierTemplateSpec(ref), "github.com/codeready-toolchain/api/api/v1alpha1.TiersConfig": schema_codeready_toolchain_api_api_v1alpha1_TiersConfig(ref), "github.com/codeready-toolchain/api/api/v1alpha1.ToolchainCluster": schema_codeready_toolchain_api_api_v1alpha1_ToolchainCluster(ref), @@ -4341,6 +4342,40 @@ func schema_codeready_toolchain_api_api_v1alpha1_SpaceStatus(ref common.Referenc } } +func schema_codeready_toolchain_api_api_v1alpha1_TierTemplateRevisionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TierTemplateRevisionSpec defines the desired state of TierTemplateRevision", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "templateObjects": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "TemplateObjects contains list of Unstructured Objects that can be parsed at runtime and will be applied as part of the tier provisioning. The template parameters values will be defined in the NSTemplateTier CRD.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + } +} + func schema_codeready_toolchain_api_api_v1alpha1_TierTemplateSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/make/generate.mk b/make/generate.mk index fbf340b8..fb56cab9 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -4,8 +4,7 @@ API_FULL_GROUPNAME=toolchain.dev.openshift.com 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 spaceprovisionerconfigs +HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates tiertemplaterevisions 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