get_pg_options

in files/gitlab-ctl-commands-ee/pgbouncer.rb [70:135]


def get_pg_options
  options = {
    'database' => nil,
    'databases_ini' => nil,
    'databases_json' => nil,
    'host' => nil,
    'port' => nil,
    'user' => 'pgbouncer',
    'pg_database' => nil,
    'newhost' => nil,
    'host_user' => nil,
    'host_group' => nil
  }

  OptionParser.new do |opts|
    opts.on('--database NAME', 'Name of the database to connect to') do |d|
      options['database'] = d
    end

    opts.on('--host HOSTNAME', 'Host the database runs on ') do |h|
      options['host'] = h
    end

    opts.on('--port PORT', 'Port the database is listening on') do |p|
      options['port'] = p
    end

    opts.on('--user USERNAME', 'User to connect to the database as') do |u|
      options['user'] = u
    end

    opts.on('--hostuser USERNAME', 'User to write the pgpass file for') do |h|
      options['host_user'] = h
    end

    opts.on('--hostgroup GROUP', 'Group to write the pgpass file for') do |h|
      options['host_group'] = h
    end

    opts.on('--pg-database DATABASE', 'Pgbouncer database to modify') do |db|
      options['pg_database'] = db
    end

    opts.on('--pg-host HOST', 'Host that pgbouncer is running on') do |h|
      options['pg_host'] = h
    end

    opts.on('--pg-port PORT', 'Port that pgbouncer is listening on') do |p|
      options['pg_port'] = p
    end

    opts.on('--newhost HOSTNAME', 'The new master when updating pgbouncer') do |h|
      options['newhost'] = h
    end

    opts.on('--databases-json JSON', 'The location of the databases.json file') do |j|
      options['databases_json'] = j
    end

    opts.on('--databases-ini JSON', 'The location of the databases.json file') do |j|
      options['databases_ini'] = j
    end
  end.parse!(ARGV)
  options
end