-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Several call sites write and read Gordon container labels using raw inline string literals instead of the canonical constants defined in internal/domain/labels.go. This does not cause any incorrect behavior today — the raw strings are byte-for-byte identical to the constants. The issue is one of maintainability: a future rename of any label key in labels.go will not be caught at compile time, and containers could silently lose their managed status or routing.
Inconsistencies Found
Labels written as raw strings (should use constants)
| File | Lines | Raw string used | Correct constant |
|---|---|---|---|
internal/usecase/container/service.go |
222–225 | "gordon.domain", "gordon.image", "gordon.managed", "gordon.route" |
domain.LabelDomain, domain.LabelImage, domain.LabelManaged, domain.LabelRoute |
internal/usecase/container/service.go |
1878–1881 | "gordon.managed", "gordon.attachment", "gordon.attached-to", "gordon.image" |
domain.Label* constants |
internal/adapters/out/docker/runtime.go |
1019–1020 | "gordon.managed", "gordon.created" |
domain.LabelManaged, domain.LabelCreated |
internal/adapters/out/docker/runtime.go |
1145 | "gordon.managed" |
domain.LabelManaged |
Labels read as raw strings (should use constants)
| File | Lines | Raw string used |
|---|---|---|
internal/usecase/container/service.go |
908 | "gordon.domain", "gordon.managed" |
internal/usecase/container/events.go |
114, 122 | "gordon.route", "gordon.image" |
Constants defined but never used as constants
| Constant | File | Issue |
|---|---|---|
LabelRoute = "gordon.route" |
labels.go:9 |
Never referenced via domain.LabelRoute; all reads/writes use the raw string |
LabelCreated = "gordon.created" |
labels.go:12 |
runtime.go:1020 writes "gordon.created": "auto" as a raw string |
Undocumented inconsistency: gordon.created value
LabelCreated is documented as a timestamp-like label (docs/reference/docker-labels.md:15) but the runtime always writes the static string "auto" (internal/adapters/out/docker/runtime.go:1020). The label's intended value is inconsistent between docs and implementation.
Out of Scope: gordon.proxy.port vs gordon.port
These two labels are intentionally distinct and documented separately (docs/reference/docker-labels.md:44, docs/config/auto-route.md:178):
gordon.proxy.port— read by the proxy service via Docker runtime inspect at routing timegordon.port— read by the auto-route system from the image config blob at push time
No action needed here.
Out of Scope: Manifest annotation "version" key
The bare "version" annotation key in pkg/manifest/annotations.go has low practical collision risk — it is not driving production decisions and is mostly pass-through logic. Not a priority.
Impact
- No current runtime bug — behavior is correct today because the raw strings match the constants exactly.
- Refactor/rename safety risk: a label key change in
labels.gowill not be caught by the compiler.
Affected Files
internal/domain/labels.go— canonical constants (source of truth)internal/usecase/container/service.go:221-226,908,1877-1882internal/usecase/container/events.go:114,122internal/adapters/out/docker/runtime.go:1018-1021,1144-1153