berkshelf 7.0.8 → 8.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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/Rakefile +3 -3
  4. data/berkshelf.gemspec +3 -4
  5. data/bin/berks +1 -1
  6. data/lib/berkshelf/api_client/chef_server_connection.rb +7 -8
  7. data/lib/berkshelf/api_client/connection.rb +1 -1
  8. data/lib/berkshelf/api_client/remote_cookbook.rb +1 -1
  9. data/lib/berkshelf/api_client.rb +2 -2
  10. data/lib/berkshelf/berksfile.rb +44 -42
  11. data/lib/berkshelf/cached_cookbook.rb +5 -3
  12. data/lib/berkshelf/chef_config_compat.rb +1 -1
  13. data/lib/berkshelf/chef_repo_universe.rb +4 -2
  14. data/lib/berkshelf/cli.rb +6 -6
  15. data/lib/berkshelf/commands/shelf.rb +1 -1
  16. data/lib/berkshelf/community_rest.rb +6 -6
  17. data/lib/berkshelf/config.rb +3 -3
  18. data/lib/berkshelf/cookbook_store.rb +2 -4
  19. data/lib/berkshelf/core_ext/file_utils.rb +3 -3
  20. data/lib/berkshelf/core_ext.rb +1 -1
  21. data/lib/berkshelf/dependency.rb +1 -1
  22. data/lib/berkshelf/downloader.rb +9 -6
  23. data/lib/berkshelf/errors.rb +5 -2
  24. data/lib/berkshelf/file_syncer.rb +10 -12
  25. data/lib/berkshelf/formatters/human.rb +1 -1
  26. data/lib/berkshelf/formatters/json.rb +1 -1
  27. data/lib/berkshelf/installer.rb +8 -8
  28. data/lib/berkshelf/location.rb +4 -4
  29. data/lib/berkshelf/locations/git.rb +6 -12
  30. data/lib/berkshelf/locations/github.rb +1 -1
  31. data/lib/berkshelf/lockfile.rb +11 -11
  32. data/lib/berkshelf/logger.rb +4 -2
  33. data/lib/berkshelf/mixin/git.rb +3 -3
  34. data/lib/berkshelf/packager.rb +5 -7
  35. data/lib/berkshelf/resolver.rb +1 -1
  36. data/lib/berkshelf/ridley_compat.rb +1 -1
  37. data/lib/berkshelf/shell.rb +2 -1
  38. data/lib/berkshelf/shell_out.rb +4 -3
  39. data/lib/berkshelf/source.rb +8 -7
  40. data/lib/berkshelf/source_uri.rb +1 -1
  41. data/lib/berkshelf/ssl_policies.rb +6 -10
  42. data/lib/berkshelf/thor.rb +1 -1
  43. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  44. data/lib/berkshelf/thor_ext.rb +1 -1
  45. data/lib/berkshelf/uploader.rb +37 -35
  46. data/lib/berkshelf/validator.rb +2 -8
  47. data/lib/berkshelf/version.rb +1 -1
  48. data/lib/berkshelf/visualizer.rb +3 -3
  49. data/lib/berkshelf.rb +8 -9
  50. data/spec/config/knife.rb +2 -2
  51. data/spec/spec_helper.rb +1 -1
  52. data/spec/support/chef_server.rb +2 -2
  53. data/spec/support/git.rb +19 -19
  54. data/spec/support/path_helpers.rb +4 -4
  55. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
  56. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
  57. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
  58. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
  59. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
  60. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
  61. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
  62. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
  63. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
  64. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
  65. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  66. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  67. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
  68. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  69. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
  70. data/spec/unit/berkshelf/berksfile_spec.rb +7 -7
  71. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  72. data/spec/unit/berkshelf/cli_spec.rb +1 -2
  73. data/spec/unit/berkshelf/community_rest_spec.rb +1 -1
  74. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
  75. data/spec/unit/berkshelf/dependency_spec.rb +6 -6
  76. data/spec/unit/berkshelf/downloader_spec.rb +4 -8
  77. data/spec/unit/berkshelf/location_spec.rb +1 -1
  78. data/spec/unit/berkshelf/locations/base_spec.rb +1 -2
  79. data/spec/unit/berkshelf/locations/git_spec.rb +2 -5
  80. data/spec/unit/berkshelf/locations/path_spec.rb +1 -2
  81. data/spec/unit/berkshelf/lockfile_spec.rb +9 -18
  82. data/spec/unit/berkshelf/ridley_compat_spec.rb +2 -2
  83. data/spec/unit/berkshelf/source_spec.rb +30 -19
  84. data/spec/unit/berkshelf/ssl_policies_spec.rb +3 -6
  85. data/spec/unit/berkshelf/uploader_spec.rb +6 -10
  86. data/spec/unit/berkshelf/validator_spec.rb +0 -13
  87. metadata +26 -10
