Skip to content

Commit

Permalink
Workaround helm complaining about the directory already existing
Browse files Browse the repository at this point in the history
  • Loading branch information
luxas committed May 5, 2022
1 parent 0127c3e commit 9476fe3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,19 @@ func downloadChart(ctx context.Context, externalChartFile string) error {
log.Infof("Found external chart to download %q", externalChart)
// This extracts the chart to e.g. .cache/kubernetes-dashboard/{Chart.yaml,values.yaml,templates}
cacheDir := util.JoinPaths(ctx, constants.CacheDir)
_, _, err = util.Command(ctx, "helm", "fetch", externalChart, "--untar", "--untardir", cacheDir).Run()
return err
tmpCacheDir := util.JoinPaths(ctx, cacheDir, "tmp")

if exists, _ := util.PathExists(tmpCacheDir); exists {
if err := os.RemoveAll(tmpCacheDir); err != nil {
return err
}
}

_, _, err = util.Command(ctx, "helm", "fetch", externalChart, "--untar", "--untardir", tmpCacheDir).Run()
if err != nil {
return err
}
return util.Copy(tmpCacheDir, cacheDir)
}

func GenerateChart(ctx context.Context, cd *ChartData, clusterInfo *config.ClusterInfo, valuesProcessors, chartProcessors []Processor) error {
Expand Down

0 comments on commit 9476fe3

Please sign in to comment.