From f1b031589e6c58296cdf73b975c71b10c407bdb3 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 10 Apr 2022 09:26:56 +0200
Subject: T4353: enable linting of Jinja2 templates

---
 .../accel-ppp/config_chap_secrets_radius.j2        | 24 ++++++++++----------
 data/templates/accel-ppp/config_ip_pool.j2         | 16 ++++++-------
 data/templates/accel-ppp/config_ipv6_pool.j2       | 18 +++++++--------
 .../accel-ppp/config_modules_auth_protocols.j2     |  8 +++----
 data/templates/accel-ppp/config_name_server.j2     |  8 +++----
 data/templates/accel-ppp/config_shaper_radius.j2   |  6 ++---
 data/templates/frr/rip_ripng.frr.j2                | 26 +++++++++++-----------
 data/templates/frr/rpki.frr.tmpl                   | 18 ---------------
 data/templates/frr/rpki.frr.tmpl.j2                | 18 +++++++++++++++
 data/templates/frr/static_routes_macro.j2          | 22 +++++++++---------
 10 files changed, 82 insertions(+), 82 deletions(-)
 delete mode 100644 data/templates/frr/rpki.frr.tmpl
 create mode 100644 data/templates/frr/rpki.frr.tmpl.j2

(limited to 'data')

diff --git a/data/templates/accel-ppp/config_chap_secrets_radius.j2 b/data/templates/accel-ppp/config_chap_secrets_radius.j2
index 1b28dbe46..bb820497b 100644
--- a/data/templates/accel-ppp/config_chap_secrets_radius.j2
+++ b/data/templates/accel-ppp/config_chap_secrets_radius.j2
@@ -4,27 +4,27 @@ chap-secrets={{ chap_secrets_file }}
 {% elif authentication.mode is vyos_defined('radius') %}
 [radius]
 verbose=1
-{%   for server, options in authentication.radius.server.items() if not options.disable is vyos_defined %}
+{%     for server, options in authentication.radius.server.items() if not options.disable is vyos_defined %}
 server={{ server }},{{ options.key }},auth-port={{ options.port }},acct-port={{ options.acct_port }},req-limit=0,fail-time={{ options.fail_time }}
-{%   endfor %}
-{%   if authentication.radius.acct_interim_jitter is vyos_defined %}
+{%     endfor %}
+{%     if authentication.radius.acct_interim_jitter is vyos_defined %}
 acct-interim-jitter={{ authentication.radius.acct_interim_jitter }}
-{%   endif %}
+{%     endif %}
 acct-timeout={{ authentication.radius.acct_timeout }}
 timeout={{ authentication.radius.timeout }}
 max-try={{ authentication.radius.max_try }}
-{%   if authentication.radius.nas_identifier is vyos_defined %}
+{%     if authentication.radius.nas_identifier is vyos_defined %}
 nas-identifier={{ authentication.radius.nas_identifier }}
-{%   endif %}
-{%   if authentication.radius.nas_ip_address is vyos_defined %}
+{%     endif %}
+{%     if authentication.radius.nas_ip_address is vyos_defined %}
 nas-ip-address={{ authentication.radius.nas_ip_address }}
-{%   endif %}
-{%   if authentication.radius.source_address is vyos_defined %}
+{%     endif %}
+{%     if authentication.radius.source_address is vyos_defined %}
 bind={{ authentication.radius.source_address }}
-{%   endif %}
-{%   if authentication.radius.dynamic_author.server is vyos_defined %}
+{%     endif %}
+{%     if authentication.radius.dynamic_author.server is vyos_defined %}
 dae-server={{ authentication.radius.dynamic_author.server }}:{{ authentication.radius.dynamic_author.port }},{{ authentication.radius.dynamic_author.key }}
