Skip to content

Commit 0d75e74

Browse files
authored
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.
1 parent d548e54 commit 0d75e74

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/helm/charts.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ func (c Charts) Vendor() error {
9191
return err
9292
}
9393

94-
log.Println("Syncing Repositories ...")
95-
if err := c.Helm.RepoUpdate(Opts{Repositories: c.Manifest.Repositories}); err != nil {
96-
return err
97-
}
98-
94+
repositoriesUpdated := false
9995
log.Println("Pulling Charts ...")
10096
for _, r := range c.Manifest.Requires {
10197
chartName := parseReqName(r.Chart)
@@ -126,6 +122,13 @@ func (c Charts) Vendor() error {
126122
return err
127123
}
128124

125+
if !repositoriesUpdated {
126+
log.Println("Syncing Repositories ...")
127+
if err := c.Helm.RepoUpdate(Opts{Repositories: c.Manifest.Repositories}); err != nil {
128+
return err
129+
}
130+
repositoriesUpdated = true
131+
}
129132
err = c.Helm.Pull(r.Chart, r.Version.String(), PullOpts{
130133
Destination: dir,
131134
Opts: Opts{Repositories: c.Manifest.Repositories},

0 commit comments

Comments
 (0)