kyverno / chainsaw

Declarative K8s e2e testing
https://kyverno.github.io/chainsaw/
Apache License 2.0
310 stars 46 forks source link

[Feature] support outputs transmit to follow steps #2157

Open nkuacac opened 1 week ago

nkuacac commented 1 week ago

Problem Statement

steps:
    - try:
      - description: ""
        script:
          ...
          outputs:
            - name: result
              value: (json_parse($stdout).status.result)
    - try:
       - description: "use outputs_result to get before step result"
          apply:
            bindings:
               - name: get_from_before_step
                  value: ($outputs_result)

Solution Description

type StepProcessor interface {
    Run(context.Context, namespacer.Namespacer, engine.Context, engine.Context) **engine.Context**
}
func (p *stepProcessor) Run(ctx context.Context, namespacer namespacer.Namespacer, tc engine.Context, testTc engine.Context) engine.Context {
...
            for k, v := range outputs {
                tc = tc.WithBinding(ctx, k, v)
                **testTc = testTc.WithBinding(ctx, "outputs_"+k, v)**
            }
        }
    }
    return testTc
}

Alternatives

No response

Additional Context

No response

Slack discussion

No response

Research