apiVersion: v1
data:
  configure: |
    set -e
    mkdir -p /init-secrets-workhorse/gitlab-workhorse
    cp -v -r -L /init-config/gitlab-workhorse/secret /init-secrets-workhorse/gitlab-workhorse/secret
    mkdir -p /init-secrets-workhorse/redis
    cp -v -r -L /init-config/redis/redis-password /init-secrets-workhorse/redis/
    if [ -d /init-config/minio ]; then
      mkdir -p /init-secrets-workhorse/minio
      cp -v -r -L /init-config/minio/* /init-secrets-workhorse/minio/
    fi
  installation_type: |
    gitlab-helm-chart
  workhorse-config.toml.tpl: |
    shutdown_timeout = "61s"
    [redis]
    URL = "redis://RELEASE-NAME-redis-master.default.svc:6379"
    Password = {% file.Read "/etc/gitlab/redis/redis-password" | strings.TrimSpace | data.ToJSON %}
    {%- $supported_providers := slice "AWS" "AzureRM" -%}
    {%- $provider := "" -%}
    {%- $aws_access_key_id := "" -%}
    {%- $aws_secret_access_key := "" -%}
    {%- $azure_storage_account_name := "" -%}
    {%- $azure_storage_access_key := "" -%}
    {%- if file.Exists "/etc/gitlab/minio/accesskey" %}
      {%- $provider = "AWS" -%}
      {%- $aws_access_key_id = file.Read "/etc/gitlab/minio/accesskey" | strings.TrimSpace -%}
      {%- $aws_secret_access_key = file.Read "/etc/gitlab/minio/secretkey" | strings.TrimSpace -%}
    {%- end %}
    {%- if file.Exists "/etc/gitlab/objectstorage/object_store" %}
      {%- $connection := file.Read "/etc/gitlab/objectstorage/object_store" | strings.TrimSpace | data.YAML -%}
      {%- $provider = $connection.provider -%}
      {%- if has $connection "aws_access_key_id" -%}
        {%- $aws_access_key_id = $connection.aws_access_key_id -%}
        {%- $aws_secret_access_key = $connection.aws_secret_access_key -%}
      {%- else if has $connection "azure_storage_account_name" -%}
        {%- $azure_storage_account_name = $connection.azure_storage_account_name -%}
        {%- $azure_storage_access_key = $connection.azure_storage_access_key -%}
      {%- end -%}
    {%- end %}
    {%- if has $supported_providers $provider %}
    [object_storage]
    provider = "{% $provider %}"
    {%-   if eq $provider "AWS" %}
    # AWS / S3 object storage configuration.
    [object_storage.s3]
    # access/secret can be blank!
    aws_access_key_id = "{% $aws_access_key_id %}"
    aws_secret_access_key = "{% $aws_secret_access_key %}"
    {%-   else if eq $provider "AzureRM" %}
    # Azure Blob storage configuration.
    [object_storage.azurerm]
    azure_storage_account_name = "{% $azure_storage_account_name %}"
    azure_storage_access_key = "{% $azure_storage_access_key %}"
    {%-   end %}
    {%- end %}
    [image_resizer]
    max_scaler_procs = 2
    max_filesize = 250000
kind: ConfigMap
metadata:
  labels:
    app: webservice
    chart: webservice-5.7.0
    heritage: Helm
    release: RELEASE-NAME
  name: RELEASE-NAME-workhorse-default
  namespace: default