@@ -4,8 +4,9 @@ module Berkshelf
4
4
  describe Source do
5
5
  let(:berksfile) { double("Berksfile", filepath: "/test/Berksfile") }
6
6
  let(:arguments) { [] }
7
+ let(:kwargs) { {} }
7
8
  let(:config) { Config.new }
8
- subject(:instance) { described_class.new(berksfile, *arguments) }
9
+ subject(:instance) { described_class.new(berksfile, *arguments, **kwargs) }
9
10
  before do
10
11
  allow(Berkshelf::Config).to receive(:instance).and_return(config)
11
12
  end
@@ -19,7 +20,8 @@ module Berkshelf
19
20
  end
20
21
 
21
22
  context "with a string argument and options" do
22
- let(:arguments) { ["https://example.com", { key: "value" }] }
23
+ let(:arguments) { ["https://example.com" ] }
24
+ let(:kwargs) { { key: "value" } }
23
25
  it { is_expected.to eq :supermarket }
24
26
  end
25
27
 
@@ -29,7 +31,8 @@ module Berkshelf
29
31
  end
30
32
 
31
33
  context "with a symbol argument and options" do
32
- let(:arguments) { [:chef_server, { key: "value" }] }
34
+ let(:arguments) { [:chef_server ] }
35
+ let(:kwargs) { { key: "value" } }
33
36
  it { is_expected.to eq :chef_server }
34
37
  end
35
38
 
@@ -44,7 +47,8 @@ module Berkshelf
44
47
  end
45
48
 
46
49
  context "with a hash argument and disconnected options" do
47
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
50
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
51
+ let(:kwargs) { { key: "value" } }
48
52
  it { is_expected.to eq :artifactory }
49
53
  end
50
54
  end
@@ -58,7 +62,8 @@ module Berkshelf
58
62
  end
59
63
 
60
64
  context "with a string argument and options" do
61
- let(:arguments) { ["https://example.com", { key: "value" }] }
65
+ let(:arguments) { ["https://example.com" ] }
66
+ let(:kwargs) { { key: "value" } }
62
67
  it { is_expected.to eq "https://example.com" }
63
68
  end
64
69
 
@@ -69,7 +74,8 @@ module Berkshelf
69
74
  end
70
75
 
71
76
  context "with a symbol argument and options" do
72
- let(:arguments) { [:chef_server, { key: "value" }] }
77
+ let(:arguments) { [:chef_server] }
78
+ let(:kwargs) { { key: "value" } }
73
79
  before { config.chef.chef_server_url = "https://chefserver/" }
74
80
  it { is_expected.to eq "https://chefserver/" }
75
81
  end
@@ -85,7 +91,8 @@ module Berkshelf
85
91
  end
86
92
 
87
93
  context "with a hash argument and disconnected options" do
88
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
94
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" } ] }
95
+ let(:kwargs) { { key: "value" } }
89
96
  it { is_expected.to eq "https://example.com/api/chef/chef-virtual" }
90
97
  end
91
98
 
@@ -96,7 +103,7 @@ module Berkshelf
96
103
 
97
104
  context "with a chef_repo source" do
98
105
  let(:arguments) { [{ chef_repo: "." }] }
99
- it { is_expected.to eq(windows? ? "file://C/test" : "file:///test") }
106
+ it { is_expected.to eq(windows? ? "file://D/test" : "file:///test") }
100
107
  end
101
108
  end
102
109
 
@@ -110,16 +117,17 @@ module Berkshelf
110
117
  # Check all baseline values.
111
118
  its([:timeout]) { is_expected.to eq 30 }
112
119
  its([:open_timeout]) { is_expected.to eq 3 }
113
- its([:ssl, :verify]) { is_expected.to be true }
114
- its([:ssl, :ca_file]) { is_expected.to be_nil }
115
- its([:ssl, :ca_path]) { is_expected.to be_nil }
116
- its([:ssl, :client_cert]) { is_expected.to be_nil }
117
- its([:ssl, :client_key]) { is_expected.to be_nil }
118
- its([:ssl, :cert_store]) { is_expected.to be_a(OpenSSL::X509::Store) }
120
+ its(%i{ssl verify}) { is_expected.to be true }
121
+ its(%i{ssl ca_file}) { is_expected.to be_nil }
122
+ its(%i{ssl ca_path}) { is_expected.to be_nil }
123
+ its(%i{ssl client_cert}) { is_expected.to be_nil }
124
+ its(%i{ssl client_key}) { is_expected.to be_nil }
125
+ its(%i{ssl cert_store}) { is_expected.to be_a(OpenSSL::X509::Store) }
119
126
  end
120
127
 
121
128
  context "with a string argument and options" do
122
- let(:arguments) { ["https://example.com", { key: "value" }] }
129
+ let(:arguments) { ["https://example.com"] }
130
+ let(:kwargs) { { key: "value" } }
123
131
  its([:key]) { is_expected.to eq "value" }
124
132
  end
125
133
 
@@ -129,7 +137,8 @@ module Berkshelf
129
137
  end
130
138
 
131
139
  context "with a symbol argument and options" do
132
- let(:arguments) { [:chef_server, { key: "value" }] }
140
+ let(:arguments) { [:chef_server] }
141
+ let(:kwargs) { { key: "value" } }
133
142
  its([:key]) { is_expected.to eq "value" }
134
143
  end
135
144
 
@@ -144,7 +153,8 @@ module Berkshelf
144
153
  end
145
154
 
146
155
  context "with a hash argument and disconnected options" do
147
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
156
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" } ] }
157
+ let(:kwargs) { { key: "value" } }
148
158
  its([:key]) { is_expected.to eq "value" }
149
159
  end
150
160
 
@@ -156,7 +166,7 @@ module Berkshelf
156
166
 
157
167
  context "with a chef_repo source" do
158
168
  let(:arguments) { [{ chef_repo: "." }] }
159
- its([:path]) { is_expected.to eq(windows? ? "C:/test" : "/test") }
169
+ its([:path]) { is_expected.to eq(windows? ? "D:/test" : "/test") }
160
170
  end
161
171
  end
162
172
 
@@ -198,7 +208,8 @@ module Berkshelf
198
208
  [
199
209
  APIClient::RemoteCookbook.new("cb1", "1.0.8"),
200
210
  APIClient::RemoteCookbook.new("cb1", "1.0.22"),
201
- ] end
211
+ ]
212
+ end
202
213
 
203
214
  before do
204
215
  allow_any_instance_of(APIClient::Connection).to receive(:universe).and_return(cookbooks)
@@ -16,19 +16,17 @@ describe Berkshelf::SSLPolicy do
16
16
  cookbook_copyright: "user",
17
17
  cookbook_email: "user@example.com",
18
18
  cookbook_license: "apachev2",
19
- trusted_certs_dir: self_signed_crt_path
20
- )
19
+ trusted_certs_dir: self_signed_crt_path)
21
20
  end
22
21
 
23
22
  let(:berkshelf_config) do
24
23
  double(Berkshelf::Config,
25
24
  ssl: double(verify: true),
26
- chef: chef_config
27
- )
25
+ chef: chef_config)
28
26
  end
29
27
 
30
28
  subject do
31
- Berkshelf::SSLPolicy.new()
29
+ Berkshelf::SSLPolicy.new
32
30
  end
33
31
 
34
32
  before do
@@ -75,7 +73,6 @@ describe Berkshelf::SSLPolicy do
75
73
  before do
76
74
  allow(chef_config).to receive_messages(trusted_certs_dir: self_signed_crt_path_windows_backslashes)
77
75
  allow(File).to receive(:exist?).with(self_signed_crt_path_windows_forwardslashes).and_return(true)
78
- allow(Dir).to receive(:chdir).with(self_signed_crt_path_windows_forwardslashes)
79
76
  end
80
77
 
81
78
  it "replaces the backslashes in trusted_certs_dir from Berkshelf config with forwardslashes" do
@@ -5,14 +5,12 @@ module Berkshelf
5
5
  let(:berksfile) do
6
6
  double(Berksfile,
7
7
  lockfile: lockfile,
8
- dependencies: []
9
- )
8
+ dependencies: [])
10
9
  end
11
10
 
12
11
  let(:lockfile) do
13
12
  double(Lockfile,
14
- graph: graph
15
- )
13
+ graph: graph)
16
14
  end
17
15
 
18
16
  let(:graph) { double(Lockfile::Graph, locks: {}) }
@@ -48,7 +46,7 @@ module Berkshelf
48
46
  end
49
47
 
50
48
  describe "#run" do
51
- let(:options) { Hash.new }
49
+ let(:options) { {} }
52
50
 
