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

Sos2403b #616

Merged
merged 4 commits into from
Feb 22, 2024
Merged

Sos2403b #616

merged 4 commits into from
Feb 22, 2024

Conversation

gsmith-sas
Copy link
Member

No description provided.

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In bin/openshift-include.sh line 1:
# Copyright © 2021, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In bin/openshift-include.sh line 11:
  allArr=($(oc version 2>/dev/null))
          ^-----------------------^ SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting).


In bin/openshift-include.sh line 16:
    verArr=(${allArr[$i]})
            ^-----------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.


In bin/openshift-include.sh line 97:
      if [ ! $(which oc) ]; then
             ^---------^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- bin/kube-include.sh.orig
+++ bin/kube-include.sh
@@ -7,8 +7,8 @@
 # Assumes bin/common.sh has been sourced
 
 if [ ! "$(which kubectl)" ]; then
-  log_error "kubectl not found on the current PATH"
-  exit 1
+	log_error "kubectl not found on the current PATH"
+	exit 1
 fi
 
 KUBE_CLIENT_VER=$(kubectl version --short | grep 'Client Version' | awk '{print $3}' 2>/dev/null)
@@ -16,10 +16,10 @@
 
 # Client version allowed to be one minor version earlier than minimum server version
 if [[ $KUBE_CLIENT_VER =~ v1.2[0-9] ]]; then
-  :
-else 
-  log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
-  log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
+	:
+else
+	log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
+	log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
 fi
 
 # SAS Viya 4 versions
@@ -34,10 +34,10 @@
 # 2024.02     1.26 1.28
 
 if [[ $KUBE_SERVER_VER =~ v1.2[1-9] ]]; then
-  :
-else 
-  log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
-  log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
+	:
+else
+	log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
+	log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
 fi
 
 export KUBE_CLIENT_VER="$KUBE_CLIENT_VER"
