Skip to content

Commit 1dcfe9c

Browse files
committed
adding helm-diff target
Signed-off-by: hjoshi123 <[email protected]>
1 parent d226527 commit 1dcfe9c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

modules/helm/helm.mk

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ helm_chart_sources := $(shell find $(helm_chart_source_dir) -maxdepth 1 -type f)
4444
helm_chart_archive := $(bin_dir)/scratch/helm/$(helm_chart_name)-$(helm_chart_version).tgz
4545
helm_digest_path := $(bin_dir)/scratch/helm/$(helm_chart_name)-$(helm_chart_version).digests
4646
helm_digest = $(shell head -1 $(helm_digest_path) 2> /dev/null)
47+
HELM_IGNORE_FIELDS ?= 'app.kubernetes.io/version\|helm.sh/chart\|chart:\|appVersion:\|managed-by:\|meta.helm.sh/release-namespace'
48+
helm_chart_old_version ?=
4749

4850
$(bin_dir)/scratch/helm:
4951
@mkdir -p $@
@@ -187,3 +189,19 @@ verify-helm-kubeconform: $(helm_chart_archive) | $(NEEDS_KUBECONFORM)
187189
-strict
188190

189191
shared_verify_targets_dirty += verify-helm-kubeconform
192+
193+
.PHONY helm-diff
194+
helm-diff: $(helm_chart_archive) | $(NEEDS_HELM)
195+
@if [ -z "$(helm_chart_old_version)" ] then; \
196+
echo "Usage: make helm-diff helm_chart_old_version=<version>"; \
197+
exit 1; \
198+
fi
199+
200+
@TMP_OLD=$$(mktemp -d);
201+
@TMP_NEW=$$(mktemp -d);
202+
@OUTPUT_DIR=$$(mktemp -d);
203+
204+
$(HELM) template cert-manager --repo "oci://$(helm_chart_image_registry)" --version "$(helm_chart_old_version)" > $${TMP_OLD}/old.yaml;
205+
$(HELM) template $(helm_chart_archive) > $${TMP_NEW}/new.yaml;
206+
207+
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;

0 commit comments

Comments
 (0)