Skip to content

Commit

Permalink
v2.2.0
Browse files Browse the repository at this point in the history
=====================================================================

--- New Scripts --------------------------

zsh )
  amazon EKS
   - aws/eks/login

--- Changes ------------------------------

- moved global .config to global/config.zsh
- moved various global configurations to global/

--- Bug Fixes ----------------------------

- REDIS_AUTH no longer required to attempt connection
- global configurations now propagate to non-zsh scripts
  • Loading branch information
wrynegade committed Aug 9, 2022
1 parent 89e899d commit e8bb889
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 35 deletions.
32 changes: 32 additions & 0 deletions global/common.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#####################################################################

[ ! $SCWRYPTS_ROOT ] && SCWRYPTS_ROOT="$(dirname ${0:a:h})"

source "${0:a:h}/config.zsh"

#####################################################################

__SCWRYPT=1 # arbitrary; indicates scwrypts exists

__PREFERRED_PYTHON_VERSIONS=(3.10 3.9)
__NODE_VERSION=18.0.0

__ENV_TEMPLATE=$SCWRYPTS_ROOT/.env.template

#####################################################################

__RUN_SCWRYPT() {
((SUBSCWRYPT+=1))
printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " BEGIN SUBSCWRYPT : $(basename $1)"

SUBSCWRYPT=$SUBSCWRYPT SCWRYPTS_ENV=$ENV_NAME \
"$SCWRYPTS_ROOT/scwrypts" $@
EXIT_CODE=$?

printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " END SUBSCWRYPT : $(basename $1)"
((SUBSCWRYPT-=1))

return $EXIT_CODE
}
Binary file renamed .config → global/config.zsh
Binary file not shown.
2 changes: 1 addition & 1 deletion py/redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self):
super().__init__(
host = getenv('REDIS_HOST'),
port = getenv('REDIS_PORT'),
password = getenv('REDIS_AUTH'),
password = getenv('REDIS_AUTH', required=False),
decode_responses = True,
)

Expand Down
6 changes: 6 additions & 0 deletions zsh/aws/eks/common.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_DEPENDENCIES+=(
kubectl
)
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
19 changes: 19 additions & 0 deletions zsh/aws/eks/login
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################

__STATUS "performing AWS ECR docker login"

CLUSTER_NAME=$(\
_AWS eks list-clusters \
| jq -r '.[] | .[]' \
| __FZF 'select a cluster'
)
[ ! $CLUSTER_NAME ] && __ABORT

__STATUS "updating kubeconfig for '$CLUSTER_NAME'"
_AWS eks update-kubeconfig --name $CLUSTER_NAME \
&& __SUCCESS "kubeconfig updated with '$CLUSTER_NAME'" \
|| __ERROR "failed to update kubeconfig; do you have permissions to access '$CLUSTER_NAME'?"
39 changes: 6 additions & 33 deletions zsh/common.zsh
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#####################################################################

[ ! $SCWRYPTS_ROOT ] && SCWRYPTS_ROOT="$(dirname ${0:a:h})"

__PREFERRED_PYTHON_VERSIONS=(3.10 3.9)
__NODE_VERSION=18.0.0
__ENV_TEMPLATE=$SCWRYPTS_ROOT/.env.template

__SCWRYPT=1

source $SCWRYPTS_ROOT/.config
source ${0:a:h}/utils/utils.module.zsh || {
[ $DONT_EXIT ] && return 1 || exit 1
}
source ${0:a:h}/../global/common.zsh
source ${0:a:h}/utils/utils.module.zsh \
|| { [ $DONT_EXIT ] && return 1 || exit 1; }

#####################################################################

Expand All @@ -26,33 +17,15 @@ __GET_ENV_NAMES() { __GET_ENV_FILES | sed 's/.*\///'; }
__GET_ENV_FILE() { echo "$SCWRYPTS_CONFIG_PATH/env/$1"; }

__SELECT_OR_CREATE_ENV() { __GET_ENV_NAMES | __FZF_TAIL 'select/create an environment'; }
__SELECT_ENV() { __GET_ENV_NAMES | __FZF 'select an environment'; }
__SELECT_ENV() { __GET_ENV_NAMES | __FZF 'select an environment'; }

#####################################################################

__GET_AVAILABLE_SCRIPTS() {
cd $SCWRYPTS_ROOT;
find . -mindepth 2 -type f -executable \
| grep -v '\.git' \
| grep -v '\.env' \
| grep -v 'node_modules' \
| sed 's/^\.\///; s/\.[^.]*$//' \
;
}

#####################################################################

__RUN_SCWRYPT() {
# run a scwrypt inside a scwrypt w/stack-depth indicators
((SUBSCWRYPT+=1))
printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " BEGIN SUBSCWRYPT : $(basename $1)"

SUBSCWRYPT=$SUBSCWRYPT SCWRYPTS_ENV=$ENV_NAME \
"$SCWRYPTS_ROOT/scwrypts" $@
EXIT_CODE=$?

printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " END SUBSCWRYPT : $(basename $1)"
((SUBSCWRYPT-=1))

return $EXIT_CODE
}
2 changes: 1 addition & 1 deletion zsh/scwrypts/configure
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source ${0:a:h}/common.zsh
echo '#'
echo '# configuration for scwrypts'
echo '#'
sed -n '1d; /^###/q; p' $SCWRYPTS_ROOT/.config | sed '$d'
sed -n '1d; /^###/q; p' $SCWRYPTS_ROOT/global/config.zsh | sed '$d'
} > $SCWRYPTS_CONFIG_PATH/config

__EDIT $SCWRYPTS_CONFIG_PATH/config
Expand Down

0 comments on commit e8bb889

Please sign in to comment.