Skip to content

Commit

Permalink
Fix: Ensure that empty array of labels causes graceful exit (#123)
Browse files Browse the repository at this point in the history
* Ensure that empty array of labels causes graceful exit
* Changes to create_update_pr.sh affect stackrox and collector repos
  • Loading branch information
vikin91 authored Mar 16, 2022
1 parent 7c87afd commit 67b3694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .circleci/changes_affect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ affects_all() {
}

affects_collector() {
[[ " $* " =~ [[:space:]]images/collector.Dockerfile[[:space:]] ]]
[[ " $* " =~ [[:space:]]images/collector.Dockerfile[[:space:]] ]] \
|| [[ " $* " =~ [[:space:]]images/static-contents/scripts/create_update_pr.sh[[:space:]] ]]
}

affects_scanner() {
Expand All @@ -41,7 +42,8 @@ affects_stackrox() {
|| [[ " $* " =~ [[:space:]]images/stackrox-build.Dockerfile[[:space:]] ]] \
|| [[ " $* " =~ [[:space:]]images/stackrox-test.Dockerfile[[:space:]] ]] \
|| [[ " $* " =~ [[:space:]]images/circleci.Dockerfile[[:space:]] ]] \
|| [[ " $* " =~ [[:space:]]images/static-contents/etc/yum.repos.d/google-cloud-sdk.repo[[:space:]] ]]
|| [[ " $* " =~ [[:space:]]images/static-contents/etc/yum.repos.d/google-cloud-sdk.repo[[:space:]] ]] \
|| [[ " $* " =~ [[:space:]]images/static-contents/scripts/create_update_pr.sh[[:space:]] ]]
}

affects_jenkins-plugin() {
Expand Down
4 changes: 2 additions & 2 deletions images/static-contents/scripts/create_update_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ main() {
echo "Assigning PR to: '${CIRCLE_USERNAME}'"
set_assignee "$repo_name" "$pr_number" "$CIRCLE_USERNAME"

[[ "${#labels}" -gt 0 ]] || return 0
[[ "${#labels[@]}" -gt 0 ]] || return 0 # no labels to set
local labels_to_add=()
for label in "${labels[@]}"; do
if array_contains "$label" "${known_labels[@]}"; then
if [[ -n "$label" ]] && array_contains "$label" "${known_labels[@]}"; then
labels_to_add+=( "$label" )
else
echo "Skipping label '$label'"
Expand Down

0 comments on commit 67b3694

Please sign in to comment.