Skip to content

Commit

Permalink
feat(controller): Inline templates
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Jun 8, 2021
1 parent e7808af commit 1b0cefc
Show file tree
Hide file tree
Showing 24 changed files with 954 additions and 548 deletions.
8 changes: 8 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3429,6 +3429,10 @@
"description": "Hooks hold the lifecycle hook which is invoked at lifecycle of task, irrespective of the success, failure, or error status of the primary task",
"type": "object"
},
"inline": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Template",
"description": "Inline is the template. Template must be empty if this is declared (and vice-versa)."
},
"name": {
"description": "Name is the name of the target",
"type": "string"
Expand Down Expand Up @@ -5884,6 +5888,10 @@
"description": "Hooks holds the lifecycle hook which is invoked at lifecycle of step, irrespective of the success, failure, or error status of the primary step",
"type": "object"
},
"inline": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Template",
"description": "Inline is the template. Template must be empty if this is declared (and vice-versa)."
},
"name": {
"description": "Name of the step",
"type": "string"
Expand Down
8 changes: 8 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6862,6 +6862,10 @@
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
}
},
"inline": {
"description": "Inline is the template. Template must be empty if this is declared (and vice-versa).",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Template"
},
"name": {
"description": "Name is the name of the target",
"type": "string"
Expand Down Expand Up @@ -9310,6 +9314,10 @@
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
}
},
"inline": {
"description": "Inline is the template. Template must be empty if this is declared (and vice-versa).",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Template"
},
"name": {
"description": "Name of the step",
"type": "string"
Expand Down
88 changes: 88 additions & 0 deletions docs/fields.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions docs/templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Templates

See [core concepts](core-concepts.md) for DAG, steps, container templates.

## Container Set Template

See [container set template](container-set-template.md).

## Inline Templates

![alpha](assets/alpha.svg)

> v3.2 and after
You can inline other templates within DAG and steps.

Examples:

* [DAG](examples/dag-inline-workflow.yaml)
* [Steps](examples/steps-inline-workflow.yaml)

!!! Warning
You can only inline once. Inlining a DAG within a DAG will not work.
18 changes: 18 additions & 0 deletions examples/dag-inline-clusterworkflowtemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: dag-inline
annotations:
workflows.argoproj.io/description: |
This examples demonstrates running a DAG with inline templates.
workflows.argoproj.io/version: ">= 3.2.0"
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: a
inline:
container:
image: argoproj/argosay:v2
13 changes: 13 additions & 0 deletions examples/dag-inline-cronworkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: dag-inline
annotations:
workflows.argoproj.io/description: |
This example demonstrates running cron workflow that has a DAG with inline templates.
workflows.argoproj.io/version: ">= 3.2.0"
spec:
schedule: "*/5 * * * *"
workflowSpec:
workflowTemplateRef:
name: dag-inline
22 changes: 22 additions & 0 deletions examples/dag-inline-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-inline-
labels:
workflows.argoproj.io/test: "true"
annotations:
workflows.argoproj.io/description: |
This example demonstrates running a DAG with inline templates.
workflows.argoproj.io/version: ">= 3.2.0"
workflows.argoproj.io/verify.py: |
assert status["phase"] == "Succeeded"
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: a
inline:
container:
image: argoproj/argosay:v2
18 changes: 18 additions & 0 deletions examples/dag-inline-workflowtemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: dag-inline
annotations:
workflows.argoproj.io/description: |
This example demonstrates running a DAG with inline templates.
workflows.argoproj.io/version: ">= 3.2.0"
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: a
inline:
container:
image: argoproj/argosay:v2
21 changes: 21 additions & 0 deletions examples/steps-inline-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: steps-inline-
labels:
workflows.argoproj.io/test: "true"
annotations:
workflows.argoproj.io/description: |
This workflow demonstrates running a steps with inline templates.
workflows.argoproj.io/version: ">= 3.2.0"
workflows.argoproj.io/verify.py: |
assert status["phase"] == "Succeeded"
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: a
inline:
container:
image: argoproj/argosay:v2
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -9536,6 +9537,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down
2 changes: 2 additions & 0 deletions manifests/base/crds/full/argoproj.io_cronworkflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3406,6 +3406,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -9557,6 +9558,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down
5 changes: 5 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3394,6 +3394,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -9545,6 +9546,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -18399,6 +18401,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -25502,6 +25505,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -31653,6 +31657,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down
1 change: 1 addition & 0 deletions manifests/base/crds/full/argoproj.io_workflowtasksets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down
2 changes: 2 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflowtemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down Expand Up @@ -9535,6 +9536,7 @@ spec:
- template
type: object
type: object
inline: {}
name:
type: string
onExit:
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ nav:
- cluster-workflow-templates.md
- cron-workflows.md
- cron-backfill.md
- templates.md
- container-set-template.md
- template-defaults.md
- work-avoidance.md
- enhanced-depends-logic.md
- data-sourcing-and-transformation.md
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/workflow/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ type WorkflowSpecHolder interface {

// TemplateReferenceHolder is an object that holds a reference to other templates; e.g. WorkflowStep, DAGTask, and NodeStatus
type TemplateReferenceHolder interface {
GetTemplateName() string
// GetTemplate returns the template. This maybe nil. This is first precedence.
GetTemplate() *Template
// GetTemplateRef returns the template ref. This maybe nil. This is second precedence.
GetTemplateRef() *TemplateRef
// GetTemplateName returns the template name. This maybe empty. This is last precedence.
GetTemplateName() string
}

// SubmitOpts are workflow submission options
Expand Down
Loading

0 comments on commit 1b0cefc

Please sign in to comment.