Skip to content

Commit

Permalink
feat(tool/charts): Only update helm repositories when necessary (graf…
Browse files Browse the repository at this point in the history
…ana#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.
  • Loading branch information
craigfurman authored Mar 18, 2021
1 parent d548e54 commit 0d75e74
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/helm/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 0d75e74

Please sign in to comment.