Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that workflow.priority substitution didn't pass validation #1690

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix issue that workflow.priority substitution didn't pass validation
  • Loading branch information
markterm committed Oct 17, 2019
commit d883eee7de4d93d3a698fc96ea233c371c2f56ac
5 changes: 5 additions & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"reflect"
"regexp"
"strconv"
"strings"

"github.com/valyala/fasttemplate"
Expand Down Expand Up @@ -123,6 +124,10 @@ func ValidateWorkflow(wfClientset wfclientset.Interface, namespace string, wf *w
ctx.globalParams["workflow.labels."+k] = placeholderValue
}

if wf.Spec.Priority != nil {
ctx.globalParams[common.GlobalVarWorkflowPriority] = strconv.Itoa(int(*wf.Spec.Priority))
}

if wf.Spec.Entrypoint == "" {
return errors.New(errors.CodeBadRequest, "spec.entrypoint is required")
}
Expand Down
23 changes: 23 additions & 0 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ kind: Workflow
metadata:
generateName: global-parameters-complex-
spec:
priority: 100
entrypoint: test-workflow
arguments:
parameters:
Expand Down Expand Up @@ -872,6 +873,28 @@ func TestExitHandler(t *testing.T) {
assert.Nil(t, err)
}

var workflowWithPriority = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: with-priority-
spec:
entrypoint: whalesay
priority: 100
templates:
- name: whalesay
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{workflow.priority}}"]
`

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


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