Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions dev-tools/roxctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ set -eo pipefail

is_operator_on_openshift() {
local result=0
kubectl get clusterversions.config.openshift.io version | grep -v "No resources found" > /dev/null
if [[ "$?" -ne "0" ]]; then
cmd() {
kubectl get clusterversions.config.openshift.io version | grep -v "No resources found" > /dev/null && kubectl get centrals.platform.stackrox.io -n stackrox | grep -v "No resources found" > /dev/null
}
if ! cmd; then
result=1
fi

kubectl get centrals.platform.stackrox.io -n stackrox | grep -v "No resources found" > /dev/null
if [[ "$?" -ne "0" ]]; then
result=1
fi
return "$result"
}

Expand All @@ -28,18 +25,18 @@ fi

cache=""
if [[ -n "${KUBECONFIG}" ]]; then
cache="/tmp/$(md5 -q ${KUBECONFIG})"
cache="/tmp/$(md5 -q "${KUBECONFIG}")"
fi
endpoint="localhost:8000"
password="$(cat "$DIR/../deploy/k8s/central-deploy/password")"

if [[ -n "$cache" ]]; then
endpoint=$(cat "${cache}" | awk '{print $1}')
password=$(cat "${cache}" | awk '{print $2}')
endpoint=$(awk '{print $1}' < "${cache}")
password=$(awk '{print $2}' < "${cache}")
elif is_operator_on_openshift; then
endpoint="$(oc get route -n stackrox central -o json | jq -r '.spec.host'):443"
password=$(oc get secret -n stackrox central-htpasswd -o json | jq -r '.data.password' | base64 --decode)
printf "$endpoint\t$password" > "${cache}"
printf "%s\t%s" "$endpoint" "$password" > "${cache}"
fi

"$roxctl_bin" -e "https://${endpoint}" -p "$password" --insecure-skip-tls-verify "$@"
1 change: 0 additions & 1 deletion scripts/style/shellcheck_skip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ deploy/openshift/deploy.sh
deploy/openshift/sensor.sh
dev-tools/add-host-alias.sh
dev-tools/enable-hotreload.sh
dev-tools/roxctl.sh
image/assets/docker-auth.sh
image/central-entrypoint.sh
image/postgres/scripts/docker-entrypoint.sh
Expand Down