Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Improve error handling for users using the schema command #750

Merged
merged 1 commit into from
Mar 12, 2020
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
6 changes: 6 additions & 0 deletions docs/source/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release History
===============

3.3.9 (2020-03-12)
------------------

- Improve error handling for template specification in workflow schema command.
- Pin the click library to avoid changing look and feel of output.

3.3.8 (2020-01-14)
------------------

Expand Down
10 changes: 10 additions & 0 deletions docs/source/cli_ref/usage/WORKFLOWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ network with a tower-cli command after the constituent resources like
the job templates and projects were created by preceding tower-cli
commands.

Workflows Inside Workflows
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. How about adding workflow above as well in the example https://github.com/ansible/tower-cli/pull/750/files#diff-e888d13496218a3618bbee8be0d2a7d1R114-R124 ? I see example already shows jt, project, inv_source, so we can add workflow there and make it a complete example. Just a suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you don't mind that I don't do that out of sheer laziness. I know that I've tested the content here is functional. The implication is that you can combine them all together, but we just don't want poke this library any more than we have to.

~~~~~~~~~~~~~~~~~~~~~~~~~~

It is possible to have a workflow embedded inside of the schema of another
workflow. To do this, use the key "workflow".

.. code:: yaml
- workflow: Another workflow
Differences with Machine Formatted Schemas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 7 additions & 4 deletions tower_cli/resources/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ def __init__(self, data, wfjt, include_id=False):
else:
node_attrs[fd] = data[fd]
node_attrs['workflow_job_template'] = wfjt
ujt_ambiguity_msg = (
'You should provide exactly one of the attributes'
' job_template, project, workflow, inventory_source, or unified_job_template.'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for this clear message. Although I am not familiar with unified_job_template

)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way better wording!

for ujt_name in ujt_attrs:
if ujt_name not in node_attrs:
continue
if 'unified_job_template' not in node_attrs:
node_attrs['unified_job_template'] = node_attrs.pop(ujt_name)
else:
raise BadRequest(
'You should not provide more than one of the attributes'
' job_template, project and inventory_source.'
)
raise BadRequest(ujt_ambiguity_msg)
if 'unified_job_template' not in node_attrs:
raise BadRequest(ujt_ambiguity_msg)
self.unified_job_template = node_attrs.get('unified_job_template', None)
self.node_attrs = node_attrs
for rel in ['success_nodes', 'failure_nodes', 'always_nodes']:
Expand Down