From e466145e1c1e359a388f3bd2e15130941ac76c1e Mon Sep 17 00:00:00 2001
From: Pawel Wieczorek
Date: Wed, 31 Jul 2019 15:38:15 +0200
Subject: k8s: Make ONAP context default for kubectl
This patch uses previously added alias for kubectl context switching in
case it is needed as a template for other contexts as well.
Issue-ID: SECCOM-235
Change-Id: Ie92641ee3763a027cd74dd21bf4364a2d796eb1d
Signed-off-by: Pawel Wieczorek
---
test/security/k8s/tools/dublin/setup_kubectl.sh | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/test/security/k8s/tools/dublin/setup_kubectl.sh b/test/security/k8s/tools/dublin/setup_kubectl.sh
index a50c23656..bbd31a930 100755
--- a/test/security/k8s/tools/dublin/setup_kubectl.sh
+++ b/test/security/k8s/tools/dublin/setup_kubectl.sh
@@ -17,7 +17,9 @@
#
# Constants
+BASHRC='.bashrc'
BASH_ALIASES='.bash_aliases'
+USE_ONAP_ALIAS='useonap'
DEFAULT_RKE_CONFIG='kube_config_cluster.yml'
DEFAULT_KUBE_DIR='.kube'
@@ -31,11 +33,20 @@ KUBE_CONFIG="${3:-$DEFAULT_KUBE_CONFIG}"
KUBE_CONTEXT="${4:-$DEFAULT_KUBE_CONTEXT}"
USE_ONAP="f() { export KUBECONFIG=${KUBE_DIR}/${KUBE_CONFIG}; kubectl config use-context ${KUBE_CONTEXT}; }; f"
+USE_ONAP_CONFIG="$(cat<> "${HOME}/${BASH_ALIASES}"
+echo "alias ${USE_ONAP_ALIAS}='${USE_ONAP}'" >> "${HOME}/${BASH_ALIASES}"
# Setup
cp "$RKE_CONFIG" "${KUBE_DIR}/${KUBE_CONFIG}"
+
+# Post-setup
+echo "$USE_ONAP_CONFIG" >> "${HOME}/${BASHRC}"
--
cgit 1.2.3-korg