From 009873587e44cc28bfb13a8648fbd6eb313a1c62 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Wed, 4 Oct 2023 15:12:10 +0200 Subject: [PATCH 1/2] Updated make module-build to use config file --- .gitignore | 2 ++ Makefile | 21 +++++++++++++++++---- hack/ci/Makefile | 2 +- module-config-template.yaml | 9 +++++++++ scripts/release.sh | 1 - 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 module-config-template.yaml diff --git a/.gitignore b/.gitignore index 311d4829..79f3366d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,7 @@ bin/* vendor/ module-template.yaml +nats-manager.yaml +module-config.yaml .env.dev diff --git a/Makefile b/Makefile index afadf4fc..5646703f 100644 --- a/Makefile +++ b/Makefile @@ -190,16 +190,29 @@ module-image: docker-build docker-push ## Build the Module Image and push it to DEFAULT_CR ?= $(shell pwd)/config/samples/default.yaml .PHONY: module-build -module-build: kyma kustomize ## Build the Module and push it to a registry defined in MODULE_REGISTRY +module-build: kyma render-manifest module-config-template configure-git-origin ## Build the Module and push it to a registry defined in MODULE_REGISTRY ################################################################# ## Building module with: # - image: ${IMG} # - channel: ${MODULE_CHANNEL} # - name: kyma-project.io/module/$(MODULE_NAME) # - version: $(MODULE_VERSION) - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - @$(KYMA) alpha create module --kubebuilder-project --channel=${MODULE_CHANNEL} --name kyma-project.io/module/$(MODULE_NAME) --version $(MODULE_VERSION) --path . $(MODULE_CREATION_FLAGS) --output=template.yaml --default-cr=$(DEFAULT_CR) - + @$(KYMA) alpha create module --path . --output=module-template.yaml --module-config-file=module-config.yaml $(MODULE_CREATION_FLAGS) + +.PHONY: module-config-template +module-config-template: + @cat module-config-template.yaml \ + | sed -e 's/{{.Channel}}/${MODULE_CHANNEL}/g' \ + -e 's/{{.Version}}/$(MODULE_VERSION)/g' \ + -e 's/{{.Name}}/kyma-project.io\/module\/$(MODULE_NAME)/g' \ + > module-config.yaml + +.PHONY: configure-git-origin +configure-git-origin: +# test-infra does not include origin remote in the .git directory. +# the CLI is looking for the origin url in the .git dir so first we need to be sure it's not empty + @git remote | grep '^origin$$' -q || \ + git remote add origin https://github.com/kyma-project/nats-manager ## Tool Binaries KUSTOMIZE ?= $(LOCALBIN)/kustomize diff --git a/hack/ci/Makefile b/hack/ci/Makefile index d0523e54..5096abdd 100644 --- a/hack/ci/Makefile +++ b/hack/ci/Makefile @@ -17,7 +17,7 @@ module-build: ## Build the Module, push it to a registry and print it based on t IMG=${IMG} \ MODULE_REGISTRY=${MODULE_REGISTRY} \ MODULE_VERSION=${MODULE_VERSION}-${MODULE_SHA} - cp -f ${PROJECT_ROOT}/template.yaml ${ARTIFACTS}/module-template.yaml + cp -f ${PROJECT_ROOT}/module-template.yaml ${ARTIFACTS}/module-template.yaml @echo "Added template to job artifacts: ${ARTIFACTS}/module-template.yaml" @echo "\n~~~~~~~~~~~~BEGINNING OF MODULE TEMPLATE~~~~~~~~~~~~~~" @cat ${ARTIFACTS}/module-template.yaml diff --git a/module-config-template.yaml b/module-config-template.yaml new file mode 100644 index 00000000..f5745d8d --- /dev/null +++ b/module-config-template.yaml @@ -0,0 +1,9 @@ +name: {{.Name}} +channel: {{.Channel}} +version: {{.Version}} +defaultCR: config/samples/default.yaml +manifest: nats-operator.yaml +security: sec-scanners-config.yaml +annotations: + "operator.kyma-project.io/doc-url": "https://kyma-project.io/#/nats-manager/user/README" +moduleRepo: https://github.com/kyma-project/nats-manager.git diff --git a/scripts/release.sh b/scripts/release.sh index 6ef39014..03ac301c 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -37,7 +37,6 @@ echo "Generated nats-manager.yaml:" cat nats-manager.yaml MODULE_VERSION=${PULL_BASE_REF} make module-build -mv template.yaml module-template.yaml echo "Generated moduletemplate.yaml:" cat module-template.yaml From d0bdf3b8763e70cf27965ab2e4bcd87dc4d41749 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Wed, 4 Oct 2023 15:21:59 +0200 Subject: [PATCH 2/2] updated file name --- module-config-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-config-template.yaml b/module-config-template.yaml index f5745d8d..0849cd58 100644 --- a/module-config-template.yaml +++ b/module-config-template.yaml @@ -2,7 +2,7 @@ name: {{.Name}} channel: {{.Channel}} version: {{.Version}} defaultCR: config/samples/default.yaml -manifest: nats-operator.yaml +manifest: nats-manager.yaml security: sec-scanners-config.yaml annotations: "operator.kyma-project.io/doc-url": "https://kyma-project.io/#/nats-manager/user/README"