Skip to content

Commit c22001d

Browse files
committed
fix sort order to be consistent across OSes; sort the preinstalled list too
Signed-off-by: Nick Boldt <nboldt@redhat.com>
1 parent 4486abe commit c22001d

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

modules/extend_dynamic-plugins-reference/rhdh-supported-plugins.sh

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ $0 -b stable-ref-branch [options]
6060
Options:
6161
-b, --ref-branch : Branch against which plugin versions should be incremented, like release-1.y; default: main
6262
--skip-tables : Skip re-generating dynamic plugin tables and .csv
63-
--skip-community-table : Skip re-generating the community plugins table
63+
--skip-community-table : Skip re-generating the community plugins table
6464
--clean : Force a clean GH checkout (do not reuse files on disk)
6565
-v : more verbose output
6666
-h, --help : Show this help
@@ -157,7 +157,7 @@ generate_dynamic_plugins_table() {
157157
fi
158158
jq -r '.dependencies' "${rhdhtmpdir}"/packages/{app,backend}/package.json | grep -E -v "\"\*\"|\{|\}" | grep "@" | tr -d "," >> "$pluginVersFile"
159159
# Use LC_ALL=C for consistent sorting across different locales
160-
sort -u "$pluginVersFile" > "$pluginVersFile".out; mv -f "$pluginVersFile".out "$pluginVersFile"
160+
LC_ALL=C sort -u "$pluginVersFile" > "$pluginVersFile".out; mv -f "$pluginVersFile".out "$pluginVersFile"
161161

162162
rm -fr /tmp/warnings_"${BRANCH}".txt
163163

@@ -272,14 +272,14 @@ generate_dynamic_plugins_table() {
272272

273273
# check if there's a newer version at npmjs.com and warn if so
274274
# for tags and associated repo digests (git head)
275-
# curl -sSLko- https://registry.npmjs.org/@janus-idp%2fcli | jq -r '.versions[]|(.version+", "+.gitHead)' | sort -uV
275+
# curl -sSLko- https://registry.npmjs.org/@janus-idp%2fcli | jq -r '.versions[]|(.version+", "+.gitHead)' | LC_ALL=C sort -uV
276276
# for timestamp when tag is created
277-
# curl -sSLko- https://registry.npmjs.org/@janus-idp%2fcli | jq -r '.time' | grep -v -E "created|modified|{|}" | sort -uV
277+
# curl -sSLko- https://registry.npmjs.org/@janus-idp%2fcli | jq -r '.time' | grep -v -E "created|modified|{|}" | LC_ALL=C sort -uV
278278
# echo "Searching for ${Plugin/\//%2f} at npmjs.org..."
279279
allVersionsPublished="$(curl -sSLko- "https://registry.npmjs.org/${Plugin/\//%2f}" | jq -r '.versions[].version')"
280280
# echo "Found $allVersionsPublished"
281281
# clean out any pre-release versions
282-
latestXYRelease="$(echo "$allVersionsPublished" | grep -v -E -- "next|alpha|-" | grep -E "^${Version%.*}" | sort -u | tail -1)"
282+
latestXYRelease="$(echo "$allVersionsPublished" | grep -v -E -- "next|alpha|-" | grep -E "^${Version%.*}" | LC_ALL=C sort -u | tail -1)"
283283
# echo "[DEBUG] Latest x.y version at https://registry.npmjs.org/${Plugin/\//%2f} : $latestXYRelease"
284284
if [[ "$latestXYRelease" != "$Version" ]]; then
285285
echo -e "${blue}[WARN] Can upgrade $Version to https://www.npmjs.com/package/$Plugin/v/$latestXYRelease ${norm}" | tee -a /tmp/warnings_"${BRANCH}".txt
@@ -335,7 +335,7 @@ generate_dynamic_plugins_table() {
335335
if [[ -n "$appConfig" && "$appConfig" != "null" ]]; then
336336
# Extract ${VARIABLE_NAME} patterns
337337
# shellcheck disable=SC2016
338-
vars=$(echo "$appConfig" | grep -o '\${[^}]*}' | sed 's/\${//g' | sed 's/}//g' | sort -u)
338+
vars=$(echo "$appConfig" | grep -o '\${[^}]*}' | sed 's/\${//g' | sed 's/}//g' | LC_ALL=C sort -u)
339339
for var in $vars; do
340340
if [[ $var ]]; then
341341
Required_Variables="${Required_Variables}\`$var\`\n\n"
@@ -410,8 +410,8 @@ generate_dynamic_plugins_table() {
410410
echo "$key|$adoc_content" >> "$TEMP_DIR/adoc.production.tmp"
411411
elif [[ ${Support_Level} == "Red Hat Tech Preview" ]]; then
412412
echo "$key|$adoc_content" >> "$TEMP_DIR/adoc.tech-preview.tmp"
413-
else
414-
echo "$key|$adoc_content" >> "$TEMP_DIR/adoc.community.tmp"
413+
# else
414+
# echo "$key|$adoc_content" >> "$TEMP_DIR/adoc.community.tmp"
415415
fi
416416

417417
# Group CSV by support level
@@ -443,7 +443,7 @@ generate_dynamic_plugins_table() {
443443
rm -f "$out_file"
444444
count=0
445445
if [[ -f "$temp_file" ]]; then
446-
sort "$temp_file" | while IFS='|' read -r key content; do
446+
LC_ALL=C sort "$temp_file" | while IFS='|' read -r key content; do
447447
(( count = count + 1 ))
448448
debug " * [$count] $key [ ${out_file##*/} ]"
449449
echo -e "$content" >> "$out_file"
@@ -459,7 +459,7 @@ generate_dynamic_plugins_table() {
459459
rm -f "$out_file"
460460
count=0
461461
if [[ -f "$temp_file" ]]; then
462-
sort "$temp_file" | while IFS='|' read -r key content; do
462+
LC_ALL=C sort "$temp_file" | while IFS='|' read -r key content; do
463463
(( count = count + 1 ))
464464
debug " * [$count] $key [ ${out_file##*/} ]"
465465
echo -e "$content" >> "$out_file"
@@ -476,7 +476,7 @@ generate_dynamic_plugins_table() {
476476
rm -f "$out_file"
477477
count=0
478478
if [[ -f "$temp_file" ]]; then
479-
sort "$temp_file" | while IFS='|' read -r key content; do
479+
LC_ALL=C sort "$temp_file" | while IFS='|' read -r key content; do
480480
(( count = count + 1 ))
481481
debug " * [$count] $key [ ${out_file##*/} ]"
482482
echo -e "$content" >> "$out_file"
@@ -486,10 +486,10 @@ generate_dynamic_plugins_table() {
486486
# shellcheck disable=SC2206
487487
num_plugins+=($count)
488488

489-
# Process CSV: sort by SupportSort (1,2,3,4) then PrettyName, and omit techdocs
489+
# Process CSV: LC_ALL=C sort by SupportLC_ALL=C sort (1,2,3,4) then PrettyName, and omit techdocs
490490
if [[ -f "$TEMP_DIR/csv.tmp" ]]; then
491491
debug
492-
sort -t '|' -k1,1 -k2,2 "$TEMP_DIR/csv.tmp" | while IFS='|' read -r key content; do
492+
LC_ALL=C sort -t '|' -k1,1 -k2,2 "$TEMP_DIR/csv.tmp" | while IFS='|' read -r key content; do
493493
# RHIDP-4196 omit techdocs plugins from the .csv
494494
if [[ $key != *"techdocs"* ]]; then
495495
echo -e "$content" >> "${0/.sh/.csv}"
@@ -501,7 +501,7 @@ generate_dynamic_plugins_table() {
501501

502502
debug
503503

504-
# merge the content from the 4 .adocX files into the .template.adoc file, replacing the TABLE_CONTENT markers
504+
# merge the content from the 3 .adocX files into the .template.adoc file, replacing the TABLE_CONTENT markers
505505
count=1
506506
index=0
507507
empties=0
@@ -526,11 +526,15 @@ generate_dynamic_plugins_table() {
526526
echo ""
527527
(( count = count + 1 ))
528528
done
529-
# count enabled plugins
529+
530+
# LC_ALL=C sort the list of enabled plugins
531+
LC_ALL=C sort -uV "$ENABLED_PLUGINS" > "$ENABLED_PLUGINS".sorted; mv -f "$ENABLED_PLUGINS".sorted "$ENABLED_PLUGINS"
530532

531533
# shellcheck disable=SC2002
532534
COUNT_ENABLED_PLUGINS=$(cat "$ENABLED_PLUGINS" | wc -l ) # if we use wc by itself we get the count AND the filename; only want the count
535+
# count enabled plugins
533536
echo "Got COUNT_ENABLED_PLUGINS = $COUNT_ENABLED_PLUGINS preinstalled plugins"
537+
534538
# inject ENABLED_PLUGINS into con-preinstalled-dynamic-plugins.template.adoc, and the counter
535539
sed -r -e "/%%ENABLED_PLUGINS%%/{r $ENABLED_PLUGINS" -e 'd;}' \
536540
-e "s/%%COUNT_ENABLED_PLUGINS%%/$COUNT_ENABLED_PLUGINS/" \
@@ -595,6 +599,9 @@ generate_community_table() {
595599
continue
596600
fi
597601

602+
if [[ $QUIET -eq 0 ]]; then
603+
echo -e "${blue}[WARN] Check overlay metadata: $metadata_dir${norm}"
604+
fi
598605
# Process each metadata YAML file in the workspace
599606
for metadata_file in "$metadata_dir"/*.yaml; do
600607
[[ ! -f "$metadata_file" ]] && continue
@@ -615,6 +622,8 @@ generate_community_table() {
615622
if grep -qF "$plugin_name" "$PROCESSED_PLUGINS_FILE" 2>/dev/null; then
616623
continue
617624
fi
625+
626+
# only include this plugin if its metadata matches the entry we're looking for
618627
echo "$plugin_name" >> "$PROCESSED_PLUGINS_FILE"
619628

620629

@@ -646,11 +655,11 @@ generate_community_table() {
646655
# Cleanup processed plugins tracking file
647656
rm -f "$PROCESSED_PLUGINS_FILE"
648657

649-
650-
# Sort the community table by plugin title and format for adoc
658+
659+
# LC_ALL=C sort the community table by plugin title and format for adoc
651660
COMMUNITY_TABLE_SORTED="/tmp/community_table_sorted_${BRANCH}.txt"
652661
if [[ -f "$COMMUNITY_TABLE_FILE" ]]; then
653-
sort -t '|' -k1,1 "$COMMUNITY_TABLE_FILE" | while IFS='||' read -r key content; do
662+
LC_ALL=C sort -t '|' -k1,1 "$COMMUNITY_TABLE_FILE" | while IFS='||' read -r key content; do
654663
echo -e "$content\n" >> "$COMMUNITY_TABLE_SORTED"
655664
done
656665
fi
@@ -687,7 +696,7 @@ pushd "$SCRIPT_DIR" >/dev/null || exit
687696
popd >/dev/null || exit
688697

689698
# see https://issues.redhat.com/browse/RHIDP-3187 - only GA plugins should be enabled by default
690-
if [[ -f "${ENABLED_PLUGINS}.errors" ]]; then echo;sort -u "${ENABLED_PLUGINS}.errors"; fi
699+
if [[ -f "${ENABLED_PLUGINS}.errors" ]]; then echo;LC_ALL=C sort -u "${ENABLED_PLUGINS}.errors"; fi
691700

692701
# clean up CQA warnings
693702
pushd "${SCRIPT_DIR}"/../.. >/dev/null || exit

0 commit comments

Comments
 (0)