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

Method Template

pkg/devspace/helm/v3/client.go:154–223  ·  view source on GitHub ↗
(ctx devspacecontext.Context, releaseName, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig)

Source from the content-addressed store, hash-verified

152}
153
154func (c *client) Template(ctx devspacecontext.Context, releaseName, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (string, error) {
155 valuesFile, err := c.genericHelm.WriteValues(values)
156 if err != nil {
157 return "", err
158 }
159 defer os.Remove(valuesFile)
160
161 if releaseNamespace == "" {
162 releaseNamespace = ctx.KubeClient().Namespace()
163 }
164
165 args := []string{
166 "template",
167 releaseName,
168 "--values",
169 valuesFile,
170 }
171 if releaseNamespace != "" {
172 args = append(args, "--namespace", releaseNamespace)
173 }
174
175 // Chart settings
176 chartPath := ""
177 if helmConfig.Chart.Source != nil {
178 dependencyPath, err := dependencyutil.GetDependencyPath(ctx.WorkingDir(), helmConfig.Chart.Source)
179 if err != nil {
180 return "", err
181 }
182
183 chartPath = filepath.Dir(dependencyPath)
184 args = append(args, chartPath)
185 } else {
186 chartName, chartRepo := generic.ChartNameAndRepo(helmConfig)
187 chartPath = filepath.Join(ctx.WorkingDir(), chartName)
188 args = append(args, chartName)
189 if chartRepo != "" {
190 args = append(args, "--repo", chartRepo)
191 args = append(args, "--repository-config=''")
192 }
193 if helmConfig.Chart.Version != "" {
194 args = append(args, "--version", helmConfig.Chart.Version)
195 }
196 if helmConfig.Chart.Username != "" {
197 args = append(args, "--username", helmConfig.Chart.Username)
198 }
199 if helmConfig.Chart.Password != "" {
200 args = append(args, "--password", helmConfig.Chart.Password)
201 }
202 }
203
204 // Update dependencies if needed
205 if helmConfig.DisableDependencyUpdate == nil || (helmConfig.DisableDependencyUpdate != nil && !*helmConfig.DisableDependencyUpdate) {
206 stat, err := os.Stat(chartPath)
207 if err == nil && stat.IsDir() {
208 // Do not use --dependency-update because it will not update dependencies when the Chart.yaml is updated:
209 // https://github.com/helm/helm/issues/9545
210 _, err := c.genericHelm.Exec(ctx.WithWorkingDir(chartPath), []string{"dependency", "update"})
211 if err != nil {

Callers

nothing calls this directly

Calls 11

ChartNameAndRepoFunction · 0.92
WriteValuesMethod · 0.65
RemoveMethod · 0.65
NamespaceMethod · 0.65
KubeClientMethod · 0.65
WorkingDirMethod · 0.65
ExecMethod · 0.65
WithWorkingDirMethod · 0.65
LogMethod · 0.65
IsDirMethod · 0.45
WarnfMethod · 0.45

Tested by

no test coverage detected