===================================================================== Excited to bring V5 to life. This includes some BREAKING CHANGES to several aspects of ZSH-type scwrypts. Please refer to the readme for upgrade details (specifically docs/upgrade/v4-to-v5.md) --- New Features ------------------------- - ZSH testing library with basic mock capabilities - new scwrypts environment file format includes metadata and more advanced features like optional parent env overrides, selection inheritence, and improved structurual flexibility - speedup cache for non-CI runs of ZSH-type scwrypts - ${scwryptsmodule} syntax now allows a consistent unique-naming scheme for functions in ZSH-type scwrypts while providing better insight into origin of API calls in other modules - reusable, case-statement-driven argument parsers in ZSH-type scwrypts --- Changes ------------------------------ - several utility function renames in ZSH-type scwrypts to improve consistency - documentation comments included in ZSH libraries - ZSH-type scwrypts now allow library modules to live alongside executables (zsh/lib still supported; autodetection determines default) --- Bug Fixes ---------------------------- - hardened environment checking for REQUIRED_ENV variables; this removes the ability to overwrite variables in local function contexts
57 lines
1.2 KiB
Bash
57 lines
1.2 KiB
Bash
#####################################################################
|
|
|
|
use --group kube kubectl/cli
|
|
use --group kube kubectl/namespace
|
|
use --group kube redis
|
|
|
|
#####################################################################
|
|
|
|
${scwryptsmodule}.get() { kube.redis get --prefix "current:context"; }
|
|
|
|
${scwryptsmodule}.set() {
|
|
local CONTEXT=$1
|
|
[ ! "${CONTEXT}" ] && return 1
|
|
|
|
[[ "${CONTEXT}" =~ reset ]] && {
|
|
: \
|
|
&& kube.redis del --prefix "current:context" \
|
|
&& kube.kubectl.namespace.set reset \
|
|
;
|
|
return $?
|
|
}
|
|
|
|
: \
|
|
&& kube.redis set --prefix "current:context" "${CONTEXT}" \
|
|
&& kube.kubectl.namespace.set reset \
|
|
;
|
|
}
|
|
|
|
${scwryptsmodule}.select() {
|
|
case "$(kube.kubectl.context.list | grep -v '^reset$' | wc -l)" in
|
|
( 0 )
|
|
echo.error "no contexts available"
|
|
return 1
|
|
;;
|
|
( 1 )
|
|
kube.kubectl.context.list | tail -n1
|
|
;;
|
|
( * )
|
|
kube.kubectl.context.list | utils.fzf 'select a context'
|
|
;;
|
|
esac
|
|
}
|
|
|
|
${scwryptsmodule}.list() {
|
|
echo reset
|
|
local ALL_CONTEXTS="$(kube.cli config get-contexts -o name | sort -u)"
|
|
|
|
echo "${ALL_CONTEXTS}" | grep -v '^arn:aws:eks'
|
|
|
|
[[ "${AWS_ACCOUNT}" ]] && {
|
|
echo "${ALL_CONTEXTS}" | grep "^arn:aws:eks:.*:${AWS_ACCOUNT}"
|
|
true
|
|
} || {
|
|
echo "${ALL_CONTEXTS}" | grep '^arn:aws:eks'
|
|
}
|
|
}
|