Ilya Kharin | fd293c4 | 2017-03-14 17:34:12 +0400 | [diff] [blame] | 1 | {%- from "devops_portal/map.jinja" import config with context -%} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 2 | {%- from "devops_portal/map.jinja" import services with context -%} |
Ilya Kharin | e1cf854 | 2017-03-17 18:37:09 +0400 | [diff] [blame] | 3 | {%- from "devops_portal/map.jinja" import service_url with context -%} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 4 | {%- macro credentials(parameters) -%} |
| 5 | {%- set keys = ['token', 'username', 'password'] -%} |
| 6 | "credentials": { |
| 7 | {%- for key, value in salt['devops_utils.iter_items'](keys, parameters) %} |
| 8 | {%- if not loop.first %},{% endif %} |
| 9 | "{{ key }}": "{{ value }}" |
| 10 | {%- endfor %} |
| 11 | } |
| 12 | {%- endmacro %} |
| 13 | { |
| 14 | "services": { |
Ilya Kharin | 918686b | 2017-03-16 20:09:13 +0400 | [diff] [blame] | 15 | {%- for service_name, service in salt['devops_utils.iter_items'](services, config.service) %} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 16 | {%- if not loop.first %},{% endif -%} |
| 17 | {%- if service|length() > 0 and service.enabled %} |
| 18 | "{{ service_name }}": { |
Ilya Kharin | e1cf854 | 2017-03-17 18:37:09 +0400 | [diff] [blame] | 19 | "endpoint": "{{ service_url(service.endpoint) }}" |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 20 | {%- if service.credentials is defined and service.credentials|length() > 0 -%}, |
| 21 | {{ credentials(service.credentials)|indent(width=8) }} |
| 22 | {%- endif %} |
| 23 | } |
| 24 | {%- endif %} |
| 25 | {%- endfor %} |
| 26 | } |
| 27 | } |