Make the lab templates configuration instead of hardcoded Nimbus objects - #20
Merged
Conversation
…imbus objects `create_lab` builds a test LB by CLONING a known-good origin pool and HTTP LB — so every field XC requires is present — then stripping the copy back to a clean slate. That mechanism is right and is unchanged. What moved is where the two object NAMES come from. They were hardcoded defaults naming this operator's own tenant (`nimbus-bigip-pool`, `nimbus-www`), which cost three things: - `lab-create` only worked on a tenant that happened to contain objects by those names; anywhere else it failed at the first GET with a bare 404. - The CLI exposed no flag reaching either parameter, so from the command line they were effectively hardcoded. - `nimbus-www` was simultaneously the default source template here and the default PROTECTED object in `engine.protected_lbs()` — the one load balancer the tool refuses to mutate was the one it read to build every lab. Safe, since templates are only ever read and the deep copy is what gets created, but it reads oddly in a codebase this careful about blast radius. Now `--pool-template` / `--lb-template`, or `$VPCOPILOT_LAB_POOL_TEMPLATE` / `$VPCOPILOT_LAB_LB_TEMPLATE`, following the same shape `protected_lbs()` already uses for `VPCOPILOT_PROTECTED_LBS`. A missing template names both remedies and says why a template is needed at all, rather than surfacing the 404. No regressions: the defaults keep the same values, so behaviour on this tenant is identical — pinned by a test asserting the two template reads are still `nimbus-bigip-pool` and `nimbus-www` when nothing is configured. 785 tests pass with no credentials and no .env, ruff clean. Co-Authored-By: Claude Opus 5 (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.
Small, standalone, and independent of L1/L2. Nothing is removed — the cloning mechanism stays exactly as it was; only where two object names come from changes.
What
create_labdoes, and why cloning is rightIt builds a test LB by cloning a known-good origin pool and HTTP LB, then stripping the copy back to a clean slate with every security control off. Composing a spec from scratch would discover a missing required XC field at PUT time; copying one that already works cannot. That is deliberate and unchanged.
What was wrong with the defaults
Three costs:
lab-createonly worked on a tenant that happened to contain objects by those names. Anywhere else it failed at the firstget_origin_poolwith a bare 404.--domain,--origin,--name,--origin-tls. No flag reached either template parameter, so from the command line they were effectively hardcoded.nimbus-wwwwas doing two jobs. It was simultaneously the default source template here and the default protected object inengine.protected_lbs()— the one load balancer the tool refuses to mutate was the one it read to build every lab. Safe, because templates are only ever read and the deep copy is what gets created, but it reads oddly in a codebase this careful about blast radius.The change
--pool-template/--lb-template, or$VPCOPILOT_LAB_POOL_TEMPLATE/$VPCOPILOT_LAB_LB_TEMPLATE— the same shapeprotected_lbs()already uses forVPCOPILOT_PROTECTED_LBS. Explicit argument beats environment beats default.A missing template now names both remedies and says why a template is needed at all:
That is the first failure any other tenant hits, so it should say what to set.
No regressions
The defaults keep the same values, so behaviour on this tenant is identical — pinned by
test_the_defaults_are_unchanged_so_this_tenant_behaves_identically, which asserts the two template reads are stillnimbus-bigip-poolandnimbus-wwwwhen nothing is configured.Also pinned: environment override, explicit-argument precedence, an empty env value falling back rather than asking XC for an object named
"", the error naming both remedies, that the CLI actually reaches both parameters, and — the one worth keeping — that the templates are only ever read, never written, since that is what makes it safe for the default template to also be the protected object.Verification
785 tests pass with
XC_API_URL/XC_API_TOKEN/XC_NAMESPACEunset and no.env, ruff clean.docs/TRY_IT.mddocuments both flags and the read-only property.Context: this came out of the L1/L2 rescope (#19), which flagged it as the cheapest decoupling win in the repo — it needs no hardware decision and is worth doing whether or not L1/L2 ever start.
🤖 Generated with Claude Code