From 818ab28eecb650857f2505bee436fb0e9d68557f Mon Sep 17 00:00:00 2001 From: Luis Sampaio Date: Fri, 25 Feb 2022 14:13:05 -0800 Subject: [PATCH] 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 Change-Id: I6b87f8584830973cec88132b0578cb7df6026747 --- import-stx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/import-stx b/import-stx index 92d1c13e..cf4f5844 100644 --- a/import-stx +++ b/import-stx @@ -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