Skip to content

Commit 8aa3ddc

Browse files
authored
fix(runtime-manifest.go): fix resolution for step- and bundle-level outputs (#1205)
* fix(runtime-manifest.go): fix resolution for step- and bundle-level outputs Signed-off-by: Vaughn Dice <vadice@microsoft.com> * update runtime-manifest fix * mod testdata bundle for outputs int test Signed-off-by: Vaughn Dice <vadice@microsoft.com>
1 parent 1cff9e4 commit 8aa3ddc

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

pkg/runtime/runtime-manifest.go

+6
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ func (m *RuntimeManifest) buildSourceData() (map[string]interface{}, error) {
329329
continue
330330
}
331331

332+
// A bundle-level output may also be a step-level output
333+
// If already set, do not override
334+
if val, exists := m.outputs[ps.OutputName]; exists && val != "" {
335+
continue
336+
}
337+
332338
val, err := m.resolveBundleOutput(ps.OutputName)
333339
if err != nil {
334340
return nil, err

tests/testdata/bundles/outputs-example/helpers.sh

+7
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@ dump() {
99
echo $1
1010
}
1111

12+
assert-output-value() {
13+
if [ "$1" != "$2" ]; then
14+
echo "'$1' does not match the expected output value of '$2'."
15+
exit 1
16+
fi
17+
}
18+
1219
# Call the requested function and pass the arguments as-is
1320
"$@"

tests/testdata/bundles/outputs-example/porter.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mixins:
99
outputs:
1010
- name: user-output
1111
type: string
12-
sensitive: true
12+
sensitive: false
1313
applyTo:
1414
- upgrade
1515

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

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

0 commit comments

Comments
 (0)