yage
f3e70c61cb
===================================================================== --- Changes ------------------------------ - scwrypts runner has new arguments -q/--quiet allows quiet-mode operation while still logging to logfiles -v/--verbose forces verbose mode --version longform required (-v is now for "verbose" mode) - scwrypts runner now auto-detects certain CLI usage, running in quiet, logged mode if pattern match successfully identifies a single scwrypt (or when using --name); use --verbose to override this behavior - 'k exec' no longer requires double '--' if a '--' comes after - old : k exec -it my-pod-0 -- -- /bin/sh + new : k exec -it my-pod-0 -- /bin/sh + still works : k -- exec -it my-pod-0 -- /bin/sh --- Bug Fixes ---------------------------- - fixed various plugins/kubectl auto-completion settings; arguments after '--' or profile number (e.g. 'k 1 get deployments') will now appropriately autocomplete in the indicated profile - helm template functions now work on related .tpl files as well (renders from chart root) - fixed some goofy UTF-8 icons in zsh/lib/utils/io --- New Features ------------------------- - (experimental) scwrypts zsh plugin for interactive command selection (like CTRL+SPACE), but allows you to build command arguments, providing help dialogue for the selected command --- New Scripts -------------------------- - zsh/misc/tally ) helps keep tally-counts of things; helpful when running long scripts "what iteration am I on"
96 lines
2.1 KiB
Bash
96 lines
2.1 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
|
|
}
|
|
|
|
[[ $TEMPLATE_FILENAME =~ tests/.*.yaml$ ]] && {
|
|
HELM_ARGS+=(--values $TEMPLATE_FILENAME)
|
|
USE_CHART_ROOT=1
|
|
}
|
|
[[ $TEMPLATE_FILENAME =~ .tpl$ ]] \
|
|
&& 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/tests/default.yaml" \
|
|
"$CHART_ROOT/values.test.yaml" \
|
|
"$CHART_ROOT/values.yaml" \
|
|
;
|
|
do
|
|
[ -f "$F" ] && HELM_ARGS=(--values "$F" $HELM_ARGS)
|
|
done
|
|
|
|
for LOCAL_REPOSITORY in $(\
|
|
cat "$CHART_ROOT/Chart.yaml" \
|
|
| YQ -r '.dependencies[] | .repository' \
|
|
| grep '^file://' \
|
|
| sed 's|file://||' \
|
|
)
|
|
do
|
|
[[ $LOCAL_REPOSITORY =~ ^[/~] ]] \
|
|
&& LOCAL_REPOSITORY_ROOT="$LOCAL_REPOSITORY" \
|
|
|| LOCAL_REPOSITORY_ROOT="$CHART_ROOT/$LOCAL_REPOSITORY" \
|
|
;
|
|
|
|
for F in \
|
|
"$LOCAL_REPOSITORY_ROOT/tests/default.yaml" \
|
|
"$LOCAL_REPOSITORY_ROOT/values.test.yaml" \
|
|
"$LOCAL_REPOSITORY_ROOT/values.yaml" \
|
|
;
|
|
do
|
|
[ -f "$F" ] && HELM_ARGS=(--values "$F" $HELM_ARGS)
|
|
done
|
|
done
|
|
}
|
|
|