Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbuild/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ def _enrich_metadata(cfg: Config, community_override: str | None = None) -> dict
context["director_override_env"] = _render_override_env(authored, context) if authored else ""
context["sidecar_templates"] = _sidecar_templates(cfg)
context["stack_parts"] = _stack_parts(cfg)
context["is_stack"] = cfg.type == "stack"
return context


Expand Down
3 changes: 2 additions & 1 deletion dbuild/templates/README.j2
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ Then run `podman-compose up -d`.
Save as `compose.yaml`, then run `podman-compose up -d`.
{%- endif %}
{%- endif %}
{%- if appjail_enabled and choices %}
{#- A stack's director comes from its author; without one there is none to render. #}
{%- if appjail_enabled and choices and (not is_stack or appjail_sidecar or director_override_text) %}

### AppJail Director
{%- if choices_capped.appjail %}
Expand Down
2 changes: 1 addition & 1 deletion dbuild/templates/README.mkdocs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Before deploying, ensure your host environment is ready. See the [Quick Start Gu

Then run `podman-compose up -d`.
{% endif %}
{% if appjail_enabled and choices %}
{% if appjail_enabled and choices and (not is_stack or appjail_sidecar or director_override_text) %}
=== ":appjail-appjail: AppJail"
{{ choice_form("appjail") | indent(4, first=True) }}
{% elif appjail_enabled and appjail_sidecar %}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,20 @@ def test_readme_has_parts_and_the_authored_director(self):
self.assertIn("**db-template.conf**", aj)
self.assertIn("sysvshm: new", aj)

def test_a_stack_without_a_director_gets_no_appjail_section(self):
compose = STACK_COMPOSE[:STACK_COMPOSE.index(" appjail:\n")] + " appjail: true\n" + STACK_COMPOSE[STACK_COMPOSE.index("\nservices:\n") + 1:]
with tempfile.TemporaryDirectory() as d:
t = Path(d)
(t / "compose.yaml").write_text(compose)
(t / "example.env").write_text(STACK_ENV)
with _chdir(t):
cfg = dbuild_config.load(t)
outputs, errors = docs.render_generated(cfg, argparse.Namespace(community=None), t)
site = docs._get_jinja_env(t).get_template("README.mkdocs.j2").render(dict(docs._enrich_metadata(cfg), render_mode="mkdocs"))
self.assertEqual(errors, [])
self.assertNotIn("### AppJail Director", outputs["README.md"], "no single-image director for a stack")
self.assertNotIn(":appjail-appjail: AppJail", site)

def test_the_line_resolves_tags_and_skips_the_clock_mount(self):
compose = STACK_COMPOSE.replace(" image: ghcr.io/daemonless/photos-server:latest\n network_mode: host\n",
" image: ghcr.io/daemonless/photos-server:${TAG:-latest}\n network_mode: host\n", 1)
Expand Down
Loading