--- title: "ADR 0074: Console URL builders are immutable and take per-call parameters" --- * Status: accepted * Code: [`pkg/consoleui/interface.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/consoleui/interface.go), [`pkg/consoleui/custom.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/consoleui/custom.go), [`pkg/consoleui/custom_test.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/consoleui/custom_test.go) ## Context A single console object is built once and then used to render links for many PipelineRuns. `CustomConsole` renders URLs from user-configured templates in `info.PacOpts`, and callers can also supply extra substitution parameters through `WithParams`. If any of this state were mutable, two handlers sharing the console could see each other's values. ## Decision * `NewCustomConsole` copies the `PacOpts` struct (`snapshot := *pacInfo`), so later changes by the caller do not change the URLs it renders. * `WithParams` returns a new `*CustomConsole` sharing `pacInfo` and holding a `maps.Clone` of the given map. The receiver and the caller's map are not modified. * Built-in values (`namespace`, `pr`, `task`, `pod`, `firstFailedStep`, `step`) are computed per call in `consoleParams` and `taskParams` into a fresh map, never stored on the console. * `generateURL` merges the console's extra params over that per-call map with `maps.Copy`, so extra params win over built-ins. * If the rendered URL fails `url.ParseRequestURI` or still matches `keys.ParamsRe`, the console base URL is returned. * `StepLogURL` falls back to `TaskLogURL` when no step template is configured or the step name is empty. ## Consequences * The tests in `custom_test.go` check that a step name from one call does not appear in the next, that the shared console keeps no params of its own, and that a scoped console is unaffected by a later one. * An unresolved placeholder yields the console root URL instead of a broken link. * The code does not show why `PacOpts` is copied shallowly; pointer or map fields inside it would still be shared.