From 7a8ef5f1bb0ddd96ce1961d59e5494bef7ecdd81 Mon Sep 17 00:00:00 2001
From: Pete Birley <pete@port.direct>
Date: Sun, 5 Aug 2018 08:39:17 -0500
Subject: [PATCH] Keystone: move all configuration to be values driven

This PS moves the keystone chart to be linine with other OSH
components and drives all config via the charts values.yaml

Change-Id: I14ee6ede0a87619ecbb2c56d0edf82ffbc5606be
Signed-off-by: Pete Birley <pete@port.direct>
---
 keystone/templates/configmap-etc.yaml         |  9 +--
 keystone/templates/etc/_mpm_event.conf.tpl    | 25 -------
 .../etc/_sso_callback_template.html.tpl       | 38 ----------
 .../templates/etc/_wsgi-keystone.conf.tpl     | 42 -----------
 keystone/values.yaml                          | 69 ++++++++++++++++---
 5 files changed, 63 insertions(+), 120 deletions(-)
 delete mode 100644 keystone/templates/etc/_mpm_event.conf.tpl
 delete mode 100644 keystone/templates/etc/_sso_callback_template.html.tpl
 delete mode 100644 keystone/templates/etc/_wsgi-keystone.conf.tpl

diff --git a/keystone/templates/configmap-etc.yaml b/keystone/templates/configmap-etc.yaml
index b837f5180c..edd97d9afe 100644
--- a/keystone/templates/configmap-etc.yaml
+++ b/keystone/templates/configmap-etc.yaml
@@ -57,15 +57,12 @@ data:
 {{ include "helm-toolkit.utils.to_ini" .Values.conf.paste | indent 4 }}
   policy.json: |
 {{  toJson .Values.conf.policy | indent 4 }}
-  mpm_event.conf: |
-{{- tuple .Values.conf.mpm_event "etc/_mpm_event.conf.tpl" . | include "helm-toolkit.utils.configmap_templater" }}
-  wsgi-keystone.conf: |
-{{- tuple .Values.conf.wsgi_keystone "etc/_wsgi-keystone.conf.tpl" . | include "helm-toolkit.utils.configmap_templater" }}
   ports.conf: ""
-  sso_callback_template.html: |
-{{- tuple .Values.conf.sso_callback_template "etc/_sso_callback_template.html.tpl" . | include "helm-toolkit.utils.configmap_templater" }}
 {{- range $k, $v := .Values.conf.ks_domains }}
   keystone.{{ $k }}.json: |
 {{ toJson $v | indent 4 }}
 {{- end }}
+{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.mpm_event "key" "mpm_event.conf") | indent 2 }}
+{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.wsgi_keystone "key" "wsgi-keystone.conf") | indent 2 }}
+{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.sso_callback_template "key" "sso_callback_template.html") | indent 2 }}
 {{- end }}
