diff --git a/core/component.go b/core/component.go index 948bed3..47c29ce 100644 --- a/core/component.go +++ b/core/component.go @@ -391,7 +391,7 @@ func (c *Component) Write() (err error) { filename := fmt.Sprintf("component.%s", c.Serialization) componentPath := path.Join(c.PhysicalPath, filename) - log.Info(emoji.Sprintf(":floppy_disk: Writing %s", componentPath)) + log.Info(emoji.Sprintf(":floppy_disk: Writing '%s'", componentPath)) return ioutil.WriteFile(componentPath, marshaledComponent, 0644) } @@ -466,7 +466,7 @@ func (c *Component) GetAccessTokens() (tokens map[string]string, err error) { // If the file is not found, return an empty map with no error return map[string]string{}, nil } else if err != nil { - log.Error(emoji.Sprintf(":no_entry_sign: Error unmarshalling access.yaml in %s", accessYamlPath)) + log.Error(emoji.Sprintf(":no_entry_sign: Error unmarshalling access.yaml in '%s'", accessYamlPath)) return nil, err } @@ -475,7 +475,7 @@ func (c *Component) GetAccessTokens() (tokens map[string]string, err error) { token := os.Getenv(envVar) if token == "" { // Give warning that failed to load env var; but continue and attempt clone - msg := fmt.Sprintf("Component %s attempted to load environment variable %s; but is either not set or an empty string. Components with source %s may fail to install", c.Name, envVar, repo) + msg := fmt.Sprintf("Component '%s' attempted to load environment variable '%s'; but is either not set or an empty string. Components with source '%s' may fail to install", c.Name, envVar, repo) log.Warn(emoji.Sprintf(":no_entry_sign: %s", msg)) } else { tokens[repo] = token diff --git a/generators/helm.go b/generators/helm.go index ce9ce41..335dc17 100644 --- a/generators/helm.go +++ b/generators/helm.go @@ -159,19 +159,17 @@ func (hg *HelmGenerator) Install(c *core.Component) (err error) { if err = core.CloneRepo(c.Source, c.Version, helmRepoPath, c.Branch); err != nil { return err } + // Remove .git + _ = os.RemoveAll(path.Join(helmRepoPath, ".git")) + // Update chart dependencies in chart path -- this is manually done here but automatically done in downloadChart + chartPath, err := hg.getChartPath(c) + if err != nil { + return err + } + _ = updateHelmChartDep(chartPath) } } - // Update chart dependencies -- don't fail if error is returned, but throw warning - chartPath, err := hg.getChartPath(c) - if err != nil { - return err - } - log.Info(emoji.Sprintf(":helicopter: Updating helm chart's dependencies for component '%s'", c.Name)) - if output, err := exec.Command("helm", "dependency", "update", chartPath).CombinedOutput(); err != nil { - log.Warn(emoji.Sprintf(":no_entry_sign: Updating chart dependencies failed for chart '%s' in component '%s'; run `helm dependency update %s` for more error details.\n%s: %s", c.Name, c.Path, chartPath, err, output)) - } - return err } @@ -217,6 +215,9 @@ func (hd *helmDownloader) downloadChart(repo, chart, into string) (err error) { return err } + // Update chart dependencies before removing temp repo + _ = updateHelmChartDep(into) + // Remove repository once completed log.Info(emoji.Sprintf(":bomb: Removing temporary helm repo %s", randomName)) hd.mu.Lock() @@ -230,3 +231,22 @@ func (hd *helmDownloader) downloadChart(repo, chart, into string) (err error) { chartDirectoryInRandomDir := path.Join(randomDir, chart) return copy.Copy(chartDirectoryInRandomDir, into) } + +// updateHelmChartDep attempts to run `helm dependency update` on chartPath +func updateHelmChartDep(chartPath string) (err error) { + absChartPath := chartPath + if isAbs := filepath.IsAbs(absChartPath); !isAbs { + asAbs, err := filepath.Abs(chartPath) + if err != nil { + return err + } + absChartPath = asAbs + } + log.Info(emoji.Sprintf(":helicopter: Updating helm chart's dependencies for chart in '%s'", absChartPath)) + if output, err := exec.Command("helm", "dependency", "update", chartPath).CombinedOutput(); err != nil { + log.Warn(emoji.Sprintf(":no_entry_sign: Updating chart dependencies failed for chart in '%s'; run `helm dependency update %s` for more error details.\n%s: %s", absChartPath, absChartPath, err, output)) + return err + } + + return err +}