From 8eec42f89953142753efa2df519bcbf14dc64e7d Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sat, 13 Jun 2026 09:33:55 +0800 Subject: [PATCH] fix: update ociDigestRegex to match empty digest in Helm 4.2.1 OCI pull output Helm 4.2.1 outputs "Digest: sha256:" (empty hash) when pulling OCI charts. The regex required at least one hex char ([0-9a-f]+), so it did not match and the digest was not normalized to $DIGEST in snapshot tests. Also fix the replacement string: Go regex ReplaceAllString interprets $DIGEST as a capture group reference (resolving to empty). Use $$DIGEST to produce a literal $DIGEST in the output. Signed-off-by: yxxhero --- test/e2e/template/helmfile/snapshot_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/template/helmfile/snapshot_test.go b/test/e2e/template/helmfile/snapshot_test.go index 9db54337..c39e5ee3 100644 --- a/test/e2e/template/helmfile/snapshot_test.go +++ b/test/e2e/template/helmfile/snapshot_test.go @@ -31,7 +31,7 @@ var ( helmShortVersionRegex = regexp.MustCompile(`v\d+\.\d+\.\d+\+[a-z0-9]+`) // OCI digest regex. e.g. Digest: sha256:abc123... // The digest is non-deterministic because helm packages include build timestamps. - ociDigestRegex = regexp.MustCompile(`Digest: sha256:[0-9a-f]+`) + ociDigestRegex = regexp.MustCompile(`Digest: sha256:[0-9a-f]*`) ) type Config struct { @@ -405,7 +405,7 @@ func testHelmfileTemplateWithBuildCommand(t *testing.T, GoYamlV3 bool) { // Normalize OCI digest values that change between test runs because // helm packages include build timestamps making each digest unique. - gotStr = ociDigestRegex.ReplaceAllString(gotStr, "Digest: sha256:$DIGEST") + gotStr = ociDigestRegex.ReplaceAllString(gotStr, "Digest: sha256:$$DIGEST") sc := bufio.NewScanner(strings.NewReader(gotStr)) for sc.Scan() {