Module: COMAP
- Defined in:
- lib/comap.rb,
lib/comap/app.rb,
lib/comap/version.rb,
lib/comap/docker_client.rb
Overview
Defined Under Namespace
Classes: App, DockerClient
Constant Summary
collapse
- VERSION =
'1.2.0'
Class Method Summary
collapse
Class Method Details
.add_docker_host_option(opts) ⇒ Object
32
33
34
35
36
|
# File 'lib/comap.rb', line 32
def add_docker_host_option(opts)
desc = "Docker Engine API Host (default: #{@config[:docker_host]})"
help = '--docker_host HOST'
opts.on('-H', help, desc) { |v| @config[:docker_host] = v }
end
|
.add_docker_port_option(opts) ⇒ Object
Merge port with -H (to be coherent with docker)
39
40
41
42
43
|
# File 'lib/comap.rb', line 39
def add_docker_port_option(opts)
desc = "Docker Engine API Port (default: #{@config[:docker_port]})"
help = '--docker_port PORT'
opts.on('-p', help, desc) { |v| @config[:docker_port] = v }
end
|
.add_docker_ssl_option(opts) ⇒ Object
45
46
47
48
49
|
# File 'lib/comap.rb', line 45
def add_docker_ssl_option(opts)
desc = 'Docker Engine API SSL (default: none)'
help = '--docker_ssl k1=v1,k2=v2'
opts.on('-s', help, desc) { |v| @config[:docker_ssl] = v }
end
|
.add_metrics_path_option(opts) ⇒ Object
57
58
59
60
61
|
# File 'lib/comap.rb', line 57
def add_metrics_path_option(opts)
desc = "Metrics path (default: #{@config[:metrics_path]})"
help = '--metrics_path METRICS_PATH'
opts.on('-m', help, desc) { |v| @config[:metrics_path] = v }
end
|
.add_network_option(opts) ⇒ Object
51
52
53
54
55
|
# File 'lib/comap.rb', line 51
def add_network_option(opts)
desc = 'Docker swarm service network (default: none)'
help = '--docker_network NETWORK'
opts.on('-n', help, desc) { |v| @config[:network] = v }
end
|
.add_options(opts) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/comap.rb', line 63
def add_options(opts)
opts.banner =
"Usage: #{File.basename($PROGRAM_NAME)} [options] swarm_service"
add_docker_host_option(opts)
add_docker_port_option(opts)
add_docker_ssl_option(opts)
add_network_option(opts)
add_metrics_path_option(opts)
end
|
.app ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/comap.rb', line 84
def app
config = @config
Rack::Builder.new do
use Rack::Deflater
run COMAP::App.new(config)
end
end
|
.parse_opts ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/comap.rb', line 73
def parse_opts
OptionParser.new do |opts|
add_options(opts)
opts.on('-h', '--help', 'Display this screen') do
puts opts
exit
end
opts.parse!
end
end
|
.start(args = ARGV) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/comap.rb', line 92
def start(args = ARGV)
@config = {
docker_host: 'http://127.0.0.1',
docker_port: 2375,
docker_ssl: '',
metrics_path: '',
network: '',
services: args
}
parse_opts
Rack::Server.start(app: app, Host: '0.0.0.0', Port: 9397)
end
|