Sha256: 16277095b03a56f9fe0a2102bcd57a013e3383070f4e4ee967dcbed761d7a066
Contents?: true
Size: 860 Bytes
Versions: 1
Compression:
Stored size: 860 Bytes
Contents
module Maril class Generator def initialize(options={}) @host = options[:host] || options['host'] @id = options[:id] || options['id'] end def generate app = fetch_app cmd = [ 'docker run --rm -it' ] app['env'].each do |k, v| cmd << "--env #{k}=#{v}" end app['container']['docker']['parameters'].each do |parameter| cmd << "--#{parameter['key']} #{parameter['value']}" end app['container']['docker']['portMappings'].each do |mapping| cmd << "-p #{mapping['containerPort']}:#{mapping['containerPort']}" end cmd << app['container']['docker']['image'] cmd << app['cmd'] if app['cmd'] cmd.join(" \\\n") end private def fetch_app res = RestClient.get("#{@host}/v2/apps#{@id}") JSON.parse(res.body)['app'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
maril-0.1.2 | lib/maril/generator.rb |