Skip to content

Commit 1220d14

Browse files
authored
fix(helm): Detect already pulled charts (#402)
No longer attempts to download Helm Charts that are already locally in the `charts` folder. To re-download a chart, `rm` it from the `charts` folder and run `tk tool charts vendor` again!
1 parent 59a5f5f commit 1220d14

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/helm/charts.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ func (c Charts) Vendor() error {
9393

9494
log.Println("Pulling Charts ...")
9595
for _, r := range c.Manifest.Requires {
96+
chartName := parseReqName(r.Chart)
97+
chartPath := filepath.Join(dir, chartName)
98+
if _, err := os.Stat(chartPath); err == nil {
99+
log.Printf(" %s@%s exists", r.Chart, r.Version.String())
100+
continue
101+
}
102+
96103
err := c.Helm.Pull(r.Chart, r.Version.String(), PullOpts{
97104
Destination: dir,
98105
Opts: Opts{Repositories: c.Manifest.Repositories},
@@ -101,7 +108,7 @@ func (c Charts) Vendor() error {
101108
return err
102109
}
103110

104-
log.Printf(" %s@%s", r.Chart, r.Version.String())
111+
log.Printf(" %s@%s downloaded", r.Chart, r.Version.String())
105112
}
106113

107114
return nil
@@ -199,3 +206,10 @@ func parseReq(s string) (*Requirement, error) {
199206
Version: *ver,
200207
}, nil
201208
}
209+
210+
// parseReqName parses a name from a string of the format `repo/name`
211+
func parseReqName(s string) string {
212+
elems := strings.Split(s, "/")
213+
name := elems[1]
214+
return name
215+
}

0 commit comments

Comments
 (0)