From 46ed6fcfbee6d6962c61d474e646deea5a8c7ec9 Mon Sep 17 00:00:00 2001 From: Karl Matthias Date: Thu, 21 May 2015 16:22:51 -0700 Subject: [PATCH] Revert "Offer dry-run capability" This reverts commit 81b1d9a2d75b1d30fa1eff93fee107a5c816315e. --- bin/centurion | 6 ------ lib/centurion/mock.rb | 49 ------------------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 lib/centurion/mock.rb diff --git a/bin/centurion b/bin/centurion index cfdb38aa..d019fb80 100755 --- a/bin/centurion +++ b/bin/centurion @@ -33,7 +33,6 @@ opts = Trollop::options do opt :registry_user, 'user for registry auth', type: String, short: :none opt :registry_password,'password for registry auth', type: String, short: :none opt :override_env, 'override environment variables, comma separated', type: String - opt :dry_run, 'print out docker command do run', type: :flag, default: false, short: :none end set_current_environment(opts[:environment].to_sym) @@ -78,9 +77,4 @@ set :registry_user, opts[:registry_user] if opts[:registry_user] set :registry_password, opts[:registry_password] if opts[:registry_password] invoke('centurion:setup') -if opts[:dry_run] - Centurion::Mock.new(env).run - exit -end - invoke(opts[:action]) diff --git a/lib/centurion/mock.rb b/lib/centurion/mock.rb deleted file mode 100644 index 8ef28eed..00000000 --- a/lib/centurion/mock.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Centurion - class Mock - def initialize(opts) - environment = opts[:current_environment] - @options = opts[environment] - end - - def run - require 'pry-byebug' - - result = hosts.map do |host| - string = "docker -H=tcp://#{host}:2375 run" - - string << environment_vars unless env_vars.empty? - string << ports_vars unless ports_vars.empty? - end.join("\n\n\n ******* \n\n\n") - puts "#{result}" - end - - private - - attr_reader :options - - - def env_vars - options[:env_vars] - end - - def environment_vars - env_vars.reduce('') { |string, (k, v)| " -e #{k.split('"')[0]}='#{v}'#{string}" }.rstrip - end - - def ports - options[:port_bindings] - end - - def hosts - options[:hosts] - end - - def ports_vars - ports.reduce('') do |string, (host_port_protocol, container_port)| - h = host_port_protocol.split('/') - c = container_port.first['HostPort'] - " -p #{h[0]}:#{c}/#{h[1]}#{string}" - end.rstrip - end - end -end