berkshelf 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -3
  3. data/Gemfile +31 -31
  4. data/Gemfile.lock +3 -3
  5. data/Guardfile +13 -13
  6. data/Rakefile +1 -0
  7. data/Thorfile +16 -16
  8. data/berkshelf.gemspec +35 -35
  9. data/features/step_definitions/chef/config_steps.rb +4 -4
  10. data/features/step_definitions/chef_server_steps.rb +6 -6
  11. data/features/step_definitions/cli_steps.rb +3 -3
  12. data/features/step_definitions/config_steps.rb +5 -5
  13. data/features/step_definitions/filesystem_steps.rb +12 -11
  14. data/features/support/env.rb +21 -21
  15. data/lib/berkshelf.rb +66 -66
  16. data/lib/berkshelf/base_generator.rb +10 -11
  17. data/lib/berkshelf/berksfile.rb +38 -38
  18. data/lib/berkshelf/cached_cookbook.rb +7 -7
  19. data/lib/berkshelf/cli.rb +126 -126
  20. data/lib/berkshelf/commands/shelf.rb +19 -18
  21. data/lib/berkshelf/commands/test_command.rb +2 -2
  22. data/lib/berkshelf/community_rest.rb +38 -38
  23. data/lib/berkshelf/config.rb +42 -41
  24. data/lib/berkshelf/cookbook_generator.rb +38 -38
  25. data/lib/berkshelf/cookbook_store.rb +4 -4
  26. data/lib/berkshelf/core_ext/file_utils.rb +1 -1
  27. data/lib/berkshelf/dependency.rb +23 -21
  28. data/lib/berkshelf/downloader.rb +24 -25
  29. data/lib/berkshelf/errors.rb +17 -17
  30. data/lib/berkshelf/file_syncer.rb +9 -8
  31. data/lib/berkshelf/formatters/human.rb +3 -3
  32. data/lib/berkshelf/formatters/json.rb +2 -2
  33. data/lib/berkshelf/init_generator.rb +64 -64
  34. data/lib/berkshelf/installer.rb +103 -102
  35. data/lib/berkshelf/location.rb +9 -9
  36. data/lib/berkshelf/locations/git.rb +16 -16
  37. data/lib/berkshelf/locations/github.rb +1 -1
  38. data/lib/berkshelf/locations/path.rb +2 -2
  39. data/lib/berkshelf/lockfile.rb +309 -315
  40. data/lib/berkshelf/mixin/git.rb +3 -3
  41. data/lib/berkshelf/packager.rb +4 -4
  42. data/lib/berkshelf/resolver.rb +2 -2
  43. data/lib/berkshelf/resolver/graph.rb +1 -1
  44. data/lib/berkshelf/shell.rb +1 -1
  45. data/lib/berkshelf/source.rb +6 -6
  46. data/lib/berkshelf/source_uri.rb +2 -2
  47. data/lib/berkshelf/ssl_policies.rb +3 -3
  48. data/lib/berkshelf/thor.rb +1 -1
  49. data/lib/berkshelf/uploader.rb +48 -48
  50. data/lib/berkshelf/validator.rb +2 -2
  51. data/lib/berkshelf/version.rb +1 -1
  52. data/lib/berkshelf/visualizer.rb +11 -11
  53. data/spec/config/knife.rb +2 -2
  54. data/spec/fixtures/Berksfile +3 -3
  55. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  56. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  57. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  58. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  59. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  60. data/spec/spec_helper.rb +9 -9
  61. data/spec/support/chef_api.rb +11 -12
  62. data/spec/support/chef_server.rb +10 -10
  63. data/spec/support/git.rb +23 -23
  64. data/spec/support/kitchen.rb +2 -2
  65. data/spec/support/matchers/filepath_matchers.rb +2 -2
  66. data/spec/support/path_helpers.rb +12 -12
  67. data/spec/support/shared_examples/formatter.rb +1 -1
  68. data/spec/unit/berkshelf/berksfile_spec.rb +78 -78
  69. data/spec/unit/berkshelf/cached_cookbook_spec.rb +42 -42
  70. data/spec/unit/berkshelf/cli_spec.rb +6 -6
  71. data/spec/unit/berkshelf/community_rest_spec.rb +83 -83
  72. data/spec/unit/berkshelf/config_spec.rb +13 -13
  73. data/spec/unit/berkshelf/cookbook_generator_spec.rb +39 -39
  74. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  75. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +5 -6
  76. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  77. data/spec/unit/berkshelf/dependency_spec.rb +43 -43
  78. data/spec/unit/berkshelf/downloader_spec.rb +20 -20
  79. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  80. data/spec/unit/berkshelf/file_syncer_spec.rb +86 -86
  81. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  82. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  83. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  84. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  85. data/spec/unit/berkshelf/init_generator_spec.rb +92 -92
  86. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  87. data/spec/unit/berkshelf/location_spec.rb +11 -11
  88. data/spec/unit/berkshelf/locations/base_spec.rb +35 -35
  89. data/spec/unit/berkshelf/locations/git_spec.rb +87 -87
  90. data/spec/unit/berkshelf/locations/path_spec.rb +40 -40
  91. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  92. data/spec/unit/berkshelf/lockfile_spec.rb +197 -197
  93. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  94. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  95. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  96. data/spec/unit/berkshelf/resolver/graph_spec.rb +1 -1
  97. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  98. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  99. data/spec/unit/berkshelf/source_spec.rb +12 -11
  100. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  101. data/spec/unit/berkshelf/ssl_policies_spec.rb +25 -25
  102. data/spec/unit/berkshelf/uploader_spec.rb +54 -54
  103. data/spec/unit/berkshelf/validator_spec.rb +16 -16
  104. data/spec/unit/berkshelf/visualizer_spec.rb +17 -17
  105. data/spec/unit/berkshelf_spec.rb +18 -18
  106. metadata +5 -5
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe HumanFormatter do
5
- it_behaves_like 'a formatter object'
5
+ it_behaves_like "a formatter object"
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe JsonFormatter do
5
- it_behaves_like 'a formatter object'
5
+ it_behaves_like "a formatter object"
6
6
  end