53
51
  let(:chef_config) do
54
52
  double(Berkshelf::ChefConfigCompat,
@@ -61,15 +59,13 @@ module Berkshelf
61
59
  cookbook_copyright: "user",
62
60
  cookbook_email: "user@example.com",
63
61
  cookbook_license: "apachev2",
64
- trusted_certs_dir: self_signed_crt_path
65
- )
62
+ trusted_certs_dir: self_signed_crt_path)
66
63
  end
67
64
 
68
65
  let(:berkshelf_config) do
69
66
  double(Config,
70
67
  ssl: double(verify: true),
71
- chef: chef_config
72
- )
68
+ chef: chef_config)
73
69
  end
74
70
 
75
71
  let(:default_ridley_options) do
@@ -211,7 +207,7 @@ module Berkshelf
211
207
  subject { described_class.new(berksfile).send(:lookup_dependencies, "runit") }
212
208
 
213
209
  it "returns array of cookbook's dependencies and their dependencies" do
214
- expect(subject).to eq ["build-essential", "yum", "yum-epel"]
210
+ expect(subject).to eq %w{build-essential yum yum-epel}
215
211
  end
216
212
  end
217
213
  end
@@ -4,10 +4,6 @@ describe Berkshelf::Validator do
4
4
  describe "#validate_files" do
5
5
  let(:cookbook) { double("cookbook", cookbook_name: "cookbook", path: "path") }
6
6
 
7
- before do
8
- allow(Dir).to receive(:chdir) { |&block| block.call }
9
- end
10
-
11
7
  it "raises an error when the cookbook has spaces in the files" do
12
8
  allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
13
9
  expect do
@@ -21,14 +17,5 @@ describe Berkshelf::Validator do
21
17
  subject.validate_files(cookbook)
22
18
  end.to_not raise_error
23
19
  end
24
-
25
- it "does not raise an exception with spaces in the path" do
26
- allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
27
- allow_any_instance_of(Pathname).to receive(:dirname).and_return("/there are/spaces/in this")
28
-
29
- expect do
30
- subject.validate_files(cookbook)
31
- end.to_not raise_error
32
- end
33
20
  end
34
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.8
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,10 +9,10 @@ authors:
9
9
  - Michael Ivey
10
10
  - Justin Campbell
11
11
  - Seth Vargo
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2019-03-18 00:00:00.000000000 Z
15
+ date: 2022-04-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: '0.4'
133
+ version: 1.1.4
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: '0.4'
143
+ version: 1.1.4
144
144
  - - "<"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '2.0'
@@ -164,14 +164,14 @@ dependencies:
164
164
  requirements:
165
165
  - - ">="
166
166
  - !ruby/object:Gem::Version
167
- version: 13.6.52
167
+ version: 15.7.32
168
168
  type: :runtime
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 13.6.52
174
+ version: 15.7.32
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: chef-config
177
177
  requirement: !ruby/object:Gem::Requirement
@@ -314,7 +314,23 @@ files:
314
314
  - spec/support/matchers/filepath_matchers.rb
315
315
  - spec/support/path_helpers.rb
316
316
  - spec/support/shared_examples/formatter.rb
317
+ - spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb
318
+ - spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h
319
+ - spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb
320
+ - spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb
321
+ - spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb
322
+ - spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb
323
+ - spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h
324
+ - spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb
325
+ - spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb
326
+ - spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb
327
+ - spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb
328
+ - spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h
329
+ - spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb
330
+ - spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb
331
+ - spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb
317
332
  - spec/unit/berkshelf/berksfile_spec.rb
333
+ - spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb
318
334
  - spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb
319
335
  - spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb
320
336
  - spec/unit/berkshelf/berkshelf/api_client_spec.rb
@@ -359,7 +375,7 @@ homepage: https://docs.chef.io/berkshelf.html
359
375
  licenses:
360
376
  - Apache-2.0
361
377
  metadata: {}
362
- post_install_message:
378
+ post_install_message:
363
379
  rdoc_options: []
364
380
  require_paths:
365
381
  - lib
@@ -374,8 +390,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
374
390
  - !ruby/object:Gem::Version
375
391
  version: 2.0.0
376
392
  requirements: []
377
- rubygems_version: 3.0.3
378
- signing_key:
393
+ rubygems_version: 3.3.7
394
+ signing_key:
379
395
  specification_version: 4
380
396
  summary: Manages a Chef cookbook's dependencies
381
397
  test_files: []