module COMAP
Main Module
Main module
Module Docker
Define version
Constants
- VERSION
Public Class Methods
add_docker_host_option(opts)
click to toggle source
# 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)
click to toggle source
Merge port with -H (to be coherent with docker)
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# 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