Skip to content
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

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

chang-annie
Copy link
Contributor

@chang-annie chang-annie commented Aug 26, 2024

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, the exclude-tags parameter gets set to ,1.7.0,1.8.0 (with an extra comma at the front).

@@ -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
Copy link
Contributor Author

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/,$//')
Copy link
Contributor

@ewilkins-csi ewilkins-csi Aug 26, 2024

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?

Copy link
Contributor Author

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

@chang-annie chang-annie merged commit ba0a83e into dev Aug 26, 2024
@chang-annie chang-annie deleted the 270-2-adjust-prune-workflow-remove-empty-values branch August 26, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants