rbbt-image 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7138ef89baa52f6d13bd5f72140b5a6dcbba36b
4
- data.tar.gz: 8ded0f2a9d48bb91da685af3aecf49e7d55422c4
3
+ metadata.gz: 2f2b171f1bf5d33e7943f98071ae139ddcbda3c4
4
+ data.tar.gz: 7b87e701e36fbb39245dd2348e9f30f847677505
5
5
  SHA512:
6
- metadata.gz: 35fb2d664acbc7c8d93f68c0f3b139ff623d8b56d1a5b18e02d9ffb84e74d6d4d014e62b23efcc30c6b0ea1d44d83d20984f60c89495e4165733c3e14723aa92
7
- data.tar.gz: c6f7504c49416ee3ab66810082987446ad8eb4fc140efb8a6c99e1d94d8e36228453c1580fefc1d67e78aeda8f86fb8f6f59fdc1739780dd4151494507f54ce3
6
+ metadata.gz: 7d9e957806da59454ea69adb49ca59e9ab684f42f7eb1ad2bc5fe3c4bf03ba2dc661239bc9fb7180d14c87ee8cc7e63e3593c5f25f88640f20f1108bc7252001
7
+ data.tar.gz: 867c87a6749369707391e30db5352d8f70ffceb378e14594418e42711cf6f3b8fb9f19553425335760f87dbc6f9f3aa593bbf7b720e14782d21db45d3ba10812
@@ -12,12 +12,17 @@ Runs a docker image from an infrastructure definition file
12
12
 
13
13
  $ #{ $0 } [<options>] <infrastructure.yaml> <command> <args> [-- <extra docker options>]
14
14
 
15
- Infrastruture definition comes in YAML.
15
+ Infrastruture definition comes in YAML. Note that the options listed here will
16
+ be consumed and thus not passed to the container command, with the exception of
17
+ '--log' which applies to both. To get help from the container command use '-ch'
18
+ or '--chelp' which will append the '--help' options to the container command.
19
+ The other options have been named to avoid clashes.
16
20
 
17
21
  -h--help Print this help
18
- --log* Log level
19
- -d--dry_run Dry run
20
- -n--name* Container name
22
+ -ch--chelp Print help on the container command
23
+ --log* Log level (both this command and the container command)
24
+ --docker_dry_run Dry run. Just output docker command line
25
+ --container_name* Container name
21
26
  --extra_mounts* Extra mounts separated by ','
22
27
  EOF
23
28
 
@@ -53,6 +58,10 @@ while args.any? and args[0] != '--'
53
58
  cmd_args << args.shift
54
59
  end
55
60
 
61
+ if options[:chelp]
62
+ cmd_args << '--help'
63
+ end
64
+
56
65
  docker_args = args[1..-1] || []
57
66
 
58
67
  if not File.exists? infrastructure_file
data/lib/rbbt/docker.rb CHANGED
@@ -3,6 +3,7 @@ module RbbtDocker
3
3
  cmd_args.collect!{|a| '"' << a << '"' }
4
4
  docker_args.collect!{|a| '"' << a << '"' }
5
5
 
6
+
6
7
  IndiferentHash.setup(infrastructure)
7
8
 
8
9
  image = infrastructure[:image]
@@ -54,12 +55,18 @@ module RbbtDocker
54
55
  name_conf = options[:name]
55
56
  name_conf = "--name " << name_conf if name_conf
56
57
  name_conf ||= ""
57
- cmd_str = "docker run #{name_conf} #{mount_conf} #{user_conf} #{docker_args.select{|arg| arg != '"--"'}*" "} #{image} /bin/bash --login -c '#{umask}#{cmd} #{cmd_args*" "}"
58
- cmd_str += " --log #{Log.severity} " if cmd =~ /\brbbt$/
59
- cmd_str += "'"
60
58
 
61
- Log.debug "Docker: \n\n" << cmd_str << "\n\n"
59
+ container_command = "#{umask}#{cmd} #{cmd_args*" "}"
60
+ container_command += " --log #{Log.severity} " if cmd =~ /\brbbt$/
61
+
62
+ cmd_str = "docker run #{name_conf} #{mount_conf} #{user_conf} #{(docker_args - ["--"])*" "} #{Log.color(:green, image)} /bin/bash --login -c '#{Log.color :green, container_command}'"
63
+
64
+ if options[:docker_dry_run]
65
+ puts Log.color(:magenta, "#Docker CMD:") << "\n" << cmd_str << "\n"
66
+ else
67
+ Log.debug Log.color(:magenta, "#Docker CMD:") << "\n" << cmd_str << "\n\n"
68
+ end
62
69
 
63
- exec(cmd_str) unless options[:dry_run]
70
+ exec(Log.uncolor(cmd_str)) unless options[:docker_dry_run]
64
71
  end
65
72
  end
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.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util