import-stx: namespace validation after KUBECONFIG export

Changing the order where we check if the namespace exists as
we need the KUBECONFIG file exported before we can use kubectl

Signed-off-by: Luis Sampaio <luis.sampaio@windriver.com>
Change-Id: I6b87f8584830973cec88132b0578cb7df6026747
This commit is contained in:
Luis Sampaio 2022-02-25 14:13:05 -08:00
parent a6e4871dd9
commit 818ab28eec

View File

@ -139,11 +139,6 @@ elif [ "$STX_PLATFORM" = "kubernetes" ]; then
return 1
fi
if ! kubectl get namespace 2>/dev/null | grep -q $STX_K8S_NAMESPACE; then
notice_warn "namespace $STX_K8S_NAMESPACE not found"
return 1
fi
if [ -z "$KUBECONFIG" ]; then
# Kubeconfig default location inside STX_BUILD_HOME
export KUBECONFIG=$STX_BUILD_HOME/.kube/config
@ -155,6 +150,11 @@ elif [ "$STX_PLATFORM" = "kubernetes" ]; then
return 1
fi
if ! kubectl get namespace 2>/dev/null | grep -q $STX_K8S_NAMESPACE; then
notice_warn "namespace $STX_K8S_NAMESPACE not found"
return 1
fi
else
notice_warn "\$STX_PLATFORM not specified, valid options are: 'minikube' or 'kubernetes'"
return 1