Skip to content

Commit

Permalink
Fix AUTHENTICATION_ENABLED unbound variable bug (#51)
Browse files Browse the repository at this point in the history
* Fix AUTHENTICATION_ENABLED unbound variable bug
  • Loading branch information
agianey committed Sep 14, 2020
1 parent 3b59679 commit c8a6d5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions aladdin-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ function environment_init() {

_handle_aws_config

# export AUTHENTICATION_ENABLED for change-permissions and bash command. By default it is false.
# It will only get set to true if the cluster is ready and it is enabled in aladdin-config
export AUTHENTICATION_ENABLED=false

# Make sure we are on local or that cluster has been created before initializing helm, creating namespaces, etc
if "$IS_LOCAL" || ( kops export kubecfg --name $CLUSTER_NAME > /dev/null && \
kops validate cluster --name $CLUSTER_NAME ) > /dev/null; then
if _is_cluster_ready; then

if "$IS_LOCAL"; then
mkdir -p $HOME/.kube/
Expand Down Expand Up @@ -122,6 +125,11 @@ function environment_init() {

}

function _is_cluster_ready() {
# Cluster is ready if we are on LOCAL or if we can pull kube config via kops
"$IS_LOCAL" || kops export kubecfg --name $CLUSTER_NAME
}

function _initialize_helm() {
local rbac_enabled="$(_extract_cluster_config_value rbac_enabled)"
if $rbac_enabled; then
Expand All @@ -135,7 +143,6 @@ function _initialize_helm() {

function _handle_authentication_config() {
# This function adds appropriate users to kubeconfig, and exports necessary AUTHENTICATION variables
# export AUTHENTICATION_ENABLED for change-permissions and bash command
export AUTHENTICATION_ENABLED="$(_extract_cluster_config_value authentication_enabled)"
if $AUTHENTICATION_ENABLED; then
AUTHENTICATION_ROLES="$(_extract_cluster_config_value authentication_roles)"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bash_profile.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function restore_permission() {
}

function with_aladdin_perms_wrapper() {
old_user="$(get_current_user)"
if "$AUTHENTICATION_ENABLED"; then
old_user="$(get_current_user)"
change_to_aladdin_permission
fi
"$@"
Expand Down

0 comments on commit c8a6d5c

Please sign in to comment.