Module: Armada::DeployDSL
- Defined in:
- lib/armada/deploy_dsl.rb
Defined Under Namespace
Classes: CurrentEnvironmentNotSetError, Store
Instance Method Summary
collapse
Instance Method Details
#any?(key) ⇒ Boolean
38
39
40
41
42
43
44
45
|
# File 'lib/armada/deploy_dsl.rb', line 38
def any?(key)
value = fetch(key)
if value && value.respond_to?(:any?)
value.any?
else
!fetch(key).nil?
end
end
|
#clear_env ⇒ Object
66
67
68
|
# File 'lib/armada/deploy_dsl.rb', line 66
def clear_env
env.clear
end
|
#container_config(cfg) ⇒ Object
136
137
138
|
# File 'lib/armada/deploy_dsl.rb', line 136
def container_config(cfg)
set(:container_config, cfg)
end
|
#container_name(name) ⇒ Object
70
71
72
|
# File 'lib/armada/deploy_dsl.rb', line 70
def container_name(name)
set(:container_name, name)
end
|
#current_environment ⇒ Object
61
62
63
64
|
# File 'lib/armada/deploy_dsl.rb', line 61
def current_environment
raise CurrentEnvironmentNotSetError.new('Must set current environment') unless env[:current_environment]
env[:current_environment]
end
|
#delete(key) ⇒ Object
51
52
53
|
# File 'lib/armada/deploy_dsl.rb', line 51
def delete(key)
env[current_environment].delete(key)
end
|
#env ⇒ Object
30
31
32
|
# File 'lib/armada/deploy_dsl.rb', line 30
def env
Store.instance
end
|
#env_vars(new_vars) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/armada/deploy_dsl.rb', line 74
def env_vars(new_vars)
current = fetch(:env_vars, {})
new_vars.each_pair do |new_key, new_value|
current[new_key.to_s] = new_value
end
set(:env_vars, current)
end
|
#fetch(key, default = nil, &block) ⇒ Object
34
35
36
|
# File 'lib/armada/deploy_dsl.rb', line 34
def fetch(key, default=nil, &block)
env[current_environment][key] || default
end
|
#host(hostname) ⇒ Object
82
83
84
85
86
|
# File 'lib/armada/deploy_dsl.rb', line 82
def host(hostname)
current = fetch(:hosts, [])
current << hostname
set(:hosts, current)
end
|
#host_config(cfg) ⇒ Object
145
146
147
|
# File 'lib/armada/deploy_dsl.rb', line 145
def host_config(cfg)
set(:host_config, cfg)
end
|
#host_port(port, options) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/armada/deploy_dsl.rb', line 99
def host_port(port, options)
validate_options_keys(options, [ :host_ip, :container_port, :type ])
require_options_keys(options, [ :container_port ])
add_to_bindings(
options[:host_ip] || '0.0.0.0',
options[:container_port],
port,
options[:type] || 'tcp'
)
end
|
#host_volume(volume, options) ⇒ Object
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/armada/deploy_dsl.rb', line 125
def host_volume(volume, options)
validate_options_keys(options, [ :container_volume ])
require_options_keys(options, [ :container_volume ])
binds = fetch(:binds, [])
container_volume = options[:container_volume]
binds << "#{volume}:#{container_volume}"
set(:binds, binds)
end
|
#hostname(hostname) ⇒ Object
88
89
90
|
# File 'lib/armada/deploy_dsl.rb', line 88
def hostname(hostname)
set(:hostname, hostname)
end
|
#localhost ⇒ Object
92
93
94
95
96
97
|
# File 'lib/armada/deploy_dsl.rb', line 92
def localhost
docker_host_uri = URI.parse(ENV['DOCKER_HOST'] || "tcp://127.0.0.1")
host_and_port = [docker_host_uri.host, docker_host_uri.port].compact.join(':')
host(host_and_port)
end
|
#privileged ⇒ Object
149
150
151
|
# File 'lib/armada/deploy_dsl.rb', line 149
def privileged
set(:privileged, true)
end
|
#public_port_for(port_bindings) ⇒ Object
119
120
121
122
123
|
# File 'lib/armada/deploy_dsl.rb', line 119
def public_port_for(port_bindings)
first_port_binding = port_bindings.values.first
first_port_binding.first['HostPort']
end
|
#restart_policy(opts) ⇒ Object
111
112
113
|
# File 'lib/armada/deploy_dsl.rb', line 111
def restart_policy(opts)
set(:restart_policy, opts)
end
|
#secret_value(key) ⇒ Object
115
116
117
|
# File 'lib/armada/deploy_dsl.rb', line 115
def secret_value(key)
`conjur variable value #{key}`
end
|
#set(key, value) ⇒ Object
47
48
49
|
# File 'lib/armada/deploy_dsl.rb', line 47
def set(key, value)
env[current_environment][key] = value
end
|
#set_current_environment(environment) ⇒ Object
55
56
57
58
59
|
# File 'lib/armada/deploy_dsl.rb', line 55
def set_current_environment(environment)
env[:current_environment] = environment
env[environment] ||= {}
env_vars ENV: environment.to_s.downcase
end
|
#start_config(cfg) ⇒ Object
140
141
142
143
|
# File 'lib/armada/deploy_dsl.rb', line 140
def start_config(cfg)
Armada.ui.warn "This option will be deprecated soon. Use host_config instead."
set(:host_config, cfg)
end
|