Commit e671bfc2 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Aplica variables para chequeo con stack config

parent 80a3f585
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -117,12 +117,14 @@ echo -e "\n${INFO_COLOR}Checking deployment configuration in compose files ..${N
echo -e "  ${INFO_COLOR}compose files [ ${DATA_COLOR}${COMPOSE_FILE}${INFO_COLOR} ]${NULL_COLOR}"
echo -en "  ${INFO_COLOR}check command [ ${DATA_COLOR}"

cleanEnvConfigCmd="[ -f .env-config ] && rm -f .env-config"
# Antes de continuar, se comprueba que la configuración de despliegue sea válida para compose o swarm.
if [ ${docker23CompatibleTarget} -eq 0 ] && [ ${deployingToSwarm} -eq 0 ]
then
	echo -e "docker stack config${INFO_COLOR} ]${NULL_COLOR}\n"
	swarmComposeFileSplitted=$(echo ${COMPOSE_FILE} | sed 's/:/ -c /g')
	checkComposeFilesCmd="docker stack config -c ${swarmComposeFileSplitted} > /dev/null"
	grep -v '^[#| ]' .env | sed -r "s/(\w+)=(.*)/export \1='\2'/g" > .env-config
	checkComposeFilesCmd="env -i /bin/sh -c \". \$(pwd)/.env-config && docker stack config -c ${swarmComposeFileSplitted} > /dev/null\""
else
	echo -e "docker compose config${INFO_COLOR} ]${NULL_COLOR}\n"
	checkComposeFilesCmd="docker compose config -q"
@@ -131,8 +133,10 @@ fi
if eval "${checkComposeFilesCmd}"
then
	echo -e "${PASS_COLOR}Valid compose configuration!${NULL_COLOR}"
	eval "${cleanEnvConfigCmd}"
else
	echo -e "\n${FAIL_COLOR}Invalid compose configuration!${NULL_COLOR}"
	eval "${cleanEnvConfigCmd}"
	eval "${restoreEnvFileCmd}"
	eval "${closeSshCmd}"
	exit 1