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



63
64
65
# File 'lib/kamal/commander.rb', line 63

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

#accessory(name) ⇒ Object



72
73
74
# File 'lib/kamal/commander.rb', line 72

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

#accessory_namesObject



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

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

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



68
69
70
# File 'lib/kamal/commander.rb', line 68

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

#auditor(**details) ⇒ Object



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

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

#boot_strategyObject



129
130
131
132
133
134
135
# File 'lib/kamal/commander.rb', line 129

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

#builderObject



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

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)


141
142
143
# File 'lib/kamal/commander.rb', line 141

def connected?
  self.connected
end

#dockerObject



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

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

#healthcheckObject



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

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

#holding_lock?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/kamal/commander.rb', line 137

def holding_lock?
  self.holding_lock
end

#hookObject



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

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

#lockObject



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

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

#pruneObject



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

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

#registryObject



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

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

#serverObject



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

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



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

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

#with_verbosity(level) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/kamal/commander.rb', line 117

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