berkshelf 7.0.9 → 7.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.
- checksums.yaml +4 -4
- data/Gemfile +3 -12
- data/Rakefile +2 -2
- data/berkshelf.gemspec +3 -4
- data/bin/berks +1 -1
- data/lib/berkshelf.rb +7 -8
- data/lib/berkshelf/api_client.rb +2 -2
- data/lib/berkshelf/api_client/chef_server_connection.rb +4 -6
- data/lib/berkshelf/api_client/remote_cookbook.rb +1 -1
- data/lib/berkshelf/berksfile.rb +32 -32
- data/lib/berkshelf/chef_config_compat.rb +1 -1
- data/lib/berkshelf/cli.rb +5 -5
- data/lib/berkshelf/community_rest.rb +3 -3
- data/lib/berkshelf/config.rb +2 -2
- data/lib/berkshelf/cookbook_store.rb +2 -4
- data/lib/berkshelf/core_ext/file_utils.rb +3 -3
- data/lib/berkshelf/downloader.rb +5 -5
- data/lib/berkshelf/errors.rb +3 -0
- data/lib/berkshelf/file_syncer.rb +10 -12
- data/lib/berkshelf/installer.rb +7 -7
- data/lib/berkshelf/location.rb +3 -3
- data/lib/berkshelf/locations/git.rb +6 -12
- data/lib/berkshelf/lockfile.rb +9 -9
- data/lib/berkshelf/mixin/git.rb +2 -2
- data/lib/berkshelf/packager.rb +5 -7
- data/lib/berkshelf/shell.rb +1 -1
- data/lib/berkshelf/shell_out.rb +4 -3
- data/lib/berkshelf/source.rb +2 -2
- data/lib/berkshelf/source_uri.rb +1 -1
- data/lib/berkshelf/ssl_policies.rb +5 -7
- data/lib/berkshelf/uploader.rb +36 -36
- data/lib/berkshelf/validator.rb +2 -8
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf/visualizer.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/support/git.rb +18 -18
- data/spec/support/path_helpers.rb +4 -4
- data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
- data/spec/unit/berkshelf/locations/git_spec.rb +2 -5
- data/spec/unit/berkshelf/ridley_compat_spec.rb +1 -1
- data/spec/unit/berkshelf/source_spec.rb +22 -12
- data/spec/unit/berkshelf/ssl_policies_spec.rb +0 -1
- data/spec/unit/berkshelf/validator_spec.rb +0 -13
- metadata +11 -10
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Berkshelf::APIClient::ChefServerConnection do
|
4
|
+
let(:instance) do
|
5
|
+
described_class.new(
|
6
|
+
server_url: "https://chef.example.org/organizations/foobar",
|
7
|
+
timeout: 30,
|
8
|
+
open_timeout: 3,
|
9
|
+
ssl: {}
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#universe" do
|
14
|
+
before do
|
15
|
+
body_response = %q{{"ruby":{"1.2.3":{"endpoint_priority":0,"platforms":{},"dependencies":{"build-essential":">= 1.2.2"},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"},"2.0.0":{"endpoint_priority":0,"platforms":{},"dependencies":{"build-essential":">= 1.2.2"},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"}},"elixir":{"1.0.0":{"endpoint_priority":0,"platforms":{"CentOS":"= 6.0.0"},"dependencies":{},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"}}}}
|
16
|
+
|
17
|
+
stub_request(:get, "https://chef.example.org/organizations/foobar/universe")
|
18
|
+
.to_return(status: 200, body: body_response, headers: { "Content-Type" => "application/json; charset=utf-8" })
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { instance.universe }
|
22
|
+
|
23
|
+
it "returns an array of APIClient::RemoteCookbook" do
|
24
|
+
expect(subject).to be_a(Array)
|
25
|
+
|
26
|
+
subject.each do |remote|
|
27
|
+
expect(remote).to be_a(Berkshelf::APIClient::RemoteCookbook)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "contains a item for each dependency" do
|
32
|
+
expect(subject.size).to eq(3)
|
33
|
+
expect(subject[0].name).to eql("ruby")
|
34
|
+
expect(subject[0].version).to eql("1.2.3")
|
35
|
+
expect(subject[1].name).to eql("ruby")
|
36
|
+
expect(subject[1].version).to eql("2.0.0")
|
37
|
+
expect(subject[2].name).to eql("elixir")
|
38
|
+
expect(subject[2].version).to eql("1.0.0")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has the dependencies for each" do
|
42
|
+
expect(subject[0].dependencies).to include("build-essential" => ">= 1.2.2")
|
43
|
+
expect(subject[1].dependencies).to include("build-essential" => ">= 1.2.2")
|
44
|
+
expect(subject[2].dependencies).to be_empty
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has the platforms for each" do
|
48
|
+
expect(subject[0].platforms).to be_empty
|
49
|
+
expect(subject[1].platforms).to be_empty
|
50
|
+
expect(subject[2].platforms).to include("CentOS" => "= 6.0.0")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "has a location_path for each" do
|
54
|
+
subject.each do |remote|
|
55
|
+
expect(remote.location_path).to_not be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a location_type for each" do
|
60
|
+
subject.each do |remote|
|
61
|
+
expect(remote.location_type).to_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -7,12 +7,12 @@ describe FileUtils do
|
|
7
7
|
let(:options) { {} }
|
8
8
|
|
9
9
|
it "uses mv by default" do
|
10
|
-
expect(FileUtils).to receive(:old_mv).with(src, dest, options)
|
10
|
+
expect(FileUtils).to receive(:old_mv).with(src, dest, **options)
|
11
11
|
FileUtils.mv(src, dest, options)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "replaces mv with cp_r and rm_rf" do
|
15
|
-
expect(FileUtils).to receive(:cp_r).with(src, dest, options)
|
15
|
+
expect(FileUtils).to receive(:cp_r).with(src, dest, **options)
|
16
16
|
expect(FileUtils).to receive(:rm_rf).with(src)
|
17
17
|
|
18
18
|
FileUtils.mv(src, dest, options)
|
@@ -104,11 +104,10 @@ module Berkshelf
|
|
104
104
|
|
105
105
|
context "when the repository is cached" do
|
106
106
|
it "pulls a new version" do
|
107
|
-
|
108
|
-
|
107
|
+
cache_path = subject.send(:cache_path)
|
109
108
|
allow(subject).to receive(:cached?).and_return(true)
|
110
109
|
expect(subject).to receive(:git).with(
|
111
|
-
'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"'
|
110
|
+
'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"', cwd: cache_path.to_s
|
112
111
|
)
|
113
112
|
subject.install
|
114
113
|
end
|
@@ -116,8 +115,6 @@ module Berkshelf
|
|
116
115
|
|
117
116
|
context "when the revision is not cached" do
|
118
117
|
it "clones the repository" do
|
119
|
-
allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
|
120
|
-
|
121
118
|
cache_path = subject.send(:cache_path)
|
122
119
|
allow(subject).to receive(:cached?).and_return(false)
|
123
120
|
expect(subject).to receive(:git).with(
|
@@ -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"
|
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
|
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" }
|
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"
|
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
|
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" }
|
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://
|
106
|
+
it { is_expected.to eq(windows? ? "file://D/test" : "file:///test") }
|
100
107
|
end
|
101
108
|
end
|
102
109
|
|
@@ -119,7 +126,8 @@ module Berkshelf
|
|
119
126
|
end
|
120
127
|
|
121
128
|
context "with a string argument and options" do
|
122
|
-
let(:arguments) { ["https://example.com"
|
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
|
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" }
|
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? ? "
|
169
|
+
its([:path]) { is_expected.to eq(windows? ? "D:/test" : "/test") }
|
160
170
|
end
|
161
171
|
end
|
162
172
|
|
@@ -73,7 +73,6 @@ describe Berkshelf::SSLPolicy do
|
|
73
73
|
before do
|
74
74
|
allow(chef_config).to receive_messages(trusted_certs_dir: self_signed_crt_path_windows_backslashes)
|
75
75
|
allow(File).to receive(:exist?).with(self_signed_crt_path_windows_forwardslashes).and_return(true)
|
76
|
-
allow(Dir).to receive(:chdir).with(self_signed_crt_path_windows_forwardslashes)
|
77
76
|
end
|
78
77
|
|
79
78
|
it "replaces the backslashes in trusted_certs_dir from Berkshelf config with forwardslashes" do
|
@@ -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.
|
4
|
+
version: 7.2.2
|
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:
|
15
|
+
date: 2021-06-16 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:
|
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:
|
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:
|
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:
|
174
|
+
version: 15.7.32
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
176
|
name: chef-config
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -315,6 +315,7 @@ files:
|
|
315
315
|
- spec/support/path_helpers.rb
|
316
316
|
- spec/support/shared_examples/formatter.rb
|
317
317
|
- spec/unit/berkshelf/berksfile_spec.rb
|
318
|
+
- spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb
|
318
319
|
- spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb
|
319
320
|
- spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb
|
320
321
|
- spec/unit/berkshelf/berkshelf/api_client_spec.rb
|
@@ -359,7 +360,7 @@ homepage: https://docs.chef.io/berkshelf.html
|
|
359
360
|
licenses:
|
360
361
|
- Apache-2.0
|
361
362
|
metadata: {}
|
362
|
-
post_install_message:
|
363
|
+
post_install_message:
|
363
364
|
rdoc_options: []
|
364
365
|
require_paths:
|
365
366
|
- lib
|
@@ -374,8 +375,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
375
|
- !ruby/object:Gem::Version
|
375
376
|
version: 2.0.0
|
376
377
|
requirements: []
|
377
|
-
rubygems_version: 3.
|
378
|
-
signing_key:
|
378
|
+
rubygems_version: 3.2.15
|
379
|
+
signing_key:
|
379
380
|
specification_version: 4
|
380
381
|
summary: Manages a Chef cookbook's dependencies
|
381
382
|
test_files: []
|