Change the list of extensions to a dict
The stage-output role accepts a list of extensions to be replaced as txt
so that they can be seen directly from within a web browser.
Using a list means that children jobs cannot add to the parent setting,
only overwrite. Adding support for dicts while preserving, at least for
now, support for lists - to avoid breaking existing implementations.
This reverts change 844b3333aa
.
Change-Id: I5052c873f0a5da7ecaa38627e8900af86bbec2f9
Needed-By: https://review.openstack.org/539686
Needed-By: https://review.openstack.org/539708
Needed-By: https://review.openstack.org/539854
This commit is contained in:
parent
844b3333aa
commit
f7fd2fce61
@ -31,7 +31,7 @@ intended to be used before output fetching in a base job's post-playbook.
|
||||
.. zuul:rolevar:: extensions_to_txt
|
||||
:default: null
|
||||
|
||||
A list of file extensions to be replaced with .txt when staging.
|
||||
A dict of file extensions to be replaced with .txt when staging.
|
||||
This can be useful to ensure that text files with an extension not
|
||||
registered in the web server may be viewed via browser when uploaded
|
||||
to a file server.
|
||||
@ -43,8 +43,9 @@ intended to be used before output fetching in a base job's post-playbook.
|
||||
Example:
|
||||
|
||||
extensions_to_txt:
|
||||
- conf
|
||||
- log
|
||||
conf: True
|
||||
log: True
|
||||
txt: False
|
||||
|
||||
zuul.conf --(staged as)--> zuul_conf.txt
|
||||
|
||||
|
@ -4,12 +4,38 @@
|
||||
with_dict: "{{ zuul_copy_output }}"
|
||||
register: sources
|
||||
|
||||
- name: Build the replace regex
|
||||
set_fact:
|
||||
extensions_regex: "{{ extensions_to_txt | join('|') | default('__do_not_replace__') }}"
|
||||
- name: Output a warning when input is not a dict and not empty
|
||||
debug:
|
||||
msg: "WARNING: extensions_to_txt is a list, values defined by parents will be overwritten"
|
||||
when:
|
||||
- extensions_to_txt is not mapping
|
||||
- extensions_to_txt
|
||||
|
||||
- debug:
|
||||
var: extensions_regex
|
||||
- name: Build the extensions list when input is not a dict (including empty)
|
||||
set_fact:
|
||||
extension_list: >
|
||||
{% set extensions = ['__does_not_match__'] -%}
|
||||
{% if extensions_to_txt -%}
|
||||
{% set extensions = extensions_to_txt -%}
|
||||
{% endif -%}
|
||||
{{- extensions -}}
|
||||
when: extensions_to_txt is not mapping
|
||||
|
||||
- name: Build the extensions list when input is a dict
|
||||
set_fact:
|
||||
extension_list: >
|
||||
{% set extensions = [] -%}
|
||||
{% for extension, extension_bool in extensions_to_txt.items() -%}
|
||||
{% if extension_bool -%}
|
||||
{% set _ = extensions.append(extension) -%}
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
{{- extensions -}}
|
||||
when: extensions_to_txt is mapping
|
||||
|
||||
- name: Build the extensions regular expression
|
||||
set_fact:
|
||||
extensions_regex: "{{ extension_list | join('|') }}"
|
||||
|
||||
# TODO(andreaf) We might want to enforce that item.value is a valid value
|
||||
# in docs, artifacts, logs. Null case already handled.
|
||||
|
Loading…
Reference in New Issue
Block a user