From 65fe6fcbf0a674f4adbfda15a798f5e5b804126a Mon Sep 17 00:00:00 2001 From: diverdane Date: Fri, 6 Aug 2021 18:50:38 -0400 Subject: [PATCH] Eliminates CONJUR_NAMESPACE undefined errors in KinD example Currently, if you run the Kubernetes-in-Docker (KinD) example in 'examples/kubernetes-in-docker', the scripts generate an error for CONJUR_NAMESPACE being an undefined environment variable. This is fixed by reversing the order in which CONJUR_NAMESPACE and CONJUR_NAMESPACE_NAME environment variables are evaluated. This also eliminates a minor, benign error message about a non-existent "conjur-oss" Namespace when the scripts check to see if this Namespace exists and it does not exist. --- examples/common/utils.sh | 2 +- examples/kubernetes-in-docker/0_export_env_vars.sh | 6 +++--- examples/openshift/0_export_env_vars.sh | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/common/utils.sh b/examples/common/utils.sh index 29429b2..ff4895d 100755 --- a/examples/common/utils.sh +++ b/examples/common/utils.sh @@ -32,7 +32,7 @@ get_master_pod_name() { } has_namespace() { - if kubectl get namespace "$1" > /dev/null; then + if kubectl get namespace "$1" &>/dev/null; then true else false diff --git a/examples/kubernetes-in-docker/0_export_env_vars.sh b/examples/kubernetes-in-docker/0_export_env_vars.sh index f554454..e379d56 100755 --- a/examples/kubernetes-in-docker/0_export_env_vars.sh +++ b/examples/kubernetes-in-docker/0_export_env_vars.sh @@ -5,10 +5,10 @@ export KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" # Helm install options export HELM_INSTALL_CONJUR="${HELM_INSTALL_CONJUR:-true}" export HELM_RELEASE="${HELM_RELEASE:-conjur-oss}" -# The Conjur namespace name might be set with CONJUR_NAMESPACE_NAME in other projects -# so look for both. Use CONJUR_NAMESPACE_NAME if both are set. -export CONJUR_NAMESPACE="${CONJUR_NAMESPACE_NAME:-$CONJUR_NAMESPACE}" +# The Conjur namespace name might be set with CONJUR_NAMESPACE_NAME in other +# projects so look for both. Use CONJUR_NAMESPACE_NAME if both are set. export CONJUR_NAMESPACE="${CONJUR_NAMESPACE:-conjur-oss}" +export CONJUR_NAMESPACE="${CONJUR_NAMESPACE_NAME:-$CONJUR_NAMESPACE}" export CONJUR_ACCOUNT="${CONJUR_ACCOUNT:-myConjurAccount}" export CONJUR_LOG_LEVEL="${CONJUR_LOG_LEVEL:-info}" diff --git a/examples/openshift/0_export_env_vars.sh b/examples/openshift/0_export_env_vars.sh index a523dab..09bb450 100755 --- a/examples/openshift/0_export_env_vars.sh +++ b/examples/openshift/0_export_env_vars.sh @@ -5,10 +5,10 @@ export KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" # Helm install options export HELM_INSTALL_CONJUR="${HELM_INSTALL_CONJUR:-true}" export HELM_RELEASE="${HELM_RELEASE:-conjur-oss}" -# The Conjur namespace name might be set with CONJUR_NAMESPACE_NAME in other projects -# so look for both. Use CONJUR_NAMESPACE_NAME if both are set. -export CONJUR_NAMESPACE="${CONJUR_NAMESPACE_NAME:-$CONJUR_NAMESPACE}" +# The Conjur namespace name might be set with CONJUR_NAMESPACE_NAME in other +# projects so look for both. Use CONJUR_NAMESPACE_NAME if both are set. export CONJUR_NAMESPACE="${CONJUR_NAMESPACE:-conjur-oss}" +export CONJUR_NAMESPACE="${CONJUR_NAMESPACE_NAME:-$CONJUR_NAMESPACE}" export CONJUR_ACCOUNT="${CONJUR_ACCOUNT:-myConjurAccount}" export CONJUR_LOG_LEVEL="${CONJUR_LOG_LEVEL:-info}"