File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,14 @@ func ValidateWorkflow(wftmplGetter templateresolution.WorkflowTemplateNamespaced
244
244
return errors .New (errors .CodeBadRequest , "spec.entrypoint is required" )
245
245
}
246
246
247
+ // if resource templates are present, workflow failure variables may appear in the manifest
248
+ for _ , tmpl := range wf .Spec .Templates {
249
+ if tmpl .Resource != nil && tmpl .Resource .Manifest != "" {
250
+ ctx .globalParams [common .GlobalVarWorkflowFailures ] = placeholderGenerator .NextPlaceholder ()
251
+ break
252
+ }
253
+ }
254
+
247
255
if ! opts .IgnoreEntrypoint {
248
256
var args wfv1.ArgumentsProvider
249
257
args = & wfArgs
Original file line number Diff line number Diff line change @@ -1041,6 +1041,47 @@ spec:
1041
1041
args: ["echo {{workflow.failures}}"]
1042
1042
`
1043
1043
1044
+ var workflowStatusInResourceTemplateManifest = `
1045
+ apiVersion: argoproj.io/v1alpha1
1046
+ kind: Workflow
1047
+ metadata:
1048
+ generateName: exit-handlers-parent-workflow-
1049
+ spec:
1050
+ entrypoint: trigger-child-workflow
1051
+ serviceAccountName: argo
1052
+ templates:
1053
+ - name: trigger-child-workflow
1054
+ resource:
1055
+ action: create
1056
+ manifest: |
1057
+ apiVersion: argoproj.io/v1alpha1
1058
+ kind: Workflow
1059
+ metadata:
1060
+ generateName: {{workflow.name}}-child-workflow-
1061
+ spec:
1062
+ entrypoint: main
1063
+ onExit: exit-handler
1064
+ templates:
1065
+ - name: main
1066
+ dag:
1067
+ tasks:
1068
+ - name: say-hello-task
1069
+ template: say-hello
1070
+ - name: say-hello
1071
+ script:
1072
+ image: alpine:latest
1073
+ command: [sh]
1074
+ source: |
1075
+ echo "hello from child workflow"
1076
+ - name: exit-handler
1077
+ script:
1078
+ image: alpine:latest
1079
+ command: [sh]
1080
+ source: |
1081
+ echo "hello from exit handler"
1082
+ echo '{{workflow.failures}}'
1083
+ `
1084
+
1044
1085
func TestExitHandler (t * testing.T ) {
1045
1086
// ensure {{workflow.status}} is not available when not in exit handler
1046
1087
err := validate (workflowStatusNotOnExit )
@@ -1049,6 +1090,10 @@ func TestExitHandler(t *testing.T) {
1049
1090
// ensure {{workflow.status}} is available in exit handler
1050
1091
err = validate (exitHandlerWorkflowStatusOnExit )
1051
1092
require .NoError (t , err )
1093
+
1094
+ // ensure {{workflow.status}} is available when in resource template manifest
1095
+ err = validate (workflowStatusInResourceTemplateManifest )
1096
+ require .NoError (t , err )
1052
1097
}
1053
1098
1054
1099
var workflowWithPriority = `
You can’t perform that action at this time.
0 commit comments