feat: added mergo to handle the differences between versions of jx-requirements.yml when upgrading a cluster #5912
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.
Submitter checklist
Description
Created a new function to merge a given requirements struct with the calling one's data and save the output in the given path.
We are using
mergo
to do so. It will work for any struct and any number of nested structs within the requirements file.A Transformer however was needed to handle the slice of EnvironmentConfig structs as we want to modify any existing ones with the ones provided in the given requirements file and also append to the slice if there's a new one.
Mergo will always take the calling requirements as base and replace any property with the given requirement's data if and only if the property from the given requirements file is non-zero valued.
Also removed the function that obtained the VersionsStreamConfig from the requirements file because it basically checked that the file existed and returned the versions stream ref struct. These checks are already done when loading the requirements file so it wasn't needed.
Special notes for the reviewer(s)
Which issue this PR fixes
fixes #5896