Identifiable container names (template-based naming for both modes)#1
Open
mpasternak wants to merge 13 commits into
Open
Identifiable container names (template-based naming for both modes)#1mpasternak wants to merge 13 commits into
mpasternak wants to merge 13 commits into
Conversation
Template-based naming of plugin containers in both default and reuse mode, encoding (project, service, branch, dirtag, worker) with a configurable name_template, PROJECT_NAME/COMPOSE_PROJECT_NAME project resolution, and a deterministic 255-char trim+checksum. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…wd basename Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…_name_for Rewire makers to container_name_for so containers are named in both default and reuse mode (folds the makers import/call update forward to keep the package importable after reuse_name_for is removed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Widen the placeholder regex so any {token} is checked against the valid set;
previously only lowercase tokens were validated, so {Project}/{dir2} silently
passed through and got mangled instead of raising NameTemplateError.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace lingering <project>-tc-<service>-<worker_id> references and the stale §8.4 _compose snippet (digest_size=2 / name[:250]) with the shipped finalize_name behavior (digest_size=4, [:246], hash of the full name) and the default template. The normative §8.3 / §8.7 were already correct; this clears the descriptive drift the final review flagged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every container the plugin starts now gets a readable, identifiable name in both default and reuse mode, instead of Docker's random names (
heuristic_cannon,nifty_ganguly). The name is rendered from a configurable template and encodes project + service + git branch + directory + worker.Default template:
e.g.
myproj-tc-psql-feature-x-3f9ac1b2-masterWhat's new
{rand}suffix so overlapping/leaked runs never collide. Reuse-mode names are byte-stable ({rand}empty) so find-or-create still works, and are now scoped per(project, service, branch, directory, worker).--testcontainers-name-template>PYTEST_TESTCONTAINERS_NAME_TEMPLATE> pyproject[tool.pytest_testcontainers].name_template> built-in default). Placeholders:{project} {service} {branch} {dir} {dirtag} {worker} {rand}. An unknown/typo'd placeholder raisesNameTemplateError.--testcontainers-project>PYTEST_TESTCONTAINERS_PROJECT>PROJECT_NAME>COMPOSE_PROJECT_NAME> pyproject[project].name> cwd basename._internal/git_identity.pyreads.git/HEADdirectly (handles normal clones, linked worktrees, and detached HEAD → 12-char SHA).{dirtag}is an 8-hex blake2s of the worktree-root absolute path, so the same branch checked out in two directories does not collide.finalize_namesanitizes the whole rendered name and, on overflow, truncates to 246 and appends an 8-char hash of the full name (deterministic, so reuse stays stable).Backward compatibility (pre-1.0)
pytest --testcontainers-clean. Documented in the README "Upgrading from 0.1.0" note and SPEC §8.7.Layering
Direction preserved (
plugin → fixtures → makers → containers → _internal;errorsis a leaf).reuse.pygained downward edges to_internal.git_identityanderrors.NameTemplateErroronly.Testing
dirtagstability,finalize_name(≤255, deterministic, tail-distinguishing), reuse byte-stability vs. default{rand}, unknown/miscased placeholder →NameTemplateError, maker naming in both modes.docker_requiredsmoke tests: a real default-mode container carries the templated name; reuse identity differs across branches.Process notes
Built via spec → plan → subagent-driven TDD (one implementer + reviewer per task, plus a final whole-branch review). Design and plan live under
docs/superpowers/.🤖 Generated with Claude Code