apiVersion: v1
data:
  config.toml.erb: |
    # The directory where Gitaly's executables are stored
    bin_dir = "/usr/local/bin"

    # listen on a TCP socket. This is insecure (no authentication)
    listen_addr = "0.0.0.0:8075"

    # Directory where internal sockets reside
    # note: no value will result in a `/tmp/gitlab-internal-*` path
    # internal_socket_dir = "/home/git"

    # If metrics collection is enabled, inform gitaly about that
    prometheus_listen_addr = "0.0.0.0:9236"

    <% @storages = [  "default",  ] %>

    <% @index=`echo ${HOSTNAME##*-}`.to_i %>
    <% if @storages.length > @index %>
    [[storage]]
    name = "<%= @storages[@index] %>"
    path = "/home/git/repositories"
    <% else %>
    <% raise Exception, "Storage for node #{@index} is not present in the storageNames array. Did you use kubectl to scale up? You need to solely use helm for this purpose." %>
    <% end %>

    [logging]
    format = "json"
    dir = "/var/log/gitaly"

    [auth]
    token = <%= File.read('/etc/gitlab-secrets/gitaly/gitaly_token').strip.to_json %>

    [git]

    [gitaly-ruby]
    # The directory where gitaly-ruby is installed
    dir = "/srv/gitaly-ruby"
    rugged_git_config_search_path = "/usr/local/etc"

    [gitlab-shell]
    # The directory where gitlab-shell is installed
    dir = "/srv/gitlab-shell"

    [gitlab]
    # location of shared secret for GitLab Shell / API interaction
    secret_file = "/etc/gitlab-secrets/shell/.gitlab_shell_secret"
    # URL of API
    url = "http://RELEASE-NAME-webservice-default.default.svc:8181/"

    [gitlab.http-settings]
    # read_timeout = 300
    # user = someone
    # password = somepass
    # ca_file = /etc/ssl/cert.pem
    # ca_path = /etc/pki/tls/certs
    self_signed_cert = false

    [hooks]
    # directory containing custom hooks
    custom_hooks_dir = "/home/git/custom_hooks"
  configure: |
    set -e
    mkdir -p /init-secrets/gitaly /init-secrets/shell
    cp -v -r -L /init-config/.gitlab_shell_secret  /init-secrets/shell/.gitlab_shell_secret
    cp -v -r -L /init-config/gitaly_token  /init-secrets/gitaly/gitaly_token
kind: ConfigMap
metadata:
  labels:
    app: gitaly
    chart: gitaly-5.7.0
    heritage: Helm
    release: RELEASE-NAME
  name: RELEASE-NAME-gitaly
  namespace: default
