Skip to content

feat: propagate step outputs across steps#2745

Open
lukkaempf wants to merge 1 commit into
kyverno:mainfrom
lukkaempf:feat/step-outputs
Open

feat: propagate step outputs across steps#2745
lukkaempf wants to merge 1 commit into
kyverno:mainfrom
lukkaempf:feat/step-outputs

Conversation

@lukkaempf

Copy link
Copy Markdown

Explanation

Currently, outputs defined in a test step are only available within that same step.
This PR propagates outputs across steps, so a binding set via outputs in step N is
available in step N+1 and beyond. This is an addition of new behavior.

Related issue

Fixes #2464

Proposed Changes

runStep now returns the updated TestContext (including output bindings) in addition to the stop signal.
The step loop passes this context to subsequent steps, making outputs from one step available in the next.

Named return values are used so that catch/finally deferred blocks can also propagate their outputs —
without them, deferred changes to the context would be lost before the function returns.

Story Proces

  1. Prior to this PR, outputs were scoped to a single step — a binding set via outputs
    in step N could not be referenced in step N+1.

  2. This PR returns the updated TestContext from runStep and passes it to subsequent
    steps in the step loop.

  3. After this PR, outputs from step N are available as bindings in all following steps.

Proof Manifest

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: step-outputs
spec:
  steps:
  - name: get-namespace-name
    try:
    - script:
        content: echo $NAMESPACE
        outputs:
        - name: ns
          value: (trim_space($stdout))
  - name: assert-namespace-exists
    try:
    - assert:
        resource:
          apiVersion: v1
          kind: Namespace
          metadata:
            name: ($ns)

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

@lukkaempf lukkaempf requested a review from a team as a code owner June 20, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Make outputs available to other steps

1 participant