apiVersion: v1
kind: ConfigMap
metadata:
  name: platform-secret-configmap
  annotations:
    reloader.stakater.com/match: "true" 
data:
    templates-base.hcl: |
        {{ with secret "secret/webstore-sso" }}
        export AzureAd__ApplicationId={{ .Data.ApplicationID }}
        {{ end }}
        {{ with secret "secret/webstore-sso" }}
        export AzureAd__TenantId={{ .Data.TenantID }}
        {{ end }}
        {{ with secret "secret/redis" }}
        export ConnectionStrings__RedisConnectionString=redis-master.redis:6379,password={{ .Data.REDIS_PASS }},ssl=False,abortConnect=False
        {{ end }} 
        {{ with secret "secret/mssql" }}
        export ConnectionStrings__VirtoCommerce="Server=tcp:vc-dev-dbserver.database.windows.net,1433;Database=$(VC_PLATFORM_SERVICE)_$(VC_NAMESPACE);User ID=virto@vc-dev-dbserver;Password={{ .Data.db_password }};Trusted_Connection=False;Encrypt=True;"
        {{ end }}
    templates-custom.hcl: |
         
    config-init.hcl: |
        "auto_auth" = {
            "method" = {
                "config" = {
                    "role" = "myapp"
                }
            "type" = "kubernetes"
            }

            "sink" = {
                "config" = {
                    "path" = "/home/vault/.token"
                }

                "type" = "file"
            }
        }

        "exit_after_auth" = true
        "pid_file" = "/home/vault/.pid"

        "template" = {
            "source" = "/vault/configs/templates-base.hcl"
            "destination" = "/vault/secrets/config_base"
        }

         "template" = {
            "source" = "/vault/configs/templates-custom.hcl"
            "destination" = "/vault/secrets/config_custom"
        }

        "vault" = {
            "address" = "http://vault.hashicorp-vault.svc.cluster.local:8200"
        }

