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 %} |
Ramon Melero | 8abe5a4 | 2017-10-05 17:38:53 -0500 | [diff] [blame] | 9 | {%- if value != None %} |
| 10 | "{{ key }}": "{{ value }}"{% else %} |
| 11 | "{{ key }}": ""{%- endif %} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 12 | {%- endfor %} |
| 13 | } |
| 14 | {%- endmacro %} |
| 15 | { |
| 16 | "services": { |
Ilya Kharin | 918686b | 2017-03-16 20:09:13 +0400 | [diff] [blame] | 17 | {%- 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] | 18 | {%- if not loop.first %},{% endif -%} |
Ilya Kharin | 3ce0cd1 | 2017-03-17 18:49:45 +0400 | [diff] [blame] | 19 | {%- if service.enabled|default(True) %} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 20 | "{{ service_name }}": { |
Ilya Kharin | e1cf854 | 2017-03-17 18:37:09 +0400 | [diff] [blame] | 21 | "endpoint": "{{ service_url(service.endpoint) }}" |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 22 | {%- if service.credentials is defined and service.credentials|length() > 0 -%}, |
| 23 | {{ credentials(service.credentials)|indent(width=8) }} |
| 24 | {%- endif %} |
| 25 | } |
| 26 | {%- endif %} |
| 27 | {%- endfor %} |
| 28 | } |
| 29 | } |