Skip to content

Commit

Permalink
Added the outputs.parameters.<NAME>.path placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-kun committed Apr 2, 2019
1 parent c0ac699 commit 5ad8197
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The following variables are made available to reference various metadata of a wo
| `pod.name` | Pod name of the container/script |
| `inputs.artifacts.<NAME>.path` | Local path of the input artifact |
| `outputs.artifacts.<NAME>.path` | Local path of the output artifact |
| `outputs.parameters.<NAME>.path` | Local path of the output parameter |

## Loops (withItems / withParam)
| Variable | Description|
Expand Down
6 changes: 6 additions & 0 deletions workflow/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ func substituteParams(tmpl *wfv1.Template, globalParams, localParams map[string]
replaceMap["outputs.artifacts."+outArt.Name+".path"] = outArt.Path
}
}
for _, param := range globalReplacedTmpl.Outputs.Parameters {
if param.ValueFrom != nil && param.ValueFrom.Path != "" {
replaceMap["outputs.parameters."+param.Name+".path"] = param.ValueFrom.Path
}
}

fstTmpl = fasttemplate.New(globalReplacedTmplStr, "{{", "}}")
s, err := Replace(fstTmpl, replaceMap, true)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ func (ctx *wfValidationCtx) validateTemplate(tmpl *wfv1.Template, args wfv1.Argu
scope[fmt.Sprintf("outputs.artifacts.%s.path", art.Name)] = true
}
}
for _, param := range tmpl.Outputs.Parameters {
if param.ValueFrom != nil && param.ValueFrom.Path != "" {
scope[fmt.Sprintf("outputs.parameters.%s.path", param.Name)] = true
}
}
}

_, err = common.ProcessArgs(tmpl, args, ctx.globalParams, localParams, true)
Expand Down
24 changes: 24 additions & 0 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,30 @@ func TestResolveIOArtifactPathPlaceholders(t *testing.T) {
assert.Nil(t, err)
}

var outputParameterPath = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: get-current-date-
spec:
entrypoint: get-current-date
templates:
- name: get-current-date
outputs:
parameters:
- name: current-date
valueFrom:
path: /tmp/current-date
container:
image: busybox
command: [sh, -c, 'date > {{outputs.parameters.current-date.path}}']
`

func TestResolveOutputParameterPathPlaceholder(t *testing.T) {
err := validate(outputParameterPath)
assert.Nil(t, err)
}

var stepOutputReferences = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
Expand Down

0 comments on commit 5ad8197

Please sign in to comment.