fix(init.sh): streamline image pulling and saving process with associative array #5872
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.
This pull request refactors the image pulling and saving logic in
deploy/cloud/init.shto make it more maintainable and scalable. Instead of listing each image and its tar file individually, the script now uses an associative array to manage image-to-tar mappings and loops over them to perform the operations. This reduces code duplication and makes it easier to add or modify images in the future.Refactoring and maintainability improvements:
retryPullImageandsealos savecalls with a single associative array (images) mapping image names to their respective tar files, streamlining the process.tarsdirectory is created before saving images, improving robustness.