Fix: Address various shellcheck linting errors in scripts 02/72702/3 v0.90.2
authorMatthew Watkins <mwatkins@linuxfoundation.org>
Thu, 29 Feb 2024 12:54:46 +0000 (12:54 +0000)
committerMatthew Watkins <mwatkins@linuxfoundation.org>
Thu, 29 Feb 2024 14:44:50 +0000 (14:44 +0000)
Issue: RELENG-5183
Change-Id: I068c27b215fd487985d6204af05fe6619c9d8f15
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml [new file with mode: 0644]
shell/openstack-cleanup-orphaned-objects.sh
shell/release-job.sh

diff --git a/releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml b/releasenotes/notes/fix-shellcheck-errors-04d1683561e9ecc9.yaml
new file mode 100644 (file)
index 0000000..b237658
--- /dev/null
@@ -0,0 +1,4 @@
+---
+fixes:
+  - |
+    Address several linting errors in scripts, mostly unquoted variables
index 59e1edf..689eab2 100755 (executable)
@@ -83,11 +83,11 @@ trap _rmtemp EXIT
 # Output the initial list of object UUIDs to a temporary file
 if [[ -n ${filters} ]]; then
     # If a filter/match condition is requested/set
-    openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \
+    openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID "$attributes" \
      | { $filters || true; } | { awk '{print $1}' || true; } > "$tmpfile"
 else
     # Otherwise don't pipe through an additional command
-    openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID $attributes \
+    openstack --os-cloud "$os_cloud" "${object}" list -f value -c ID "$attributes" \
      | { awk '{print $1}' || true; } > "$tmpfile"
 fi
 
index 57e4038..e01d3a9 100644 (file)
@@ -97,7 +97,7 @@ set_variables_common(){
 
     TAG_RELEASE="${TAG_RELEASE:-None}"
     if [[ $TAG_RELEASE == "None" ]]; then
-        if grep -q "tag_release" $release_file ; then
+        if grep -q "tag_release" "$release_file"; then
             TAG_RELEASE=$(yq -r .tag_release "$release_file")
         else
             TAG_RELEASE=true
@@ -183,7 +183,7 @@ set_variables_packagecloud(){
         VERSION=$(yq -r ".version" "$release_file")
     fi
     if [[ -z ${GIT_TAG:-} ]]; then
-        if grep -q "git_tag" $release_file ; then
+        if grep -q "git_tag" "$release_file"; then
             GIT_TAG=$(yq -r ".git_tag" "$release_file")
         else
             GIT_TAG="$VERSION"
@@ -385,8 +385,8 @@ artifact_release_file(){
     mkdir artifacts
     ORG=$(echo "$NEXUS_URL" | awk -F'.' '{print $2}')
 
-    for namequoted in $(yq '.artifacts[].name' $release_file); do
-        pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" $release_file)
+    for namequoted in $(yq '.artifacts[].name' "$release_file"); do
+        pathquoted=$(yq ".artifacts[] |select(.name==$namequoted) |.path" "$release_file")
 
         #Remove extra yaml quotes
         name="${namequoted#\"}"
@@ -420,8 +420,8 @@ container_release_file(){
     local lfn_umbrella
     lfn_umbrella="$(echo "$GERRIT_URL" | awk -F"." '{print $2}')"
 
-    for namequoted in $(yq '.containers[].name' $release_file); do
-        versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" $release_file)
+    for namequoted in $(yq '.containers[].name' "$release_file"); do
+        versionquoted=$(yq ".containers[] |select(.name==$namequoted) |.version" "$release_file")
 
         #Remove extra yaml quotes
         name="${namequoted#\"}"
@@ -657,7 +657,7 @@ case $DISTRIBUTION_TYPE in
         fi
         set_variables_packagecloud
         verify_packagecloud_match_release
-        for name in $(yq -r '.packages[].name' $release_file); do
+        for name in $(yq -r '.packages[].name' "$release_file"); do
             package=$name
             packagecloud_verify "$package" "$packagecloud_account"
             if [[ "$JOB_NAME" =~ "merge" ]] && ! $DRY_RUN; then