Class: Kamal::Commander

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

Defined Under Namespace

Classes: Specifics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommander

Returns a new instance of Commander.



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

def initialize
  self.verbosity = :info
  self.holding_lock = false
  self.connected = false
  @specifics = nil
end

Instance Attribute Details

#connectedObject

Returns the value of attribute connected.



5
6
7
# File 'lib/kamal/commander.rb', line 5

def connected
  @connected
end

#holding_lockObject

Returns the value of attribute holding_lock.



5
6
7
# File 'lib/kamal/commander.rb', line 5

def holding_lock
  @holding_lock
end

#specific_hostsObject

Returns the value of attribute specific_hosts.



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

def specific_hosts
  @specific_hosts
end

#specific_rolesObject

Returns the value of attribute specific_roles.



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

def specific_roles
  @specific_roles
end

#verbosityObject

Returns the value of attribute verbosity.



5
6
7
# File 'lib/kamal/commander.rb', line 5

def verbosity
  @verbosity
end

Instance Method Details

#accessories_on(host) ⇒ Object



70
71
72
# File 'lib/kamal/commander.rb', line 70

def accessories_on(host)
  config.accessories.select { |accessory| accessory.hosts.include?(host.to_s) }.map(&:name)
end

#accessory(name) ⇒ Object



79
80
81
# File 'lib/kamal/commander.rb', line 79

def accessory(name)
  Kamal::Commands::Accessory.new(config, name: name)
end

#accessory_namesObject



66
67
68
# File 'lib/kamal/commander.rb', line 66

def accessory_names
  config.accessories&.collect(&:name) || []
end

#app(role: nil, host: nil) ⇒ Object



75
76
77
# File 'lib/kamal/commander.rb', line 75

def app(role: nil, host: nil)
  Kamal::Commands::App.new(config, role: role, host: host)
end

#auditor(**details) ⇒ Object



83
84
85
# File 'lib/kamal/commander.rb', line 83

def auditor(**details)
  Kamal::Commands::Auditor.new(config, **details)
end

#boot_strategyObject



136
137
138
139
140
141
142
# File 'lib/kamal/commander.rb', line 136

def boot_strategy
  if config.boot.limit.present?
    { in: :groups, limit: config.boot.limit, wait: config.boot.wait }
  else
    {}
  end
end

#builderObject



87
88
89
# File 'lib/kamal/commander.rb', line 87

def builder
  @builder ||= Kamal::Commands::Builder.new(config)
end

#configObject



15
16
17
18
19
20
# File 'lib/kamal/commander.rb', line 15

def config
  @config ||= Kamal::Configuration.create_from(**@config_kwargs).tap do |config|
    @config_kwargs = nil
    configure_sshkit_with(config)
  end
end

#configure(**kwargs) ⇒ Object



22
23
24
# File 'lib/kamal/commander.rb', line 22

def configure(**kwargs)
  @config, @config_kwargs = nil, kwargs
end

#connected?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/kamal/commander.rb', line 148

def connected?
  self.connected
end

#dockerObject



91
92
93
# File 'lib/kamal/commander.rb', line 91

def docker
  @docker ||= Kamal::Commands::Docker.new(config)
end

#healthcheckObject



95
96
97
# File 'lib/kamal/commander.rb', line 95

def healthcheck
  @healthcheck ||= Kamal::Commands::Healthcheck.new(config)
end

#holding_lock?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/kamal/commander.rb', line 144

def holding_lock?
  self.holding_lock
end

#hookObject



99
100
101
# File 'lib/kamal/commander.rb', line 99

def hook
  @hook ||= Kamal::Commands::Hook.new(config)
end

#lockObject



103
104
105
# File 'lib/kamal/commander.rb', line 103

def lock
  @lock ||= Kamal::Commands::Lock.new(config)
end

#pruneObject



107
108
109
# File 'lib/kamal/commander.rb', line 107

def prune
  @prune ||= Kamal::Commands::Prune.new(config)
end

#registryObject



111
112
113
# File 'lib/kamal/commander.rb', line 111

def registry
  @registry ||= Kamal::Commands::Registry.new(config)
end

#serverObject



115
116
117
# File 'lib/kamal/commander.rb', line 115

def server
  @server ||= Kamal::Commands::Server.new(config)
end

#specific_primary!Object



28
29
30
31
# File 'lib/kamal/commander.rb', line 28

def specific_primary!
  @specifics = nil
  self.specific_hosts = [ config.primary_host ]
end

#traefikObject



119
120
121
# File 'lib/kamal/commander.rb', line 119

def traefik
  @traefik ||= Kamal::Commands::Traefik.new(config)
end

#with_specific_hosts(hosts) ⇒ Object



59
60
61
62
63
64
# File 'lib/kamal/commander.rb', line 59

def with_specific_hosts(hosts)
  original_hosts, self.specific_hosts = specific_hosts, hosts
  yield
ensure
  self.specific_hosts = original_hosts
end

#with_verbosity(level) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/kamal/commander.rb', line 124

def with_verbosity(level)
  old_level = self.verbosity

  self.verbosity = level
  SSHKit.config.output_verbosity = level

  yield
ensure
  self.verbosity = old_level
  SSHKit.config.output_verbosity = old_level
end