mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
hey
This commit is contained in:
@@ -42,7 +42,7 @@ func TestChartInflatorExecPlugin(t *testing.T) {
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin(
|
||||
"builtin", "", "ChartInflatorExec")
|
||||
"someteam.example.com", "v1", "ChartInflatorExec")
|
||||
|
||||
th := NewKustTestHarnessWithPluginConfig(
|
||||
t, "/app", plugin.ActivePluginConfig())
|
||||
@@ -53,11 +53,11 @@ namePrefix: LOOOOOOOONG-
|
||||
`)
|
||||
|
||||
th.writeF("/app/chartInflatorExec.yaml", `
|
||||
apiVersion: builtin
|
||||
apiVersion: someteam.example.com/v1
|
||||
kind: ChartInflatorExec
|
||||
metadata:
|
||||
name: notImportantHere
|
||||
chart: minecraft
|
||||
chartName: minecraft
|
||||
`)
|
||||
|
||||
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||
|
||||
@@ -9,18 +9,22 @@ set -e
|
||||
# kind: ChartInflatorExec
|
||||
# metadata:
|
||||
# name: notImportantHere
|
||||
# chart: chartName
|
||||
# values: /absolute/path/to/values/file
|
||||
# helmBin: /absolute/path/to/helmBin
|
||||
# chartName: nameOfStableChart
|
||||
# values: /abs/path/to/local/values/file
|
||||
# chartHome: /abs/path/local/chart/storage
|
||||
# helmHome: /abs/path/to/helm/config
|
||||
# helmBin: /abs/path/to/helmBin
|
||||
#
|
||||
# fetches the given chart from stable/$chartName,
|
||||
# and inflates it to stdout, using the given values file.
|
||||
#
|
||||
# chartDir default: $TMP_DIR/charts
|
||||
# chartDir default:
|
||||
|
||||
# Example execution:
|
||||
# ./plugins/kustomize.config.k8s.io/v1/ChartInflatorExec configFile.yaml
|
||||
|
||||
|
||||
|
||||
# Yaml parsing is a ridiculous thing to do in bash,
|
||||
# but let's try:
|
||||
function parseYaml {
|
||||
@@ -30,48 +34,57 @@ function parseYaml {
|
||||
local k=${line%:*}
|
||||
local v=${line#*:}
|
||||
|
||||
[ "$k" == "chart" ] && chartName=$v
|
||||
[ "$k" == "chartName" ] && chartName=$v
|
||||
[ "$k" == "chartHome" ] && chartHome=$v
|
||||
[ "$k" == "values" ] && valuesFile=$v
|
||||
[ "$k" == "helmHome" ] && helmHome=$v
|
||||
[ "$k" == "helmBin" ] && helmBin=$v
|
||||
done <"$file"
|
||||
|
||||
# Trim leading space
|
||||
chartName="${chartName#"${chartName%%[![:space:]]*}"}"
|
||||
chartHome="${chartHome#"${chartHome%%[![:space:]]*}"}"
|
||||
valuesFile="${valuesFile#"${valuesFile%%[![:space:]]*}"}"
|
||||
helmBin="${helmBin#"${helmBin%%[![:space:]]*}"}"
|
||||
}
|
||||
|
||||
TMP_DIR=$(mktemp -d)
|
||||
|
||||
# Where all the files generated by 'helm init' live.
|
||||
HELM_HOME=$TMP_DIR/dotHelm
|
||||
|
||||
# Where helm charts are unpacked.
|
||||
CHART_HOME=$TMP_DIR/charts
|
||||
|
||||
parseYaml $1
|
||||
|
||||
# Where all the files generated by 'helm init' live.
|
||||
if [ -z "$helmHome" ]; then
|
||||
helmHome=$TMP_DIR/dotHelm
|
||||
fi
|
||||
|
||||
# Where helm charts are unpacked.
|
||||
if [ -z "$chartHome" ]; then
|
||||
chartHome=$TMP_DIR/charts
|
||||
fi
|
||||
|
||||
if [ -z "$helmBin" ]; then
|
||||
helmBin=/usr/local/bin/helm
|
||||
helmBin=helm
|
||||
fi
|
||||
|
||||
if [ -z "$valuesFile" ]; then
|
||||
valuesFile=$CHART_HOME/$chartName/values.yaml
|
||||
valuesFile=$chartHome/$chartName/values.yaml
|
||||
fi
|
||||
|
||||
function doHelm {
|
||||
$helmBin --home $HELM_HOME $@
|
||||
$helmBin --home $helmHome $@
|
||||
}
|
||||
|
||||
# The init command is extremely chatty
|
||||
doHelm init --client-only >& /dev/null
|
||||
|
||||
doHelm fetch --untar \
|
||||
--untardir $CHART_HOME \
|
||||
stable/$chartName
|
||||
if [ ! -d "$chartHome/$chartName" ]; then
|
||||
doHelm fetch --untar \
|
||||
--untardir $chartHome \
|
||||
stable/$chartName
|
||||
fi
|
||||
|
||||
doHelm template \
|
||||
--values $valuesFile \
|
||||
$CHART_HOME/$chartName
|
||||
$chartHome/$chartName
|
||||
|
||||
/bin/rm -rf $TMP_DIR
|
||||
Reference in New Issue
Block a user