From f67a24499b0402ae5a591d0ead31c212b29634f4 Mon Sep 17 00:00:00 2001
From: Tony Fouchard <djnos14@hotmail.com>
Date: Mon, 17 Jun 2019 08:14:07 +0200
Subject: [PATCH] Allow to specify feature_control in calico cni config (#4879)

* Allow to specify feature_control in calico cni config

* list length checking

* double check

* remove 2 conditions
---
 roles/network_plugin/calico/defaults/main.yml            | 2 ++
 .../calico/templates/cni-calico.conflist.j2              | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/roles/network_plugin/calico/defaults/main.yml b/roles/network_plugin/calico/defaults/main.yml
index d010bcebe..d7108a4ad 100644
--- a/roles/network_plugin/calico/defaults/main.yml
+++ b/roles/network_plugin/calico/defaults/main.yml
@@ -72,3 +72,5 @@ calico_datastore: "etcd"
 typha_enabled: false
 # Number of typha replicas
 typha_replicas: 1
+
+calico_feature_control: {}
diff --git a/roles/network_plugin/calico/templates/cni-calico.conflist.j2 b/roles/network_plugin/calico/templates/cni-calico.conflist.j2
index f9c50e133..cfee547d7 100644
--- a/roles/network_plugin/calico/templates/cni-calico.conflist.j2
+++ b/roles/network_plugin/calico/templates/cni-calico.conflist.j2
@@ -28,6 +28,15 @@
         "subnet": "usePodCidr"
       },
 {% endif %}
+{% if (calico_feature_control is defined) and (calico_feature_control|length > 0) %}
+      "feature_control": {
+        {% for fc in calico_feature_control -%}
+        {% set fcval = calico_feature_control[fc] -%}
+          "{{ fc }}": {{ (fcval | string | lower) if (fcval == true or fcval == false) else "\"" + fcval + "\"" }}{{ "," if not loop.last else "" }}
+        {% endfor -%}
+      {{- "" }}
+      },
+{% endif %}
 {% if enable_network_policy %}
       "policy": {
         "type": "k8s"
-- 
GitLab