lib/gitlab/setup_helper.rb
# We cannot create config.toml files for all possible Gitaly configuations.
# For instance, if Gitaly is running on another machine then it makes no
# sense to write a config.toml file on the current machine. This method will
# only generate a configuration for the most common and simplest case: when
# we have exactly one Gitaly process and we are sure it is running locally
# because it uses a Unix socket.
# For development and testing purposes, an extra storage is added to gitaly,
# which is not known to Rails, but must be explicitly stubbed.
We cannot create config.toml files for all possible Gitaly configuations.
For instance, if Gitaly is running on another machine then it makes no
sense to write a config.toml file on the current machine. This method will
only generate a configuration for the most common and simplest case: when
we have exactly one Gitaly process and we are sure it is running locally
because it uses a Unix socket.
For development and testing purposes, an extra storage is added to gitaly,
which is not known to Rails, but must be explicitly stubbed.
We cannot create config . toml files for all possible Gitaly configuations . For instance if Gitaly is running on another machine then it makes no sense to write a config . toml file on the current machine . This method will only generate a configuration for the most common and simplest case : when we have exactly one Gitaly process and we are sure it is running locally because it uses a Unix socket . For development and testing purposes an extra storage is added to gitaly which is not known to Rails but must be explicitly stubbed .
def configuration_toml(gitaly_dir, storage_paths, gitaly_ruby: true)
          storages = []
          address = nil
          Gitlab.config.repositories.storages.each do |key, val|
            if address
              if address != val['gitaly_address']
                raise ArgumentError, "Your gitlab.yml contains more than one gitaly_address."
              end
            elsif URI(val['gitaly_address']).scheme != 'unix'
              raise ArgumentError, "Automatic config.toml generation only supports 'unix:' addresses."
            else
              address = val['gitaly_address']
            end
            storages << { name: key, path: storage_paths[key] }
          end
          config = { socket_path: address.sub(/\Aunix:/, '') }
          if Rails.env.test?
            storage_path = Rails.root.join('tmp', 'tests', 'second_storage').to_s
            storages << { name: 'test_second_storage', path: storage_path }
            config[:auth] = { token: 'secret' }
            config[:git] = { catfile_cache_size: 5 }
          end
          config[:storage] = storages
          internal_socket_dir = File.join(gitaly_dir, 'internal_sockets')
          FileUtils.mkdir(internal_socket_dir) unless File.exist?(internal_socket_dir)
          config[:internal_socket_dir] = internal_socket_dir
          config[:'gitaly-ruby'] = { dir: File.join(gitaly_dir, 'ruby') } if gitaly_ruby
          config[:'gitlab-shell'] = { dir: Gitlab.config.gitlab_shell.path }
          config[:bin_dir] = Gitlab.config.gitaly.client_path
          config[:gitlab] = { url: Gitlab.config.gitlab.url }
          TomlRB.dump(config)
        end
def configuration_toml ( gitaly_dir , storage_paths , gitaly_ruby : true ) storages = [ ] address = nil Gitlab . config . repositories . storages . each do | key , val | if address if address != val [ 'gitaly_address' ] raise ArgumentError , "Your gitlab.yml contains more than one gitaly_address." end elsif URI ( val [ 'gitaly_address' ] ) . scheme != 'unix' raise ArgumentError , "Automatic config.toml generation only supports 'unix:' addresses." else address = val [ 'gitaly_address' ] end storages << { name : key , path : storage_paths [ key ] } end config = { socket_path : address . sub ( / \A unix: / , '' ) } if Rails . env . test? storage_path = Rails . root . join ( 'tmp' , 'tests' , 'second_storage' ) . to_s storages << { name : 'test_second_storage' , path : storage_path } config [ :auth ] = { token : 'secret' } config [ :git ] = { catfile_cache_size : 5 } end config [ :storage ] = storages internal_socket_dir = File . join ( gitaly_dir , 'internal_sockets' ) FileUtils . mkdir ( internal_socket_dir ) unless File . exist? ( internal_socket_dir ) config [ :internal_socket_dir ] = internal_socket_dir config [ :' gitaly-ruby ' ] = { dir : File . join ( gitaly_dir , 'ruby' ) } if gitaly_ruby config [ :' gitlab-shell ' ] = { dir : Gitlab . config . gitlab_shell . path } config [ :bin_dir ] = Gitlab . config . gitaly . client_path config [ :gitlab ] = { url : Gitlab . config . gitlab . url } TomlRB . dump ( config ) end
We cannot create config.toml files for all possible Gitaly configuations.
We cannot create config . toml files for all possible Gitaly configuations .
# Compared to production, tests run in constrained environments. This # number is meant to grow with the number of concurrent rails requests / # sidekiq jobs, and concurrency will be low anyway in test.
gitaly_dir
<not_specific>
storage_paths
<not_specific>
gitaly_ruby
<not_specific>