knife-container 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/knife-container.gemspec +1 -1
- data/lib/chef/knife/container_docker_build.rb +15 -5
- data/lib/knife-container/version.rb +1 -1
- data/spec/unit/container_docker_build_spec.rb +42 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80850e4057f993db9ecb2f81135a9c201cab57bc
|
4
|
+
data.tar.gz: 33813a502452bd26fb2f004977e31b618ad6490d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d90cbb6aaec8406ed47061c633b6930373dbfd42e7ce3caf2851727b1721bd9eb76306c733aefaee6edfde807f285e0b59e085a0aa62fcfb0f6b9b7f45ddbdc0
|
7
|
+
data.tar.gz: 3447e0aee997c6ca6de715f227ede41e2886668890303223943ffb6d37c19f653a259d7cb851522720ce3c3c327f6f24774fc306ec1a5deb6228e2a516c617cc
|
data/CHANGELOG.md
CHANGED
data/knife-container.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "chef", "
|
21
|
+
spec.add_dependency "chef", ">= 11.0"
|
22
22
|
spec.add_dependency "mixlib-config", "~> 2.0"
|
23
23
|
spec.add_dependency "json", ">= 1.4.4", "<= 1.8.1"
|
24
24
|
|
@@ -37,6 +37,10 @@ class Chef
|
|
37
37
|
:default => true,
|
38
38
|
:boolean => true
|
39
39
|
|
40
|
+
option :berks_config,
|
41
|
+
:long => "--berks-config CONFIG",
|
42
|
+
:description => "Use the specified Berkshelf configuration"
|
43
|
+
|
40
44
|
option :cleanup,
|
41
45
|
:long => "--[no-]cleanup",
|
42
46
|
:description => "Cleanup Chef and Docker artifacts",
|
@@ -80,6 +84,13 @@ class Chef
|
|
80
84
|
if config[:run_berks]
|
81
85
|
ver = shell_out("berks -v")
|
82
86
|
config[:run_berks] = ver.stdout.match(/\d+\.\d+\.\d+/) ? true : false
|
87
|
+
|
88
|
+
if config[:berks_config]
|
89
|
+
unless File.exists?(config[:berks_config])
|
90
|
+
ui.fatal("No Berksfile configuration found at #{config[:berks_config]}")
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
end
|
83
94
|
end
|
84
95
|
end
|
85
96
|
|
@@ -155,11 +166,10 @@ class Chef
|
|
155
166
|
#
|
156
167
|
def run_berks_upload
|
157
168
|
run_berks_install
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
end
|
169
|
+
berks_upload_cmd = "berks upload"
|
170
|
+
berks_upload_cmd << " --force" if config[:force_build]
|
171
|
+
berks_upload_cmd << " --config=#{File.expand_path(config[:berks_config])}" if config[:berks_config]
|
172
|
+
run_command(berks_upload_cmd)
|
163
173
|
end
|
164
174
|
|
165
175
|
#
|
@@ -129,6 +129,21 @@ describe Chef::Knife::ContainerDockerBuild do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
|
+
|
133
|
+
context "--berks-config was passed" do
|
134
|
+
let(:argv) { %w[ docker/demo --berks-config my_berkshelf/config.json ] }
|
135
|
+
|
136
|
+
context "and configuration file does not exist" do
|
137
|
+
before do
|
138
|
+
File.stub(:exists?).with('my_berkshelf/config.json').and_return(false)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should exit immediately' do
|
142
|
+
expect(knife.ui).to receive(:fatal)
|
143
|
+
expect { knife.run }.to raise_error(SystemExit)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
132
147
|
end
|
133
148
|
|
134
149
|
describe '#setup_config_defaults' do
|
@@ -297,6 +312,33 @@ describe Chef::Knife::ContainerDockerBuild do
|
|
297
312
|
knife.run_berks_upload
|
298
313
|
end
|
299
314
|
end
|
315
|
+
|
316
|
+
context "when berks-config is specified" do
|
317
|
+
before do
|
318
|
+
knife.config[:berks_config] = 'my_berkshelf/config.json'
|
319
|
+
File.stub(:exists?).with('my_berkshelf/config.json').and_return(true)
|
320
|
+
File.stub(:expand_path).with('my_berkshelf/config.json').and_return('/home/my_berkshelf/config.json')
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should run berks upload with specified config file" do
|
324
|
+
expect(knife).to receive(:run_command).with("berks upload --config=/home/my_berkshelf/config.json")
|
325
|
+
knife.run_berks_upload
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
context "when berks-config _and_ force-build is specified" do
|
330
|
+
before do
|
331
|
+
knife.config[:force_build] = true
|
332
|
+
knife.config[:berks_config] = 'my_berkshelf/config.json'
|
333
|
+
File.stub(:exists?).with('my_berkshelf/config.json').and_return(true)
|
334
|
+
File.stub(:expand_path).with('my_berkshelf/config.json').and_return('/home/my_berkshelf/config.json')
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should run berks upload with specified config file _and_ force flag" do
|
338
|
+
expect(knife).to receive(:run_command).with("berks upload --force --config=/home/my_berkshelf/config.json")
|
339
|
+
knife.run_berks_upload
|
340
|
+
end
|
341
|
+
end
|
300
342
|
end
|
301
343
|
|
302
344
|
describe "#docker_build_command" do
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Duffield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '11.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '11.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -231,3 +231,4 @@ test_files:
|
|
231
231
|
- spec/unit/fixtures/nodes/demo.json
|
232
232
|
- spec/unit/fixtures/roles/base.json
|
233
233
|
- spec/unit/fixtures/site-cookbooks/apt/metadata.rb
|
234
|
+
has_rdoc:
|