Skip to content

Simplify Jinja2 templates by removing duplication - #952

Merged
gdams merged 2 commits into
adoptium:mainfrom
gdams:simplify
May 29, 2026
Merged

gdams merged 2 commits into
adoptium:mainfrom
gdams:simplify

Conversation

@gdams

@gdams gdams commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove arch-variable.j2 partial and pass arch_cmd directly from each OS template into multi-arch-install.j2
  • Replace repeated version flag conditionals ({% if version|int >= 11 %}--{% else %}-{% endif %}) with a single vflag variable in version-check.j2, version-check-windows.j2, and nanoserver.Dockerfile.j2

Details

The arch-variable.j2 partial was only used in one place (multi-arch-install.j2) and just mapped the os variable to an architecture detection command. Each OS template now sets arch_cmd directly before including multi-arch-install.j2, making the data flow clearer.

The version flag pattern {% if version|int >= 11 %}--{% else %}-{% endif %} was repeated 6 times across 3 files. A single {% set vflag = "--" if version|int >= 11 else "-" %} at the top of each file eliminates the duplication.

No change to generated Dockerfiles or entrypoint scripts.

gdams added 2 commits May 12, 2026 13:09
- Remove arch-variable.j2 partial and pass arch_cmd directly from each
  OS template into multi-arch-install.j2
- Replace repeated version flag conditionals with a single vflag variable
  in version-check.j2, version-check-windows.j2, and nanoserver.Dockerfile.j2

No change to generated Dockerfiles or entrypoint scripts.
- Remove version-check-windows.j2 partial (only used in servercore)
- Inline the version check logic directly into servercore.Dockerfile.j2
- Unify nanoserver vflag to include 'version' in the value
- Remove corresponding test for deleted partial
@gdams
gdams enabled auto-merge (squash) May 29, 2026 13:38
@gdams
gdams merged commit 9787df3 into adoptium:main May 29, 2026
237 of 239 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants