support multiples fichiers de config
This commit is contained in:
parent
ac4b03dff7
commit
cd09a07cda
|
@ -113,7 +113,7 @@ function build_images() {
|
|||
for image in "$@"; do
|
||||
case "$image" in
|
||||
rundk)
|
||||
[ -n "$Config" ] && export RUNDK_FORCE_BUILDENV="$Config"
|
||||
[ ${#Configs[*]} -gt 0 ] && export RUNDK_FORCE_BUILDENVS="${Configs[*]}"
|
||||
local -a args=(--bootstrap)
|
||||
[ -z "$ForceBuild" ] && args+=(--unless-exists)
|
||||
[ -n "$Pull" ] && args+=(--pull)
|
||||
|
@ -122,8 +122,10 @@ function build_images() {
|
|||
;;
|
||||
*)
|
||||
if [ -z "$sourced" ]; then
|
||||
[ -n "$Config" ] || Config="$PROJDIR/$BUILDENV"
|
||||
source "$Config"
|
||||
[ ${#Configs[*]} -gt 0 ] || Configs=("$PROJDIR/$BUILDENV")
|
||||
for config in "${Configs[@]}"; do
|
||||
source "$config"
|
||||
done
|
||||
after_source_buildenv
|
||||
read -a HOST_MAPPINGS <<<"${HOST_MAPPINGS//
|
||||
/ }"
|
||||
|
@ -136,7 +138,7 @@ function build_images() {
|
|||
}
|
||||
|
||||
action=build
|
||||
Config=
|
||||
Configs=()
|
||||
ForceBuild=
|
||||
Pull=
|
||||
NoCache=
|
||||
|
@ -146,7 +148,7 @@ args=(
|
|||
"Construire les images pour DRE"
|
||||
#"usage"
|
||||
--check-only action=none "++Ne faire que la vérification de l'environnement"
|
||||
-c:,--config:BUILDENV Config= "Spécifier un fichier d'environnement pour le build"
|
||||
-c:,--config:BUILDENV Configs "Spécifier un fichier d'environnement pour le build"
|
||||
-r,--rebuild ForceBuild=1 "Forcer la (re)construction de l'image"
|
||||
-U,--pull Pull=1 "++Forcer le re-téléchargement des images dépendantes"
|
||||
-j,--no-cache NoCache=1 "++Construire l'image en invalidant le cache"
|
||||
|
@ -155,9 +157,14 @@ args=(
|
|||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
||||
if [ -n "$Config" ]; then
|
||||
setx Config=abspath "$Config"
|
||||
# pas de vérification d'environnement si on spécifie Config
|
||||
if [ ${#Configs[*]} -gt 0 ]; then
|
||||
aconfigs=()
|
||||
for config in "${Configs[@]}"; do
|
||||
setx config=abspath "$config"
|
||||
aconfigs+=("$config")
|
||||
done
|
||||
Configs=("${aconfigs[@]}")
|
||||
# pas de vérification d'environnement si on spécifie Configs
|
||||
# ne pas oublier d'implémenter un traitement spécifique si build_check_env()
|
||||
# contient d'autres vérifications
|
||||
else
|
||||
|
|
|
@ -188,8 +188,11 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
|
|||
|
||||
IMAGE=
|
||||
if [ -z "$bootstrap" ]; then
|
||||
if [ -n "$RUNDK_FORCE_BUILDENV" ]; then
|
||||
source "$RUNDK_FORCE_BUILDENV" || exit 1
|
||||
if [ -n "$RUNDK_FORCE_BUILDENVS" ]; then
|
||||
eval "Configs=($RUNDK_FORCE_BUILDENVS)"
|
||||
for config in "${Configs[@]}"; do
|
||||
source "$config" || exit 1
|
||||
done
|
||||
after_source_buildenv
|
||||
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
|
||||
source "$PROJDIR/$BUILDENV" || exit 1
|
||||
|
@ -221,14 +224,14 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
|
|||
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
||||
|
||||
Dist=
|
||||
if [ -n "$RUNDK_FORCE_BUILDENV" ]; then
|
||||
Config="$RUNDK_FORCE_BUILDENV"
|
||||
if [ -n "$RUNDK_FORCE_BUILDENVS" ]; then
|
||||
eval "Configs=($RUNDK_FORCE_BUILDENVS)"
|
||||
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
|
||||
Config="$PROJDIR/$BUILDENV"
|
||||
Configs=("$PROJDIR/$BUILDENV")
|
||||
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
|
||||
Config="$PROJDIR/$BUILDENV0"
|
||||
Configs=("$PROJDIR/$BUILDENV0")
|
||||
else
|
||||
Config=
|
||||
Configs=()
|
||||
fi
|
||||
UnlessExists=
|
||||
Pull=
|
||||
|
@ -266,7 +269,7 @@ OPTIONS
|
|||
-d|--dist) shift; Dist="$1";;
|
||||
-[0-9]) Dist="d1${1#-}";;
|
||||
--d*) Dist="${1#--}";;
|
||||
-c|--config) shift; Config="$1";;
|
||||
-c|--config) shift; Configs+="$1";;
|
||||
--ue|--unless-exists) UnlessExists=1;;
|
||||
-U|--pull) Pull=1;;
|
||||
-j|--nc|--no-cache) NoCache=1;;
|
||||
|
@ -283,9 +286,16 @@ OPTIONS
|
|||
shift
|
||||
done
|
||||
|
||||
[ "$Config" == none ] && Config=
|
||||
if [ -n "$Config" ]; then
|
||||
source "$Config" || exit 1
|
||||
for config in "${Configs[@]}"; do
|
||||
if [ "$config" == none ]; then
|
||||
Configs=()
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ${#Configs[*]} -gt 0 ]; then
|
||||
for config in "${Configs[@]}"; do
|
||||
source "$config" || exit 1
|
||||
done
|
||||
after_source_buildenv
|
||||
fi
|
||||
[ -n "$Dist" ] && DIST="$Dist"
|
||||
|
|
Loading…
Reference in New Issue