rbbt-image 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/run_rbbt_docker.rb +30 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd48d97fc8707d8d5134f72b06e1952afe55a90d
4
- data.tar.gz: b0522b2cae2fc954546c2252f90187caf5235a56
3
+ metadata.gz: 4c6c02d65f9cb1b09a00fa6b4dedb55be5682651
4
+ data.tar.gz: 5c3f398274a92282a5bccdfd540a6b4f499a0ea3
5
5
  SHA512:
6
- metadata.gz: 37369385d4fc586d0f8385793304ceff96dafefe2cf79ad3553e203d97cf700f999591617fcbee317cce90482944258b1b1b868d6a088848a27e57a3c538f495
7
- data.tar.gz: 7782bfcea40ad56f099d327afd1324bed69cb121b4004638e3aa009933ca11bb79680c9ae87b1d8ce1dcc5d714f7b28f22774768b5f5e41cefebceacf0b9bbac
6
+ metadata.gz: fc0248394e0fa3c48473ce874c71e175feddf8484217e5d485bb8420e43941785d507f90209f82d89869b729f935ca4d312c3bfbdc3347b7bfbd0d512e5d614d
7
+ data.tar.gz: 4c8e8024cadf7256c39b84093c53386473d4f1e7e6f9c0467b63ebd6691691ac27a526da7ac5a3818af98096500613e4130cb3d4df1361f5eb1c5f008f355299
@@ -9,16 +9,26 @@ options = SOPT.setup <<EOF
9
9
 
10
10
  Runs a docker image from an infrastructure definition file
11
11
 
12
- $ #{ $0 } [options] <infrastructure.yaml> <command> <args>
12
+ $ #{ $0 } [options] <infrastructure.yaml> <command> <args> -- <extra docker options>
13
13
 
14
14
  Infrastruture definition comes in YAML
15
15
 
16
16
  -h--help Print this help
17
+ --log* Log level
17
18
 
18
19
  EOF
19
- infrastructure_file, cmd, *cmd_args = ARGV
20
20
 
21
- cmd_args.collect!{|a| "'" << a << "'" }
21
+ Log.severity = options[:log].to_i if options[:log]
22
+
23
+ module Log
24
+ def self.log(msg,level)
25
+ msg = "" if msg.nil?
26
+ puts msg
27
+ end
28
+ end
29
+
30
+ infrastructure_file, cmd, *args = ARGV
31
+
22
32
 
23
33
  if options[:help] or infrastructure_file.nil?
24
34
  if defined? rbbt_usage
@@ -29,6 +39,15 @@ if options[:help] or infrastructure_file.nil?
29
39
  exit 0
30
40
  end
31
41
 
42
+ cmd_args = []
43
+ while args[0] != '--'
44
+ cmd_args << args.shift
45
+ end
46
+
47
+ docker_args = args[1..-1]
48
+
49
+ cmd_args.collect!{|a| '"' << a << '"' }
50
+ docker_args.collect!{|a| '"' << a << '"' }
32
51
 
33
52
  infrastructure = File.open(infrastructure_file){|io| YAML.load io }
34
53
  IndiferentHash.setup(infrastructure)
@@ -48,18 +67,22 @@ if infrastructure[:mounts]
48
67
  if source.nil? or source.empty?
49
68
  mount_conf << " -v #{target}"
50
69
  else
70
+ FileUtils.mkdir_p source unless File.directory? source
71
+ FileUtils.chmod 0777, source
51
72
  mount_conf << " -v #{File.expand_path(source)}:#{target}"
52
73
  end
53
74
  end
54
75
  end
55
76
 
56
- if infrastructure[:workflow_autoinstall] and infrastructure[:workflow_autoinstall].to_s == 'true'
77
+ if infrastructure[:workflow_autoinstall] and infrastructure[:workflow_autoinstall].to_s == 'true' and cmd =~ /rbbt/
57
78
  cmd = "env RBBT_WORKFLOW_AUTOINSTALL=true " + cmd
58
79
  end
59
80
 
60
- cmd_str = "docker run #{mount_conf} #{user_conf} #{image} #{cmd} #{cmd_args*" "} "
61
- Log.info "Running docker: \n" << cmd_str
62
- Log.severity = 0
81
+ cmd_str = "docker run #{mount_conf} #{user_conf} #{docker_args*" "} #{image} /bin/bash --login -c '#{cmd} #{cmd_args*" "}"
82
+ cmd_str += " --log #{Log.severity} " if cmd =~ / rbbt$/
83
+ cmd_str += "'"
84
+
85
+ Log.info "Docker: \n" << cmd_str
63
86
  io = CMD.cmd(cmd_str, :pipe => true, :log => true, :stderr => 0)
64
87
 
65
88
  while line = io.gets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util