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 <aurelcanciu@gmail.com>
This commit is contained in:
parent
00d9d1d209
commit
f1b5768200
|
@ -504,19 +504,12 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
|
||||||
err = fmt.Errorf("invalid values file path: %s", chart.Spec.ValuesFile)
|
err = fmt.Errorf("invalid values file path: %s", chart.Spec.ValuesFile)
|
||||||
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
|
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
|
valuesData, err := ioutil.ReadFile(srcPath)
|
||||||
if _, err := src.Read(valuesData); err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("failed to read from values file '%s': %w", chart.Spec.ValuesFile, err)
|
err = fmt.Errorf("failed to read from values file '%s': %w", chart.Spec.ValuesFile, err)
|
||||||
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
|
return sourcev1.HelmChartNotReady(chart, sourcev1.StorageOperationFailedReason, err.Error()), err
|
||||||
}
|
}
|
||||||
|
|
||||||
isValuesFileOverriden, err = helm.OverwriteChartDefaultValues(helmChart, valuesData)
|
isValuesFileOverriden, err = helm.OverwriteChartDefaultValues(helmChart, valuesData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
|
return sourcev1.HelmChartNotReady(chart, sourcev1.ChartPackageFailedReason, err.Error()), err
|
||||||
|
|
Loading…
Reference in New Issue