From 3b27dcfb3ded74c8282f98ce94aaba295eb2ca03 Mon Sep 17 00:00:00 2001 From: Rafaela Soares <119665479+rsoaresd@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:58:03 +0100 Subject: [PATCH 1/3] SANDBOX-681: add 'Reason' field to BannedUserSpec (#442) * add 'Description' field to BannedUserSpec * improve * change field to optional * change description to reason --- api/v1alpha1/banneduser_types.go | 4 ++++ api/v1alpha1/docs/apiref.adoc | 1 + api/v1alpha1/zz_generated.openapi.go | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/api/v1alpha1/banneduser_types.go b/api/v1alpha1/banneduser_types.go index 994f681e..a73a5ed9 100644 --- a/api/v1alpha1/banneduser_types.go +++ b/api/v1alpha1/banneduser_types.go @@ -25,6 +25,10 @@ type BannedUserSpec struct { // The e-mail address of the account that has been banned Email string `json:"email"` + + // Reason of the ban + // +optional + Reason string `json:"reason,omitempty"` } //+kubebuilder:object:root=true diff --git a/api/v1alpha1/docs/apiref.adoc b/api/v1alpha1/docs/apiref.adoc index 7983142c..a5045ebb 100644 --- a/api/v1alpha1/docs/apiref.adoc +++ b/api/v1alpha1/docs/apiref.adoc @@ -201,6 +201,7 @@ BannedUserSpec defines the desired state of BannedUser |=== | Field | Description | Default | Validation | *`email`* __string__ | The e-mail address of the account that has been banned + | | +| *`reason`* __string__ | Reason of the ban + | | |=== diff --git a/api/v1alpha1/zz_generated.openapi.go b/api/v1alpha1/zz_generated.openapi.go index 91d99004..ff81a6d4 100644 --- a/api/v1alpha1/zz_generated.openapi.go +++ b/api/v1alpha1/zz_generated.openapi.go @@ -291,6 +291,13 @@ func schema_codeready_toolchain_api_api_v1alpha1_BannedUserSpec(ref common.Refer Format: "", }, }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "Reason of the ban", + Type: []string{"string"}, + Format: "", + }, + }, }, Required: []string{"email"}, }, From 94e42f4a0a956aa1fccaf404f9efa925c684a36c Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Wed, 11 Sep 2024 08:15:11 +0200 Subject: [PATCH 2/3] drop registration-service.yaml from registration-service repo (#443) --- make/generate.mk | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/make/generate.mk b/make/generate.mk index e4e57252..fbf340b8 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -25,7 +25,7 @@ LOCAL_GOPATH=`$(GO) env GOPATH` .PHONY: generate ## Generate deepcopy, openapi and CRD files after the API was modified -generate: generate-deepcopy-and-crds generate-openapi gen-crd-ref-docs dispatch-crds copy-reg-service-template +generate: generate-deepcopy-and-crds generate-openapi gen-crd-ref-docs dispatch-crds .PHONY: generate-deepcopy-and-crds generate-deepcopy-and-crds: remove-config controller-gen @@ -118,11 +118,6 @@ dispatch-crds: prepare-host-operator prepare-member-operator fi @echo "Dispatch successfuly finished \o/" -.PHONY: copy-reg-service-template -copy-reg-service-template: - cp ../registration-service/deploy/registration-service.yaml ../host-operator/deploy/registration-service/registration-service.yaml - - CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen controller-gen: ## Download controller-gen locally if necessary. GOBIN=$(PROJECT_DIR)/bin $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen From ca625184d294f6fbb1db6771ecd78497819363b9 Mon Sep 17 00:00:00 2001 From: Francisc Munteanu Date: Thu, 12 Sep 2024 13:32:07 +0200 Subject: [PATCH 3/3] feat: Add new field for TemplateObjects in TierTemplate CRD to support go template syntax (#441) * add TemplateObjects in TierTemplate CRD --- api/v1alpha1/docs/apiref.adoc | 12 +++++++++++- api/v1alpha1/tiertemplate_types.go | 14 ++++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 9 ++++++++- api/v1alpha1/zz_generated.openapi.go | 23 +++++++++++++++++++++-- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/docs/apiref.adoc b/api/v1alpha1/docs/apiref.adoc index a5045ebb..477e55ff 100644 --- a/api/v1alpha1/docs/apiref.adoc +++ b/api/v1alpha1/docs/apiref.adoc @@ -3108,7 +3108,17 @@ TierTemplateSpec defines the desired state of TierTemplate | *`tierName`* __string__ | The tier of the template. For example: "basic", "advanced", or "team" + | | | *`type`* __string__ | The type of the template. For example: "code", "dev", "stage" or "cluster" + | | | *`revision`* __string__ | The revision of the corresponding template + | | -| *`template`* __xref:{anchor_prefix}-github-com-openshift-api-template-v1-template[$$Template$$]__ | Template contains an OpenShift Template to be used to provision either a user's namespace or cluster-wide resources + | | +| *`template`* __xref:{anchor_prefix}-github-com-openshift-api-template-v1-template[$$Template$$]__ | Template contains an OpenShift Template to be used to provision either a user's namespace or cluster-wide resources + +Note: this field will be removed in favor of the new TemplateObjects below. + | | +| *`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. + + + +NOTE: when specifying variables as part of the objects list , those concatenated as part of other strings do not need to be wrapped inside quotes, + +while those that are not part of other strings do need to be wrapped in single quotes. This is required otherwise the yaml parser will error while trying to parse those resources containing variables. + +eg: https://docs.google.com/document/d/1x5SoBT80df9fmVsaDgAE6DE7hE6lzmNIK087JUmgaJs/edit#heading=h.2iuytpfnmul5 + + + +The template parameters values will be defined in the NSTemplateTier CRD. + | | |=== diff --git a/api/v1alpha1/tiertemplate_types.go b/api/v1alpha1/tiertemplate_types.go index d15f08c3..b1adeddd 100644 --- a/api/v1alpha1/tiertemplate_types.go +++ b/api/v1alpha1/tiertemplate_types.go @@ -3,6 +3,7 @@ package v1alpha1 import ( templatev1 "github.com/openshift/api/template/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) const ( @@ -28,7 +29,20 @@ type TierTemplateSpec struct { Revision string `json:"revision"` // Template contains an OpenShift Template to be used to provision either a user's namespace or cluster-wide resources + // Note: this field will be removed in favor of the new TemplateObjects below. Template templatev1.Template `json:"template"` + + // TemplateObjects contains list of Unstructured Objects that can be parsed at runtime and will be applied as part of the tier provisioning. + // + // NOTE: when specifying variables as part of the objects list , those concatenated as part of other strings do not need to be wrapped inside quotes, + // while those that are not part of other strings do need to be wrapped in single quotes. This is required otherwise the yaml parser will error while trying to parse those resources containing variables. + // eg: https://docs.google.com/document/d/1x5SoBT80df9fmVsaDgAE6DE7hE6lzmNIK087JUmgaJs/edit#heading=h.2iuytpfnmul5 + // + // 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 diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index bd658802..6c152100 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -6,7 +6,7 @@ package v1alpha1 import ( - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -3016,6 +3016,13 @@ func (in *TierTemplateList) DeepCopyObject() runtime.Object { func (in *TierTemplateSpec) DeepCopyInto(out *TierTemplateSpec) { *out = *in in.Template.DeepCopyInto(&out.Template) + 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 TierTemplateSpec. diff --git a/api/v1alpha1/zz_generated.openapi.go b/api/v1alpha1/zz_generated.openapi.go index ff81a6d4..6ee9baf0 100644 --- a/api/v1alpha1/zz_generated.openapi.go +++ b/api/v1alpha1/zz_generated.openapi.go @@ -4265,17 +4265,36 @@ func schema_codeready_toolchain_api_api_v1alpha1_TierTemplateSpec(ref common.Ref }, "template": { SchemaProps: spec.SchemaProps{ - Description: "Template contains an OpenShift Template to be used to provision either a user's namespace or cluster-wide resources", + Description: "Template contains an OpenShift Template to be used to provision either a user's namespace or cluster-wide resources Note: this field will be removed in favor of the new TemplateObjects below.", Default: map[string]interface{}{}, Ref: ref("github.com/openshift/api/template/v1.Template"), }, }, + "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.\n\nNOTE: when specifying variables as part of the objects list , those concatenated as part of other strings do not need to be wrapped inside quotes, while those that are not part of other strings do need to be wrapped in single quotes. This is required otherwise the yaml parser will error while trying to parse those resources containing variables. eg: https://docs.google.com/document/d/1x5SoBT80df9fmVsaDgAE6DE7hE6lzmNIK087JUmgaJs/edit#heading=h.2iuytpfnmul5\n\nThe 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"), + }, + }, + }, + }, + }, }, Required: []string{"tierName", "type", "revision", "template"}, }, }, Dependencies: []string{ - "github.com/openshift/api/template/v1.Template"}, + "github.com/openshift/api/template/v1.Template", "k8s.io/apimachinery/pkg/runtime.RawExtension"}, } }