Skip to content

Commit

Permalink
Merge pull request #8489 from sean-m-sullivan/workflow_node_logic
Browse files Browse the repository at this point in the history
Update Logic for workflow node creation/deletion

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
  • Loading branch information
softwarefactory-project-zuul[bot] authored Oct 29, 2020
2 parents 82a42d1 + 5703aa8 commit 52d178b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,17 @@ def main():
state=dict(choices=['present', 'absent'], default='present'),
)
mutually_exclusive = [("unified_job_template", "approval_node")]
required_one_of = [["unified_job_template", "approval_node", "success_nodes", "always_nodes", "failure_nodes"]]
required_if = [
['state', 'absent', ['identifier']],
['state', 'present', ['identifier']],
['state', 'present', ['unified_job_template', 'approval_node', 'success_nodes', 'always_nodes', 'failure_nodes'], 'true'],
]

# Create a module for ourselves
module = TowerAPIModule(
argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of,
required_if=required_if,
)

# Extract our parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@
that:
- "no_name_results.msg == 'Approval node name is required to create approval node.'"

- name: Fail if absent and no identifier set
tower_workflow_job_template_node:
approval_node:
description: "{{ approval_node_name }}"
workflow: "{{ wfjt_name }}"
state: absent
register: no_identifier_results
ignore_errors: true

- assert:
that:
- "no_identifier_results.msg == 'missing required arguments: identifier'"

- name: Fail if present and no unified job template set
tower_workflow_job_template_node:
identifier: approval_test
workflow: "{{ wfjt_name }}"
register: no_unified_results
ignore_errors: true

- assert:
that:
- "no_unified_results.msg == 'state is present but any of the following are missing: unified_job_template, approval_node, success_nodes, always_nodes, failure_nodes'"

- name: Create approval node
tower_workflow_job_template_node:
identifier: approval_test
Expand Down

0 comments on commit 52d178b

Please sign in to comment.