7
7
  end
@@ -1,10 +1,10 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe NullFormatter do
5
- it_behaves_like 'a formatter object'
5
+ it_behaves_like "a formatter object"
6
6
 
7
- it 'does not raise an error for abstract metods methods' do
7
+ it "does not raise an error for abstract metods methods" do
8
8
  expect { subject.install }.to_not raise_error
9
9
  expect { subject.use }.to_not raise_error
10
10
  expect { subject.msg }.to_not raise_error
@@ -1,173 +1,173 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::InitGenerator do
4
4
  let(:target) { tmp_path.join("some_cookbook") }
5
- let(:resolver) { double('resolver') }
6
- let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
5
+ let(:resolver) { double("resolver") }
6
+ let(:kitchen_generator) { double("kitchen-generator", invoke_all: nil) }
7
7
 
8
8
  before do
9
9
  allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
10
10
  FileUtils.mkdir_p(target)
11
- File.open(File.join(target, 'metadata.rb'), 'w') do |f|
11
+ File.open(File.join(target, "metadata.rb"), "w") do |f|
12
12
  f.write("name 'some_cookbook'")
13
13
  end
14
14
  end
15
15
 
16
- context 'with default options' do
16
+ context "with default options" do
17
17
  before do
18
- capture(:stdout) {
18
+ capture(:stdout) do
19
19
  Berkshelf::InitGenerator.new([target]).invoke_all
20
- }
20
+ end
21
21
  end
22
22
 
23
23
  specify do
24
24
  expect(target).to have_structure {
25
- file '.gitignore'
26
- file 'Berksfile'
27
- file 'Gemfile'
28
- file 'Vagrantfile' do
29
- contains %(recipe[some_cookbook::default])
30
- contains %(config.omnibus.chef_version = 'latest')
31
- contains %(config.vm.box = 'bento/ubuntu-14.04')
25
+ file ".gitignore"
26
+ file "Berksfile"
27
+ file "Gemfile"
28
+ file "Vagrantfile" do
29
+ contains %{recipe[some_cookbook::default]}
30
+ contains %{config.omnibus.chef_version = 'latest'}
31
+ contains %{config.vm.box = 'bento/ubuntu-14.04'}
32
32
  end
33
- file 'chefignore'
33
+ file "chefignore"
34
34
  }
35
35
  end
36
36
  end
37
37
 
38
- context 'with a chefignore' do
38
+ context "with a chefignore" do
39
39
  before(:each) do
40
- capture(:stdout) {
40
+ capture(:stdout) do
41
41
  Berkshelf::InitGenerator.new([target], chefignore: true).invoke_all
42
- }
42
+ end
43
43
  end
44
44
 
45
45
  specify do
