From 13e2dcfde53c735dc313d0145bca063ba3a9d121 Mon Sep 17 00:00:00 2001 From: Song Shukun Date: Fri, 21 Feb 2020 16:10:11 +0900 Subject: [PATCH] Fix dep build to be compatiable with Helm 2 when requirements use repo alias Signed-off-by: Song Shukun --- pkg/downloader/manager.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index cb139f824..ff451a6e8 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -82,6 +82,19 @@ func (m *Manager) Build() error { // Check that all of the repos we're dependent on actually exist. req := c.Metadata.Dependencies + + // If using apiVersion v1, calculate the hash before resolve repo names + // because resolveRepoNames will change req if req uses repo alias + // and Helm 2 calculate the digest from the original req + // Fix for: https://github.com/helm/helm/issues/7619 + var v2Sum string + if c.Metadata.APIVersion == chart.APIVersionV1 { + v2Sum, err = resolver.HashV2Req(req) + if err != nil { + return errors.New("the lock file (requirements.lock) is out of sync with the dependencies file (requirements.yaml). Please update the dependencies") + } + } + if _, err := m.resolveRepoNames(req); err != nil { return err } @@ -92,7 +105,7 @@ func (m *Manager) Build() error { // Fix for: https://github.com/helm/helm/issues/7233 if c.Metadata.APIVersion == chart.APIVersionV1 { log.Println("warning: a valid Helm v3 hash was not found. Checking against Helm v2 hash...") - if sum, err := resolver.HashV2Req(req); err != nil || sum != lock.Digest { + if v2Sum != lock.Digest { return errors.New("the lock file (requirements.lock) is out of sync with the dependencies file (requirements.yaml). Please update the dependencies") } } else {