Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions modules/helm/helm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ helm_chart_sources := $(shell find $(helm_chart_source_dir) -maxdepth 1 -type f)
helm_chart_archive := $(bin_dir)/scratch/helm/$(helm_chart_name)-$(helm_chart_version).tgz
helm_digest_path := $(bin_dir)/scratch/helm/$(helm_chart_name)-$(helm_chart_version).digests
helm_digest = $(shell head -1 $(helm_digest_path) 2> /dev/null)
HELM_IGNORE_FIELDS ?= 'app.kubernetes.io/version\|helm.sh/chart\|chart:\|appVersion:\|managed-by:\|meta.helm.sh/release-namespace'
helm_chart_old_version ?=
helm_chart_oci_name ?= cert-manager

$(bin_dir)/scratch/helm:
@mkdir -p $@
Expand Down Expand Up @@ -187,3 +190,19 @@ verify-helm-kubeconform: $(helm_chart_archive) | $(NEEDS_KUBECONFORM)
-strict

shared_verify_targets_dirty += verify-helm-kubeconform

.PHONY: helm-diff
helm-diff: $(helm_chart_archive) | $(NEEDS_HELM)
@if [ -z "$(helm_chart_old_version)" ]; then \
echo "Usage: make helm-diff helm_chart_old_version=<version>"; \
exit 1; \
fi

$(eval export TMP_OLD=$$(mktemp -d))
$(eval export TMP_NEW=$$(mktemp -d))
$(eval export OUTPUT_DIR=$$(mktemp -d))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, i might have given you the wrong command, I'm now getting:

$ make helm-diff
make/_shared/helm///helm.mk:196: warning: undefined variable `mktemp -d'
make/_shared/helm///helm.mk:196: warning: undefined variable `mktemp -d'
make/_shared/helm///helm.mk:196: warning: undefined variable `mktemp -d'
make/_shared/helm///helm.mk:196: warning: undefined variable `mktemp -d'
Usage: make helm-diff helm_chart_old_version=<version>
make: *** [helm-diff] Error 1

I guess it could be:

Suggested change
$(eval export OUTPUT_DIR=$$(mktemp -d))
$(eval export TMP_OLD=$(shell mktemp -d))
$(eval export TMP_NEW=$(shell mktemp -d))
$(eval export OUTPUT_DIR=$(shell mktemp -d))


$(HELM) template $(helm_chart_oci_name) --repo "oci://$(helm_chart_image_registry)" --version "$(helm_chart_old_version)" > $${TMP_OLD}/old.yaml;
$(HELM) template $(helm_chart_archive) > $${TMP_NEW}/new.yaml;

diff -u <(grep -vE $(HELM_IGNORE_FIELDS) $${TMP_OLD}/old.yaml) <(grep -vE $(HELM_IGNORE_FIELDS) $${TMP_NEW}/new.yaml) | tee "$(OUTPUT_DIR)/diff.txt" || true;
Loading