46
46
  expect(target).to have_structure {
47
- file 'Berksfile'
48
- file 'chefignore'
47
+ file "Berksfile"
48
+ file "chefignore"
49
49
  }
50
50
  end
51
51
  end
52
52
 
53
- context 'with no metadata' do
53
+ context "with no metadata" do
54
54
  before do
55
- FileUtils.rm(File.join(target, 'metadata.rb'))
56
- expect {
55
+ FileUtils.rm(File.join(target, "metadata.rb"))
56
+ expect do
57
57
  Berkshelf::InitGenerator.new([target]).invoke_all
58
- }.to raise_error(Berkshelf::NotACookbook)
58
+ end.to raise_error(Berkshelf::NotACookbook)
59
59
  end
60
60
  end
61
61
 
62
- context 'with a metadata entry in the Berksfile' do
62
+ context "with a metadata entry in the Berksfile" do
63
63
  before(:each) do
64
- capture(:stdout) {
64
+ capture(:stdout) do
65
65
  Berkshelf::InitGenerator.new([target], metadata_entry: true).invoke_all
66
- }
66
+ end
67
67
  end
68
68
 
69
69
  specify do
70
70
  expect(target).to have_structure {
71
- file 'Berksfile' do
72
- contains 'metadata'
71
+ file "Berksfile" do
72
+ contains "metadata"
73
73
  end
74
74
  }
75
75
  end
76
76
  end
77
77
 
78
- context 'with the foodcritic option true' do
78
+ context "with the foodcritic option true" do
79
79
  before(:each) do
80
- capture(:stdout) {
80
+ capture(:stdout) do
81
81
  Berkshelf::InitGenerator.new([target], foodcritic: true).invoke_all
82
- }
82
+ end
83
83
  end
84
84
 
85
85
  specify do
86
86
  expect(target).to have_structure {
87
- file 'Thorfile' do
87
+ file "Thorfile" do
88
88
  contains "require 'thor/foodcritic'"
89
89
  end
90
- file 'Gemfile' do
90
+ file "Gemfile" do
91
91
  contains "gem 'thor-foodcritic'"
92
92
  end
93
93
  }
94
94
  end
95
95
  end
96
96
 
97
- context 'with the scmversion option true' do
97
+ context "with the scmversion option true" do
98
98
  before(:each) do
99
- capture(:stdout) {
99
+ capture(:stdout) do
100
100
  Berkshelf::InitGenerator.new([target], scmversion: true).invoke_all
101
- }
101
+ end
102
102
  end
103
103
 
104
104
  specify do
105
105
  expect(target).to have_structure {
106
- file 'Thorfile' do
106
+ file "Thorfile" do
107
107
  contains "require 'thor/scmversion'"
108
108
  end
109
- file 'Gemfile' do
109
+ file "Gemfile" do
110
110
  contains "gem 'thor-scmversion'"
111
111
  end
112
112
  }
113
113
  end
114
114
  end
115
115
 
116
- context 'with the bundler option true' do
116
+ context "with the bundler option true" do
117
117
  before(:each) do
118
- capture(:stdout) {
118
+ capture(:stdout) do
119
119
  Berkshelf::InitGenerator.new([target], no_bundler: true).invoke_all
120
- }
120
+ end
121
121
  end
122
122
 
123
123
  specify do
124
124
  expect(target).to have_structure {
125
- no_file 'Gemfile'
125
+ no_file "Gemfile"
126
126
  }
127
127
  end
128
128
  end
129
129
 
130
- context 'given a value for the cookbook_name option' do
131
- it 'sets the value of cookbook_name attribute to the specified option' do
132
- generator = Berkshelf::InitGenerator.new([target], cookbook_name: 'nautilus')
130
+ context "given a value for the cookbook_name option" do
131
+ it "sets the value of cookbook_name attribute to the specified option" do
132
+ generator = Berkshelf::InitGenerator.new([target], cookbook_name: "nautilus")
133
133
  cookbook = generator.send(:cookbook_name)
134
134
 
135
- expect(cookbook).to eq('nautilus')
135
+ expect(cookbook).to eq("nautilus")
136
136
  end
137
137
  end
138
138
 
139
- context 'when no value for cookbook_name option is specified' do
140
- it 'infers the name of the cookbook from the directory name' do
139
+ context "when no value for cookbook_name option is specified" do
140
+ it "infers the name of the cookbook from the directory name" do
141
141
  generator = Berkshelf::InitGenerator.new([target])
