Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Commit

Permalink
gk-deploy: fail to run without user-key and admin-key
Browse files Browse the repository at this point in the history
Signed-off-by: Prasanna Kumar Kalever <[email protected]>
  • Loading branch information
Prasanna Kumar Kalever committed May 22, 2020
1 parent 7815b05 commit 544daf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions deploy/gk-deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
# Copyright (c) 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

PROG="$(basename "${0}")"
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
PROG="$(/usr/bin/basename "${0}")"
SCRIPT_DIR="$(cd "$(/usr/bin/dirname "${0}")" && pwd)"
TOPOLOGY='topology.json'
LOG_FILE=''
VERBOSE=0
Expand Down Expand Up @@ -574,7 +574,7 @@ if [[ ! -f ${TOPOLOGY} ]]; then
echo "Topology File not found!"
exit 1
else
NODES=$(python - <<END
NODES=$(/usr/bin/python - <<END
# coding: utf8
import sys
import json
Expand Down Expand Up @@ -604,8 +604,8 @@ if [[ "x${ADMIN_KEY}" == "x" || "x${USER_KEY}" == "x" ]]; then
fi

if [[ "x${CLI}" == "x" ]]; then
kubectl=$(type kubectl 2>/dev/null | awk '{print $3}')
oc=$(type oc 2>/dev/null | awk '{print $3}')
kubectl=$(type kubectl 2>/dev/null | /usr/bin/awk '{print $3}')
oc=$(type oc 2>/dev/null | /usr/bin/awk '{print $3}')
if [[ "x${oc}" != "x" ]]; then
CLI="${oc}"
elif [[ "x${kubectl}" != "x" ]]; then
Expand Down
17 changes: 9 additions & 8 deletions tests/simple/gk-deploy/test_gk_deploy_basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BASE_DIR="${SCRIPT_DIR}/../../.."
DEPLOY_DIR="${BASE_DIR}/deploy"

GK_DEPLOY="${DEPLOY_DIR}/gk-deploy"
MANDATORY_OPTS="--admin-key=test --user-key=test"
TOPOLOGY="${DEPLOY_DIR}/topology.json.sample"

PATH="${STUBS_DIR}:$PATH"
Expand All @@ -18,10 +19,10 @@ source "${INC_DIR}/shell_tests.sh"
test_missing_topology () {
local args=( -y )

OUT=$("${GK_DEPLOY}" "${args[@]}")
OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}")
local rc=${?}

echo "cmd: '${GK_DEPLOY} ${args[*]}'"
echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]}'"
echo "output:"
echo "${OUT}"

Expand All @@ -37,10 +38,10 @@ test_cli_not_found () {
local args=( -y )
local expected_out="Container platform CLI (e.g. kubectl, oc) not found."

OUT=$(PATH='/doesnotexist' "${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}")
OUT=$(PATH='/doesnotexist' "${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}")
local rc=${?}

echo "cmd: 'PATH='/doesnotexist' ${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'"
echo "cmd: 'PATH='/doesnotexist' ${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'"
echo "output:"
echo "${OUT}"

Expand Down Expand Up @@ -68,10 +69,10 @@ test_cli_unknown () {
local args=( -y -c "${cli}" )
local expected_out="Unknown CLI '${cli}'."

OUT=$("${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}")
OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}")
local rc=${?}

echo "cmd: '${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'"
echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'"
echo "output:"
echo "${OUT}"

Expand Down Expand Up @@ -99,10 +100,10 @@ test_namespace_invalid () {
local expected_out="Namespace 'invalid' not found"

# shellcheck disable=SC2086
OUT=$("${GK_DEPLOY}" "${args[@]}" "${TOPOLOGY}")
OUT=$("${GK_DEPLOY}" "${MANDATORY_OPTS}" "${args[@]}" "${TOPOLOGY}")
local rc=${?}

echo "cmd: '${GK_DEPLOY} ${args[*]} ${TOPOLOGY}'"
echo "cmd: '${GK_DEPLOY} ${MANDATORY_OPTS} ${args[*]} ${TOPOLOGY}'"
echo "output:"
echo "${OUT}"

Expand Down

0 comments on commit 544daf8

Please sign in to comment.