MCPcopy Index your code
hub / github.com/devspace-sh/devspace / InstallChart

Method InstallChart

pkg/devspace/helm/v3/client.go:42–152  ·  view source on GitHub ↗

InstallChart installs the given chart via helm v3

(ctx devspacecontext.Context, releaseName string, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig)

Source from the content-addressed store, hash-verified

40
41// InstallChart installs the given chart via helm v3
42func (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

Callers

nothing calls this directly

Calls 15

ListReleasesMethod · 0.95
ChartNameAndRepoFunction · 0.92
WriteValuesMethod · 0.65
RemoveMethod · 0.65
NamespaceMethod · 0.65
KubeClientMethod · 0.65
LogMethod · 0.65
WorkingDirMethod · 0.65
ParseMethod · 0.65
ExecMethod · 0.65
WithWorkingDirMethod · 0.65
WriterMethod · 0.65

Tested by

no test coverage detected