Skip to content

Commit

Permalink
fix: Support inputs for inline DAG template. Fixes argoproj#7432 (arg…
Browse files Browse the repository at this point in the history
…oproj#7439)

Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec authored Jan 20, 2022
1 parent bc27ada commit f9fa0e3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
41 changes: 41 additions & 0 deletions workflow/controller/inline_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package controller

import (
"context"
"testing"

"github.com/stretchr/testify/assert"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
)

func TestInlineDAG(t *testing.T) {
wf := wfv1.MustUnmarshalWorkflow(`
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: inline-
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: a
inline:
container:
image: argoproj/argosay:v2
args:
- echo
- "{{inputs.parameters.foo}}"
inputs:
parameters:
- name: foo
value: bar
`)
cancel, wfc := newController(wf)
defer cancel()
woc := newWorkflowOperationCtx(wf, wfc)
woc.operate(context.Background())
assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase)
}
6 changes: 6 additions & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,12 @@ func (ctx *templateValidationCtx) validateDAG(scope map[string]interface{}, tmpl
aggregate := len(ancestorTask.WithItems) > 0 || ancestorTask.WithParam != ""
ctx.addOutputsToScope(resolvedTmpl, ancestorPrefix, taskScope, aggregate, true)
}
if i := task.Inline; i != nil {
for _, p := range i.Inputs.Parameters {
taskScope["inputs.parameters."+p.Name] = placeholderGenerator.NextPlaceholder()
}
}

err = addItemsToScope(task.WithItems, task.WithParam, task.WithSequence, taskScope)
if err != nil {
return errors.Errorf(errors.CodeBadRequest, "templates.%s.tasks.%s %s", tmpl.Name, task.Name, err.Error())
Expand Down

0 comments on commit f9fa0e3

Please sign in to comment.