Skip to content

Commit b144399

Browse files
committed
fix(helm): Check prior vendoring of helm charts
1 parent a18afbf commit b144399

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pkg/helm/charts.go

+19-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,14 @@ 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` or `name`
211+
func parseReqName(s string) string {
212+
if !strings.Contains(s, "/") {
213+
return s
214+
}
215+
216+
elems := strings.Split(s, "/")
217+
name := elems[1]
218+
return name
219+
}

0 commit comments

Comments
 (0)