apiVersion: v1
kind: ConfigMap
metadata:
  name: gitlab-migrations
  namespace: public-service
  labels:
    app: gitlab
    component: migrations
data:
  installation_type: |
    gitlab-helm-chart
    
  database.yml.erb: |
    production:
      adapter: postgresql
      encoding: unicode
      database: gitlabhq_production
      username: gitlab
      password: "<%= File.read("/etc/gitlab/postgres/psql-password").strip.dump[1..-2] %>"
      host: "gitlab-postgresql"
      port: 5432
      pool: 1
      connect_timeout: 
      prepared_statements: false
      
  resque.yml.erb: |
    production:
      url: redis://:<%= ERB::Util::url_encode(File.read("/etc/gitlab/redis/redis-password").strip) %>@gitlab-redis-master:6379
      id:

  cable.yml.erb: |
    production:
      url: redis://:<%= ERB::Util::url_encode(File.read("/etc/gitlab/redis/redis-password").strip) %>@gitlab-redis-master:6379
      id:
      adapter: redis
      
  gitlab.yml.erb: |
    production: &base
      gitlab:
        host: gitlab.lzxlinux.com
      gitaly:
        client_path: /home/git/gitaly/bin
        token: "<%= File.read('/etc/gitlab/gitaly/gitaly_token').strip.dump[1..-2] %>"
      repositories:
        storages: # You must have at least a `default` storage path.
          default:
            path: /var/opt/gitlab/repo
            gitaly_address: tcp://gitlab-gitaly-0.gitlab-gitaly.public-service:8075
          
  configure: |
    set -e
    config_dir="/init-config"
    secret_dir="/init-secrets"
    
    for secret in rails-secrets migrations gitaly ; do
      mkdir -p "${secret_dir}/${secret}"
      cp -v -r -L "${config_dir}/${secret}/." "${secret_dir}/${secret}/"
    done
    for secret in redis minio objectstorage postgres ldap omniauth smtp kas ; do
      if [ -e "${config_dir}/${secret}" ]; then
        mkdir -p "${secret_dir}/${secret}"
        cp -v -r -L "${config_dir}/${secret}/." "${secret_dir}/${secret}/"
      fi
    done
