Class: RailsOrbit::Kamal::ConfigReader

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_orbit/kamal/config_reader.rb

Constant Summary collapse

DEPLOY_YML =
"config/deploy.yml"

Class Method Summary collapse

Class Method Details

.loadObject



7
8
9
10
11
12
13
# File 'lib/rails_orbit/kamal/config_reader.rb', line 7

def load
  @config ||= begin
    path = Rails.root.join(DEPLOY_YML)
    raise "Kamal config not found at #{path}" unless path.exist?
    YAML.safe_load_file(path, permitted_classes: [Symbol])
  end
end

.reload!Object



15
16
17
18
# File 'lib/rails_orbit/kamal/config_reader.rb', line 15

def reload!
  @config = nil
  load
end

.serversObject



20
21
22
23
24
# File 'lib/rails_orbit/kamal/config_reader.rb', line 20

def servers
  config = load
  Array(config.dig("servers", "web")) +
    Array(config.dig("servers", "workers"))
end

.ssh_userObject



26
27
28
# File 'lib/rails_orbit/kamal/config_reader.rb', line 26

def ssh_user
  load.dig("ssh", "user") || "root"
end