Fix env injection crashing on variables the compose file also sets #3
2 changed files with 11 additions and 7 deletions
|
|
@ -208,10 +208,11 @@ to every compose command:
|
||||||
The UI points out variables the compose file uses without a default that
|
The UI points out variables the compose file uses without a default that
|
||||||
aren't set.
|
aren't set.
|
||||||
- With **Pass to every container** (the default), `deploy`/`restart` also
|
- With **Pass to every container** (the default), `deploy`/`restart` also
|
||||||
generate `stacks/<app>/.panel-env.yaml`, a compose override that lists the
|
generate `stacks/<app>/.panel-env.yaml`, a compose override that sets
|
||||||
keys under every service's `environment:`. Compose reads the values from its
|
`KEY: ${KEY}` under every service's `environment:`. Compose fills the values
|
||||||
own environment, so they are never quoted into YAML, and they take
|
in from its own environment, so they are never quoted into YAML, and they
|
||||||
precedence over values set in the compose file.
|
take precedence over values set in the compose file (including variables
|
||||||
|
the compose file sets itself, in list or map form).
|
||||||
|
|
||||||
Values must be single-line. Names that would change how podman/compose run
|
Values must be single-line. Names that would change how podman/compose run
|
||||||
(`PATH`, `HOME`, `XDG_*`, `DOCKER_*`, `COMPOSE_*`, `PODMAN_*`, …) are rejected.
|
(`PATH`, `HOME`, `XDG_*`, `DOCKER_*`, `COMPOSE_*`, `PODMAN_*`, …) are rejected.
|
||||||
|
|
|
||||||
|
|
@ -279,8 +279,11 @@ load_app_env() {
|
||||||
|
|
||||||
# (Re)generate the env override before containers are created. Variables are
|
# (Re)generate the env override before containers are created. Variables are
|
||||||
# always available for ${VAR} interpolation; with APP_ENV_INJECT (default true)
|
# always available for ${VAR} interpolation; with APP_ENV_INJECT (default true)
|
||||||
# every service also receives them. Bare keys make compose read the values from
|
# every service also receives them as `KEY: ${KEY}`, which compose fills in from
|
||||||
# its own environment, so values never have to be quoted into YAML.
|
# its own environment, so values never have to be quoted into YAML. (Bare keys
|
||||||
|
# would do the same, but podman-compose can't merge a bare key with a value the
|
||||||
|
# compose file sets for the same variable: "can't merge value of [KEY] of type
|
||||||
|
# str and NoneType".)
|
||||||
prepare_env_override() {
|
prepare_env_override() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local override services svc key tmp
|
local override services svc key tmp
|
||||||
|
|
@ -303,7 +306,7 @@ prepare_env_override() {
|
||||||
[[ "${svc}" =~ ^[A-Za-z0-9._-]+$ ]] || continue
|
[[ "${svc}" =~ ^[A-Za-z0-9._-]+$ ]] || continue
|
||||||
printf ' "%s":\n environment:\n' "${svc}"
|
printf ' "%s":\n environment:\n' "${svc}"
|
||||||
for key in "${APP_ENV_KEYS[@]}"; do
|
for key in "${APP_ENV_KEYS[@]}"; do
|
||||||
printf ' - %s\n' "${key}"
|
printf ' %s: ${%s}\n' "${key}" "${key}"
|
||||||
done
|
done
|
||||||
done <<<"${services}"
|
done <<<"${services}"
|
||||||
} >"${tmp}"
|
} >"${tmp}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue