--- title: "ADR 0070: PipelineRun labels hold cleaned values, annotations hold the originals" --- * Status: accepted * Code: [`pkg/kubeinteraction/labels.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/kubeinteraction/labels.go), [`pkg/kubeinteraction/cleanups.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/kubeinteraction/cleanups.go) ## Context `AddLabelsAndAnnotations` decorates the PipelineRun before it is created so the UI and the CLI can query it. Kubernetes label values are restricted, so event data (organization, repository, SHA, event type, version) is passed through `formatting.CleanValueKubernetes` before it becomes a label. The cleaned value may differ from the real one. Label selectors are what `CleanupPipelines` uses to find the runs of a repository: `keys.Repository`, `keys.OriginalPRName` and `keys.State`. ## Decision * The keys used in label selectors (`URLOrg`, `URLRepository`, `SHA`, `Repository`, `EventType`, `PullRequest`) are set as labels with the cleaned value, and set again as annotations with the raw value, so a reader can get the unmodified value from the annotation. * Everything else (titles, URLs, sender, branches, controller info, trace context) is annotation only. * Provider specific data is added to the annotations in the same function, with no per-provider split: GitHub installation ID and GHE URL (only for `github` and `github-enterprise`), GitLab source and target project IDs, Bitbucket Data Center clone URL and project key. Each is added only when the event carries a value. * The labels `keys.CancelInProgress` is copied from the PipelineRun annotation when present. * Tekton Results annotations are added at the end through `AddResultsAnnotation`. ## Consequences * A selector must use the cleaned value (`CleanupPipelines` does so for the repository name and the original PipelineRun name). * The provider specific blocks are keyed on the event fields, not on a provider interface; a new provider adds more branches to this function. * The code does not record why the provider data is not moved behind the provider; a former TODO asked for it and gave no reason.