Promote PipelinesAsCode from spec.platforms.* to a top-level TektonConfigSpec field
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 608
- Forks
- 263
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 125
Description
Summary
TektonConfigSpec configures TektonChain, TektonTrigger, and TektonPipeline
as direct top-level fields (spec.chain, spec.trigger, spec.pipeline), but
PipelinesAsCode is nested under platform-specific blocks —
spec.platforms.openshift.pipelinesAsCode and
spec.platforms.kubernetes.pipelinesAsCode — with the value duplicated per
platform and resolved at runtime via a helper method. This issue proposes
promoting it to a single top-level spec.pipelinesAsCode field, consistent
with every other component.
Background
PipelinesAsCode was historically an OpenShift-branded project
(openshift-pipelines/pipelines-as-code), which is presumably why its
operator config was placed under the OpenShift-specific platforms block in
the first place, later duplicated under platforms.kubernetes when
Kubernetes support was added. The upstream project has since moved to
tektoncd/pipelines-as-code (see #3841, which tracks renaming the
OpenShiftPipelinesAsCode CRD kind to TektonPipelinesAsCode for the same
reason). #3841 explicitly scopes out this structural question:
Update
TektonConfigSpecreferences that wire PAC installation (field
names inPlatforms.OpenShift.PipelinesAsCode/
Platforms.Kubernetes.PipelinesAsCodemay stay as-is since they are not
the CRD kind)
This issue tracks that follow-up separately, since it's an independent (if
related) change to TektonConfigSpec shape rather than the CRD kind name.
Current State
pkg/apis/operator/v1alpha1/tektonconfig_types.go:
type TektonConfigSpec struct {
...
Pipeline Pipeline `json:"pipeline,omitempty"`
Trigger Trigger `json:"trigger,omitempty"`
Chain Chain `json:"chain,omitempty"`
...
Platforms Platforms `json:"platforms,omitempty"`
}
// PipelinesAsCodeForCurrentPlatform returns the PipelinesAsCode block for the operator build
func (s *TektonConfigSpec) PipelinesAsCodeForCurrentPlatform() *PipelinesAsCode {
if IsOpenShiftPlatform() {
return s.Platforms.OpenShift.PipelinesAsCode
}
return s.Platforms.Kubernetes.PipelinesAsCode
}
pkg/apis/operator/v1alpha1/openshift_platform.go / kubernetes_platform.go
each carry their own PipelinesAsCode *PipelinesAsCode field — two copies of
the same struct, one per platform, only one of which is ever active per
build.
Every call site has to route through PipelinesAsCodeForCurrentPlatform()
or duplicate the IsOpenShiftPlatform() branch directly:
pkg/apis/operator/v1alpha1/tektonconfig_defaults.go(lines ~42-109) —
copies the Kubernetes value into the OpenShift field, nils out the other,
and applies PAC defaults per-platformpkg/apis/operator/v1alpha1/tektonconfig_validation.go(lines 78-81) —
branches onIsOpenShiftPlatform()to validate whichever field is activepkg/reconciler/shared/tektonconfig/pipelinesascode/pipelinesascode.go
(createOPAC/updateOPAC) — reads via
config.Spec.PipelinesAsCodeForCurrentPlatform()pkg/reconciler/openshift/tektonconfig/extension.go(lines 215, 288) and
pkg/reconciler/kubernetes/tektonconfig/extension.go(lines 62, 82) —
same helperpkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade.go(line 181) —
readsPlatforms.OpenShift.PipelinesAsCodedirectly
The user-facing YAML also has to route through the platform block even
though PAC itself already runs identically on both platforms:
spec:
platforms:
openshift: # or `kubernetes:` on Kubernetes clusters
pipelinesAsCode:
enable: true
settings:
application-name: Pipelines as Code CI
...
(docs/TektonConfig.md, lines 124-146)
Proposed Change
Add PipelinesAsCode PipelinesAsCode as a top-level field on
TektonConfigSpec, alongside Pipeline, Trigger, and Chain:
type TektonConfigSpec struct {
...
Pipeline Pipeline `json:"pipeline,omitempty"`
Trigger Trigger `json:"trigger,omitempty"`
Chain Chain `json:"chain,omitempty"`
PipelinesAsCode PipelinesAsCode `json:"pipelinesAsCode,omitempty"`
...
}
Resulting YAML:
spec:
pipelinesAsCode:
enable: true
settings:
application-name: Pipelines as Code CI
...
This removes the need for PipelinesAsCodeForCurrentPlatform() and the
per-platform defaulting dance in tektonconfig_defaults.go entirely — one
field, one validation path, one reconciler read.
Scope of Changes
API types
- Add
PipelinesAsCodetoTektonConfigSpecin
pkg/apis/operator/v1alpha1/tektonconfig_types.go - Remove
PipelinesAsCodefromOpenShift(openshift_platform.go) and
Kubernetes(kubernetes_platform.go) platform structs - Remove
PipelinesAsCodeForCurrentPlatform()and update every call site
listed above to readconfig.Spec.PipelinesAsCodedirectly
Defaults / validation
- Simplify
tektonconfig_defaults.go— drop the Kubernetes→OpenShift copy
logic and the two separate default blocks in favor of one - Simplify
tektonconfig_validation.go— drop theIsOpenShiftPlatform()
branch at lines 78-81
Reconcilers
pkg/reconciler/shared/tektonconfig/pipelinesascode/pipelinesascode.go,
pkg/reconciler/openshift/tektonconfig/extension.go,
pkg/reconciler/kubernetes/tektonconfig/extension.go— read the new
top-level fieldpkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade.go— this is an
existing upgrade-path file; it may need a companion migration step that
copies a populatedplatforms.{openshift,kubernetes}.pipelinesAsCode
forward into the newspec.pipelinesAsCodefield for existing clusters
(see Migration below)
Code generation
- Re-run
./hack/update-codegen.shandmake generate-crds/
make sync-helm-crdsafter the type change; commit regenerated CRDs
underconfig/base/generated-crds/and the Helm chart templates
Docs
docs/TektonConfig.md— update theplatforms.{openshift,kubernetes}
YAML examples (lines 124-146) and theOpenShiftPipelinesAsCodesection
(line ~556) to referencespec.pipelinesAsCode- CR samples under
config/crs/referencing PAC settings underplatforms
Tests
- Unit tests for defaults/validation currently asserting on
Platforms.{OpenShift,Kubernetes}.PipelinesAsCode - E2E tests that build a
TektonConfigCR with PAC settings under
platforms
Migration / Compatibility
This is a breaking API change for any TektonConfig CR that currently
sets spec.platforms.openshift.pipelinesAsCode or
spec.platforms.kubernetes.pipelinesAsCode.
Suggested approach, consistent with the deprecation-window strategy
discussed in #3841: keep the old platforms.*.pipelinesAsCode fields
accepted (deprecated, not removed) for one or two minor releases, with
SetDefaults/pre_upgrade.go copying a populated old field forward into
the new spec.pipelinesAsCode if the new field is unset. Remove the old
fields in a later release once the deprecation window closes. Whichever
approach is chosen should land in the same release cycle as #3841 given the
overlapping migration/upgrade-guide work, and both should be documented
together in the release notes.
Acceptance Criteria
-
spec.pipelinesAsCodeis a top-level field onTektonConfig,
consistent withspec.chain/spec.trigger/spec.pipeline -
Platforms.OpenShift.PipelinesAsCodeand
Platforms.Kubernetes.PipelinesAsCodeare removed (or deprecated per
the migration plan) andPipelinesAsCodeForCurrentPlatform()is
deleted -
make lintandmake testpass with zero failures -
./hack/update-codegen.shandmake sync-helm-crdshave been re-run
and generated files are committed -
docs/TektonConfig.mdand any CR samples updated to the new field
location - Upgrade path documented (migration guide or release note), and
coordinated with #3841 if both land close together
References
- Related: #3841 (rename
OpenShiftPipelinesAsCodeCRD kind to
TektonPipelinesAsCode) — explicitly scopes out this structural question - Current field definitions:
pkg/apis/operator/v1alpha1/tektonconfig_types.go,
pkg/apis/operator/v1alpha1/openshift_platform.go,
pkg/apis/operator/v1alpha1/kubernetes_platform.go - Naming convention reference:
Chain/Trigger/Pipelinefields in
pkg/apis/operator/v1alpha1/tektonconfig_types.go - Pipelines-as-Code upstream repo: https://github.com/tektoncd/pipelines-as-code
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the field definitions in pkg/apis/operator/v1alpha1/tektonconfig_types.go, openshift_platform.go, and kubernetes_platform.go, then trace defaults, validation, reconcilers, upgrade handling, tests, docs, and generated CRDs listed in the issue. Decide and document the compatibility migration, update all affected references and samples, regenerate code and CRDs, and verify with make lint and make test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- api, documentation, infrastructure, testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100