diff --git a/keystone/templates/etc/_mpm_event.conf.tpl b/keystone/templates/etc/_mpm_event.conf.tpl
deleted file mode 100644
index c402e58ade..0000000000
--- a/keystone/templates/etc/_mpm_event.conf.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-{{/*
-Copyright 2017 The Openstack-Helm Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/}}
-
-<IfModule mpm_event_module>
-  ServerLimit         1024
-  StartServers        32
-  MinSpareThreads     32
-  MaxSpareThreads     256
-  ThreadsPerChild     25
-  MaxRequestsPerChild 128
-  ThreadLimit         720
-</IfModule>
diff --git a/keystone/templates/etc/_sso_callback_template.html.tpl b/keystone/templates/etc/_sso_callback_template.html.tpl
deleted file mode 100644
index 27b4cd9ccc..0000000000
--- a/keystone/templates/etc/_sso_callback_template.html.tpl
+++ /dev/null
@@ -1,38 +0,0 @@
-{{/*
-Copyright 2017 The Openstack-Helm Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/}}
-
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <title>Keystone WebSSO redirect</title>
-  </head>
-  <body>
-     <form id="sso" name="sso" action="$host" method="post">
-       Please wait...
-       <br/>
-       <input type="hidden" name="token" id="token" value="$token"/>
-       <noscript>
-         <input type="submit" name="submit_no_javascript" id="submit_no_javascript"
-            value="If your JavaScript is disabled, please click to continue"/>
-       </noscript>
-     </form>
-     <script type="text/javascript">
-       window.onload = function() {
-         document.forms['sso'].submit();
-       }
-     </script>
-  </body>
-</html>
diff --git a/keystone/templates/etc/_wsgi-keystone.conf.tpl b/keystone/templates/etc/_wsgi-keystone.conf.tpl
deleted file mode 100644
index 1ba01856ae..0000000000
--- a/keystone/templates/etc/_wsgi-keystone.conf.tpl
+++ /dev/null
@@ -1,42 +0,0 @@
-{{/*
-Copyright 2017 The Openstack-Helm Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/}}
-
-{{- $portInt := tuple "identity" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
-
-Listen 0.0.0.0:{{ $portInt }}
-
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
-
-SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
-CustomLog /dev/stdout combined env=!forwarded
-CustomLog /dev/stdout proxy env=forwarded
-
-<VirtualHost *:{{ $portInt }}>
-    WSGIDaemonProcess keystone-public processes=1 threads=1 user=keystone group=keystone display-name=%{GROUP}
-    WSGIProcessGroup keystone-public
-    WSGIScriptAlias / /var/www/cgi-bin/keystone/keystone-wsgi-public
-    WSGIApplicationGroup %{GLOBAL}
-    WSGIPassAuthorization On
-    <IfVersion >= 2.4>
-      ErrorLogFormat "%{cu}t %M"
-    </IfVersion>
-    ErrorLog /dev/stdout
-
-    SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
-    CustomLog /dev/stdout combined env=!forwarded
-    CustomLog /dev/stdout proxy env=forwarded
-</VirtualHost>
diff --git a/keystone/values.yaml b/keystone/values.yaml
index 2c7c5109b1..9b46ec15a4 100644
--- a/keystone/values.yaml
+++ b/keystone/values.yaml
@@ -787,15 +787,66 @@ conf:
           sla:
             failure_rate:
               max: 0
-  mpm_event:
-    override:
-    append:
-  wsgi_keystone:
-    override:
-    append:
-  sso_callback_template:
-    override:
-    append:
+  mpm_event: |
+    <IfModule mpm_event_module>
+      ServerLimit         1024
+      StartServers        32
+      MinSpareThreads     32
+      MaxSpareThreads     256
+      ThreadsPerChild     25
+      MaxRequestsPerChild 128
+      ThreadLimit         720
+    </IfModule>
+  wsgi_keystone: |
+    {{- $portInt := tuple "identity" "internal" "api" $ | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+
+    Listen 0.0.0.0:{{ $portInt }}
+
+    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
+
+    SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
+    CustomLog /dev/stdout combined env=!forwarded
+    CustomLog /dev/stdout proxy env=forwarded
+
+    <VirtualHost *:{{ $portInt }}>
+        WSGIDaemonProcess keystone-public processes=1 threads=1 user=keystone group=keystone display-name=%{GROUP}
+        WSGIProcessGroup keystone-public
+        WSGIScriptAlias / /var/www/cgi-bin/keystone/keystone-wsgi-public
+        WSGIApplicationGroup %{GLOBAL}
+        WSGIPassAuthorization On
+        <IfVersion >= 2.4>
+          ErrorLogFormat "%{cu}t %M"
+        </IfVersion>
+        ErrorLog /dev/stdout
+
+        SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
+        CustomLog /dev/stdout combined env=!forwarded
+        CustomLog /dev/stdout proxy env=forwarded
+    </VirtualHost>
+  sso_callback_template: |
+    <!DOCTYPE html>
+    <html xmlns="http://www.w3.org/1999/xhtml">
+      <head>
+        <title>Keystone WebSSO redirect</title>
+      </head>
+      <body>
+         <form id="sso" name="sso" action="$host" method="post">
+           Please wait...
+           <br/>
+           <input type="hidden" name="token" id="token" value="$token"/>
+           <noscript>
+             <input type="submit" name="submit_no_javascript" id="submit_no_javascript"
+                value="If your JavaScript is disabled, please click to continue"/>
+           </noscript>
+         </form>
+         <script type="text/javascript">
+           window.onload = function() {
+             document.forms['sso'].submit();
+           }
+         </script>
+      </body>
+    </html>
   logging:
     loggers:
       keys: