internal/helm: return callback on empty TLS config
...and no-op on empty valuesFile string.
This commit is contained in:
parent
4da80b65e5
commit
969a46f4d6
|
|
@ -296,9 +296,7 @@ func (r *HelmChartReconciler) reconcileFromHelmRepository(ctx context.Context,
|
||||||
err = fmt.Errorf("auth options error: %w", err)
|
err = fmt.Errorf("auth options error: %w", err)
|
||||||
return sourcev1.HelmChartNotReady(chart, sourcev1.AuthenticationFailedReason, err.Error()), err
|
return sourcev1.HelmChartNotReady(chart, sourcev1.AuthenticationFailedReason, err.Error()), err
|
||||||
}
|
}
|
||||||
if cleanup != nil {
|
defer cleanup()
|
||||||
defer cleanup()
|
|
||||||
}
|
|
||||||
clientOpts = opts
|
clientOpts = opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -435,11 +433,9 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
|
||||||
return chart, nil
|
return chart, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite default values if instructed to
|
// Overwrite default values if configured
|
||||||
if chart.Spec.ValuesFile != "" {
|
if err := helm.OverwriteChartDefaultValues(chartPath, chart.Spec.ValuesFile); err != nil {
|
||||||
if err := helm.OverwriteChartDefaultValues(chartPath, chart.Spec.ValuesFile); err != nil {
|
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
|
||||||
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure artifact directory exists
|
// Ensure artifact directory exists
|
||||||
|
|
|
||||||
|
|
@ -195,9 +195,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
|
||||||
err = fmt.Errorf("auth options error: %w", err)
|
err = fmt.Errorf("auth options error: %w", err)
|
||||||
return sourcev1.HelmRepositoryNotReady(repository, sourcev1.AuthenticationFailedReason, err.Error()), err
|
return sourcev1.HelmRepositoryNotReady(repository, sourcev1.AuthenticationFailedReason, err.Error()), err
|
||||||
}
|
}
|
||||||
if cleanup != nil {
|
defer cleanup()
|
||||||
defer cleanup()
|
|
||||||
}
|
|
||||||
clientOpts = opts
|
clientOpts = opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
// OverwriteChartDefaultValues overwrites the chart default values file in the
|
// OverwriteChartDefaultValues overwrites the chart default values file in the
|
||||||
// given chartPath with the contents of the given valuesFile.
|
// given chartPath with the contents of the given valuesFile.
|
||||||
func OverwriteChartDefaultValues(chartPath, valuesFile string) error {
|
func OverwriteChartDefaultValues(chartPath, valuesFile string) error {
|
||||||
if valuesFile == chartutil.ValuesfileName {
|
if valuesFile == "" || valuesFile == chartutil.ValuesfileName {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
srcPath := path.Join(chartPath, valuesFile)
|
srcPath := path.Join(chartPath, valuesFile)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ func TLSClientConfigFromSecret(secret corev1.Secret) (getter.Option, func(), err
|
||||||
certBytes, keyBytes, caBytes := secret.Data["certFile"], secret.Data["keyFile"], secret.Data["caFile"]
|
certBytes, keyBytes, caBytes := secret.Data["certFile"], secret.Data["keyFile"], secret.Data["caFile"]
|
||||||
switch {
|
switch {
|
||||||
case len(certBytes)+len(keyBytes)+len(caBytes) == 0:
|
case len(certBytes)+len(keyBytes)+len(caBytes) == 0:
|
||||||
return nil, nil, nil
|
return nil, func() {}, nil
|
||||||
case (len(certBytes) > 0 && len(keyBytes) == 0) || (len(keyBytes) > 0 && len(certBytes) == 0):
|
case (len(certBytes) > 0 && len(keyBytes) == 0) || (len(keyBytes) > 0 && len(certBytes) == 0):
|
||||||
return nil, nil, fmt.Errorf("invalid '%s' secret data: fields 'certFile' and 'keyFile' require each other's presence",
|
return nil, nil, fmt.Errorf("invalid '%s' secret data: fields 'certFile' and 'keyFile' require each other's presence",
|
||||||
secret.Name)
|
secret.Name)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue