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

[CHANGE] Use OpenSource datasource plugin for connecting to back-end log message store #679

Merged
merged 16 commits into from
Sep 30, 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 monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 169:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 171:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 174:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 176:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 181:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 184:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 198:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 199:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 206:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 216:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 217:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 218:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 227:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 228:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 231:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 232:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
  https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ...
----------

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:

----------
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -158,23 +158,22 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"         "$LOG_NS"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"    "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"            "$grfds_user"     "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"            "$grfds_passwd"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -181,41 +180,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -224,11 +223,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 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 .github/workflows/build-artifact/generate_inventory.sh line 12:
CHECK_HELM=false
^--------^ SC2034 (warning): CHECK_HELM appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 13:
CHECK_KUBERNETES=false
^--------------^ SC2034 (warning): CHECK_KUBERNETES appears unused. Verify use (or export if used externally).


In .github/workflows/build-artifact/generate_inventory.sh line 15:
source bin/common.sh
       ^-----------^ SC1091 (info): Not following: bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 3:
cd "$(dirname $BASH_SOURCE)/../.."
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.." || exit


In monitoring/bin/create_logging_datasource.sh line 4:
source logging/bin/common.sh
       ^-------------------^ SC1091 (info): Not following: logging/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 5:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 7:
source logging/bin/apiaccess-include.sh
       ^-- SC1091 (info): Not following: logging/bin/apiaccess-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 8:
source logging/bin/secrets-include.sh
       ^----------------------------^ SC1091 (info): Not following: logging/bin/secrets-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 9:
source logging/bin/rbac-include.sh
       ^-------------------------^ SC1091 (info): Not following: logging/bin/rbac-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/create_logging_datasource.sh line 11:
this_script=`basename "$0"`
            ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
this_script=$(basename "$0")


In monitoring/bin/create_logging_datasource.sh line 33:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 43:
      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
                          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then


In monitoring/bin/create_logging_datasource.sh line 56:
    -*|--*=) # unsupported flags
    ^-- SC2221 (warning): This pattern always overrides a later one on line 56.
       ^--^ SC2222 (warning): This pattern never matches because of a previous pattern on line 56.


In monitoring/bin/create_logging_datasource.sh line 85:
    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$MON_NS" -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 94:
    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                                ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ $(kubectl get pods -n "$tenantNS" -l app.kubernetes.io/instance=v4m-grafana-"$tenant" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 104:
if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                   ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                                                                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [[ $(kubectl get pods -n "$LOG_NS" -l app.kubernetes.io/component="$ES_SERVICENAME" -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n "$LOG_NS" -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then


In monitoring/bin/create_logging_datasource.sh line 113:
export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
       ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_USER=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 114:
export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
       ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
export ES_ADMIN_PASSWD=$(kubectl -n "$LOG_NS" get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)


In monitoring/bin/create_logging_datasource.sh line 141:
   delete_user $grfds_user
               ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   delete_user "$grfds_user"


In monitoring/bin/create_logging_datasource.sh line 147:
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
                                                      ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 149:
   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 151:
   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
                                    ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   ./logging/bin/user.sh CREATE -ns "$tenantNS" -t "$tenant" -u "$grfds_user" -p "$grfds_passwd" -g


In monitoring/bin/create_logging_datasource.sh line 156:
mkdir -p $monDir
         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
mkdir -p "$monDir"


In monitoring/bin/create_logging_datasource.sh line 157:
cp monitoring/grafana-datasource-opensearch.yaml $monDir/grafana-datasource-opensearch.yaml
                                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cp monitoring/grafana-datasource-opensearch.yaml "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 175:
    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [[ -n "$(kubectl get secret -n "$MON_NS" grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then


In monitoring/bin/create_logging_datasource.sh line 177:
        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
                                 ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$MON_NS" --ignore-not-found grafana-datasource-es


In monitoring/bin/create_logging_datasource.sh line 180:
    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
                                     ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -n "$(kubectl get secret -n "$tenantNS" v4m-grafana-datasource-es-"$tenant" -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then


In monitoring/bin/create_logging_datasource.sh line 182:
        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
                                 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        kubectl delete secret -n "$tenantNS" --ignore-not-found v4m-grafana-datasource-es-"$tenant"


In monitoring/bin/create_logging_datasource.sh line 187:
grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
                        ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
grafanaPod=$(kubectl -n "$MON_NS" get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')


In monitoring/bin/create_logging_datasource.sh line 190:
pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
                                  ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
pluginInstalled=$(kubectl exec -n "$MON_NS" "$grafanaPod"  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")


In monitoring/bin/create_logging_datasource.sh line 204:
         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
                    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                            ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl cp "$userPluginFile" "$MON_NS"/"$grafanaPod":/var/lib/grafana/plugins


In monitoring/bin/create_logging_datasource.sh line 205:
         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
                         ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                 ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                   ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         kubectl exec -n "$MON_NS" "$grafanaPod"  -- unzip -o /var/lib/grafana/plugins/"$pluginFile" -d /var/lib/grafana/plugins/


In monitoring/bin/create_logging_datasource.sh line 212:
      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                        ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl exec -n "$MON_NS" "$grafanaPod"  -- grafana cli plugins install grafana-opensearch-datasource "$pluginVersion"


In monitoring/bin/create_logging_datasource.sh line 222:
    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete secret generic -n "$MON_NS" grafana-datasource-opensearch --ignore-not-found


In monitoring/bin/create_logging_datasource.sh line 223:
    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl create secret generic -n "$MON_NS" grafana-datasource-opensearch --from-file "$monDir"/grafana-datasource-opensearch.yaml


In monitoring/bin/create_logging_datasource.sh line 224:
    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
                            ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl label secret -n "$MON_NS" grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring


In monitoring/bin/create_logging_datasource.sh line 233:
    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
                           ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$MON_NS" -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"


In monitoring/bin/create_logging_datasource.sh line 234:
    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
               ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"?

Did you mean: 
    kubectl -n "$MON_NS" wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m


In monitoring/bin/create_logging_datasource.sh line 237:
    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
                           ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl delete pods -n "$tenantNS" -l "app.kubernetes.io/instance=v4m-grafana-$tenant"


In monitoring/bin/create_logging_datasource.sh line 238:
    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
               ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                     ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl -n "$tenantNS" wait pods --selector app.kubernetes.io/instance=v4m-grafana-"$tenant" --for condition=Ready --timeout=2m

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- CHECK_HELM appears unused. Verify...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2140 -- Word is of the form "A"B"C" (B in...
----------

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:

----------
diff .github/workflows/build-artifact/generate_inventory.sh.orig .github/workflows/build-artifact/generate_inventory.sh
--- .github/workflows/build-artifact/generate_inventory.sh.orig
+++ .github/workflows/build-artifact/generate_inventory.sh
@@ -21,18 +21,18 @@
 
 function buildHelmArchiveFilename {
 
-   local prefix repo name version format chart_archive_filename
-
-   prefix=$1
-   repo="${prefix}_CHART_REPO"
-   name="${prefix}_CHART_NAME"
-   version="${prefix}_CHART_VERSION"
-   format="tgz"
-   chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
-   v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
-   v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
-   v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
-   v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
+	local prefix repo name version format chart_archive_filename
+
+	prefix=$1
+	repo="${prefix}_CHART_REPO"
+	name="${prefix}_CHART_NAME"
+	version="${prefix}_CHART_VERSION"
+	format="tgz"
+	chart_archive_filename="${!repo}\/${!name}-${!version}.$format"
+	v4m_replace "__${prefix}_CHART_REPO__" "${!repo}" "$file"
+	v4m_replace "__${prefix}_CHART_NAME__" "${!name}" "$file"
+	v4m_replace "__${prefix}_CHART_VERSION__" "${!version}" "$file"
+	v4m_replace "__${prefix}_CHART_ARCHIVE__" "$chart_archive_filename" "$file"
 
 }
 
@@ -48,7 +48,6 @@
 buildHelmArchiveFilename "PUSHGATEWAY"
 buildHelmArchiveFilename "TEMPO"
 
-
 ##
 ## Container Images (Table #1)
 ##
@@ -106,6 +105,6 @@
 ##
 ## Misc components (Table #4)
 ##
-v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file" 
+v4m_replace "__GRAFANA_DATASOURCE_PLUGIN_VERSION__" "$GRAFANA_DATASOURCE_PLUGIN_VERSION" "$file"
 
 log_notice "Be sure to review the generated file [$file] prior to adding/committing it to the repo"
diff monitoring/bin/create_logging_datasource.sh.orig monitoring/bin/create_logging_datasource.sh
--- monitoring/bin/create_logging_datasource.sh.orig
+++ monitoring/bin/create_logging_datasource.sh
@@ -8,19 +8,19 @@
 source logging/bin/secrets-include.sh
 source logging/bin/rbac-include.sh
 
-this_script=`basename "$0"`
+this_script=$(basename "$0")
 
 function show_usage {
-  log_message  "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
-  log_message  ""
-  log_message  "Creates the logging data source to allow log messages to be viewed in Grafana."
-  log_message  ""
-  log_message  "To create the logging data source at the cluster level, do not pass any "
-  log_message  "arguments.  To create the logging data source at the tenant level, you need"
-  log_message  "to provide the following arguments:"
-  log_message  "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
-  log_message  "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
-  log_message  ""
+	log_message "Usage: $this_script [--namespace NAMESPACE --tenant TENANT]"
+	log_message ""
+	log_message "Creates the logging data source to allow log messages to be viewed in Grafana."
+	log_message ""
+	log_message "To create the logging data source at the cluster level, do not pass any "
+	log_message "arguments.  To create the logging data source at the tenant level, you need"
+	log_message "to provide the following arguments:"
+	log_message "     -ns, --namespace NAMESPACE   - The namespace where the SAS Viya tenant resides."
+	log_message "     -t,  --tenant TENANT         - The tenant whose logging data source you want to set up."
+	log_message ""
 }
 
 # Assigning passed in parameters as variables for the script:
@@ -27,91 +27,91 @@
 POS_PARMS=""
 
 # Setting passed in variables:
-while (( "$#" )); do
-  case "$1" in
-    -ns|--namespace)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenantNS=$2
-        shift 2
-      else
-        log_error "A value for parameter [NAMESPACE] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -t|--tenant)
-      if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
-        tenant=$2
-        shift 2
-      else
-        log_error "A value for parameter [TENANT] has not been provided." >&2
-        show_usage
-        exit 2
-      fi
-      ;;
-    -h|--help)
-      show_usage
-      exit
-      ;;
-    -*|--*=) # unsupported flags
-      log_error "Unsupported flag $1" >&2
-      show_usage
-      exit 1
-      ;;
-    *) # preserve positional arguments
-      POS_PARMS="$POS_PARMS $1"
-      shift
-      ;;
-  esac
+while (("$#")); do
+	case "$1" in
+	-ns | --namespace)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenantNS=$2
+			shift 2
+		else
+			log_error "A value for parameter [NAMESPACE] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-t | --tenant)
+		if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
+			tenant=$2
+			shift 2
+		else
+			log_error "A value for parameter [TENANT] has not been provided." >&2
+			show_usage
+			exit 2
+		fi
+		;;
+	-h | --help)
+		show_usage
+		exit
+		;;
+	-* | --*=) # unsupported flags
+		log_error "Unsupported flag $1" >&2
+		show_usage
+		exit 1
+		;;
+	*) # preserve positional arguments
+		POS_PARMS="$POS_PARMS $1"
+		shift
+		;;
+	esac
 done
 
 # Convert namespace and tenant to all lower-case
-tenantNS=$(echo "$tenantNS"| tr '[:upper:]' '[:lower:]')
-tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
+tenantNS=$(echo "$tenantNS" | tr '[:upper:]' '[:lower:]')
+tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
 
 # Check for parameters - set with cluster or tenant
 if [ -z "$tenantNS" ] && [ -z "$tenant" ]; then
-   cluster="true"
+	cluster="true"
 elif [ -n "$tenantNS" ] && [ -n "$tenant" ]; then
-    nst="${tenantNS}_${tenant}"
-else
-   log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source.";
-   exit 1
+	nst="${tenantNS}_${tenant}"
+else
+	log_error "Both a [NAMESPACE] and a [TENANT] are required in order to set up the data source."
+	exit 1
 fi
 
 # Check to see if monitoring/Viya namespace provided exists and components have already been deployed
 if [ "$cluster" == "true" ]; then
-    log_info "Checking for Grafana pods in the $MON_NS namespace ..."
-    if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components found in the [$MON_NS] namespace."
-        log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring found in $MON_NS namespace.  Continuing."
-    fi
-else
-    log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
-    if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-        log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
-        log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana.";
-        exit 1
-    else
-        log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
-    fi
+	log_info "Checking for Grafana pods in the $MON_NS namespace ..."
+	if [[ $(kubectl get pods -n $MON_NS -l app.kubernetes.io/instance=v4m-prometheus-operator -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components found in the [$MON_NS] namespace."
+		log_error "Monitoring needs to be deployed in this namespace in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring found in $MON_NS namespace.  Continuing."
+	fi
+else
+	log_info "Checking the [$tenantNS] namespace for monitoring deployment for the [$tenant] tenant ..."
+	if [[ $(kubectl get pods -n $tenantNS -l app.kubernetes.io/instance=v4m-grafana-$tenant -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
+		log_error "No monitoring components were found for [$tenantNS/$tenant] tenant."
+		log_error "Monitoring needs to be deployed using the deploy_monitoring_tenant script in order to configure the logging data source in Grafana."
+		exit 1
+	else
+		log_debug "Monitoring deployment was found for the [$tenantNS/$tenant] tenant.  Continuing."
+	fi
 fi
 
 # Check to see if logging namespace provided exists and components have already been deployed
 if [[ $(kubectl get pods -n $LOG_NS -l app.kubernetes.io/component=$ES_SERVICENAME -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]] && [[ $(kubectl get pods -n $LOG_NS -l app=v4m-es -o custom-columns=:metadata.namespace --no-headers | uniq | wc -l) == 0 ]]; then
-  log_error "Search backend was not found in the [$LOG_NS] namespace."
-  log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
-  exit 1
-else
-  log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
+	log_error "Search backend was not found in the [$LOG_NS] namespace."
+	log_error "All of the required log monitoring components need to be deployed in this namespace before this script can configure the logging data source."
+	exit 1
+else
+	log_debug "Logging deployment found in [$LOG_NS] namespace.  Continuing."
 fi
 
 # get admin credentials
-export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" |base64 --decode)
-export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" |base64 --decode)
+export ES_ADMIN_USER=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.username}" | base64 --decode)
+export ES_ADMIN_PASSWD=$(kubectl -n $LOG_NS get secret internal-user-admin -o=jsonpath="{.data.password}" | base64 --decode)
 
 get_sec_api_url
 get_credentials_from_secret admin
@@ -118,37 +118,37 @@
 
 # FOR TENANT - Check to see if tenant has been deployed in logging.
 if [ "$cluster" != "true" ]; then
-    log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
-
-    if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
-        log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
-        log_error "This can be done by running the logging/bin/onboard.sh script"
-        exit 1
-    else
-        log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
-    fi 
+	log_info "Verify that the log monitoring onboarding process has been performed for [${tenantNS}/${tenant}] tenant ..."
+
+	if ! kibana_tenant_exists "${tenantNS}_${tenant}"; then
+		log_error "Unable to configure logging datasource for this tenant because the log monitoring onboarding process has not been completed for the [$tenant] in the [$tenantNS] namespace."
+		log_error "This can be done by running the logging/bin/onboard.sh script"
+		exit 1
+	else
+		log_debug "The [${tenantNS}/${tenant}] tenant has been been onboarded.  Continuing."
+	fi
 fi
 
 # Set user ID and password
 if [ "$cluster" == "true" ]; then
-   grfds_user="V4M_ALL_grafana_ds"
-else
-   grfds_user="${nst}_grafana_ds"
+	grfds_user="V4M_ALL_grafana_ds"
+else
+	grfds_user="${nst}_grafana_ds"
 fi
 
 if user_exists "$grfds_user"; then
-   log_verbose "Removing the existing [$grfds_user] utility account."
-   delete_user $grfds_user
+	log_verbose "Removing the existing [$grfds_user] utility account."
+	delete_user $grfds_user
 fi
 
 grfds_passwd="$(randomPassword)"
 
 if [ "$cluster" == "true" ]; then
-   ./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns _all_ -t _all_ -u $grfds_user -p "$grfds_passwd" -g
 elif [ -z "$tenant" ]; then
-   ./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
-else
-   ./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
+	./logging/bin/user.sh CREATE -ns $tenantNS -u $grfds_user -p "$grfds_passwd" -g
+else
+	./logging/bin/user.sh CREATE -ns $tenantNS -t $tenant -u $grfds_user -p "$grfds_passwd" -g
 fi
 
 # Create temporary directory for string replacement in the grafana-datasource-opensearch.yaml file
@@ -163,24 +163,23 @@
 
 # Replace placeholders
 log_debug "Replacing variables in $monDir/grafana-datasource-opensearch.yaml file"
-v4m_replace "__namespace__"          "$LOG_NS"               "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__ES_SERVICENAME__"     "$ES_SERVICENAME"       "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__userID__"             "$grfds_user"           "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__passwd__"             "$grfds_passwd"         "$monDir/grafana-datasource-opensearch.yaml"
-v4m_replace "__opensearch_version__" "$opensearch_version"   "$monDir/grafana-datasource-opensearch.yaml"
-
+v4m_replace "__namespace__" "$LOG_NS" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__ES_SERVICENAME__" "$ES_SERVICENAME" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__userID__" "$grfds_user" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__passwd__" "$grfds_passwd" "$monDir/grafana-datasource-opensearch.yaml"
+v4m_replace "__opensearch_version__" "$opensearch_version" "$monDir/grafana-datasource-opensearch.yaml"
 
 # Removes old Elasticsearch data source if one exists
 if [ "$cluster" == "true" ]; then
-    if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
-        log_info "Removing existing logging data source secret ..."
-        kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
-    fi
-else
-    if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
-        log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
-        kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
-    fi
+	if [[ -n "$(kubectl get secret -n $MON_NS grafana-datasource-es -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]]; then
+		log_info "Removing existing logging data source secret ..."
+		kubectl delete secret -n $MON_NS --ignore-not-found grafana-datasource-es
+	fi
+else
+	if [ -n "$(kubectl get secret -n $tenantNS v4m-grafana-datasource-es-$tenant -o custom-columns=:metadata.name --no-headers --ignore-not-found)" ]; then
+		log_info "Removing existing logging data source secret for [$tenantNS/$tenant] ..."
+		kubectl delete secret -n $tenantNS --ignore-not-found v4m-grafana-datasource-es-$tenant
+	fi
 fi
 
 # Install OpenSearch datasource plug-in to Grafana
@@ -187,41 +186,41 @@
 grafanaPod=$(kubectl -n $MON_NS get pods -l app.kubernetes.io/name=grafana -o jsonpath='{.items[0].metadata.name}')
 log_debug "Grafana Pod [$grafanaPod]"
 
-pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod  -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
+pluginInstalled=$(kubectl exec -n $MON_NS $grafanaPod -- bash -c "grafana cli plugins ls |grep -c opensearch-datasource|| true")
 log_debug "Grafana OpenSearch Datasource Plugin installed? [$pluginInstalled]"
 
 if [ "$pluginInstalled" == "0" ]; then
 
-   log_info "Installing OpenSearch Datasource plugin"
-   pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
-   pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
-
-   if [ -n "$AIRGAP_HELM_REPO" ]; then
-      log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
-
-      userPluginFile="$USER_DIR/monitoring/$pluginFile"
-      if [ -f "$userPluginFile" ]; then
-         kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
-         kubectl exec -n $MON_NS $grafanaPod  -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
-      else
-         log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
-         exit 1
-      fi
-   else
-      log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
-      kubectl exec -n $MON_NS $grafanaPod  -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
-      log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
-   fi
-else
-   log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
+	log_info "Installing OpenSearch Datasource plugin"
+	pluginVersion="${GRAFANA_DATASOURCE_PLUGIN_VERSION:-2.17.4}"
+	pluginFile="grafana-opensearch-datasource-$pluginVersion.linux_amd64.zip"
+
+	if [ -n "$AIRGAP_HELM_REPO" ]; then
+		log_debug "Air-gapped deployment detected; loading OpenSearch Datasource plugin from USER_DIR/monitoring directory"
+
+		userPluginFile="$USER_DIR/monitoring/$pluginFile"
+		if [ -f "$userPluginFile" ]; then
+			kubectl cp $userPluginFile $MON_NS/$grafanaPod:/var/lib/grafana/plugins
+			kubectl exec -n $MON_NS $grafanaPod -- unzip -o /var/lib/grafana/plugins/$pluginFile -d /var/lib/grafana/plugins/
+		else
+			log_error "The OpenSearch datasource plugin to Grafana zip file was NOT found in the expected location [$userPluginFile]"
+			exit 1
+		fi
+	else
+		log_debug "Using Grafana CLI to install plugin (version [$pluginVersion])"
+		kubectl exec -n $MON_NS $grafanaPod -- grafana cli plugins install grafana-opensearch-datasource $pluginVersion
+		log_info "You may ignore any previous messages regarding restarting the Grafana pod; it will be restarted automatically."
+	fi
+else
+	log_debug "The OpenSearch datasource plugin is already installed; skipping installation."
 fi
 
 # Adds the logging data source to Grafana
 log_info "Provisioning logging data source in Grafana"
 if [ "$cluster" == "true" ]; then
-    kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
-    kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
-    kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
+	kubectl delete secret generic -n $MON_NS grafana-datasource-opensearch --ignore-not-found
+	kubectl create secret generic -n $MON_NS grafana-datasource-opensearch --from-file $monDir/grafana-datasource-opensearch.yaml
+	kubectl label secret -n $MON_NS grafana-datasource-opensearch grafana_datasource=1 sas.com/monitoring-base=kube-viya-monitoring
 fi
 
 # Deploy the log-enabled Viya dashboards
@@ -230,11 +229,11 @@
 # Delete pods so that they can be restarted with the change.
 log_info "Logging data source provisioned in Grafana.  Restarting pods to apply the change"
 if [ "$cluster" == "true" ]; then
-    kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
-    kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured."
-else
-    kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
-    kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
-    log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
+	kubectl delete pods -n $MON_NS -l "app.kubernetes.io/instance=v4m-prometheus-operator" -l "app.kubernetes.io/name=grafana"
+	kubectl -n $MON_NS wait pods --selector "app.kubernetes.io/instance=v4m-prometheus-operator","app.kubernetes.io/name=grafana" --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured."
+else
+	kubectl delete pods -n $tenantNS -l "app.kubernetes.io/instance=v4m-grafana-$tenant"
+	kubectl -n $tenantNS wait pods --selector app.kubernetes.io/instance=v4m-grafana-$tenant --for condition=Ready --timeout=2m
+	log_info "Logging data source in Grafana has been configured for [$tenantNS/$tenant]."
 fi
----------

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

  shfmt -s -w filename


@gsmith-sas gsmith-sas merged commit f2dd0f5 into main Sep 30, 2024
1 check failed
@gsmith-sas gsmith-sas deleted the osdatasource branch September 30, 2024 20:22
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