Skip to content

Commit 87f41fd

Browse files
committed
update
1 parent e29ffc0 commit 87f41fd

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
dry-stack (0.1.32)
4+
dry-stack (0.1.33)
55

66
GEM
77
remote: https://rubygems.org/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This gem allows ...
66
cat simple_stack.drs | dry-stack -e to_compose | docker stack deploy -c - simple_stack
77
88
$ dry-stack
9-
Version: 0.1.32
9+
Version: 0.1.33
1010
Usage:
1111
dry-stack -s stackfile [options] COMMAND
1212
cat stackfile | dry-stack COMMAND

lib/dry-stack/command_line.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
require_relative '../version'
22
require 'open3'
33

4-
def exec_i(cmd, input_string = nil)
4+
def exec_i(cmd, input_string = nil, &block)
55
puts "exec_i(inputs.size #{input_string&.size}): #{cmd}"
66
Open3.popen3(cmd) do |i, o, e, wait_thr|
7+
std_out, std_err = '', ''
78
i.puts input_string unless input_string.nil?
89
i.close
9-
while line = o.gets; puts "o: " + line end
10-
while line = e.gets; puts "o: " + line end
10+
while line = o.gets; puts "o: #{line}"; std_out += "#{line}\n" end
11+
while line = e.gets; puts "o: #{line}"; std_err += "#{line}\n" end
1112
return_value = wait_thr.value
1213
puts "Error level was: #{return_value.exitstatus}" unless return_value.success?
13-
exit return_value.exitstatus unless return_value.success?
14+
15+
if block_given?
16+
block.call return_value, std_out, std_err
17+
else
18+
exit return_value.exitstatus unless return_value.success?
19+
end
1420
end
1521
end
1622

lib/dry-stack/command_swarm_deploy.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ def run(stack, params, args, extra)
2626
raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}"
2727
end
2828

29-
exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name]
30-
# TODO: o: context "dry-ssh__gis-master_ru" already exists
29+
unless contexts[name]
30+
exec_i "docker context create #{name} --docker host=#{endpoint}" do |return_value, _o, e|
31+
exit return_value.exitstatus unless return_value.success? || e !~ /already exists/m
32+
end
33+
end
3134

3235
ENV['DOCKER_CONTEXT'] = name.to_s
3336

lib/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Dry
22
class Stack
3-
VERSION = '0.1.32'
3+
VERSION = '0.1.33'
44
end
55
end

0 commit comments

Comments
 (0)