berkshelf 6.3.4 → 7.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +6 -8
- data/CHANGELOG.md +7 -19
- data/Gemfile +10 -0
- data/Gemfile.lock +68 -103
- data/Thorfile +2 -2
- data/berkshelf.gemspec +6 -8
- data/features/commands/info.feature +50 -8
- data/features/commands/shelf/show.feature +10 -40
- data/features/commands/upload.feature +73 -0
- data/features/commands/vendor.feature +43 -0
- data/features/json_formatter.feature +1 -1
- data/features/step_definitions/chef_server_steps.rb +2 -2
- data/features/step_definitions/filesystem_steps.rb +16 -0
- data/features/support/env.rb +11 -10
- data/lib/berkshelf.rb +15 -20
- data/lib/berkshelf/berksfile.rb +57 -47
- data/lib/berkshelf/cached_cookbook.rb +120 -19
- data/lib/berkshelf/chef_config_compat.rb +50 -0
- data/lib/berkshelf/chef_repo_universe.rb +2 -2
- data/lib/berkshelf/cli.rb +3 -42
- data/lib/berkshelf/community_rest.rb +40 -61
- data/lib/berkshelf/config.rb +92 -118
- data/lib/berkshelf/cookbook_store.rb +3 -2
- data/lib/berkshelf/core_ext/file.rb +1 -1
- data/lib/berkshelf/dependency.rb +1 -10
- data/lib/berkshelf/downloader.rb +19 -7
- data/lib/berkshelf/errors.rb +3 -0
- data/lib/berkshelf/location.rb +1 -1
- data/lib/berkshelf/locations/base.rb +1 -1
- data/lib/berkshelf/lockfile.rb +17 -13
- data/lib/berkshelf/logger.rb +62 -1
- data/lib/berkshelf/packager.rb +1 -1
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/ridley_compat.rb +22 -3
- data/lib/berkshelf/uploader.rb +76 -48
- data/lib/berkshelf/version.rb +1 -1
- data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/chef_api.rb +4 -4
- data/spec/support/chef_server.rb +1 -1
- data/spec/support/matchers/file_system_matchers.rb +1 -3
- data/spec/support/path_helpers.rb +1 -1
- data/spec/unit/berkshelf/berksfile_spec.rb +3 -24
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +13 -15
- data/spec/unit/berkshelf/community_rest_spec.rb +3 -12
- data/spec/unit/berkshelf/config_spec.rb +4 -4
- data/spec/unit/berkshelf/downloader_spec.rb +6 -11
- data/spec/unit/berkshelf/lockfile_spec.rb +10 -7
- data/spec/unit/berkshelf/source_spec.rb +1 -1
- data/spec/unit/berkshelf/ssl_policies_spec.rb +2 -5
- data/spec/unit/berkshelf/uploader_spec.rb +60 -10
- data/spec/unit/berkshelf/visualizer_spec.rb +2 -2
- metadata +49 -102
- data/features/commands/cookbook.feature +0 -35
- data/features/commands/init.feature +0 -27
- data/features/config.feature +0 -111
- data/lib/berkshelf/base_generator.rb +0 -42
- data/lib/berkshelf/cookbook_generator.rb +0 -133
- data/lib/berkshelf/init_generator.rb +0 -195
- data/lib/berkshelf/streaming_file_adapter.rb +0 -22
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -108
- data/spec/unit/berkshelf/init_generator_spec.rb +0 -265
@@ -1,265 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Berkshelf::InitGenerator do
|
4
|
-
let(:target) { tmp_path.join("some_cookbook") }
|
5
|
-
let(:resolver) { double("resolver") }
|
6
|
-
let(:kitchen_generator) { double("kitchen-generator", invoke_all: nil) }
|
7
|
-
|
8
|
-
before do
|
9
|
-
if defined?(Kitchen::Generator::Init)
|
10
|
-
allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
|
11
|
-
end
|
12
|
-
FileUtils.mkdir_p(target)
|
13
|
-
File.open(File.join(target, "metadata.rb"), "w") do |f|
|
14
|
-
f.write("name 'some_cookbook'")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "with default options" do
|
19
|
-
before do
|
20
|
-
capture(:stdout) do
|
21
|
-
Berkshelf::InitGenerator.new([target]).invoke_all
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
specify do
|
26
|
-
expect(target).to have_structure {
|
27
|
-
file ".gitignore"
|
28
|
-
file "Berksfile"
|
29
|
-
file "Gemfile"
|
30
|
-
file "Vagrantfile" do
|
31
|
-
contains %{recipe[some_cookbook::default]}
|
32
|
-
contains %{config.omnibus.chef_version = 'latest'}
|
33
|
-
contains %{config.vm.box = 'bento/ubuntu-14.04'}
|
34
|
-
end
|
35
|
-
file "chefignore"
|
36
|
-
}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with a chefignore" do
|
41
|
-
before(:each) do
|
42
|
-
capture(:stdout) do
|
43
|
-
Berkshelf::InitGenerator.new([target], chefignore: true).invoke_all
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
specify do
|
48
|
-
expect(target).to have_structure {
|
49
|
-
file "Berksfile"
|
50
|
-
file "chefignore"
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with no metadata" do
|
56
|
-
before do
|
57
|
-
FileUtils.rm(File.join(target, "metadata.rb"))
|
58
|
-
expect do
|
59
|
-
Berkshelf::InitGenerator.new([target]).invoke_all
|
60
|
-
end.to raise_error(Berkshelf::NotACookbook)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "with a metadata entry in the Berksfile" do
|
65
|
-
before(:each) do
|
66
|
-
capture(:stdout) do
|
67
|
-
Berkshelf::InitGenerator.new([target], metadata_entry: true).invoke_all
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
specify do
|
72
|
-
expect(target).to have_structure {
|
73
|
-
file "Berksfile" do
|
74
|
-
contains "metadata"
|
75
|
-
end
|
76
|
-
}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "with the foodcritic option true" do
|
81
|
-
before(:each) do
|
82
|
-
capture(:stdout) do
|
83
|
-
Berkshelf::InitGenerator.new([target], foodcritic: true).invoke_all
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
specify do
|
88
|
-
expect(target).to have_structure {
|
89
|
-
file "Thorfile" do
|
90
|
-
contains "require 'thor/foodcritic'"
|
91
|
-
end
|
92
|
-
file "Gemfile" do
|
93
|
-
contains "gem 'thor-foodcritic'"
|
94
|
-
end
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "with the scmversion option true" do
|
100
|
-
before(:each) do
|
101
|
-
capture(:stdout) do
|
102
|
-
Berkshelf::InitGenerator.new([target], scmversion: true).invoke_all
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
specify do
|
107
|
-
expect(target).to have_structure {
|
108
|
-
file "Thorfile" do
|
109
|
-
contains "require 'thor/scmversion'"
|
110
|
-
end
|
111
|
-
file "Gemfile" do
|
112
|
-
contains "gem 'thor-scmversion'"
|
113
|
-
end
|
114
|
-
}
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "with the bundler option true" do
|
119
|
-
before(:each) do
|
120
|
-
capture(:stdout) do
|
121
|
-
Berkshelf::InitGenerator.new([target], no_bundler: true).invoke_all
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
specify do
|
126
|
-
expect(target).to have_structure {
|
127
|
-
no_file "Gemfile"
|
128
|
-
}
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "given a value for the cookbook_name option" do
|
133
|
-
it "sets the value of cookbook_name attribute to the specified option" do
|
134
|
-
generator = Berkshelf::InitGenerator.new([target], cookbook_name: "nautilus")
|
135
|
-
cookbook = generator.send(:cookbook_name)
|
136
|
-
|
137
|
-
expect(cookbook).to eq("nautilus")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context "when no value for cookbook_name option is specified" do
|
142
|
-
it "infers the name of the cookbook from the directory name" do
|
143
|
-
generator = Berkshelf::InitGenerator.new([target])
|
144
|
-
cookbook = generator.send(:cookbook_name)
|
145
|
-
|
146
|
-
expect(cookbook).to eq("some_cookbook")
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "when skipping git" do
|
151
|
-
before(:each) do
|
152
|
-
generator = Berkshelf::InitGenerator.new([target], skip_git: true)
|
153
|
-
capture(:stdout) { generator.invoke_all }
|
154
|
-
end
|
155
|
-
|
156
|
-
it "does not have a .git directory" do
|
157
|
-
expect(target).to_not have_structure {
|
158
|
-
directory ".git"
|
159
|
-
}
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context "when skipping vagrant" do
|
164
|
-
before(:each) do
|
165
|
-
capture(:stdout) do
|
166
|
-
Berkshelf::InitGenerator.new([target], skip_vagrant: true).invoke_all
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
it "does not have a Vagrantfile" do
|
171
|
-
expect(target).to have_structure {
|
172
|
-
no_file "Vagrantfile"
|
173
|
-
}
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context "given the 'vagrant.omnibus.version' option set" do
|
178
|
-
before do
|
179
|
-
Berkshelf::Config.instance.vagrant.omnibus.version = "11.4.4"
|
180
|
-
capture(:stdout) do
|
181
|
-
Berkshelf::InitGenerator.new([target]).invoke_all
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set" do
|
186
|
-
expect(target).to have_structure {
|
187
|
-
file "Vagrantfile" do
|
188
|
-
contains "config.omnibus.chef_version = '11.4.4'"
|
189
|
-
end
|
190
|
-
}
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context "given the 'vagrant.omnibus.version' option set to 'latest'" do
|
195
|
-
before do
|
196
|
-
Berkshelf::Config.instance.vagrant.omnibus.version = "latest"
|
197
|
-
capture(:stdout) do
|
198
|
-
Berkshelf::InitGenerator.new([target]).invoke_all
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set to :latest" do
|
203
|
-
expect(target).to have_structure {
|
204
|
-
file "Vagrantfile" do
|
205
|
-
contains " config.omnibus.chef_version = 'latest'"
|
206
|
-
end
|
207
|
-
}
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
context "given the 'vagrant.vm.box_url' option set" do
|
212
|
-
before do
|
213
|
-
Berkshelf::Config.instance.vagrant.vm.box_url = "https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box"
|
214
|
-
capture(:stdout) do
|
215
|
-
Berkshelf::InitGenerator.new([target]).invoke_all
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
it "generates a Vagrantfile with the 'config.vm.box_url' value set" do
|
220
|
-
expect(target).to have_structure {
|
221
|
-
file "Vagrantfile" do
|
222
|
-
contains "config.vm.box_url = 'https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box'"
|
223
|
-
end
|
224
|
-
}
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context "with the chef_minitest option true" do
|
229
|
-
before(:each) do
|
230
|
-
allow(Berkshelf::Resolver).to receive(:resolve) { resolver }
|
231
|
-
skip "Runs fine with no mock for the HTTP call on the first pass, subsequent passes throw errors"
|
232
|
-
capture(:stdout) do
|
233
|
-
Berkshelf::InitGenerator.new([target], chef_minitest: true).invoke_all
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
specify do
|
238
|
-
expect(target).to have_structure {
|
239
|
-
file "Berksfile" do
|
240
|
-
contains "cookbook 'minitest-handler'"
|
241
|
-
end
|
242
|
-
file "Vagrantfile" do
|
243
|
-
contains "'recipe[minitest-handler::default]'"
|
244
|
-
end
|
245
|
-
directory "files" do
|
246
|
-
directory "default" do
|
247
|
-
directory "tests" do
|
248
|
-
directory "minitest" do
|
249
|
-
file "default_test.rb" do
|
250
|
-
contains "describe 'some_cookbook::default' do"
|
251
|
-
contains "include Helpers::Some_cookbook"
|
252
|
-
end
|
253
|
-
directory "support" do
|
254
|
-
file "helpers.rb" do
|
255
|
-
contains "module Some_cookbook"
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
}
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|