Repository navigation
Description
Pre-submission checklist
- I have searched existing issues and confirmed this is not a duplicate.
- I understand that submitting a feature request does not guarantee it will be implemented.
Proposed Feature
Let promotion expressions read the annotations and labels of the Stage a Promotion runs for. Checked against v1.11.2, which has no way to do this:
- ctx holds project, promotion, stage (a name string), targetFreight, meta and uiBaseUrl, and no Stage metadata (BuildCtxMap in pkg/promotion/evaluator.go).
- stageMetadata(stageName) returns stage.Status.Metadata only, and nil when that is empty (StageMetadata in pkg/expressions/function/functions.go). That is the controller-written key-value store, not metadata.annotations or metadata.labels, and it can't be declared in Git.
Any one of these would meet the need:
- Add Stage metadata to ctx, for example ctx.stageMeta.annotations and ctx.stageMeta.labels. This needs no lookup or name argument, because the Promotion already belongs to a Stage.
- Add stageAnnotations(stageName) and stageLabels(stageName) beside stageMetadata().
- Extend stageMetadata() to also return metadata.annotations and metadata.labels under their own keys, leaving its status.metadata result unchanged.
Expected behaviour:
- GIVEN a Stage annotated example.com/flag: "true" WHEN a step's if: or config expression reads it THEN the value is available.
- GIVEN a Stage with no annotations WHEN an expression reads one THEN it yields a missing value without an error, so ?? and ternary defaults work.
- GIVEN a Stage's annotations were just changed WHEN a Promotion starts THEN the new values are used, as stageMetadata() already does by reading the object uncached.
Motivation and Use Case
Teams share one ClusterPromotionTask across many Stages, and want each Stage to opt in to behaviour declared in Git. Examples:
- "this Stage requires a manual approval step before it renders";
- "post this Stage's promotion notices to a particular channel".
The natural place to declare that is the Stage's annotations. They are in Git, reviewable, and readable by other tooling that lists Stages, such as promotion gateways and drift checks.
Today the shared task can't see them. The only route is to repeat the setting as a vars entry in promotionTemplate, so each opt-in has two copies. The copies can drift, and nothing can check that they agree. In our case, an approval gate that is meant to be on for a production Stage could be silently off because only one copy was set.
Alternatives Considered
- A vars entry repeating the annotation. This works and is what we do now, but the two copies drift, as above.
- Reading the setting from a configMap(). This needs a second object kept in step with the Stage, which moves the duplication rather than removing it.
- Having an external service read the Stage and decide. The task would have to call the service on every Promotion, including ones that don't need it. That adds a runtime dependency to every promotion for a setting that is static and already in Git.
Activity
krancour commentedon Nov 26, 2026
One thing that really needs to be considered here is that Stages are among a number of objects making a transition right now from being k8s resources to being rows in a database instead. Without making any judgement on the validity of the use case, which is probably fine, I think k8s-shaped metadata won't be a thing in 2.0. Likely it gets replaced with something that fills a similar need, but I would suggest that access to that via expression naturally comes after we figure out exactly what that looks like.