InstallChart installs the given chart via helm v3
(ctx devspacecontext.Context, releaseName string, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig)
| 40 | |
| 41 | // InstallChart installs the given chart via helm v3 |
| 42 | func (c *client) InstallChart(ctx devspacecontext.Context, releaseName string, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (*types.Release, error) { |
| 43 | valuesFile, err := c.genericHelm.WriteValues(values) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | defer os.Remove(valuesFile) |
| 48 | |
| 49 | if releaseNamespace == "" { |
| 50 | releaseNamespace = ctx.KubeClient().Namespace() |
| 51 | } |
| 52 | |
| 53 | args := []string{ |
| 54 | "upgrade", |
| 55 | releaseName, |
| 56 | "--values", |
| 57 | valuesFile, |
| 58 | "--install", |
| 59 | } |
| 60 | |
| 61 | // Add debug flag |
| 62 | if ctx.Log().GetLevel() == logrus.DebugLevel { |
| 63 | args = append(args, "--debug") |
| 64 | } |
| 65 | |
| 66 | if releaseNamespace != "" { |
| 67 | args = append(args, "--namespace", releaseNamespace) |
| 68 | } |
| 69 | |
| 70 | // Chart settings |
| 71 | chartPath := "" |
| 72 | if helmConfig.Chart.Source != nil { |
| 73 | dependencyPath, err := dependencyutil.GetDependencyPath(ctx.WorkingDir(), helmConfig.Chart.Source) |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | |
| 78 | chartPath = filepath.Dir(dependencyPath) |
| 79 | args = append(args, chartPath) |
| 80 | } else { |
| 81 | chartName, chartRepo := generic.ChartNameAndRepo(helmConfig) |
| 82 | chartPath = filepath.Join(ctx.WorkingDir(), chartName) |
| 83 | args = append(args, chartName) |
| 84 | if chartRepo != "" { |
| 85 | args = append(args, "--repo", chartRepo) |
| 86 | args = append(args, "--repository-config=''") |
| 87 | } |
| 88 | if helmConfig.Chart.Version != "" { |
| 89 | args = append(args, "--version", helmConfig.Chart.Version) |
| 90 | } |
| 91 | |
| 92 | // log into OCI registry if specified |
| 93 | if strings.HasPrefix(chartName, "oci://") { |
| 94 | if helmConfig.Chart.Username != "" && helmConfig.Chart.Password != "" { |
| 95 | chartNameURL, err := url.Parse(chartName) |
| 96 | if err != nil { |
| 97 | return nil, errors.Wrap(err, "chartName malformed for oci registry") |
| 98 | } |
| 99 |
nothing calls this directly
no test coverage detected