Fix formating template and --output-map begin added at each rendering

This commit is contained in:
Daniel Berteaud 2024-01-05 10:39:35 +01:00
parent 5af628ac7f
commit 52acc19da2
1 changed files with 4 additions and 5 deletions

9
ctctl
View File

@ -571,7 +571,7 @@ ctctl_render_templates(){
# This is used for two things
# - Add the consul.suffix to every files (except job files). This allows ctctl to simply infer the policy name from the file name
# - Put job files in the current dir for conveniance, and everything else in the output dir
GOMPLATE_OUT_ARGS+=(--output-map)
local GOMPLATE_OUT_ARGS=(--output-map)
GOMPLATE_OUT_ARGS+=('[[ if (regexp.Match ".*\\.nomad(\\.hcl)?" .in) ]][[ .in ]][[ else ]]output/[[ .in | path.Dir ]]/[[ .in | path.Base | regexp.Replace "^([^\\.]+)\\.(.*)$" (printf "%s%s.%s" "$1" .ctx.consul.suffix "$2") ]][[ end ]]')
echo
@ -663,7 +663,6 @@ ctctl_render_templates(){
gomplate "${GOMPLATE_COMMON_ARGS[@]}" --context ${VAR_FILES} -f ${CONFIG} -o ${CONFIG}
# Render it twice so we can reference 2 levels of templates in variables
gomplate "${GOMPLATE_COMMON_ARGS[@]}" --context ${VAR_FILES} -f ${CONFIG} -o ${CONFIG}
#GOMPLATE_COMMON_ARGS+=(--context .=file://${CONFIG})
# First, cleanup any previously rendered files
rm -rf bundles/${NAME}/example/*
@ -682,10 +681,10 @@ ctctl_render_templates(){
done
done
fi
fi
# Format example job files
find ./bundles/${NAME}/example -maxdepth 1 -type f \( -name \*nomad.hcl -o -name \*.nomad \) -exec nomad fmt {} \;
# Format example job files
find ./bundles/${NAME}/example -maxdepth 1 -type f \( -name \*nomad.hcl -o -name \*.nomad \) -exec nomad fmt {} \;
fi
rm -f ${CONFIG}
done