<%#
 Copyright 2013-2017 the original author or authors from the JBooter project.

 This file is part of the JBooter project, see https://jbooter.github.io/
 for more information.

 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.
-%>
# ConfigMap template.
#
# This is centralized/externalized configuration service from OpenShift. Pls note wherever displayName says
# *** PLEASE DO NOT CHANGE THIS ***, don't touch that as those parameters will be referenced in other places.
#
apiVersion: v1
kind: Template
metadata:
  name: application-config-template
  namespace: <%= openshiftNamespace %>
  annotations:
    description: This template defines the config objects
    tags: "config, key/value"
    openshift.io/display-name: application-config-template
    openshift.io/long-description: "This template provides the config objects"
    openshift.io/provider-display-name: JBooter-OpenShift
labels:
  app: application-config-template
  createdBy: JBooter-Team
parameters:
  -
    name: APPLICATION_NAME
    value: application-config
    description: Name of the resource
    required: true
    displayName: "*** PLEASE DO NOT CHANGE THIS ***"
objects:
  -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: ${APPLICATION_NAME}
    #common configuration shared between all applications
    data:
      application.yml: |-
        configserver:
          name: <% if (serviceDiscoveryType == 'eureka') { %> JBooter Registry<% } %><% if (serviceDiscoveryType == 'consul') { %>Consul<% } %>
          status: Connected to <% if (serviceDiscoveryType == 'eureka') { %>the JBooter Registry<% } %><% if (serviceDiscoveryType == 'consul') { %>Consul<% } %> running in OpenShift
        <%_ if (serviceDiscoveryType == 'eureka') {  _%>
        eureka:
          client:
            service-url:
              # This must contain a list of all Eureka server replicas for registry HA to work correctly
              defaultZone: <% for(let i = 0; i < registryReplicas; i++){ %>http://admin:${jbooter.registry.password}@jbooter-registry-<%- i %>.jbooter-registry/eureka/<% if (i < registryReplicas-1) { _%>,<% }} %>
        <%_ } _%>
        jbooter:
          security:
            authentication:
              jwt:
                secret: <%= jwtSecretKey %>
