blob: 85881f0cf82895af354a077f2b5d1f6a35368c9d [file] [log] [blame]
Sapan Bhatiabfb233a2018-02-09 14:53:09 -08001{# Using regular variables has scoping issues. #}
2{# See: https://stackoverflow.com/questions/7537439/how-to-increment-a-variable-on-a-for-loop-in-jinja-template/7537466 #}
3{% set counter = {
4 'num_service_models': 0,
5 'num_service_instance_models': 0,
6 'num_orphaned_models': 0,
7 } %}
8{% macro increment(key) %}
9 {% if counter.update({key: counter[key] + 1}) %} {% endif %}
10{% endmacro %}
11{% for m in proto.messages %}
12{% set matched = False %}
13{% set base_names = m.bases | map(attribute='name') | list %}
14{% if 'Service' in base_names %}
15{{ increment('num_service_models') }}
16{% set matched = True %}
17{% endif %}
18{% if not matched and 'ServiceInstance' in base_names or 'Tenant' in base_names or 'TenantWithContainer' in base_names %}
19{{ increment('num_service_instance_models') }}
20{% set matched = True %}
21{% endif %}
22{% if not matched and 'XOSBase' not in base_names %}
23501 Model does not have a parent - {{ m.name }}
24{% endif %}
25{% endfor %}
26{% if counter.num_service_models !=1 %}
27502 {{ counter.num_service_models }} Service models instead of 1
28{% elif counter.num_service_instance_models !=1 %}
29503 {{ counter.num_service_instance_models }} ServiceInstance models instead of 1
30{% else %}
31200 OK
32{% endif %}