mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-01 18:52:21 +01:00
The three shipped compose files forwarded the variable bare, so every
`docker compose` command on a default .env printed "variable is not set".
Default it to the 500 MiB that .env.example documents, like the other
limits, and add a guard test that rejects any bare ${VAR} in compose files.
Fixes #6619
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alexandre Teixeira <general@alexandreteixeira.dev>
29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
"""Every variable a shipped compose file forwards must carry a default.
|
|
|
|
A bare ``${VAR}`` makes ``docker compose`` print "variable is not set" on every
|
|
command for a default ``.env`` (#6619), which greets fresh installs with a
|
|
warning that looks like a misconfiguration.
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
COMPOSE_FILES = sorted(ROOT.glob("docker-compose*.yml")) + sorted((ROOT / "docker").glob("*.yml"))
|
|
|
|
# ${VAR} with no ``:-``/``-``/``:?``/``?`` modifier.
|
|
BARE_VAR = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)\}")
|
|
|
|
|
|
@pytest.mark.parametrize("path", COMPOSE_FILES, ids=lambda p: p.relative_to(ROOT).as_posix())
|
|
def test_compose_variables_have_defaults(path):
|
|
bare = [
|
|
f"{path.name}:{lineno}: ${{{name}}}"
|
|
for lineno, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1)
|
|
if not line.lstrip().startswith("#")
|
|
for name in BARE_VAR.findall(line)
|
|
]
|
|
assert not bare, "compose variables without a default:\n" + "\n".join(bare)
|