Skip to content

Commit

Permalink
fix: allow non path output params (argoproj#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaniwaki committed Apr 21, 2020
1 parent af9f61e commit 7cb2fd1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
9 changes: 7 additions & 2 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,13 @@ func (ctx *templateValidationCtx) validateBaseImageOutputs(tmpl *wfv1.Template)
}
}
for _, out := range tmpl.Outputs.Parameters {
if out.ValueFrom != nil && common.FindOverlappingVolume(tmpl, out.ValueFrom.Path) == nil {
return errors.Errorf(errors.CodeBadRequest, "templates.%s.outputs.parameters.%s: %s", tmpl.Name, out.Name, errMsg)
if out.ValueFrom == nil {
continue
}
if out.ValueFrom.Path != "" {
if common.FindOverlappingVolume(tmpl, out.ValueFrom.Path) == nil {
return errors.Errorf(errors.CodeBadRequest, "templates.%s.outputs.parameters.%s: %s", tmpl.Name, out.Name, errMsg)
}
}
}
}
Expand Down
38 changes: 38 additions & 0 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1496,13 +1496,49 @@ spec:
path: /mnt
`

var nonPathOutputParameter = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: non-path-out-param-
spec:
entrypoint: non-path-out-param
templates:
- name: non-path-out-param
steps:
- - name: non-path-resource-out-param
template: non-path-resource-out-param
outputs:
parameters:
- name: param
valueFrom:
parameter: "{{steps.non-path-resource-out-param.outputs.parameters.json}}"
- name: non-path-resource-out-param
resource:
action: create
manifest: |
apiVersion: v1
kind: ConfigMap
metadata:
name: whalesay-cm
outputs:
parameters:
- name: json
valueFrom:
jsonPath: '{.metadata.name}'
- name: jqfliter
valueFrom:
jqFilter: .
`

// TestBaseImageOutputVerify verifies we error when we detect the condition when the container
// runtime executor doesn't support output artifacts from a base image layer, and fails validation
func TestBaseImageOutputVerify(t *testing.T) {
wfBaseOutArt := unmarshalWf(baseImageOutputArtifact)
wfBaseOutParam := unmarshalWf(baseImageOutputParameter)
wfEmptyDirOutArt := unmarshalWf(volumeMountOutputArtifact)
wfBaseWithEmptyDirOutArt := unmarshalWf(baseImageDirWithEmptyDirOutputArtifact)
wfNonPathOutputParam := unmarshalWf(nonPathOutputParameter)
var err error

for _, executor := range []string{common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorKubelet, common.ContainerRuntimeExecutorPNS, common.ContainerRuntimeExecutorDocker, ""} {
Expand All @@ -1514,6 +1550,8 @@ func TestBaseImageOutputVerify(t *testing.T) {
assert.Error(t, err)
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseWithEmptyDirOutArt, ValidateOpts{ContainerRuntimeExecutor: executor})
assert.Error(t, err)
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfNonPathOutputParam, ValidateOpts{ContainerRuntimeExecutor: executor})
assert.NoError(t, err)
case common.ContainerRuntimeExecutorPNS:
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseOutArt, ValidateOpts{ContainerRuntimeExecutor: executor})
assert.NoError(t, err)
Expand Down

0 comments on commit 7cb2fd1

Please sign in to comment.