142
142
  cookbook = generator.send(:cookbook_name)
143
143
 
144
- expect(cookbook).to eq('some_cookbook')
144
+ expect(cookbook).to eq("some_cookbook")
145
145
  end
146
146
  end
147
147
 
148
- context 'when skipping git' do
148
+ context "when skipping git" do
149
149
  before(:each) do
150
150
  generator = Berkshelf::InitGenerator.new([target], skip_git: true)
151
151
  capture(:stdout) { generator.invoke_all }
152
152
  end
153
153
 
154
- it 'does not have a .git directory' do
154
+ it "does not have a .git directory" do
155
155
  expect(target).to_not have_structure {
156
- directory '.git'
156
+ directory ".git"
157
157
  }
158
158
  end
159
159
  end
160
160
 
161
- context 'when skipping vagrant' do
161
+ context "when skipping vagrant" do
162
162
  before(:each) do
163
- capture(:stdout) {
163
+ capture(:stdout) do
164
164
  Berkshelf::InitGenerator.new([target], skip_vagrant: true).invoke_all
165
- }
165
+ end
166
166
  end
167
167
 
168
- it 'does not have a Vagrantfile' do
168
+ it "does not have a Vagrantfile" do
169
169
  expect(target).to have_structure {
170
- no_file 'Vagrantfile'
170
+ no_file "Vagrantfile"
171
171
  }
172
172
  end
173
173
  end
@@ -175,14 +175,14 @@ describe Berkshelf::InitGenerator do
175
175
  context "given the 'vagrant.omnibus.version' option set" do
176
176
  before do
177
177
  Berkshelf::Config.instance.vagrant.omnibus.version = "11.4.4"
178
- capture(:stdout) {
178
+ capture(:stdout) do
179
179
  Berkshelf::InitGenerator.new([target]).invoke_all
180
- }
180
+ end
181
181
  end
182
182
 
183
183
  it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set" do
184
184
  expect(target).to have_structure {
185
- file 'Vagrantfile' do
185
+ file "Vagrantfile" do
186
186
  contains "config.omnibus.chef_version = '11.4.4'"
187
187
  end
188
188
  }
@@ -192,14 +192,14 @@ describe Berkshelf::InitGenerator do
192
192
  context "given the 'vagrant.omnibus.version' option set to 'latest'" do
193
193
  before do
194
194
  Berkshelf::Config.instance.vagrant.omnibus.version = "latest"
195
- capture(:stdout) {
195
+ capture(:stdout) do
196
196
  Berkshelf::InitGenerator.new([target]).invoke_all
197
- }
197
+ end
198
198
  end
199
199
 
200
200
  it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set to :latest" do
201
201
  expect(target).to have_structure {
202
- file 'Vagrantfile' do
202
+ file "Vagrantfile" do
203
203
  contains " config.omnibus.chef_version = 'latest'"
204
204
  end
205
205
  }
@@ -209,54 +209,54 @@ describe Berkshelf::InitGenerator do
209
209
  context "given the 'vagrant.vm.box_url' option set" do
210
210
  before do
211
211
  Berkshelf::Config.instance.vagrant.vm.box_url = "https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box"
212
- capture(:stdout) {
212
+ capture(:stdout) do
213
213
  Berkshelf::InitGenerator.new([target]).invoke_all
214
- }
214
+ end
215
215
  end
216
216
 
217
217
  it "generates a Vagrantfile with the 'config.vm.box_url' value set" do
218
218
  expect(target).to have_structure {
219
- file 'Vagrantfile' do
219
+ file "Vagrantfile" do
220
220
  contains "config.vm.box_url = 'https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box'"
221
221
  end
222
222
  }
223
223
  end
224
224
  end
225
225
 
226
- context 'with the chef_minitest option true' do
226
+ context "with the chef_minitest option true" do
227
227
  before(:each) do
228
- allow(Berkshelf::Resolver).to receive(:resolve) { resolver }
229
- skip 'Runs fine with no mock for the HTTP call on the first pass, subsequent passes throw errors'
230
- capture(:stdout) {
231
- Berkshelf::InitGenerator.new([target], chef_minitest: true).invoke_all
232
- }
228
+ allow(Berkshelf::Resolver).to receive(:resolve) { resolver }
229
+ skip "Runs fine with no mock for the HTTP call on the first pass, subsequent passes throw errors"
230
+ capture(:stdout) do
231
+ Berkshelf::InitGenerator.new([target], chef_minitest: true).invoke_all
232
+ end
233
233
  end
