Merge pull request #264 from fluxcd/fix-zero-len-values-file-override

Fix values file override
This commit is contained in:
Stefan Prodan 2021-01-21 14:03:51 +02:00 committed by GitHub
commit 2dac836772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -504,19 +504,12 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
err = fmt.Errorf("invalid values file path: %s", chart.Spec.ValuesFile)
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
}
src, err := os.Open(srcPath)
if err != nil {
err = fmt.Errorf("failed to open values file '%s': %w", chart.Spec.ValuesFile, err)
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
}
defer src.Close()
var valuesData []byte
if _, err := src.Read(valuesData); err != nil {
valuesData, err := ioutil.ReadFile(srcPath)
if err != nil {
err = fmt.Errorf("failed to read from values file '%s': %w", chart.Spec.ValuesFile, err)
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
}
isValuesFileOverriden, err = helm.OverwriteChartDefaultValues(helmChart, valuesData)
if err != nil {
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err