Merge pull request #9089 from sean-m-sullivan/survey_update

Survey update to workflows

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
             https://github.com/beeankha
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-01-18 17:22:43 +00:00 committed by GitHub
commit 5959bfc4ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -94,10 +94,12 @@ options:
- Setting that variable will prompt the user for job type on the
workflow launch.
type: bool
survey:
survey_spec:
description:
- The definition of the survey associated to the workflow.
type: dict
aliases:
- survey
labels:
description:
- The labels applied to this job template
@ -149,7 +151,7 @@ import json
def update_survey(module, last_request):
spec_endpoint = last_request.get('related', {}).get('survey_spec')
module.post_endpoint(spec_endpoint, **{'data': module.params.get('survey')})
module.post_endpoint(spec_endpoint, **{'data': module.params.get('survey_spec')})
module.exit_json(**module.json_output)
@ -161,7 +163,7 @@ def main():
description=dict(),
extra_vars=dict(type='dict'),
organization=dict(),
survey=dict(type='dict'), # special handling
survey_spec=dict(type='dict', aliases=['survey']),
survey_enabled=dict(type='bool'),
allow_simultaneous=dict(type='bool'),
ask_variables_on_launch=dict(type='bool'),
@ -266,7 +268,7 @@ def main():
# association_fields['labels'].append(label_id)
on_change = None
new_spec = module.params.get('survey')
new_spec = module.params.get('survey_spec')
if new_spec:
existing_spec = None
if existing_item:

View File

@ -47,7 +47,7 @@ no_api_parameter_ok = {
# Organization is how we are looking up job templates, Approval node is for workflow_approval_templates
'tower_workflow_job_template_node': ['organization', 'approval_node'],
# Survey is how we handle associations
'tower_workflow_job_template': ['survey'],
'tower_workflow_job_template': ['survey_spec'],
# ad hoc commands support interval and timeout since its more like tower_job_launc
'tower_ad_hoc_command': ['interval', 'timeout', 'wait'],
}

View File

@ -12,7 +12,7 @@ def test_create_workflow_job_template(run_module, admin_user, organization, surv
'name': 'foo-workflow',
'organization': organization.name,
'extra_vars': {'foo': 'bar', 'another-foo': {'barz': 'bar2'}},
'survey': survey_spec,
'survey_spec': survey_spec,
'survey_enabled': True,
'state': 'present'
}, admin_user)
@ -72,7 +72,7 @@ def test_survey_spec_only_changed(run_module, admin_user, organization, survey_s
result = run_module('tower_workflow_job_template', {
'name': 'foo-workflow',
'organization': organization.name,
'survey': survey_spec,
'survey_spec': survey_spec,
'state': 'present'
}, admin_user)
assert not result.get('failed', False), result.get('msg', result)