|
20 | 20 | - name: affected_catalogs |
21 | 21 | description: Comma separated list of updated catalogs |
22 | 22 |
|
| 23 | + - name: affected_catalog_operators |
| 24 | + description: Comma separated list of operators inside all catalogs |
| 25 | + |
23 | 26 | - name: github_token_secret_name |
24 | 27 | description: The name of the Kubernetes Secret that contains the GitHub token. |
25 | 28 | default: github |
|
52 | 55 | TITLE="operator $(params.operator_name) ($(params.bundle_version))" |
53 | 56 |
|
54 | 57 | elif [[ "$(params.affected_catalogs)" != "" ]]; then |
55 | | - # Update of catalogs only |
56 | | - TITLE="Catalog update [$(params.affected_catalogs)]" |
| 58 | + # Update of catalogs only, can get quite long |
| 59 | +
|
| 60 | + # Limit that is shown by GH API |
| 61 | + MAX_TITLE_LEN=256 |
| 62 | +
|
| 63 | + TITLE_BEGINNING="Catalog update [" |
| 64 | + TITLE_ENDING="] [$(params.affected_catalogs)]" |
| 65 | +
|
| 66 | + # Catalog Operators are in the following format: |
| 67 | + # catalogVersion1/operator1,catalogVersion2/operator1,... |
| 68 | + # We need to trim Catalog version from all operators in 5 steps: |
| 69 | + # Step 1: split operators |
| 70 | + IFS=',' read -ra RAW_OPERATOR_ARR <<< "$(params.affected_catalog_operators)" |
| 71 | + unset IFS |
| 72 | + OPERATOR_ARR=() |
| 73 | +
|
| 74 | + # Step 2: Remove everything before the first '/' in each operator |
| 75 | + for OPERATOR in "${RAW_OPERATOR_ARR[@]}"; do |
| 76 | + OPERATOR_ARR+=("${OPERATOR#*/}") |
| 77 | + done |
| 78 | +
|
| 79 | + # Step 3: dedup the array |
| 80 | + IFS=' ' read -ra OPERATOR_ARR <<< "$(echo "${OPERATOR_ARR[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')" |
| 81 | + unset IFS |
| 82 | +
|
| 83 | + # Step 4: Join operator names back |
| 84 | + TITLE_MIDDLE=$(printf ",%s" "${OPERATOR_ARR[@]}") |
| 85 | +
|
| 86 | + # Step 5: Remove the heading ',' |
| 87 | + TITLE_MIDDLE="${TITLE_MIDDLE:1}" |
| 88 | +
|
| 89 | + FREE_CAPACITY=$(( "${MAX_TITLE_LEN}" - $(echo "${TITLE_BEGINNING}" | wc -m) - $( echo "${TITLE_ENDING}" | wc -m) )) |
| 90 | +
|
| 91 | + # Shorten the middle part if it is too long |
| 92 | + if [[ $(echo "${TITLE_MIDDLE}" | wc -m) -gt "${FREE_CAPACITY}" ]]; then |
| 93 | + CUT_TO_LENGTH=$(( "${FREE_CAPACITY}" - 3 )) |
| 94 | + TITLE_MIDDLE="${TITLE_MIDDLE::${CUT_TO_LENGTH}}..." |
| 95 | + fi |
| 96 | + TITLE="${TITLE_BEGINNING}${TITLE_MIDDLE}${TITLE_ENDING}" |
57 | 97 |
|
58 | 98 | else |
59 | 99 | echo "No bundles nor catalogs have been added/updated" |
|
0 commit comments