From 64f64031c7f59576bc244396d79467f8a10f443d Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian Date: Thu, 6 Feb 2020 23:21:10 -0800 Subject: [PATCH 1/5] Update cli_with_server_test.go --- test/e2e/cli_with_server_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/cli_with_server_test.go b/test/e2e/cli_with_server_test.go index 95ee1bfebc76..e16af7497b70 100644 --- a/test/e2e/cli_with_server_test.go +++ b/test/e2e/cli_with_server_test.go @@ -2,6 +2,7 @@ package e2e import ( "os" + "strings" "testing" "time" @@ -45,7 +46,7 @@ func (s *CLISuite) TestAuthToken() { } else { authString = "Basic " + token } - assert.Equal(t, authString, output) + assert.Equal(t, authString, strings.TrimSpace(output)) }) } From 38bc2ee03ab3b71178e142f139ed19dca2888d9c Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian Date: Tue, 7 Apr 2020 19:00:59 -0700 Subject: [PATCH 2/5] Update cluster-workflow-template-nested-template.yaml --- ...ter-workflow-template-nested-template.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/e2e/testdata/cluster-workflow-template-nested-template.yaml b/test/e2e/testdata/cluster-workflow-template-nested-template.yaml index 532ed0d71b9a..32399a955bca 100644 --- a/test/e2e/testdata/cluster-workflow-template-nested-template.yaml +++ b/test/e2e/testdata/cluster-workflow-template-nested-template.yaml @@ -1,3 +1,19 @@ +kind: ClusterWorkflowTemplate +metadata: + name: cluster-workflow-template-whalesay-template + labels: + argo-e2e: true +spec: + templates: + - name: whalesay-template + inputs: + parameters: + - name: message + container: + image: docker/whalesay + command: [cowsay] + args: ["{{inputs.parameters.message}}"] +--- apiVersion: argoproj.io/v1alpha1 kind: ClusterWorkflowTemplate metadata: @@ -8,8 +24,9 @@ spec: templates: - name: whalesay-inner-template templateRef: - name: workflow-template-whalesay-template + name: cluster-workflow-template-whalesay-template template: whalesay-template + clusterscope: true inputs: parameters: - name: message From 766677fab3c93866a015566b53a3c005bdfc9cd2 Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian Date: Mon, 27 Apr 2020 19:28:14 -0700 Subject: [PATCH 3/5] Fixed WFT and CWFT validation --- workflow/validate/validate.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/workflow/validate/validate.go b/workflow/validate/validate.go index 43e6739ecb5b..1a141cb9cab2 100644 --- a/workflow/validate/validate.go +++ b/workflow/validate/validate.go @@ -39,6 +39,9 @@ type ValidateOpts struct { // IgnoreEntrypoint indicates to skip/ignore the EntryPoint validation on workflow spec. // Entrypoint is optional for WorkflowTemplate and ClusterWorkflowTemplate IgnoreEntrypoint bool + + // WorkflowTemplateValidation indicates validation call for WFT/CWFT. + WorkflowTemplateValidation bool } // templateValidationCtx is the context for validating a workflow spec @@ -172,7 +175,13 @@ func ValidateWorkflow(wftmplGetter templateresolution.WorkflowTemplateNamespaced } if !opts.IgnoreEntrypoint { - _, err = ctx.validateTemplateHolder(&wfv1.WorkflowStep{Template: wf.Spec.Entrypoint}, tmplCtx, &wf.Spec.Arguments, map[string]interface{}{}) + var args wfv1.ArgumentsProvider + args = &wf.Spec.Arguments + + if opts.WorkflowTemplateValidation { + args = &FakeArguments{} + } + _, err = ctx.validateTemplateHolder(&wfv1.WorkflowStep{Template: wf.Spec.Entrypoint}, tmplCtx, args, map[string]interface{}{}) if err != nil { return nil, err } @@ -208,13 +217,13 @@ func ValidateWorkflow(wftmplGetter templateresolution.WorkflowTemplateNamespaced // ValidateWorkflowTemplate accepts a workflow template and performs validation against it. func ValidateWorkflowTemplate(wftmplGetter templateresolution.WorkflowTemplateNamespacedGetter, cwftmplGetter templateresolution.ClusterWorkflowTemplateGetter, wftmpl *wfv1.WorkflowTemplate) (*wfv1.WorkflowConditions, error) { wf := common.ConvertWorkflowTemplateToWorkflow(wftmpl) - return ValidateWorkflow(wftmplGetter, cwftmplGetter, wf, ValidateOpts{IgnoreEntrypoint: wf.Spec.Entrypoint == ""}) + return ValidateWorkflow(wftmplGetter, cwftmplGetter, wf, ValidateOpts{IgnoreEntrypoint: wf.Spec.Entrypoint == "", WorkflowTemplateValidation: true}) } // ValidateClusterWorkflowTemplate accepts a cluster workflow template and performs validation against it. func ValidateClusterWorkflowTemplate(wftmplGetter templateresolution.WorkflowTemplateNamespacedGetter, cwftmplGetter templateresolution.ClusterWorkflowTemplateGetter, cwftmpl *wfv1.ClusterWorkflowTemplate) (*wfv1.WorkflowConditions, error) { wf := common.ConvertClusterWorkflowTemplateToWorkflow(cwftmpl) - return ValidateWorkflow(wftmplGetter, cwftmplGetter, wf, ValidateOpts{IgnoreEntrypoint: wf.Spec.Entrypoint == ""}) + return ValidateWorkflow(wftmplGetter, cwftmplGetter, wf, ValidateOpts{IgnoreEntrypoint: wf.Spec.Entrypoint == "", WorkflowTemplateValidation: true}) } // ValidateCronWorkflow validates a CronWorkflow From 53f73096894a70fb36320cdbb7af33b07aaf9bc1 Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian Date: Tue, 28 Apr 2020 11:48:53 -0700 Subject: [PATCH 4/5] Added test --- workflow/validate/validate_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/workflow/validate/validate_test.go b/workflow/validate/validate_test.go index 939aa36a17f0..05602746b0ef 100644 --- a/workflow/validate/validate_test.go +++ b/workflow/validate/validate_test.go @@ -2385,3 +2385,26 @@ func TestWorfklowGlobalVariables(t *testing.T) { _, err := validate(globalVariables) assert.NoError(t, err) } + +var wfTemplateWithEntrypoint = ` +apiVersion: argoproj.io/v1alpha1 +kind: WorkflowTemplate +metadata: + name: template-with-entrypoint +spec: + entrypoint: whalesay-template + templates: + - name: whalesay-template + inputs: + parameters: + - name: message + container: + image: docker/whalesay + command: [cowsay] + args: ["{{inputs.parameters.message}}"] +` + +func TestWorkflowTemplateWithEntrypoint(t *testing.T) { + err := validateWorkflowTemplate(wfTemplateWithEntrypoint) + assert.NoError(t, err) +} From a8a5d138f6758fe7b2f37d748679ad8b316aa870 Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian Date: Tue, 28 Apr 2020 13:45:00 -0700 Subject: [PATCH 5/5] Update validate.go --- workflow/validate/validate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/validate/validate.go b/workflow/validate/validate.go index 1a141cb9cab2..cdc0e7e61749 100644 --- a/workflow/validate/validate.go +++ b/workflow/validate/validate.go @@ -40,7 +40,7 @@ type ValidateOpts struct { // Entrypoint is optional for WorkflowTemplate and ClusterWorkflowTemplate IgnoreEntrypoint bool - // WorkflowTemplateValidation indicates validation call for WFT/CWFT. + // WorkflowTemplateValidation indicates that the current context is validating a WorkflowTemplate or ClusterWorkflowTemplate WorkflowTemplateValidation bool }