-{%   endif %}
+{%     endif %}
 {% endif %}
 {# Both chap-secrets and radius block required the gw-ip-address #}
 {% if gateway_address is vyos_defined %}
diff --git a/data/templates/accel-ppp/config_ip_pool.j2 b/data/templates/accel-ppp/config_ip_pool.j2
index ec1c77112..0bef4ad69 100644
--- a/data/templates/accel-ppp/config_ip_pool.j2
+++ b/data/templates/accel-ppp/config_ip_pool.j2
@@ -1,14 +1,14 @@
 {% if client_ip_pool is vyos_defined %}
 [ip-pool]
-{%   if gateway_address is vyos_defined %}
+{%     if gateway_address is vyos_defined %}
 gw-ip-address={{ gateway_address }}
-{%   endif %}
-{%   if client_ip_pool.start is vyos_defined and client_ip_pool.stop is vyos_defined %}
+{%     endif %}
+{%     if client_ip_pool.start is vyos_defined and client_ip_pool.stop is vyos_defined %}
 {{ client_ip_pool.start }}-{{ client_ip_pool.stop.split('.')[3] }}
-{%   endif %}
-{%   if client_ip_pool.subnet is vyos_defined %}
-{%     for subnet in client_ip_pool.subnet %}
+{%     endif %}
+{%     if client_ip_pool.subnet is vyos_defined %}
+{%         for subnet in client_ip_pool.subnet %}
 {{ subnet }}
-{%     endfor %}
-{%   endif %}
+{%         endfor %}
+{%     endif %}
 {% endif %}
diff --git a/data/templates/accel-ppp/config_ipv6_pool.j2 b/data/templates/accel-ppp/config_ipv6_pool.j2
index 99a930fb2..953469577 100644
--- a/data/templates/accel-ppp/config_ipv6_pool.j2
+++ b/data/templates/accel-ppp/config_ipv6_pool.j2
@@ -2,19 +2,19 @@
 [ipv6-nd]
 AdvAutonomousFlag=1
 
-{%   if client_ipv6_pool.prefix is vyos_defined %}
+{%     if client_ipv6_pool.prefix is vyos_defined %}
 [ipv6-pool]
-{%     for prefix, options in client_ipv6_pool.prefix.items() %}
+{%         for prefix, options in client_ipv6_pool.prefix.items() %}
 {{ prefix }},{{ options.mask }}
-{%     endfor %}
-{%     if client_ipv6_pool.delegate is vyos_defined %}
-{%       for prefix, options in client_ipv6_pool.delegate.items() %}
+{%         endfor %}
+{%         if client_ipv6_pool.delegate is vyos_defined %}
+{%             for prefix, options in client_ipv6_pool.delegate.items() %}
 delegate={{ prefix }},{{ options.delegation_prefix }}
-{%       endfor %}
+{%             endfor %}
+{%         endif %}
 {%     endif %}
-{%   endif %}
-{%   if client_ipv6_pool.delegate is vyos_defined %}
+{%     if client_ipv6_pool.delegate is vyos_defined %}
 [ipv6-dhcp]
 verbose=1
-{%   endif %}
+{%     endif %}
 {% endif %}
diff --git a/data/templates/accel-ppp/config_modules_auth_protocols.j2 b/data/templates/accel-ppp/config_modules_auth_protocols.j2
index 454d37792..285468406 100644
--- a/data/templates/accel-ppp/config_modules_auth_protocols.j2
+++ b/data/templates/accel-ppp/config_modules_auth_protocols.j2
@@ -1,10 +1,10 @@
 {% for protocol in authentication.protocols %}
 {#   this should be fixed in the CLI by a migrator #}
-{%   if protocol == 'chap' %}
+{%     if protocol == 'chap' %}
 auth_chap_md5
-{%   elif protocol == 'mschap' %}
+{%     elif protocol == 'mschap' %}
 auth_mschap_v1
-{%   else %}
+{%     else %}
 auth_{{ protocol.replace('-', '_') }}
-{%   endif %}
+{%     endif %}
 {% endfor %}
diff --git a/data/templates/accel-ppp/config_name_server.j2 b/data/templates/accel-ppp/config_name_server.j2
index 4b4b5fb68..9c745fe62 100644
--- a/data/templates/accel-ppp/config_name_server.j2
+++ b/data/templates/accel-ppp/config_name_server.j2
@@ -1,13 +1,13 @@
 {% if name_server_ipv4 is vyos_defined %}
 [dns]
-{%   for ns in name_server_ipv4 %}
+{%     for ns in name_server_ipv4 %}
 dns{{ loop.index }}={{ ns }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
 
 {% if name_server_ipv6 is vyos_defined %}
 [ipv6-dns]
-{%   for ns in name_server_ipv6 %}
+{%     for ns in name_server_ipv6 %}
 {{ ns }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
diff --git a/data/templates/accel-ppp/config_shaper_radius.j2 b/data/templates/accel-ppp/config_shaper_radius.j2
index cf8b4871b..c256647e4 100644
--- a/data/templates/accel-ppp/config_shaper_radius.j2
+++ b/data/templates/accel-ppp/config_shaper_radius.j2
@@ -1,10 +1,10 @@
 {% if authentication.mode is vyos_defined('radius') %}
-{%   if authentication.radius.rate_limit.enable is vyos_defined %}
+{%     if authentication.radius.rate_limit.enable is vyos_defined %}
 [shaper]
 verbose=1
 attr={{ authentication.radius.rate_limit.attribute }}
-{%     if authentication.radius.rate_limit.vendor is vyos_defined %}
+{%         if authentication.radius.rate_limit.vendor is vyos_defined %}
 vendor={{ authentication.radius.rate_limit.vendor }}
+{%         endif %}
 {%     endif %}
-{%   endif %}
 {% endif %}
diff --git a/data/templates/frr/rip_ripng.frr.j2 b/data/templates/frr/rip_ripng.frr.j2
index 3732371b2..dd547bb3e 100644
--- a/data/templates/frr/rip_ripng.frr.j2
+++ b/data/templates/frr/rip_ripng.frr.j2
@@ -5,32 +5,32 @@
  default-metric {{ default_metric }}
 {% endif %}
 {% if passive_interface is vyos_defined %}
-{%   for interface in passive_interface %}
+{%     for interface in passive_interface %}
  passive-interface {{ interface }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
 {% if network is vyos_defined %}
-{%   for prefix in network %}
+{%     for prefix in network %}
  network {{ prefix }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
 {% if interface is vyos_defined %}
-{%   for ifname in interface %}
+{%     for ifname in interface %}
  network {{ ifname }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
 {% if route is vyos_defined %}
-{%   for prefix in route %}
+{%     for prefix in route %}
  route {{ prefix }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
 {# timers have default values #}
  timers basic {{ timers['update'] }} {{ timers.timeout }} {{ timers.garbage_collection }}
 {% if redistribute is vyos_defined %}
-{%   for protocol, protocol_config in redistribute.items() %}
-{%     if protocol is vyos_defined('ospfv3') %}
-{%       set protocol = 'ospf6' %}
-{%     endif %}
+{%     for protocol, protocol_config in redistribute.items() %}
+{%         if protocol is vyos_defined('ospfv3') %}
+{%             set protocol = 'ospf6' %}
+{%         endif %}
  redistribute {{ protocol }} {{ 'metric ' ~ protocol_config.metric if protocol_config.metric is vyos_defined }} {{ 'route-map ' ~ protocol_config.route_map if protocol_config.route_map is vyos_defined }}
-{%   endfor %}
+{%     endfor %}
 {% endif %}
diff --git a/data/templates/frr/rpki.frr.tmpl b/data/templates/frr/rpki.frr.tmpl
deleted file mode 100644
index 3f4fd3236..000000000
--- a/data/templates/frr/rpki.frr.tmpl
+++ /dev/null
@@ -1,18 +0,0 @@
-!
-{# as FRR does not support deleting the entire rpki section we leave it in place even when it's empty #}
-rpki
-{% if cache is vyos_defined %}
-{%   for peer, peer_config in cache.items() %}
-{#     port is mandatory and preference uses a default value #}
-{%     if peer_config.ssh.username is vyos_defined %}
- rpki cache {{ peer | replace('_', '-') }} {{ peer_config.port }} {{ peer_config.ssh.username }} {{ peer_config.ssh.private_key_file }} {{ peer_config.ssh.public_key_file }} {{ peer_config.ssh.known_hosts_file }} preference {{ peer_config.preference }}
-{%     else %}
- rpki cache {{ peer | replace('_', '-') }} {{ peer_config.port }} preference {{ peer_config.preference }}
-{%     endif %}
-{%   endfor %}
-{% endif %}
-{% if polling_period is vyos_defined %}
- rpki polling_period {{ polling_period }}
-{% endif %}
-exit
-!
diff --git a/data/templates/frr/rpki.frr.tmpl.j2 b/data/templates/frr/rpki.frr.tmpl.j2
new file mode 100644
index 000000000..9a549d6de
--- /dev/null
+++ b/data/templates/frr/rpki.frr.tmpl.j2
@@ -0,0 +1,18 @@
+!
+{# as FRR does not support deleting the entire rpki section we leave it in place even when it's empty #}
+rpki
+{% if cache is vyos_defined %}
+{%     for peer, peer_config in cache.items() %}
+{#         port is mandatory and preference uses a default value #}
+{%         if peer_config.ssh.username is vyos_defined %}
+ rpki cache {{ peer | replace('_', '-') }} {{ peer_config.port }} {{ peer_config.ssh.username }} {{ peer_config.ssh.private_key_file }} {{ peer_config.ssh.public_key_file }} {{ peer_config.ssh.known_hosts_file }} preference {{ peer_config.preference }}
+{%         else %}
+ rpki cache {{ peer | replace('_', '-') }} {{ peer_config.port }} preference {{ peer_config.preference }}
+{%         endif %}
+{%     endfor %}
+{% endif %}
+{% if polling_period is vyos_defined %}
+ rpki polling_period {{ polling_period }}
+{% endif %}
+exit
+!
diff --git a/data/templates/frr/static_routes_macro.j2 b/data/templates/frr/static_routes_macro.j2
index 0b242a868..1c64ac58b 100644
--- a/data/templates/frr/static_routes_macro.j2
+++ b/data/templates/frr/static_routes_macro.j2
@@ -1,24 +1,24 @@
 {% macro static_routes(ip_ipv6, prefix, prefix_config, table=None) %}
-{%   if prefix_config.blackhole is vyos_defined %}
+{% if prefix_config.blackhole is vyos_defined %}
 {{ ip_ipv6 }} route {{ prefix }} blackhole {{ prefix_config.blackhole.distance if prefix_config.blackhole.distance is vyos_defined }} {{ 'tag ' ~ prefix_config.blackhole.tag if prefix_config.blackhole.tag is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined and table is not none }}
-{%   endif %}
-{%   if prefix_config.reject is vyos_defined %}
+{% endif %}
+{% if prefix_config.reject is vyos_defined %}
 {{ ip_ipv6 }} route {{ prefix }} reject {{ prefix_config.reject.distance if prefix_config.reject.distance is vyos_defined }} {{ 'tag ' ~ prefix_config.reject.tag if prefix_config.reject.tag is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined }}
-{%   endif %}
-{%   if prefix_config.dhcp_interface is vyos_defined %}
+{% endif %}
+{% if prefix_config.dhcp_interface is vyos_defined %}
 {%     set next_hop = prefix_config.dhcp_interface | get_dhcp_router %}
 {%     if next_hop is vyos_defined %}
 {{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} {{ prefix_config.dhcp_interface }} {{ 'table ' ~ table if table is vyos_defined }}
 {%     endif %}
-{%   endif %}
-{%   if prefix_config.interface is vyos_defined %}
+{% endif %}
+{% if prefix_config.interface is vyos_defined %}
 {%     for interface, interface_config in prefix_config.interface.items() if interface_config.disable is not defined %}
 {{ ip_ipv6 }} route {{ prefix }} {{ interface }} {{ interface_config.distance if interface_config.distance is vyos_defined }} {{ 'nexthop-vrf ' ~ interface_config.vrf if interface_config.vrf is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined }}
 {%     endfor %}
-{%   endif %}
-{%   if prefix_config.next_hop is vyos_defined and prefix_config.next_hop is not none %}
+{% endif %}
+{% if prefix_config.next_hop is vyos_defined and prefix_config.next_hop is not none %}
 {%     for next_hop, next_hop_config in prefix_config.next_hop.items() if next_hop_config.disable is not defined %}
-{{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} {{ next_hop_config.interface if next_hop_config.interface is vyos_defined }} {{ next_hop_config.distance if next_hop_config.distance is vyos_defined }} {{ 'nexthop-vrf ' ~ next_hop_config.vrf if next_hop_config.vrf is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined}}
+{{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} {{ next_hop_config.interface if next_hop_config.interface is vyos_defined }} {{ next_hop_config.distance if next_hop_config.distance is vyos_defined }} {{ 'nexthop-vrf ' ~ next_hop_config.vrf if next_hop_config.vrf is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined }}
 {%     endfor %}
-{%   endif %}
+{% endif %}
 {% endmacro %}
-- 
cgit v1.2.3