From c772e543a355d2edf67fab83a264a4d1c6e31ad5 Mon Sep 17 00:00:00 2001 From: Xin Ruan Date: Fri, 4 Oct 2024 16:25:42 +0200 Subject: [PATCH] feat: Introduce ModuleTemplate Info (#1928) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add ModuleInfo as optional to ModuleTemplate * add spec.info document * Update api/v1beta2/moduletemplate_types.go Co-authored-by: Christoph Schwägerl * Update api/v1beta2/moduletemplate_types.go Co-authored-by: Christoph Schwägerl * Update api/v1beta2/moduletemplate_types.go Co-authored-by: Christoph Schwägerl * update crd * add omitempty to keep consistent * Update docs/contributor/resources/03-moduletemplate.md Co-authored-by: Christoph Schwägerl * add missing config * Update docs/contributor/resources/03-moduletemplate.md Co-authored-by: Małgorzata Świeca * add missing config * only test one e2e * update k3d and k8s version * bring back e2e * use 1.30.3 for all tests * run make generate --------- Co-authored-by: Christoph Schwägerl Co-authored-by: Małgorzata Świeca Co-authored-by: Christoph Schwägerl --- .github/actions/get-configuration/action.yaml | 4 +-- Makefile | 2 +- api-version-compatibility-config.yaml | 1 + api/v1beta2/moduletemplate_types.go | 26 ++++++++++++++ api/v1beta2/zz_generated.deepcopy.go | 36 +++++++++++++++++++ ...rator.kyma-project.io_moduletemplates.yaml | 32 +++++++++++++++++ .../resources/03-moduletemplate.md | 18 ++++++++++ 7 files changed, 116 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-configuration/action.yaml b/.github/actions/get-configuration/action.yaml index 2d6002744f..373a178541 100644 --- a/.github/actions/get-configuration/action.yaml +++ b/.github/actions/get-configuration/action.yaml @@ -26,9 +26,9 @@ runs: id: define-variables shell: bash run: | - echo "k8s_version=${{ github.event.inputs.k8s_version || '1.29.6' }}" >> $GITHUB_OUTPUT + echo "k8s_version=${{ github.event.inputs.k8s_version || '1.30.3' }}" >> $GITHUB_OUTPUT echo "istio_version=1.20.3" >> $GITHUB_OUTPUT - echo "k3d_version=5.6.0" >> $GITHUB_OUTPUT + echo "k3d_version=5.7.4" >> $GITHUB_OUTPUT echo "cert_manager_version=1.15.0" >> $GITHUB_OUTPUT echo "klm_version_tag=PR-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT echo "klm_image_repo=dev" >> $GITHUB_OUTPUT diff --git a/Makefile b/Makefile index 14e468ed3c..c2e76cabd2 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ IMG := $(IMG_NAME):$(DOCKER_TAG) BUILD_VERSION := from_makefile # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.28.0 +ENVTEST_K8S_VERSION = 1.30.3 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) diff --git a/api-version-compatibility-config.yaml b/api-version-compatibility-config.yaml index 26ad8ce1e1..e625bfd6f6 100644 --- a/api-version-compatibility-config.yaml +++ b/api-version-compatibility-config.yaml @@ -25,4 +25,5 @@ operator.kyma-project.io_moduletemplates.yaml: - .spec.properties.moduleName - .spec.properties.customStateCheck.description - .spec.properties.resources + - .spec.properties.info - .spec.properties.associatedResources diff --git a/api/v1beta2/moduletemplate_types.go b/api/v1beta2/moduletemplate_types.go index 4ed2b06fd4..9601f4f274 100644 --- a/api/v1beta2/moduletemplate_types.go +++ b/api/v1beta2/moduletemplate_types.go @@ -133,11 +133,37 @@ type ModuleTemplateSpec struct { // +listMapKey=name Resources []Resource `json:"resources,omitempty"` + // Info contains metadata about the module. + // +optional + Info ModuleInfo `json:"info,omitempty"` + // AssociatedResources is a list of module related resources that usually must be cleaned when uninstalling a module. Informational purpose only. // +optional AssociatedResources []apimetav1.GroupVersionKind `json:"associatedResources,omitempty"` } +type ModuleInfo struct { + // Repository is the link to the repository of the module. + Repository string `json:"repository"` + + // Documentation is the link to the documentation of the module. + Documentation string `json:"documentation"` + + // Icons is a list of icons of the module. + // +optional + // +listType=map + // +listMapKey=name + Icons []ModuleIcon `json:"icons,omitempty"` +} + +type ModuleIcon struct { + // Name is the name of the icon. + Name string `json:"name"` + + // Link is the link to the icon. + Link string `json:"link"` +} + type CustomStateCheck struct { // JSONPath specifies the JSON path to the state variable in the Module CR JSONPath string `json:"jsonPath" yaml:"jsonPath"` diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 905a7f2d08..e15a03b756 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -315,6 +315,41 @@ func (in *Module) DeepCopy() *Module { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ModuleIcon) DeepCopyInto(out *ModuleIcon) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModuleIcon. +func (in *ModuleIcon) DeepCopy() *ModuleIcon { + if in == nil { + return nil + } + out := new(ModuleIcon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ModuleInfo) DeepCopyInto(out *ModuleInfo) { + *out = *in + if in.Icons != nil { + in, out := &in.Icons, &out.Icons + *out = make([]ModuleIcon, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModuleInfo. +func (in *ModuleInfo) DeepCopy() *ModuleInfo { + if in == nil { + return nil + } + out := new(ModuleInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ModuleReleaseMeta) DeepCopyInto(out *ModuleReleaseMeta) { *out = *in @@ -505,6 +540,7 @@ func (in *ModuleTemplateSpec) DeepCopyInto(out *ModuleTemplateSpec) { *out = make([]Resource, len(*in)) copy(*out, *in) } + in.Info.DeepCopyInto(&out.Info) if in.AssociatedResources != nil { in, out := &in.AssociatedResources, &out.AssociatedResources *out = make([]v1.GroupVersionKind, len(*in)) diff --git a/config/crd/bases/operator.kyma-project.io_moduletemplates.yaml b/config/crd/bases/operator.kyma-project.io_moduletemplates.yaml index ea40dc5bb4..966293c44f 100644 --- a/config/crd/bases/operator.kyma-project.io_moduletemplates.yaml +++ b/config/crd/bases/operator.kyma-project.io_moduletemplates.yaml @@ -241,6 +241,38 @@ spec: charts and kustomize renderers are deprecated and ignored. type: object x-kubernetes-preserve-unknown-fields: true + info: + description: Info contains metadata about the module. + properties: + documentation: + description: Documentation is the link to the documentation of + the module. + type: string + icons: + description: Icons is a list of icons of the module. + items: + properties: + link: + description: Link is the link to the icon. + type: string + name: + description: Name is the name of the icon. + type: string + required: + - link + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + repository: + description: Repository is the link to the repository of the module. + type: string + required: + - documentation + - repository + type: object mandatory: description: |- Mandatory indicates whether the module is mandatory. It is used to enforce the installation of the module with diff --git a/docs/contributor/resources/03-moduletemplate.md b/docs/contributor/resources/03-moduletemplate.md index c66f5a54c5..019b63288e 100644 --- a/docs/contributor/resources/03-moduletemplate.md +++ b/docs/contributor/resources/03-moduletemplate.md @@ -55,6 +55,24 @@ spec: If not specified, the **namespace** of the resource mentioned in **.spec.data** will be controlled by the `sync-namespace` flag; otherwise, it will be respected. All other attributes (including **.metadata.name**, **apiVersion**, and **kind**) are taken over as stated. Note that since it behaves similarly to a `template`, any subresources, such as **status**, are ignored, even if specified in the field. +### **.spec.info** + +The **info** field contains module metadata, including the repository URL, documentation link, and icons. For example: + +``` +spec: + info: + repository: https://github.com/example/repo + documentation: https://docs.example.com + icons: + - name: example-icon + link: https://example.com/icon.png +``` + +- repository: The link to the repository of the module. +- documentation: The link to the documentation of the module. +- icons: A list of icons of the module, each with a name and link. + ### **.spec.customStateCheck** > **CAUTION:** This field was deprecated at the end of July 2024 and will be deleted in the next ModuleTemplate API version. As of the deletion day, you can define the custom state only in a module's custom resource.