From 0d75e7441e34f61c862fdc0060419417adea6fb1 Mon Sep 17 00:00:00 2001 From: Craig Furman Date: Thu, 18 Mar 2021 13:48:17 +0000 Subject: [PATCH] feat(tool/charts): Only update helm repositories when necessary (#535) We currently run `helm repo update` every time we run `tk tool charts vendor`. Some tanka users may check in their charts directory to avoid many network calls to helm repositories in CI, which can be flaky. By delaying the `helm repo update` call until there is a chart to pull, we can better support these workflows. --- pkg/helm/charts.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/helm/charts.go b/pkg/helm/charts.go index c9d340e0a..883969660 100644 --- a/pkg/helm/charts.go +++ b/pkg/helm/charts.go @@ -91,11 +91,7 @@ func (c Charts) Vendor() error { return err } - log.Println("Syncing Repositories ...") - if err := c.Helm.RepoUpdate(Opts{Repositories: c.Manifest.Repositories}); err != nil { - return err - } - + repositoriesUpdated := false log.Println("Pulling Charts ...") for _, r := range c.Manifest.Requires { chartName := parseReqName(r.Chart) @@ -126,6 +122,13 @@ func (c Charts) Vendor() error { return err } + if !repositoriesUpdated { + log.Println("Syncing Repositories ...") + if err := c.Helm.RepoUpdate(Opts{Repositories: c.Manifest.Repositories}); err != nil { + return err + } + repositoriesUpdated = true + } err = c.Helm.Pull(r.Chart, r.Version.String(), PullOpts{ Destination: dir, Opts: Opts{Repositories: c.Manifest.Repositories},