234
234
 
235
235
  specify do
236
236
  expect(target).to have_structure {
237
- file 'Berksfile' do
237
+ file "Berksfile" do
238
238
  contains "cookbook 'minitest-handler'"
239
239
  end
240
- file 'Vagrantfile' do
240
+ file "Vagrantfile" do
241
241
  contains "'recipe[minitest-handler::default]'"
242
242
  end
243
- directory 'files' do
244
- directory 'default' do
245
- directory 'tests' do
246
- directory 'minitest' do
247
- file 'default_test.rb' do
248
- contains "describe 'some_cookbook::default' do"
249
- contains 'include Helpers::Some_cookbook'
250
- end
251
- directory 'support' do
252
- file 'helpers.rb' do
253
- contains 'module Some_cookbook'
254
- end
255
- end
256
- end
257
- end
258
- end
259
- end
243
+ directory "files" do
244
+ directory "default" do
245
+ directory "tests" do
246
+ directory "minitest" do
247
+ file "default_test.rb" do
248
+ contains "describe 'some_cookbook::default' do"
249
+ contains "include Helpers::Some_cookbook"
250
+ end
251
+ directory "support" do
252
+ file "helpers.rb" do
253
+ contains "module Some_cookbook"
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
259
+ end
260
260
  }
261
261
  end
262
262
  end
@@ -1,13 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::Installer do
4
- let(:berksfile) { double('berksfile', lockfile: lockfile) }
5
- let(:lockfile) { double('lockfile') }
4
+ let(:berksfile) { double("berksfile", lockfile: lockfile) }
5
+ let(:lockfile) { double("lockfile") }
6
6
  subject { described_class.new(berksfile) }
7
7
 
8
8
  describe "#build_universe" do
9
- let(:source_one) { double('one', uri: 'https://supermarket.chef.io') }
10
- let(:source_two) { double('two', uri: 'https://api.chef.org') }
9
+ let(:source_one) { double("one", uri: "https://supermarket.chef.io") }
10
+ let(:source_two) { double("two", uri: "https://api.chef.org") }
11
11
  let(:sources) { [ source_one, source_two ] }
12
12
 
13
13
  before { allow(berksfile).to receive_messages(sources: sources) }
@@ -21,15 +21,15 @@ describe Berkshelf::Installer do
21
21
  end
22
22
 
23
23
  describe "#run" do
24
- context 'when a lockfile is not present' do
24
+ context "when a lockfile is not present" do
25
25
  skip
26
26
  end
27
27
 
28
- context 'when a value for :except is given' do
28
+ context "when a value for :except is given" do
29
29
  skip
30
30
  end
31
31
 
32
- context 'when a value for :only is given' do
32
+ context "when a value for :only is given" do
33
33
  skip
34
34
  end
35
35
  end
@@ -1,27 +1,27 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe Location do
5
- let(:dependency) { double(name: 'bacon') }
5
+ let(:dependency) { double(name: "bacon") }
6
6
 
7
- describe '.init' do
8
- it 'finds a :path location by key' do
9
- instance = described_class.init(dependency, path: '~/Dev/meats/bacon')
7
+ describe ".init" do
8
+ it "finds a :path location by key" do
9
+ instance = described_class.init(dependency, path: "~/Dev/meats/bacon")
10
10
  expect(instance).to be_a(PathLocation)
11
11
  end
12
12
 
13
- it 'finds a :git location by key' do
14
- instance = described_class.init(dependency, git: 'git://foo.com/meats/bacon.git')
13
+ it "finds a :git location by key" do
14
+ instance = described_class.init(dependency, git: "git://foo.com/meats/bacon.git")
15
15
  expect(instance).to be_a(GitLocation)
16
16
  end
17
17
 
18
- it 'finds a :github location by key' do
19
- instance = described_class.init(dependency, github: 'meats/bacon')
18
+ it "finds a :github location by key" do
19
+ instance = described_class.init(dependency, github: "meats/bacon")
20
20
  expect(instance).to be_a(GitLocation)
21
21
  end
22
22
 
23
- it 'returns nil when a location cannot be found' do
24
- instance = described_class.init(dependency, lamesauce: 'meats/bacon')
23
+ it "returns nil when a location cannot be found" do
24
+ instance = described_class.init(dependency, lamesauce: "meats/bacon")
25
25
  expect(instance).to be_nil
26
26
  end
27
27
  end