Skip to content

Commit 5b786ec

Browse files
authored
remove duplication in docs (#108)
1 parent 7ca0b64 commit 5b786ec

1 file changed

Lines changed: 10 additions & 52 deletions

File tree

‎docs/guidelines.md‎

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,6 @@ For version 2.0 and above, the gate is inactive and the baseline is applied as-i
208208
adjusts the container name and ports back to the legacy shape. The mutation is explicitly about backward compatibility,
209209
gated on the versions that need it, and will stop running entirely once those versions are no longer supported.
210210

211-
The key difference from the alternative approach: the baseline was updated to the 2.0 shape, and the mutation adapts
212-
backward. If instead you had kept the baseline at the 1.x shape and added a mutation to patch it forward to 2.0, every
213-
future version change would stack another forward-patching mutation on top, and the baseline would never reflect
214-
reality.
215-
216211
### Verifying backward compatibility mutations
217212

218213
When you update the baseline, you need confidence that older versions still produce the same object they did before. The
@@ -432,18 +427,13 @@ For v2+, the backward compat mutation is inactive and `DebugLogging` sets the en
432427
sets the env var on `"app"`, then `BackwardCompatV1Container` renames the container to `"server"` and resets its ports.
433428
The env var survives because the rename does not touch `Env`.
434429

435-
### Naming and ordering with multiple backward compat mutations
436-
437-
Name backward compat mutations `BackwardCompat<version><what>` so the pattern is self-documenting. Use the `P` separator
438-
for version dots when the function name would otherwise be ambiguous: `BackwardCompatV1P2P0Container` for v1.2.0,
439-
`BackwardCompatV2Container` for the v2 line.
430+
### Ordering with multiple backward compat mutations
440431

441-
When multiple backward compat mutations exist, register the newest first (closest to the baseline) and the oldest last.
442-
Each mutation reverts one version step: `BackwardCompatV2` reverts v3 to v2, and `BackwardCompatV1` reverts v2 to v1.
443-
For a v1 version, both fire in sequence. The key guarantee is not that they are independent of each other (they do
444-
execute in order), but that adding a new one does not require changing existing ones. When you update the baseline to v3
445-
and add `BackwardCompatV2`, the existing `BackwardCompatV1` continues to work unchanged because `BackwardCompatV2`
446-
restores the v2 shape before `BackwardCompatV1` runs.
432+
When multiple backward compat mutations exist, the same chained revert ordering from
433+
[Revert mutations vs. forward mutations](#revert-mutations-vs-forward-mutations) applies: register the newest first
434+
(closest to the baseline) and the oldest last. The additional constraint here is that feature mutations targeting a
435+
container by name must come before the backward compat mutations that rename it. Feature mutations using broad selectors
436+
can go anywhere.
447437

448438
```go
449439
res, err := deployment.NewBuilder(BaseDeployment(owner)). // baseline is v3
@@ -454,29 +444,8 @@ res, err := deployment.NewBuilder(BaseDeployment(owner)). //
454444
Build()
455445
```
456446

457-
The only ordering constraint for feature mutations is that those targeting a container by name must come before backward
458-
compat mutations that rename that container. Feature mutations that use broad selectors (like `TracingSidecar`) can go
459-
anywhere in the chain. The ordering between feature mutations themselves does not matter. When you add a new version
460-
that changes the resource structure, update the baseline and insert the new backward compat mutation before the existing
461-
ones.
462-
463-
#### Alternative: non-overlapping version gates
464-
465-
Instead of chaining reverts (each undoing one version step), you can give each backward compat mutation a
466-
non-overlapping gate so that only one fires for any given version. `BackwardCompatV2` fires for `>= 2.0.0, < 3.0.0` and
467-
`BackwardCompatV1` fires for `>= 1.0.0, < 2.0.0`. Each mutation reverts directly from the current baseline to its target
468-
version, making them truly order-independent.
469-
470-
The tradeoff is maintenance cost. When you update the baseline to v3, every existing backward compat mutation needs
471-
updating because each one must now revert from the v3 shape instead of the v2 shape. With chained reverts, only the new
472-
mutation needs writing; existing ones are untouched. The chained approach trades a visible ordering constraint (newest
473-
first, enforced by the registration chain) for a stronger stability guarantee (existing mutations never change). The
474-
non-overlapping approach trades that stability for order independence.
475-
476-
For most operators, the chained approach is the better default. The ordering is mechanical (newest first) and visible in
477-
the builder chain. The non-overlapping approach is worth considering when mutations are complex enough that reasoning
478-
about chained execution is genuinely difficult, or when backward compat mutations are maintained by different teams who
479-
cannot easily coordinate ordering.
447+
When you add a new version that changes the resource structure, update the baseline and insert the new backward compat
448+
mutation before the existing ones.
480449

481450
### What to avoid
482451

@@ -491,19 +460,8 @@ m.EditContainers(selectors.ContainersNamed("app", "server"), func(ce *editors.Co
491460
```
492461

493462
This works today but breaks if a future version renames the container again. The mutation now needs to track every name
494-
the container has ever had. Instead, target the baseline name and register the mutation before the backward compat
495-
rename:
496-
497-
```go
498-
// Correct: targets the baseline name, registered before BackwardCompatV1Container.
499-
m.EditContainers(selectors.ContainerNamed("app"), func(ce *editors.ContainerEditor) error {
500-
ce.EnsureEnvVar(corev1.EnvVar{Name: "LOG_LEVEL", Value: "debug"})
501-
return nil
502-
})
503-
```
504-
505-
The mutation only knows `"app"` (the current baseline name). The backward compat rename fires afterward and carries the
506-
edit through.
463+
the container has ever had. Instead, target the baseline name and
464+
[register the mutation before the backward compat rename](#register-name-specific-mutations-before-backward-compat-renames).
507465

508466
### When a backward compat mutation replaces the entire container
509467

0 commit comments

Comments
 (0)