-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#270-2 Fix to remove empty values from release_values #297
#270-2 Fix to remove empty values from release_values #297
Conversation
@@ -49,8 +49,8 @@ jobs: | |||
# replace all whitespaces with newline (required for sort) and then sort all release versions while removing any duplicates | |||
all_release_versions_sorted=$(echo "${all_release_versions[@]}" | tr ' ' '\n'| sort -u ) | |||
|
|||
# replace the newlines with commas and then remove the trailing comma | |||
all_release_versions=$(echo "${all_release_versions_sorted[@]}" | tr '\n' ',' | sed 's/,$//') | |||
# remove any blank rows, replace the newlines with commas, then remove the trailing comma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I: sed -r '/^\s*$/d'
command checks for any rows that only contain whitespace and deletes it
# replace the newlines with commas and then remove the trailing comma | ||
all_release_versions=$(echo "${all_release_versions_sorted[@]}" | tr '\n' ',' | sed 's/,$//') | ||
# remove any blank rows, replace the newlines with commas, then remove the trailing comma | ||
all_release_versions=$(echo "${all_release_versions_sorted[@]}" | sed -r '/^\s*$/d'| tr '\n' ',' | sed 's/,$//') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q/A: Can you not just use a -z
test of release_versions
on line 46?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ewilkins-csi similar to the -z
zero length check, we could use the -n
not empty check and loop through the release_versions
array
# Iterate over each element in release_versions
for version in "${release_versions[@]}"; do
# Check if the element is not empty
if [ -n "$version" ]; then
# Append the element to all_release_versions
all_release_versions+=("$version")
fi
done
in our case, I think adding the command to remove blank rows at the end is fine since we don't have that many docker images
This is to remove any rows that are blank from the
all_release_versions
array before saving them to output. Without this added logic, if we have any docker images that do not have any release versions, theexclude-tags
parameter gets set to,1.7.0,1.8.0
(with an extra comma at the front).