--- bin/openshift-include.sh.orig
+++ bin/openshift-include.sh
@@ -5,117 +5,117 @@
 # Assumes bin/common.sh has been sourced
 
 function ocVersionCheck {
-  origIFS=$IFS
-  IFS=$'\n'
+	origIFS=$IFS
+	IFS=$'\n'
 
-  allArr=($(oc version 2>/dev/null))
-  IFS=$origIFS
+	allArr=($(oc version 2>/dev/null))
+	IFS=$origIFS
 
-  for (( i=0; i<${#allArr[@]}; i++ )); do
-    # Split the line into an array
-    verArr=(${allArr[$i]})
-    if [ ${#verArr[@]} -eq 3 ]; then
-      verType="${verArr[0]}"
-      ver="${verArr[2]}"
-      if [ "$verType" == "Client" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OC_FULL_VERSION=${BASH_REMATCH[1]}
-            OC_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OC_MINOR_VERSION=${BASH_REMATCH[3]}
-            OC_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse client version: [$ver]"
-          fi
-      elif [ "$verType" == "Server" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
-            OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
-            OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse server version: [$ver]"
-          fi
-      fi
-    fi
-  done
-  log_info "OpenShift client version: $OC_FULL_VERSION"
-  log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
-  
-  # Version enforcement
-  if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
-    ## Server Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OSHIFT_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    ### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
-    elif (( "$OSHIFT_MINOR_VERSION" < 12 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    else
-      log_debug "OpenShift server version check OK"
-    fi
+	for ((i = 0; i < ${#allArr[@]}; i++)); do
+		# Split the line into an array
+		verArr=(${allArr[$i]})
+		if [ ${#verArr[@]} -eq 3 ]; then
+			verType="${verArr[0]}"
+			ver="${verArr[2]}"
+			if [ "$verType" == "Client" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OC_FULL_VERSION=${BASH_REMATCH[1]}
+					OC_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OC_MINOR_VERSION=${BASH_REMATCH[3]}
+					OC_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse client version: [$ver]"
+				fi
+			elif [ "$verType" == "Server" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
+					OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
+					OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse server version: [$ver]"
+				fi
+			fi
+		fi
+	done
+	log_info "OpenShift client version: $OC_FULL_VERSION"
+	log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
 
-    ## Client Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OC_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    ### Openshift 4 client version must be w/in 1 minor releases of server minimum.
-    elif (( "$OC_MINOR_VERSION" < 11 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    else
-      log_debug "OpenShift client version check OK"
-    fi
-  fi
+	# Version enforcement
+	if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
+		## Server Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OSHIFT_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
+		elif (("$OSHIFT_MINOR_VERSION" < 12)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		else
+			log_debug "OpenShift server version check OK"
+		fi
+
+		## Client Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OC_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		### Openshift 4 client version must be w/in 1 minor releases of server minimum.
+		elif (("$OC_MINOR_VERSION" < 11)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		else
+			log_debug "OpenShift client version check OK"
+		fi
+	fi
 }
 
 OPENSHIFT_VERSION_CHECK=${OPENSHIFT_VERSION_CHECK:-true}
 if [ "$SAS_OPENSHIFT_SOURCED" != "true" ]; then
-  if [ "$OPENSHIFT_CLUSTER" == "" ]; then
-    # Detect OpenShift cluster
-    if kubectl get ns openshift 2>/dev/null 1>&2; then
-      log_debug "OpenShift detected"
-      OPENSHIFT_CLUSTER="true"
-    else
-      log_debug "OpenShift not detected"
-      OPENSHIFT_CLUSTER="false"
-    fi
-  else
-    log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
-  fi
+	if [ "$OPENSHIFT_CLUSTER" == "" ]; then
+		# Detect OpenShift cluster
+		if kubectl get ns openshift 2>/dev/null 1>&2; then
+			log_debug "OpenShift detected"
+			OPENSHIFT_CLUSTER="true"
+		else
+			log_debug "OpenShift not detected"
+			OPENSHIFT_CLUSTER="false"
+		fi
+	else
+		log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
+	fi
 
-  if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-    if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
-      if [ ! $(which oc) ]; then
-        echo "'oc' is required for OpenShift and not found on the current PATH"
-        exit 1
-      fi
-      ocVersionCheck
+	if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
+		if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
+			if [ ! $(which oc) ]; then
+				echo "'oc' is required for OpenShift and not found on the current PATH"
+				exit 1
+			fi
+			ocVersionCheck
 
-      # Get base OpenShift route hostname
-      OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
-      if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
-        log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
-      else
-        log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
-        exit 1
-      fi
+			# Get base OpenShift route hostname
+			OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
+			if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
+				log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
+			else
+				log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
+				exit 1
+			fi
 
-      export OPENSHIFT_ROUTE_DOMAIN
-      export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
-      export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
-    fi
-  else
-    log_debug "OpenShift not detected. Skipping 'oc' checks."
-  fi
-  export OPENSHIFT_CLUSTER
-  export SAS_OPENSHIFT_SOURCED="true"
+			export OPENSHIFT_ROUTE_DOMAIN
+			export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
+			export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
+		fi
+	else
+		log_debug "OpenShift not detected. Skipping 'oc' checks."
+	fi
+	export OPENSHIFT_CLUSTER
+	export SAS_OPENSHIFT_SOURCED="true"
 fi
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In bin/openshift-include.sh line 1:
# Copyright © 2021, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In bin/openshift-include.sh line 11:
  allArr=($(oc version 2>/dev/null))
          ^-----------------------^ SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting).


In bin/openshift-include.sh line 16:
    verArr=(${allArr[$i]})
            ^-----------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.


In bin/openshift-include.sh line 97:
      if [ ! $(which oc) ]; then
             ^---------^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- bin/kube-include.sh.orig
+++ bin/kube-include.sh
@@ -7,8 +7,8 @@
 # Assumes bin/common.sh has been sourced
 
 if [ ! "$(which kubectl)" ]; then
-  log_error "kubectl not found on the current PATH"
-  exit 1
+	log_error "kubectl not found on the current PATH"
+	exit 1
 fi
 
 KUBE_CLIENT_VER=$(kubectl version --short | grep 'Client Version' | awk '{print $3}' 2>/dev/null)
@@ -16,10 +16,10 @@
 
 # Client version allowed to be one minor version earlier than minimum server version
 if [[ $KUBE_CLIENT_VER =~ v1.2[0-9] ]]; then
-  :
-else 
-  log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
-  log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
+	:
+else
+	log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
+	log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
 fi
 
 # SAS Viya 4 versions
@@ -34,10 +34,10 @@
 # 2024.02     1.26 1.28
 
 if [[ $KUBE_SERVER_VER =~ v1.2[1-9] ]]; then
-  :
-else 
-  log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
-  log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
+	:
+else
+	log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
+	log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
 fi
 
 export KUBE_CLIENT_VER="$KUBE_CLIENT_VER"
--- bin/openshift-include.sh.orig
+++ bin/openshift-include.sh
@@ -5,117 +5,117 @@
 # Assumes bin/common.sh has been sourced
 
 function ocVersionCheck {
-  origIFS=$IFS
-  IFS=$'\n'
+	origIFS=$IFS
+	IFS=$'\n'
 
-  allArr=($(oc version 2>/dev/null))
-  IFS=$origIFS
+	allArr=($(oc version 2>/dev/null))
+	IFS=$origIFS
 
-  for (( i=0; i<${#allArr[@]}; i++ )); do
-    # Split the line into an array
-    verArr=(${allArr[$i]})
-    if [ ${#verArr[@]} -eq 3 ]; then
-      verType="${verArr[0]}"
-      ver="${verArr[2]}"
-      if [ "$verType" == "Client" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OC_FULL_VERSION=${BASH_REMATCH[1]}
-            OC_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OC_MINOR_VERSION=${BASH_REMATCH[3]}
-            OC_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse client version: [$ver]"
-          fi
-      elif [ "$verType" == "Server" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
-            OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
-            OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse server version: [$ver]"
-          fi
-      fi
-    fi
-  done
-  log_info "OpenShift client version: $OC_FULL_VERSION"
-  log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
-  
-  # Version enforcement
-  if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
-    ## Server Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OSHIFT_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    ### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
-    elif (( "$OSHIFT_MINOR_VERSION" < 12 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    else
-      log_debug "OpenShift server version check OK"
-    fi
+	for ((i = 0; i < ${#allArr[@]}; i++)); do
+		# Split the line into an array
+		verArr=(${allArr[$i]})
+		if [ ${#verArr[@]} -eq 3 ]; then
+			verType="${verArr[0]}"
+			ver="${verArr[2]}"
+			if [ "$verType" == "Client" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OC_FULL_VERSION=${BASH_REMATCH[1]}
+					OC_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OC_MINOR_VERSION=${BASH_REMATCH[3]}
+					OC_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse client version: [$ver]"
+				fi
+			elif [ "$verType" == "Server" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
+					OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
+					OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse server version: [$ver]"
+				fi
+			fi
+		fi
+	done
+	log_info "OpenShift client version: $OC_FULL_VERSION"
+	log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
 
-    ## Client Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OC_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    ### Openshift 4 client version must be w/in 1 minor releases of server minimum.
-    elif (( "$OC_MINOR_VERSION" < 11 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    else
-      log_debug "OpenShift client version check OK"
-    fi
-  fi
+	# Version enforcement
+	if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
+		## Server Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OSHIFT_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
+		elif (("$OSHIFT_MINOR_VERSION" < 12)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		else
+			log_debug "OpenShift server version check OK"
+		fi
+
+		## Client Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OC_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		### Openshift 4 client version must be w/in 1 minor releases of server minimum.
+		elif (("$OC_MINOR_VERSION" < 11)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		else
+			log_debug "OpenShift client version check OK"
+		fi
+	fi
 }
 
 OPENSHIFT_VERSION_CHECK=${OPENSHIFT_VERSION_CHECK:-true}
 if [ "$SAS_OPENSHIFT_SOURCED" != "true" ]; then
-  if [ "$OPENSHIFT_CLUSTER" == "" ]; then
-    # Detect OpenShift cluster
-    if kubectl get ns openshift 2>/dev/null 1>&2; then
-      log_debug "OpenShift detected"
-      OPENSHIFT_CLUSTER="true"
-    else
-      log_debug "OpenShift not detected"
-      OPENSHIFT_CLUSTER="false"
-    fi
-  else
-    log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
-  fi
+	if [ "$OPENSHIFT_CLUSTER" == "" ]; then
+		# Detect OpenShift cluster
+		if kubectl get ns openshift 2>/dev/null 1>&2; then
+			log_debug "OpenShift detected"
+			OPENSHIFT_CLUSTER="true"
+		else
+			log_debug "OpenShift not detected"
+			OPENSHIFT_CLUSTER="false"
+		fi
+	else
+		log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
+	fi
 
-  if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-    if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
-      if [ ! $(which oc) ]; then
-        echo "'oc' is required for OpenShift and not found on the current PATH"
-        exit 1
-      fi
-      ocVersionCheck
+	if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
+		if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
+			if [ ! $(which oc) ]; then
+				echo "'oc' is required for OpenShift and not found on the current PATH"
+				exit 1
+			fi
+			ocVersionCheck
 
-      # Get base OpenShift route hostname
-      OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
-      if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
-        log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
-      else
-        log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
-        exit 1
-      fi
+			# Get base OpenShift route hostname
+			OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
+			if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
+				log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
+			else
+				log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
+				exit 1
+			fi
 
-      export OPENSHIFT_ROUTE_DOMAIN
-      export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
-      export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
-    fi
-  else
-    log_debug "OpenShift not detected. Skipping 'oc' checks."
-  fi
-  export OPENSHIFT_CLUSTER
-  export SAS_OPENSHIFT_SOURCED="true"
+			export OPENSHIFT_ROUTE_DOMAIN
+			export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
+			export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
+		fi
+	else
+		log_debug "OpenShift not detected. Skipping 'oc' checks."
+	fi
+	export OPENSHIFT_CLUSTER
+	export SAS_OPENSHIFT_SOURCED="true"
 fi
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


@gsmith-sas gsmith-sas requested a review from cumcke February 21, 2024 20:41
Copy link
Collaborator

@cumcke cumcke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In bin/openshift-include.sh line 1:
# Copyright © 2021, SAS Institute Inc., Cary, NC, USA.  All Rights Reserved.
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In bin/openshift-include.sh line 11:
  allArr=($(oc version 2>/dev/null))
          ^-----------------------^ SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting).


In bin/openshift-include.sh line 16:
    verArr=(${allArr[$i]})
            ^-----------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.


In bin/openshift-include.sh line 97:
      if [ ! $(which oc) ]; then
             ^---------^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2206 -- Quote to prevent word splitting/g...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- bin/kube-include.sh.orig
+++ bin/kube-include.sh
@@ -7,8 +7,8 @@
 # Assumes bin/common.sh has been sourced
 
 if [ ! "$(which kubectl)" ]; then
-  log_error "kubectl not found on the current PATH"
-  exit 1
+	log_error "kubectl not found on the current PATH"
+	exit 1
 fi
 
 KUBE_CLIENT_VER=$(kubectl version --short | grep 'Client Version' | awk '{print $3}' 2>/dev/null)
@@ -16,10 +16,10 @@
 
 # Client version allowed to be one minor version earlier than minimum server version
 if [[ $KUBE_CLIENT_VER =~ v1.2[0-9] ]]; then
-  :
-else 
-  log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
-  log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
+	:
+else
+	log_warn "Unsupported kubectl version: [$KUBE_CLIENT_VER]."
+	log_warn "This script might not work as expected. Support might not be available until kubectl is upgraded to a supported version."
 fi
 
 # SAS Viya 4 versions
@@ -34,10 +34,10 @@
 # 2024.02     1.26 1.28
 
 if [[ $KUBE_SERVER_VER =~ v1.2[1-9] ]]; then
-  :
-else 
-  log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
-  log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
+	:
+else
+	log_warn "The detected version of Kubernetes [$KUBE_SERVER_VER] is not supported by any of the currently supported releases of SAS Viya."
+	log_warn "This script might not work as expected. Support might not be available until Kubernetes is upgraded to a supported version."
 fi
 
 export KUBE_CLIENT_VER="$KUBE_CLIENT_VER"
--- bin/openshift-include.sh.orig
+++ bin/openshift-include.sh
@@ -5,117 +5,117 @@
 # Assumes bin/common.sh has been sourced
 
 function ocVersionCheck {
-  origIFS=$IFS
-  IFS=$'\n'
+	origIFS=$IFS
+	IFS=$'\n'
 
-  allArr=($(oc version 2>/dev/null))
-  IFS=$origIFS
+	allArr=($(oc version 2>/dev/null))
+	IFS=$origIFS
 
-  for (( i=0; i<${#allArr[@]}; i++ )); do
-    # Split the line into an array
-    verArr=(${allArr[$i]})
-    if [ ${#verArr[@]} -eq 3 ]; then
-      verType="${verArr[0]}"
-      ver="${verArr[2]}"
-      if [ "$verType" == "Client" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OC_FULL_VERSION=${BASH_REMATCH[1]}
-            OC_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OC_MINOR_VERSION=${BASH_REMATCH[3]}
-            OC_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse client version: [$ver]"
-          fi
-      elif [ "$verType" == "Server" ]; then
-          ver="${verArr[2]}"
-          if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
-            OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
-            OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
-            OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
-            OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
-          else
-            echo "Unable to parse server version: [$ver]"
-          fi
-      fi
-    fi
-  done
-  log_info "OpenShift client version: $OC_FULL_VERSION"
-  log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
-  
-  # Version enforcement
-  if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
-    ## Server Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OSHIFT_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    ### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
-    elif (( "$OSHIFT_MINOR_VERSION" < 12 )); then
-      log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
-      log_error "Version 4.12+ is required"
-      exit 1
-    else
-      log_debug "OpenShift server version check OK"
-    fi
+	for ((i = 0; i < ${#allArr[@]}; i++)); do
+		# Split the line into an array
+		verArr=(${allArr[$i]})
+		if [ ${#verArr[@]} -eq 3 ]; then
+			verType="${verArr[0]}"
+			ver="${verArr[2]}"
+			if [ "$verType" == "Client" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ v?(([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OC_FULL_VERSION=${BASH_REMATCH[1]}
+					OC_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OC_MINOR_VERSION=${BASH_REMATCH[3]}
+					OC_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse client version: [$ver]"
+				fi
+			elif [ "$verType" == "Server" ]; then
+				ver="${verArr[2]}"
+				if [[ $ver =~ (([0-9]+)\.([0-9]+)\.([0-9]+)) ]]; then
+					OSHIFT_FULL_VERSION=${BASH_REMATCH[1]}
+					OSHIFT_MAJOR_VERSION=${BASH_REMATCH[2]}
+					OSHIFT_MINOR_VERSION=${BASH_REMATCH[3]}
+					OSHIFT_PATCH_VERSION=${BASH_REMATCH[4]}
+				else
+					echo "Unable to parse server version: [$ver]"
+				fi
+			fi
+		fi
+	done
+	log_info "OpenShift client version: $OC_FULL_VERSION"
+	log_info "OpenShift server version: $OSHIFT_FULL_VERSION"
 
-    ## Client Version
-    ### Openshift versions that do not start with a 4 should produce an error.
-    if (( "$OC_MAJOR_VERSION" != 4 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    ### Openshift 4 client version must be w/in 1 minor releases of server minimum.
-    elif (( "$OC_MINOR_VERSION" < 11 )); then
-      log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
-      log_error "Version 4.11+ is required"
-      exit 1
-    else
-      log_debug "OpenShift client version check OK"
-    fi
-  fi
+	# Version enforcement
+	if [ "$OPENSHIFT_VERSION_CHECK" == "true" ]; then
+		## Server Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OSHIFT_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		### 21FEB24: Openshift 4 versions earlier than 4.12 should produce an error.
+		elif (("$OSHIFT_MINOR_VERSION" < 12)); then
+			log_error "Unsupported OpenShift server version: $OSHIFT_FULL_VERSION"
+			log_error "Version 4.12+ is required"
+			exit 1
+		else
+			log_debug "OpenShift server version check OK"
+		fi
+
+		## Client Version
+		### Openshift versions that do not start with a 4 should produce an error.
+		if (("$OC_MAJOR_VERSION" != 4)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		### Openshift 4 client version must be w/in 1 minor releases of server minimum.
+		elif (("$OC_MINOR_VERSION" < 11)); then
+			log_error "Unsupported OpenShift client version: $OC_FULL_VERSION"
+			log_error "Version 4.11+ is required"
+			exit 1
+		else
+			log_debug "OpenShift client version check OK"
+		fi
+	fi
 }
 
 OPENSHIFT_VERSION_CHECK=${OPENSHIFT_VERSION_CHECK:-true}
 if [ "$SAS_OPENSHIFT_SOURCED" != "true" ]; then
-  if [ "$OPENSHIFT_CLUSTER" == "" ]; then
-    # Detect OpenShift cluster
-    if kubectl get ns openshift 2>/dev/null 1>&2; then
-      log_debug "OpenShift detected"
-      OPENSHIFT_CLUSTER="true"
-    else
-      log_debug "OpenShift not detected"
-      OPENSHIFT_CLUSTER="false"
-    fi
-  else
-    log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
-  fi
+	if [ "$OPENSHIFT_CLUSTER" == "" ]; then
+		# Detect OpenShift cluster
+		if kubectl get ns openshift 2>/dev/null 1>&2; then
+			log_debug "OpenShift detected"
+			OPENSHIFT_CLUSTER="true"
+		else
+			log_debug "OpenShift not detected"
+			OPENSHIFT_CLUSTER="false"
+		fi
+	else
+		log_debug "Skipping OpenShift detection. OPENSHIFT_CLUSTER=[$OPENSHIFT_CLUSTER]"
+	fi
 
-  if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-    if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
-      if [ ! $(which oc) ]; then
-        echo "'oc' is required for OpenShift and not found on the current PATH"
-        exit 1
-      fi
-      ocVersionCheck
+	if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
+		if [ "${OPENSHIFT_OC_CHECK:-true}" == "true" ]; then
+			if [ ! $(which oc) ]; then
+				echo "'oc' is required for OpenShift and not found on the current PATH"
+				exit 1
+			fi
+			ocVersionCheck
 
-      # Get base OpenShift route hostname
-      OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
-      if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
-        log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
-      else
-        log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
-        exit 1
-      fi
+			# Get base OpenShift route hostname
+			OPENSHIFT_ROUTE_DOMAIN=${OPENSHIFT_ROUTE_DOMAIN:-$(oc get route -n openshift-console console -o 'jsonpath={.spec.host}' | cut -c 27-)}
+			if [ "$OPENSHIFT_ROUTE_DOMAIN" != "" ]; then
+				log_debug "OpenShift route host is [$OPENSHIFT_ROUTE_DOMAIN]"
+			else
+				log_error "Unable to determine OpenShift route host. Set OPENSHIFT_ROUTE_DOMAIN if necessary."
+				exit 1
+			fi
 
-      export OPENSHIFT_ROUTE_DOMAIN
-      export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
-      export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
-    fi
-  else
-    log_debug "OpenShift not detected. Skipping 'oc' checks."
-  fi
-  export OPENSHIFT_CLUSTER
-  export SAS_OPENSHIFT_SOURCED="true"
+			export OPENSHIFT_ROUTE_DOMAIN
+			export OC_MAJOR_VERSION OC_MINOR_VERSION OC_PATCH_VERSION
+			export OSHIFT_MAJOR_VERSION OSHIFT_MINOR_VERSION OSHIFT_PATCH_VERSION
+		fi
+	else
+		log_debug "OpenShift not detected. Skipping 'oc' checks."
+	fi
+	export OPENSHIFT_CLUSTER
+	export SAS_OPENSHIFT_SOURCED="true"
 fi
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


@gsmith-sas gsmith-sas merged commit 09ae0b0 into main Feb 22, 2024
1 check failed
@gsmith-sas gsmith-sas deleted the sos2403b branch February 22, 2024 16:49
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