From 8f4706f99c30fa66ff86065a2c5d3aa7405bc83b Mon Sep 17 00:00:00 2001 From: Keyvan Date: Fri, 4 Nov 2022 15:04:40 +0100 Subject: [PATCH 1/5] Update external charts via Makefile --- Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6de4c999..e15cd335 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,67 @@ -.PHONY: gen -gen: gen-chart-doc +EXTERNAL_CHARTS = $(shell grep -P "^update-\S+:$$" Makefile | cut -d: -f1) +#EXTERNAL_CHARTS = $(shell find external -mindepth 1 -maxdepth 1 -type d | sed 's/external\//update-/') -.PHONY: gen-chart-doc -gen-chart-doc: +gen: @echo "Generate chart docs" @helm-docs -s file --template-files=charts/_templates.gotmpl --template-files=DOCS.md.gotmpl --template-files=README.md.gotmpl + +deps: $(EXTERNAL_CHARTS) + @echo "Update chart dependencies" + +update-cert-manager: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://charts.jetstack.io + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-common: repo-bitnami + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + +update-elasticsearch: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://helm.elastic.co + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-fluent-bit: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://fluent.github.io/helm-charts + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-grafana: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://grafana.github.io/helm-charts + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-graylog: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://charts.kong-z.com + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-ingress-nginx: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://kubernetes.github.io/ingress-nginx + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +update-minio: repo-bitnami + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + +update-mongodb: repo-bitnami + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + +update-postgresql: repo-bitnami + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + +update-redis: repo-bitnami + @rm -rf external/$(patsubst update-%,%,$@) + @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + +update-velero: + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://vmware-tanzu.github.io/helm-charts + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + +repo-bitnami: + @helm repo add bitnami https://charts.bitnami.com/bitnami From 402362b7a4efbd2a1f2393d8bd1acf07636b54d8 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 10 Jul 2024 11:35:28 +0200 Subject: [PATCH 2/5] Manually import bitnami repo, otherwise the regex does not work --- Makefile | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index e15cd335..2a124433 100644 --- a/Makefile +++ b/Makefile @@ -6,62 +6,89 @@ gen: @helm-docs -s file --template-files=charts/_templates.gotmpl --template-files=DOCS.md.gotmpl --template-files=README.md.gotmpl deps: $(EXTERNAL_CHARTS) - @echo "Update chart dependencies" + @echo "Updated chart dependencies" update-cert-manager: + @echo "Updating cert-manager" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://charts.jetstack.io @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" -update-common: repo-bitnami +update-common: + @echo "Updating common" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + @echo "" update-elasticsearch: + @echo "Updating elasticsearch" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://helm.elastic.co @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" update-fluent-bit: + @echo "Updating fluent-bit" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://fluent.github.io/helm-charts @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" update-grafana: + @echo "Updating grafana" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://grafana.github.io/helm-charts @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" update-graylog: + @echo "Updating graylog" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://charts.kong-z.com @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" update-ingress-nginx: + @echo "Updating ingress-nginx" @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://kubernetes.github.io/ingress-nginx @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" -update-minio: repo-bitnami +update-minio: + @echo "Updating minio" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + @echo "" -update-mongodb: repo-bitnami +update-mongodb: + @echo "Updating mongodb" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + @echo "" -update-postgresql: repo-bitnami +update-postgresql: + @echo "Updating postgresql" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + @echo "" -update-redis: repo-bitnami +update-redis: + @echo "Updating redis" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) + @echo "" update-velero: + @echo "Updating velero" + @helm repo add bitnami https://charts.bitnami.com/bitnami @rm -rf external/$(patsubst update-%,%,$@) @helm repo add $(patsubst update-%,%,$@) https://vmware-tanzu.github.io/helm-charts @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) - -repo-bitnami: - @helm repo add bitnami https://charts.bitnami.com/bitnami + @echo "" From 902213b30a901edb03e040ecca39af89ece347ee Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 10 Jul 2024 11:36:06 +0200 Subject: [PATCH 3/5] Add a makefile target to list missing external dependencies --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2a124433..dac1a583 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,14 @@ EXTERNAL_CHARTS = $(shell grep -P "^update-\S+:$$" Makefile | cut -d: -f1) -#EXTERNAL_CHARTS = $(shell find external -mindepth 1 -maxdepth 1 -type d | sed 's/external\//update-/') +EXTERNAL_CHARTS_ACTUAL = $(shell find external -mindepth 1 -maxdepth 1 -type d | sed 's/external\//update-/') +MISSING_UPDATE_TARGETS = $(shell echo $(EXTERNAL_CHARTS_ACTUAL) $(EXTERNAL_CHARTS) | sed 's/ /\n/g' | sort | uniq -u) -gen: +generate-docs: @echo "Generate chart docs" @helm-docs -s file --template-files=charts/_templates.gotmpl --template-files=DOCS.md.gotmpl --template-files=README.md.gotmpl +list-missing-update-targets: + @echo $(MISSING_UPDATE_TARGETS) | sed 's/ /\n/g' + deps: $(EXTERNAL_CHARTS) @echo "Updated chart dependencies" From 112ba3eda4889b3cdcd69c4d38578838c86b865d Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 10 Jul 2024 11:45:00 +0200 Subject: [PATCH 4/5] Add missing external charts as targets --- Makefile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Makefile b/Makefile index dac1a583..ab1a3417 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,20 @@ update-ingress-nginx: @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) @echo "" +update-kratos: + @echo "Updating kratos" + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://k8s.ory.sh/helm/charts + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" + +update-kratos-selfservice-ui-node: + @echo "Updating kratos-selfservice-ui-node" + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://k8s.ory.sh/helm/charts + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" + update-minio: @echo "Updating minio" @helm repo add bitnami https://charts.bitnami.com/bitnami @@ -89,6 +103,13 @@ update-redis: @helm pull -d external --untar bitnami/$(patsubst update-%,%,$@) @echo "" +update-trivy: + @echo "Updating trivy" + @rm -rf external/$(patsubst update-%,%,$@) + @helm repo add $(patsubst update-%,%,$@) https://aquasecurity.github.io/helm-charts/ + @helm pull -d external --untar $(patsubst update-%,%,$@)/$(patsubst update-%,%,$@) + @echo "" + update-velero: @echo "Updating velero" @helm repo add bitnami https://charts.bitnami.com/bitnami From 326da2f9ca56ac9e11ef74f9da10d60d8343b1c8 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 10 Jul 2024 12:26:46 +0200 Subject: [PATCH 5/5] Add workflow to test the makefile for missing targets This would trigger if an external chart is added to the main branch without a simple way to update it --- .../check-missing-update-targets.yml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/check-missing-update-targets.yml diff --git a/.github/workflows/check-missing-update-targets.yml b/.github/workflows/check-missing-update-targets.yml new file mode 100644 index 00000000..86e11646 --- /dev/null +++ b/.github/workflows/check-missing-update-targets.yml @@ -0,0 +1,26 @@ +name: Check Missing Update Targets + +on: + pull_request: + branches: + - main + +jobs: + check-missing-update-targets: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Make + run: sudo apt-get install make + + - name: Run make list-missing-update-targets + id: check + run: | + OUTPUT=$(make list-missing-update-targets) + if [ -n "$OUTPUT" ]; then + echo "Missing update targets detected:" + echo "$OUTPUT" + exit 1 + fi \ No newline at end of file