fix: use %w for error wrapping in release values resolution
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
6fcfaf8bd8
commit
82ec080fcc
|
|
@ -1192,7 +1192,6 @@ func TestMergedReleaseTemplateData_InlineValues(t *testing.T) {
|
|||
if ingressMap["enabled"] != true {
|
||||
t.Errorf("expected ingress.enabled to be true, got %v", ingressMap["enabled"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func newTestHelmStateWithFiles(t *testing.T, files map[string]string) *HelmState {
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp
|
|||
cachedPatchTemplateDataSet = true
|
||||
cachedPatchTemplateData, cachedPatchTemplateDataErr = st.mergedReleaseTemplateData(release)
|
||||
if cachedPatchTemplateDataErr != nil {
|
||||
cachedPatchTemplateDataErr = fmt.Errorf("failed to compute merged release values for patch rendering: %v", cachedPatchTemplateDataErr)
|
||||
cachedPatchTemplateDataErr = fmt.Errorf("failed to compute merged release values for patch rendering: %w", cachedPatchTemplateDataErr)
|
||||
}
|
||||
}
|
||||
return cachedPatchTemplateData, cachedPatchTemplateDataErr
|
||||
|
|
|
|||
|
|
@ -4211,12 +4211,12 @@ func (st *HelmState) resolveReleaseValues(release *ReleaseSpec) (map[string]any,
|
|||
|
||||
yamlBytes, err := st.RenderReleaseValuesFileToBytes(release, path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to render values file \"%s\": %v", typedValue, err)
|
||||
return nil, fmt.Errorf("failed to render values file \"%s\": %w", typedValue, err)
|
||||
}
|
||||
|
||||
var rawVals map[string]any
|
||||
if err := yaml.Unmarshal(yamlBytes, &rawVals); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse values file \"%s\": %v", typedValue, err)
|
||||
return nil, fmt.Errorf("failed to parse values file \"%s\": %w", typedValue, err)
|
||||
}
|
||||
|
||||
// Normalize nested keys: yaml v2 may produce map[any]any for nested maps.
|
||||
|
|
@ -4224,7 +4224,7 @@ func (st *HelmState) resolveReleaseValues(release *ReleaseSpec) (map[string]any,
|
|||
// safe to call even when yaml v3 is in use and keys are already strings.
|
||||
normalizedVals, err := maputil.CastKeysToStrings(rawVals)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to normalize keys in values file \"%s\": %v", typedValue, err)
|
||||
return nil, fmt.Errorf("failed to normalize keys in values file \"%s\": %w", typedValue, err)
|
||||
}
|
||||
|
||||
merged = maputil.MergeMaps(merged, normalizedVals)
|
||||
|
|
|
|||
Loading…
Reference in New Issue