From f1b5768200a1e54e6be3fc331a071dba3dad7ad7 Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Thu, 21 Jan 2021 13:21:14 +0200 Subject: [PATCH] Fix values file override `io.Read` was used incorrectly to read from the override file provided by the user. This is now replaced with `ioutil.ReadFile` for better handling and error reporting. Fixes #263 Signed-off-by: Aurel Canciu --- controllers/helmchart_controller.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go index 8dcd22de..88eb50c5 100644 --- a/controllers/helmchart_controller.go +++ b/controllers/helmchart_controller.go @@ -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