cirun 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cirun/cli.rb +14 -0
- data/lib/cirun/runner.rb +10 -12
- data/lib/cirun/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1f419a6ffa683a9f8d781b09c3ba93a2db464e6f944f90337dd7bc0b0605cdc
|
4
|
+
data.tar.gz: 2d1320c38681fe7be4a533feec5875b2d9593b6e1f55f17197724d11ee2be5b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8745fdb29e9c1543e5ad7ad4442546f3917a135661ac278dc13744c18a582e1c414cdba8c55b07a0347aa6dd133ec878b9dae917487c1e1ca4db104b7df29c
|
7
|
+
data.tar.gz: b31959617b0627ea5e8b3b3911fc1f3c75af2684bc85b72bf6efa1aa58c03ec797eb466fd7ef41c16e3e3842519bf5237148bee211b342f0d8235c4d7c2b04d7
|
data/lib/cirun/cli.rb
CHANGED
@@ -13,6 +13,7 @@ module Cirun
|
|
13
13
|
@options.ruby = ''
|
14
14
|
@options.plugin = ''
|
15
15
|
@options.dependent = ''
|
16
|
+
@options.print = false
|
16
17
|
end
|
17
18
|
|
18
19
|
def parse
|
@@ -33,6 +34,19 @@ module Cirun
|
|
33
34
|
opts.on('-e', '--dependent DEPENDENT', "Specify plugin dependency") do |dependent|
|
34
35
|
@options.dependent = dependent
|
35
36
|
end
|
37
|
+
opts.on(
|
38
|
+
'-i',
|
39
|
+
'--interactive',
|
40
|
+
'Instead of executing docker for you this will just print',
|
41
|
+
' required command string to the standard output.',
|
42
|
+
' This is useful when you want to run interactive',
|
43
|
+
' debug session. Docker CLI is very hard to trick',
|
44
|
+
' so with this option you can just backtick output',
|
45
|
+
' like: `cirun -d mysql -m 2.3 -r 1.9.3-p551 -i`'
|
46
|
+
) do
|
47
|
+
@options.print = true
|
48
|
+
end
|
49
|
+
|
36
50
|
end.parse!
|
37
51
|
|
38
52
|
validate_options || abort_due_to_lack_of_options
|
data/lib/cirun/runner.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'open3'
|
2
|
-
require 'tty-command'
|
3
2
|
|
4
3
|
module Cirun
|
5
4
|
class Runner
|
@@ -8,33 +7,32 @@ module Cirun
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def update_image
|
11
|
-
puts "Pulling redmineup/#{@opts.plugin}, please wait"
|
10
|
+
puts "Pulling redmineup/#{@opts.plugin}, please wait" unless @opts.print
|
12
11
|
cmd = "docker pull redmineup/#{@opts.plugin}"
|
13
|
-
execute(cmd)
|
12
|
+
execute(cmd, @opts.print)
|
14
13
|
end
|
15
14
|
|
16
15
|
def run
|
17
16
|
update_image
|
18
17
|
ruby_short = @opts.ruby.split('-').first
|
19
|
-
cmd = "docker run
|
20
|
-
|
18
|
+
cmd = "docker run -#{@opts.print ? 'i' : ''}t --env RUBY_VERSION=ruby-#{ruby_short} --env DB=#{@opts.database} --env REDMINE=redmine-#{@opts.redmine} --env PLUGIN=#{@opts.plugin} --env DEPENDENT=#{@opts.dependent} --mount type=bind,source=#{`pwd`.chomp},target=/var/www/ruby-#{ruby_short}/#{@opts.database}/redmine-#{@opts.redmine}/plugins/#{@opts.plugin} redmineup/#{@opts.plugin} /root/run_local.sh"
|
19
|
+
@opts.print ? print(cmd) : execute(cmd)
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
def execute(cmd)
|
26
|
-
puts "Running:\n#{cmd}"
|
24
|
+
def execute(cmd, silently = false)
|
25
|
+
puts "Running:\n#{cmd}" unless silently
|
27
26
|
Open3.popen3(cmd) do |stdin, stdout, stderr|
|
28
27
|
while (line = stdout.gets)
|
29
|
-
puts line
|
28
|
+
puts line unless silently
|
30
29
|
end
|
31
|
-
puts stderr.read
|
30
|
+
puts stderr.read unless silently
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
def
|
36
|
-
|
37
|
-
cmd.run(command)
|
34
|
+
def print(command)
|
35
|
+
puts command
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
data/lib/cirun/version.rb
CHANGED