helm/cli: don't swallow error in BuildChartDependencies #9851
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do / Why do we need it:
In BuildChartDependencies function, we add the repositories, build the dependencies and thanks to a
defer
function, we remove the repository.The problem is that if the
helm repo add
fails, the error is swallowed by the defer function. (doinghelm repo remove
with no repository added triggers the following errorError: no repositories configured.
)as you can see in this the root cause ( the error from the
helm repo add
) is hidden.This PR moves the
defer
function after thehelm add repo
so we don't try to remove a repository that does not exist. It also combines previous errors (e.g. error fromhelm dependency build
) with error fromhelm repo remove
repository.Does this PR close any issues?:
Fixes #
Special notes for your reviewer:
Example of output for the different cases:
the case where add repo fails
the case where build dependencies fails
the case where build dependencies and remove repo fail
the case where remove repo fails
Documentation:
Does this PR introduce a user-facing change?: