Skip to content

Commit e298a3e

Browse files
committed
Linting: shftmt (1)
1 parent 3714242 commit e298a3e

File tree

3 files changed

+93
-98
lines changed

3 files changed

+93
-98
lines changed

logging/bin/deploy_logging_azmonitor.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tmpfile=$TMP_DIR/output.txt
1212
rm -f tmpfile
1313

1414
if [ "$(kubectl get ns "$LOG_NS" -o name 2>/dev/null)" == "" ]; then
15-
kubectl create ns "$LOG_NS"
15+
kubectl create ns "$LOG_NS"
1616
fi
1717

1818
set -e
@@ -26,6 +26,5 @@ log_notice "Deploying logging components to the [$LOG_NS] namespace [$(date)]"
2626
log_info "STEP 1: Deploying Fluent Bit"
2727
logging/bin/deploy_fluentbit_azmonitor.sh
2828

29-
3029
log_notice "The deployment of logging components has completed [$(date)]"
3130
echo ""

logging/bin/deploy_servicemonitors_openshift.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ log_debug "Script [$this_script] has started [$(date)]"
1414
DEPLOY_SERVICEMONITORS=${DEPLOY_SERVICEMONITORS:-false}
1515

1616
if [ "$DEPLOY_SERVICEMONITORS" != "true" ]; then
17-
log_info "Environment variable [DEPLOY_SERVICEMONITORS] is not set to 'true'; exiting WITHOUT deploying ServiceMonitors"
18-
exit
17+
log_info "Environment variable [DEPLOY_SERVICEMONITORS] is not set to 'true'; exiting WITHOUT deploying ServiceMonitors"
18+
exit
1919
fi
2020

2121
EVENTROUTER_ENABLE=${EVENTROUTER_ENABLE:-true}
2222
if [ "$EVENTROUTER_ENABLE" == "true" ]; then
23-
# Eventrouter ServiceMonitor
24-
kubectl apply -n "$LOG_NS" -f monitoring/monitors/kube/podMonitor-eventrouter.yaml
23+
# Eventrouter ServiceMonitor
24+
kubectl apply -n "$LOG_NS" -f monitoring/monitors/kube/podMonitor-eventrouter.yaml
2525
fi
2626

2727
ELASTICSEARCH_ENABLE=${ELASTICSEARCH_ENABLE:-true}
2828
if [ "$ELASTICSEARCH_ENABLE" == "true" ]; then
29-
# Elasticsearch ServiceMonitor
30-
kubectl apply -n "$LOG_NS" -f monitoring/monitors/logging/serviceMonitor-elasticsearch.yaml
29+
# Elasticsearch ServiceMonitor
30+
kubectl apply -n "$LOG_NS" -f monitoring/monitors/logging/serviceMonitor-elasticsearch.yaml
3131
fi
3232

3333
FLUENT_BIT_ENABLED=${FLUENT_BIT_ENABLED:-true}
3434
if [ "$FLUENT_BIT_ENABLED" == "true" ]; then
35-
# Fluent Bit ServiceMonitors
36-
kubectl apply -n "$LOG_NS" -f monitoring/monitors/logging/serviceMonitor-fluent-bit-v2.yaml
35+
# Fluent Bit ServiceMonitors
36+
kubectl apply -n "$LOG_NS" -f monitoring/monitors/logging/serviceMonitor-fluent-bit-v2.yaml
3737
fi
3838

3939
log_info "ServiceMonitors have been deployed."

logging/bin/offboard.sh

Lines changed: 84 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -12,73 +12,69 @@ source logging/bin/rbac-include.sh
1212

1313
this_script=$(basename "$0")
1414

15-
1615
function show_usage {
17-
log_message "Usage: $this_script --namespace NAMESPACE [--tenant TENANT] [OPTIONS]"
18-
log_message ""
19-
log_message "'Offboards' either the specified SAS Viya deployment (namespace) or the specified tenant within that deployment. This removes the ability to limit admins to the SAS Viya deployment (or a single tenant within a given deployment)."
20-
log_message "The offboarding process deletes the security access controls and the associated OpenSearch Dashboards tenant space (including any saved OpenSearch Dashboards content (e.g. visualizations, dashboards, etc.)."
21-
log_message ""
22-
log_message " Arguments:"
23-
log_message " -ns, --namespace NAMESPACE - (Required) The SAS Viya deployment/Kubernetes Namespace to which access should be removed."
24-
log_message " -t, --tenant TENANT - (Optional) The tenant within the specific SAS Viya deployment/Kubernetes Namespace to which access should be removed."
25-
log_message ""
26-
#log_message " Options:"
27-
#log_message ""
16+
log_message "Usage: $this_script --namespace NAMESPACE [--tenant TENANT] [OPTIONS]"
17+
log_message ""
18+
log_message "'Offboards' either the specified SAS Viya deployment (namespace) or the specified tenant within that deployment. This removes the ability to limit admins to the SAS Viya deployment (or a single tenant within a given deployment)."
19+
log_message "The offboarding process deletes the security access controls and the associated OpenSearch Dashboards tenant space (including any saved OpenSearch Dashboards content (e.g. visualizations, dashboards, etc.)."
20+
log_message ""
21+
log_message " Arguments:"
22+
log_message " -ns, --namespace NAMESPACE - (Required) The SAS Viya deployment/Kubernetes Namespace to which access should be removed."
23+
log_message " -t, --tenant TENANT - (Optional) The tenant within the specific SAS Viya deployment/Kubernetes Namespace to which access should be removed."
24+
log_message ""
25+
#log_message " Options:"
26+
#log_message ""
2827
}
2928

30-
3129
# set flag indicating wrapper/driver script being run
3230
export LOGGING_DRIVER=true
3331

34-
3532
#
3633
#Handle arguments and parameters
3734
#
3835
POS_PARMS=""
3936

4037
while (( "$#" )); do
41-
case "$1" in
42-
-ns|--namespace)
43-
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
44-
namespace=$2
45-
shift 2
46-
else
47-
log_error "A value for parameter [NAMESPACE] has not been provided." >&2
48-
show_usage
49-
exit 2
50-
fi
51-
;;
52-
-t|--tenant)
53-
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
54-
tenant=$2
55-
shift 2
56-
else
57-
log_error "A value for parameter [TENANT] has not been provided." >&2
58-
show_usage
59-
exit 2
60-
fi
61-
;;
62-
-h|--help)
63-
show_usage
64-
exit
65-
;;
66-
--*=|-*) # unsupported flags
67-
log_error "Unsupported flag $1" >&2
68-
show_usage
69-
exit 1
70-
;;
71-
*) # preserve positional arguments
72-
POS_PARMS="$POS_PARMS $1"
73-
shift
74-
;;
75-
esac
38+
case "$1" in
39+
-ns | --namespace)
40+
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
41+
namespace=$2
42+
shift 2
43+
else
44+
log_error "A value for parameter [NAMESPACE] has not been provided." >&2
45+
show_usage
46+
exit 2
47+
fi
48+
;;
49+
-t | --tenant)
50+
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
51+
tenant=$2
52+
shift 2
53+
else
54+
log_error "A value for parameter [TENANT] has not been provided." >&2
55+
show_usage
56+
exit 2
57+
fi
58+
;;
59+
-h | --help)
60+
show_usage
61+
exit
62+
;;
63+
--*= | -*) # unsupported flags
64+
log_error "Unsupported flag $1" >&2
65+
show_usage
66+
exit 1
67+
;;
68+
*) # preserve positional arguments
69+
POS_PARMS="$POS_PARMS $1"
70+
shift
71+
;;
72+
esac
7673
done
7774

7875
# set positional arguments in their proper place
7976
eval set -- "$POS_PARMS"
8077

81-
8278
# No positional parameters are supported
8379
if [ "$#" -ge 1 ]; then
8480
log_error "Unexpected additional arguments were found; exiting."
@@ -87,38 +83,38 @@ if [ "$#" -ge 1 ]; then
8783
fi
8884

8985
# Convert namespace and tenant to all lower-case
90-
namespace=$(echo "$namespace"| tr '[:upper:]' '[:lower:]')
91-
tenant=$(echo "$tenant"| tr '[:upper:]' '[:lower:]')
86+
namespace=$(echo "$namespace" | tr '[:upper:]' '[:lower:]')
87+
tenant=$(echo "$tenant" | tr '[:upper:]' '[:lower:]')
9288

9389
# validation of input args
9490
if [ "$namespace" == "global" ]; then
95-
log_error "Invalid namespace value specified; you can NOT offboard the [global] namespace."
96-
exit 1
91+
log_error "Invalid namespace value specified; you can NOT offboard the [global] namespace."
92+
exit 1
9793
fi
9894

9995
validateNamespace "$namespace"
10096

10197
if [ -n "$tenant" ]; then
102-
validateTenantID "$tenant"
98+
validateTenantID "$tenant"
10399

104-
nst="${namespace}_${tenant}"
105-
index_nst="${namespace}-__${tenant}__"
100+
nst="${namespace}_${tenant}"
101+
index_nst="${namespace}-__${tenant}__"
106102
else
107-
nst="$namespace"
108-
# shellcheck disable=SC2034
109-
index_nst="${namespace}"
103+
nst="$namespace"
104+
# shellcheck disable=SC2034
105+
index_nst="${namespace}"
110106
fi
111107

112108
# OpenSearch Dashboards tenant space
113109
ktenant=$nst
114110

115111
if [ -n "$tenant" ]; then
116-
tenant_description="An OpenSearch Dashboards tenant space for tenant [$tenant] within SAS Viya deployment (namespace) [$namespace]."
117-
log_notice "Offboarding tenant [$tenant] within namespace [$namespace] [$(date)]"
112+
tenant_description="An OpenSearch Dashboards tenant space for tenant [$tenant] within SAS Viya deployment (namespace) [$namespace]."
113+
log_notice "Offboarding tenant [$tenant] within namespace [$namespace] [$(date)]"
118114
else
119-
# shellcheck disable=SC2034
120-
tenant_description="An OpenSearch Dashboards tenant space for SAS Viya deployment (namespace) [$namespace]."
121-
log_notice "Offboarding namespace [$namespace] [$(date)]"
115+
# shellcheck disable=SC2034
116+
tenant_description="An OpenSearch Dashboards tenant space for SAS Viya deployment (namespace) [$namespace]."
117+
log_notice "Offboarding namespace [$namespace] [$(date)]"
122118
fi
123119

124120
#
@@ -136,34 +132,34 @@ get_sec_api_url
136132

137133
# Delete OpenSearch Dashboards tenant space (if it exists)
138134
if kibana_tenant_exists "$ktenant"; then
139-
delete_kibana_tenant "$ktenant"
140-
rc=$?
141-
if [ "$rc" == "0" ]; then
142-
add_notice " "
143-
add_notice " The OpenSearch Dashboards tenant space [$ktenant] has been deleted. "
144-
add_notice " "
145-
else
146-
log_error "Problems were encountered while attempting to delete tenant space [$ktenant]."
147-
exit 1
148-
fi
135+
delete_kibana_tenant "$ktenant"
136+
rc=$?
137+
if [ "$rc" == "0" ]; then
138+
add_notice " "
139+
add_notice " The OpenSearch Dashboards tenant space [$ktenant] has been deleted. "
140+
add_notice " "
141+
else
142+
log_error "Problems were encountered while attempting to delete tenant space [$ktenant]."
143+
exit 1
144+
fi
149145
else
150-
log_warn "The OpenSearch Dashboards tenant space [$ktenant] does not exist and, therefore, could not be deleted."
146+
log_warn "The OpenSearch Dashboards tenant space [$ktenant] does not exist and, therefore, could not be deleted."
151147
fi
152148

153149
# Delete ES index containing tenant content
154-
kibana_index_name=".kibana_*_$(echo "$ktenant"|tr -d _)"
155-
response=$(curl -s -o /dev/null -w "%{http_code}" -XDELETE "${es_api_url}/$kibana_index_name" --user "$ES_ADMIN_USER":"$ES_ADMIN_PASSWD" --insecure)
150+
kibana_index_name=".kibana_*_$(echo "$ktenant" | tr -d _)"
151+
response=$(curl -s -o /dev/null -w "%{http_code}" -XDELETE "${es_api_url}/$kibana_index_name" --user "$ES_ADMIN_USER":"$ES_ADMIN_PASSWD" --insecure)
156152
if [[ $response == 2* ]]; then
157-
log_info "Deleted index [$kibana_index_name]. [$response]"
153+
log_info "Deleted index [$kibana_index_name]. [$response]"
158154
else
159-
log_warn "There was an issue deleting the index [$kibana_index_name] holding content related to OpenSearch Dashboards tenant space [$ktenant]. You may need to manually delete this index. [$response]"
155+
log_warn "There was an issue deleting the index [$kibana_index_name] holding content related to OpenSearch Dashboards tenant space [$ktenant]. You may need to manually delete this index. [$response]"
160156
fi
161157

162-
response=$(curl -s -o /dev/null -w "%{http_code}" -XDELETE "${es_api_url}/${kibana_index_name}_*" --user "$ES_ADMIN_USER":"$ES_ADMIN_PASSWD" --insecure)
158+
response=$(curl -s -o /dev/null -w "%{http_code}" -XDELETE "${es_api_url}/${kibana_index_name}_*" --user "$ES_ADMIN_USER":"$ES_ADMIN_PASSWD" --insecure)
163159
if [[ $response == 2* ]]; then
164-
log_info "Deleted index [${kibana_index_name}_*]. [$response]"
160+
log_info "Deleted index [${kibana_index_name}_*]. [$response]"
165161
else
166-
log_warn "There was an issue deleting the index [${kibana_index_name}_*] holding content related to OpenSearch Dashboards tenant space [$ktenant]. You may need to manually delete this index. [$response]"
162+
log_warn "There was an issue deleting the index [${kibana_index_name}_*] holding content related to OpenSearch Dashboards tenant space [$ktenant]. You may need to manually delete this index. [$response]"
167163
fi
168164

169165

@@ -173,16 +169,16 @@ fi
173169
# Delete Grafana Datasource utility user (if exists)
174170
grfds_user="${nst}_grafana_ds"
175171
if user_exists "$grfds_user"; then
176-
log_verbose "Removing the [$grfds_user] utility account."
177-
delete_user "$grfds_user"
172+
log_verbose "Removing the [$grfds_user] utility account."
173+
delete_user "$grfds_user"
178174
fi
179175

180176
# Reminder that users are not deleted
181177
add_notice " "
182178
add_notice " The off-boarding process does NOT remove any users. If there "
183179
add_notice " are users which are no longer needed after off-boarding the "
184180
if [ -n "$tenant" ]; then
185-
add_notice " tenant [$tenant] within the "
181+
add_notice " tenant [$tenant] within the "
186182
fi
187183
add_notice " SAS Viya deployment/namespace of [$namespace] "
188184
add_notice " you must delete those users manually, either through the "
@@ -199,7 +195,7 @@ echo ""
199195

200196
# Exit with an overall success/failure message
201197
if [ -n "$tenant" ]; then
202-
log_notice "Successfully offboarded tenant [$tenant] within namespace [$namespace] [$(date)]"
198+
log_notice "Successfully offboarded tenant [$tenant] within namespace [$namespace] [$(date)]"
203199
else
204-
log_notice "Successfully offboarded namespace [$namespace] [$(date)]"
200+
log_notice "Successfully offboarded namespace [$namespace] [$(date)]"
205201
fi

0 commit comments

Comments
 (0)