Skip to content

Commit

Permalink
fix(helm): Detect already pulled charts (#402)
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
justinwalz authored Oct 24, 2020
1 parent 59a5f5f commit 1220d14
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/helm/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func (c Charts) Vendor() error {

log.Println("Pulling Charts ...")
for _, r := range c.Manifest.Requires {
chartName := parseReqName(r.Chart)
chartPath := filepath.Join(dir, chartName)
if _, err := os.Stat(chartPath); err == nil {
log.Printf(" %s@%s exists", r.Chart, r.Version.String())
continue
}

err := c.Helm.Pull(r.Chart, r.Version.String(), PullOpts{
Destination: dir,
Opts: Opts{Repositories: c.Manifest.Repositories},
Expand All @@ -101,7 +108,7 @@ func (c Charts) Vendor() error {
return err
}

log.Printf(" %s@%s", r.Chart, r.Version.String())
log.Printf(" %s@%s downloaded", r.Chart, r.Version.String())
}

return nil
Expand Down Expand Up @@ -199,3 +206,10 @@ func parseReq(s string) (*Requirement, error) {
Version: *ver,
}, nil
}

// parseReqName parses a name from a string of the format `repo/name`
func parseReqName(s string) string {
elems := strings.Split(s, "/")
name := elems[1]
return name
}

0 comments on commit 1220d14

Please sign in to comment.