Class: EtnaApp::Polyphemus
Instance Attribute Summary
#parent
Instance Method Summary
collapse
#environment, #janus_client, #magma_client, #metis_client, #polyphemus_client, #token
#completions, #fill_in_missing_params, #find_command, #initialize, parent_scope, #setup
#command_name, #completions_for, #desc, #flag_argspec, #flag_as_parameter, included, #parse_flags, #program_name, #usage
Constructor Details
This class inherits a constructor from Etna::Command
Instance Method Details
#create_config_yml ⇒ Object
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
# File 'lib/commands.rb', line 314
def create_config_yml
host_config = [:metis, :magma, :janus, :timur].map do |host|
[host, (EtnaApp.instance.config(host) || {}).update(token: token)]
end.to_h
config = {
EtnaApp.instance.environment => {
log_file: '/dev/stdout',
log_level: 'info',
}.update(host_config)
}
File.open(temp_config_file.path, 'w') { |f| YAML.dump(config, f) }
end
|
#default_tag ⇒ Object
329
330
331
332
333
334
335
336
|
# File 'lib/commands.rb', line 329
def default_tag
docker = EtnaApp.instance.config(:docker)
if docker.nil?
nil
else
docker[:default_tag]
end || 'master'
end
|
#execute(tag: nil, local: false) ⇒ Object
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/commands.rb', line 276
def execute(tag: nil, local: false)
@tag = tag || default_tag
@local = local
create_config_yml
unless @local
puts `docker pull #{image}`
end
puts run_cmd
exec(run_cmd)
end
|
#image ⇒ Object
338
339
340
341
342
343
344
|
# File 'lib/commands.rb', line 338
def image
if @local
"polyphemus:#{@tag}"
else
"etnaagent/polyphemus:#{@tag}"
end
end
|
#run_cmd ⇒ Object
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/commands.rb', line 289
def run_cmd
parts = ['docker run --rm -it']
unless Gem.win_platform?
uid = Etc.getpwnam(ENV['USER']).uid
gid = Etc.getgrnam('docker').gid
parts << "-u #{uid}:#{gid}"
parts << "-v /etc/passwd:/etc/passwd:ro"
parts << "-v /etc/group:/etc/group:ro"
end
parts << "-v #{temp_config_file.path}:/app/config.yml:ro"
parts << "-v #{Dir.pwd}:/app/workspace"
parts << "-e HOME=/root"
parts << image
parts << "bash -c 'cd /app/workspace && exec bash --rcfile /root/.bashrc'"
parts.join(' ')
end
|
#temp_config_file ⇒ Object
310
311
312
|
# File 'lib/commands.rb', line 310
def temp_config_file
@temp_config_file ||= Tempfile.new
end
|