8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/haconiwa/cli.rb', line 8
def self.attach(args)
require 'optparse'
opt = OptionParser.new
pid = nil
name = nil
allow = nil
drop = nil
opt.program_name = "haconiwa attach"
opt.on('-t', '--target PID', "Container's PID to attatch. If not set, use pid file of definition") {|v| pid = v }
opt.on('-n', '--name CONTAINER_NAME', "Container's name. Set if the name is dynamically defined") {|v| name = v }
opt.on('--allow CAPS[,CAPS...]', "Capabilities to allow attached process. Independent container's own caps") {|v| allow = v.split(',') }
opt.on('--drop CAPS[,CAPS...]', "Capabilities to drop from attached process. Independent container's own caps") {|v| drop = v.split(',') }
args = opt.parse(args)
base, exe = get_script_and_eval(args)
base.pid = pid if pid
base.name = name if name
if allow || drop
base.attached_capabilities = Capabilities.new
base.attached_capabilities.allow(*allow) if allow
base.attached_capabilities.drop(*drop) if drop
end
base.attach(*exe)
end
|