Skip to content

Commit 969a46f

Browse files
committed
internal/helm: return callback on empty TLS config
...and no-op on empty valuesFile string.
1 parent 4da80b6 commit 969a46f

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

controllers/helmchart_controller.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ func (r *HelmChartReconciler) reconcileFromHelmRepository(ctx context.Context,
296296
err = fmt.Errorf("auth options error: %w", err)
297297
return sourcev1.HelmChartNotReady(chart, sourcev1.AuthenticationFailedReason, err.Error()), err
298298
}
299-
if cleanup != nil {
300-
defer cleanup()
301-
}
299+
defer cleanup()
302300
clientOpts = opts
303301
}
304302

@@ -435,11 +433,9 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
435433
return chart, nil
436434
}
437435

438-
// Overwrite default values if instructed to
439-
if chart.Spec.ValuesFile != "" {
440-
if err := helm.OverwriteChartDefaultValues(chartPath, chart.Spec.ValuesFile); err != nil {
441-
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
442-
}
436+
// Overwrite default values if configured
437+
if err := helm.OverwriteChartDefaultValues(chartPath, chart.Spec.ValuesFile); err != nil {
438+
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
443439
}
444440

445441
// Ensure artifact directory exists

controllers/helmrepository_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
195195
err = fmt.Errorf("auth options error: %w", err)
196196
return sourcev1.HelmRepositoryNotReady(repository, sourcev1.AuthenticationFailedReason, err.Error()), err
197197
}
198-
if cleanup != nil {
199-
defer cleanup()
200-
}
198+
defer cleanup()
201199
clientOpts = opts
202200
}
203201

internal/helm/chart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
// OverwriteChartDefaultValues overwrites the chart default values file in the
2929
// given chartPath with the contents of the given valuesFile.
3030
func OverwriteChartDefaultValues(chartPath, valuesFile string) error {
31-
if valuesFile == chartutil.ValuesfileName {
31+
if valuesFile == "" || valuesFile == chartutil.ValuesfileName {
3232
return nil
3333
}
3434
srcPath := path.Join(chartPath, valuesFile)

internal/helm/getter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TLSClientConfigFromSecret(secret corev1.Secret) (getter.Option, func(), err
6060
certBytes, keyBytes, caBytes := secret.Data["certFile"], secret.Data["keyFile"], secret.Data["caFile"]
6161
switch {
6262
case len(certBytes)+len(keyBytes)+len(caBytes) == 0:
63-
return nil, nil, nil
63+
return nil, func() {}, nil
6464
case (len(certBytes) > 0 && len(keyBytes) == 0) || (len(keyBytes) > 0 && len(certBytes) == 0):
6565
return nil, nil, fmt.Errorf("invalid '%s' secret data: fields 'certFile' and 'keyFile' require each other's presence",
6666
secret.Name)

0 commit comments

Comments
 (0)