yage
6f42c9cb16
===================================================================== --- New Features ------------------------- - Github Actions integration from 3.7.0 and up! ```yaml # try it out in gh actions - uses: wrynegade/scwrypts@main with: version: v3.7.0 scwrypt: --name hello-world --group scwrypts --type py args: --message "hello from github actions ci <3" ``` --- New Scripts -------------------------- zsh/helm ) smart helm template functions (simply pass a filename) - get-template - update-dependencies --- Changes ------------------------------ - CHECK_ENVIRONMENT now uses proper argument parsing - scwrypts/plugins loaded by setting in config or environment: SCWRYPTS_PLUGIN_ENABLED__plugin=1 - SCWRYPTS__GET_PATH_TO_RELATIVE_ARGUMENT was missed in the v2->v3 refactor and has now been reincluded as SCWRYPTS__GET_REALPATH
66 lines
1.4 KiB
Bash
66 lines
1.4 KiB
Bash
#####################################################################
|
|
|
|
DEPENDENCIES+=(yq)
|
|
REQUIRED_ENV+=()
|
|
|
|
#####################################################################
|
|
|
|
HELM__VALIDATE() {
|
|
[ ! $USAGE ] && USAGE="
|
|
usage:
|
|
|
|
environment
|
|
TEMPLATE_FILENAME target template filename
|
|
|
|
Smart helm-detection / validator which determines the helm
|
|
chart root and other details given a particular filename.
|
|
"
|
|
|
|
[ $TEMPLATE_FILENAME ] && [ -f "$TEMPLATE_FILENAME" ] || {
|
|
ERROR 'must provide a template filename'
|
|
return 1
|
|
}
|
|
|
|
_HELM__GET_CHART_ROOT
|
|
[ $CHART_ROOT ] && [ -d "$CHART_ROOT" ] || {
|
|
ERROR 'unable to determine helm root; is this a helm template file?'
|
|
return 1
|
|
}
|
|
|
|
CHART_NAME=$(yq -r .name "$CHART_ROOT/Chart.yaml")
|
|
|
|
[[ $TEMPLATE_FILENAME =~ values*.yaml$ ]] && {
|
|
HELM_ARGS+=(--values $TEMPLATE_FILENAME)
|
|
USE_CHART_ROOT=1
|
|
}
|
|
|
|
[[ $(dirname $TEMPLATE_FILENAME) =~ ^$CHART_ROOT$ ]] \
|
|
&& USE_CHART_ROOT=1
|
|
|
|
_HELM__GET_DEFAULT_VALUES_ARGS
|
|
|
|
return 0
|
|
}
|
|
|
|
_HELM__GET_CHART_ROOT() {
|
|
local SEARCH_DIR=$(dirname "$TEMPLATE_FILENAME")
|
|
while [ ! $CHART_ROOT ] && [[ ! $SEARCH_DIR =~ ^/$ ]]
|
|
do
|
|
[ -f "$SEARCH_DIR/Chart.yaml" ] && CHART_ROOT="$SEARCH_DIR" && return 0
|
|
SEARCH_DIR="$(dirname "$SEARCH_DIR")"
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
_HELM__GET_DEFAULT_VALUES_ARGS() {
|
|
for F in \
|
|
"$CHART_ROOT/values.yaml" \
|
|
"$CHART_ROOT/values.test.yaml" \
|
|
"$CHART_ROOT/tests/default.yaml" \
|
|
;
|
|
do
|
|
[ -f "$F" ] && HELM_ARGS+=(--values "$F")
|
|
done
|
|
}
|