Skip to content

Commit

Permalink
fix(runtime-manifest.go): fix resolution for step- and bundle-level o…
Browse files Browse the repository at this point in the history
…utputs (#1205)

* fix(runtime-manifest.go): fix resolution for step- and bundle-level outputs

Signed-off-by: Vaughn Dice <[email protected]>

* update runtime-manifest fix

* mod testdata bundle for outputs int test

Signed-off-by: Vaughn Dice <[email protected]>
  • Loading branch information
vdice authored Aug 25, 2020
1 parent 1cff9e4 commit 8aa3ddc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions pkg/runtime/runtime-manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ func (m *RuntimeManifest) buildSourceData() (map[string]interface{}, error) {
continue
}

// A bundle-level output may also be a step-level output
// If already set, do not override
if val, exists := m.outputs[ps.OutputName]; exists && val != "" {
continue
}

val, err := m.resolveBundleOutput(ps.OutputName)
if err != nil {
return nil, err
Expand Down
7 changes: 7 additions & 0 deletions tests/testdata/bundles/outputs-example/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ dump() {
echo $1
}

assert-output-value() {
if [ "$1" != "$2" ]; then
echo "'$1' does not match the expected output value of '$2'."
exit 1
fi
}

# Call the requested function and pass the arguments as-is
"$@"
9 changes: 6 additions & 3 deletions tests/testdata/bundles/outputs-example/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mixins:
outputs:
- name: user-output
type: string
sensitive: true
sensitive: false
applyTo:
- upgrade

Expand Down Expand Up @@ -40,11 +40,14 @@ upgrade:
- name: user-output
jsonPath: '$.user'
# This step tests successful interpolation of a bundle-level output in the same action
# Note: this assertion is placed in the bundle itself as docker driver output still goes directly
# to stdout, hence we can't yet capture it in the integration test output
# https://github.com/cnabio/cnab-go/issues/78
- exec:
description: "Echo bundle-level output in same action as it was produced"
description: "Validate bundle-level output value in the same action as it was produced"
command: ./helpers.sh
arguments:
- "dump {{ bundle.outputs.user-output }}"
- "assert-output-value {{ bundle.outputs.user-output }} 'sally'"

uninstall:
# This step tests successful interpolation of a bundle-level output across actions
Expand Down

0 comments on commit 8aa3ddc

Please sign in to comment.