donce 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/donce.gemspec +1 -1
  3. data/lib/donce.rb +30 -15
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d8edc10a85c0d3eaa7fe743be71fae12afdb07925c50f2ca63c064593e18860
4
- data.tar.gz: '086f4fa0751fa6568d3a590d4b6b5d176385e7c9246d6f25452ce89f0e600646'
3
+ metadata.gz: ff61e01863f8590b3541ca6edecbf96c4a0ee9d5fe28fbe8e30b4a001c578101
4
+ data.tar.gz: 800c5ae24c1dd36a9484ec800b6c40217b9491e61b1d89f8d170faf1e4d58471
5
5
  SHA512:
6
- metadata.gz: 13a683fdc2f394bb7af1fd04bb309dbc6d21c4be5a128f4fa5457eb50f642535b9f1c3096ac88026cf37d078be3391a561d3c5e586d16204688aa4b2bd665d15
7
- data.tar.gz: a038ee334662de346c7c4da876ced657cede85e82368dfb618a23b401b9525f07e3515804205d98fd7e0060cf1a1754320d4e932ba3591a259d90a08f5049500
6
+ metadata.gz: b7164f6f5372ff0a0fd0fff126f11d48e7fd1db042404316fa5d430113a2cd8564a249ef7c6da02a489c627b218ab224cb0d0e4174f5cde3d7ef575945f7d607
7
+ data.tar.gz: 62e270b7eeee5e3e857c2ee64cdbf7c5aa9fd476ca6a7a0f1d3d011597414d2448a840ea2e0802d672a2197e9c113d670c4ea41135b3024d48dcf1150fb9aaf5
data/donce.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
10
  s.required_ruby_version = '>=3.0'
11
11
  s.name = 'donce'
12
- s.version = '0.2.1'
12
+ s.version = '0.2.2'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Builds and starts temporary Docker containers'
15
15
  s.description =
data/lib/donce.rb CHANGED
@@ -73,6 +73,21 @@ module Kernel
73
73
  raise 'Either use "image" or "home"' if home && image
74
74
  raise 'Either "dockerfile", or "home", or "image" must be provided' if !dockerfile && !home && !image
75
75
  raise 'The "timeout" must be an integer or nil' unless timeout.nil? || timeout.is_a?(Integer)
76
+ raise 'The "volumes" is nil' if volumes.nil?
77
+ raise 'The "volumes" must be a Hash' unless volumes.is_a?(Hash)
78
+ raise 'The "log" is nil' if log.nil?
79
+ raise 'The "args" is nil' if args.nil?
80
+ raise 'The "args" must be a String' unless args.is_a?(String)
81
+ raise 'The "env" is nil' if env.nil?
82
+ raise 'The "env" must be a Hash' unless env.is_a?(Hash)
83
+ raise 'The "command" is nil' if command.nil?
84
+ raise 'The "command" must be a String' unless command.is_a?(String)
85
+ raise 'The "timeout" is nil' if timeout.nil?
86
+ raise 'The "timeout" must be a number' unless timeout.is_a?(Integer) || timeout.is_a?(Float)
87
+ raise 'The "ports" is nil' if ports.nil?
88
+ raise 'The "ports" must be a Hash' unless ports.is_a?(Hash)
89
+ raise 'The "build_args" is nil' if build_args.nil?
90
+ raise 'The "build_args" must be a Hash' unless build_args.is_a?(Hash)
76
91
  docker = ENV['DONCE_SUDO'] ? 'sudo docker' : 'docker'
77
92
  img =
78
93
  if image
@@ -97,22 +112,22 @@ module Kernel
97
112
  i
98
113
  end
99
114
  container = "donce-#{SecureRandom.hex(6)}"
115
+ stdout = nil
116
+ code = 0
117
+ cmd = [
118
+ docker, 'run',
119
+ ('--detach' if block_given?),
120
+ '--name', Shellwords.escape(container),
121
+ ("--add-host #{donce_host}:host-gateway" if OS.linux?),
122
+ args,
123
+ env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
124
+ ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
125
+ volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
126
+ ("--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}" if root),
127
+ Shellwords.escape(img),
128
+ command
129
+ ].compact.join(' ')
100
130
  begin
101
- stdout = nil
102
- code = 0
103
- cmd = [
104
- docker, 'run',
105
- ('--detach' if block_given?),
106
- '--name', Shellwords.escape(container),
107
- ("--add-host #{donce_host}:host-gateway" if OS.linux?),
108
- args,
109
- env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
110
- ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
111
- volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
112
- ("--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}" if root),
113
- Shellwords.escape(img),
114
- command
115
- ].compact.join(' ')
116
131
  begin
117
132
  stdout, code =
118
133
  Timeout.timeout(timeout) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: donce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko