in internal/generators/helm.go [239:299]
func (hg *HelmGenerator) Install(c *core.Component) (err error) {
// Install the chart
if (c.Method == "helm" || c.Method == "git") && c.Source != "" && c.Path != "" {
// Download the helm chart
helmRepoPath := hg.makeHelmRepoPath(c)
switch c.Method {
case "helm":
logger.Info(emoji.Sprintf(":helicopter: Component '%s' requesting helm chart '%s' from helm repository '%s'", c.Name, c.Path, c.Source))
// Pull to a temporary directory
tmpHelmDir, err := ioutil.TempDir("", "fabrikate")
defer os.RemoveAll(tmpHelmDir)
if err != nil {
return err
}
if err = helm.Pull(c.Source, c.Path, c.Version, tmpHelmDir); err != nil {
return err
}
// Create the component directory -- deleting if it already exists
if err != nil {
return err
}
if err := os.RemoveAll(helmRepoPath); err != nil {
return err
}
// ensure the parent directory exists
if err := os.MkdirAll(filepath.Dir(helmRepoPath), 0755); err != nil {
return err
}
// Move the extracted chart from tmp to the helm_repos
extractedChartPath := path.Join(tmpHelmDir, c.Path)
if err := os.Rename(extractedChartPath, helmRepoPath); err != nil {
return err
}
case "git":
// Clone whole repo into helm repo path
logger.Info(emoji.Sprintf(":helicopter: Component '%s' requesting helm chart in path '%s' from git repository '%s'", c.Name, c.Source, c.PhysicalPath))
cloneOpts := &git.CloneOpts{
URL: c.Source,
SHA: c.Version,
Branch: c.Branch,
Into: helmRepoPath,
}
if err = git.Clone(cloneOpts); err != nil {
return err
}
// Update chart dependencies in chart path -- this is manually done here but automatically done in downloadChart in the case of `method: helm`
chartPath, err := hg.getChartPath(c)
if err != nil {
return err
}
if err = helm.DependencyUpdate(chartPath); err != nil {
return err
}
}
}
return err
}