Pass a copy of the runifs #1100
Merged
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.
Checklist
README.md
is updated with the changes (if needed)Version
Requires a PATCH version update
Context
There is an issue with run_if propagation when there is an embedded bundle mixed with steps inside a step bundle. Here is a rough example:
Using the above example, what happens is that the run_if statement from the B bundle gets inherited by the script inside the A bundle. This is incorrect as only the steps inside the B bundle should inherit the bundle's run_if statement. The A bundle has no run_ifs specified so the A bundle's script step should have no run_if statement.
We are using a recursive function to resolve all of the step bundles as there could be embedded bundles inside a bundle. The embedded bundles should inherit the parents run_if statements so we pass the so far collected run_if statements to this recursive function as we iterate over the embedded items. The Go slice is a value type from the outside but actually it wraps a pointer to the actual data inside. So passing it around and adding items to it will update all of the slices internal data storage as there is only a single one backing every value type. That is why the first embedded step bundle's run_if collection was carried over to the next step item.
The solution is to make a hard copy of the run_ifs slice which will be passed to the recursive function.