berkshelf 7.2.1 → 7.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/berkshelf/api_client.rb +2 -2
- data/lib/berkshelf/api_client/chef_server_connection.rb +4 -6
- data/lib/berkshelf/berksfile.rb +1 -1
- data/lib/berkshelf/installer.rb +7 -7
- data/lib/berkshelf/ssl_policies.rb +1 -1
- data/lib/berkshelf/uploader.rb +32 -32
- data/lib/berkshelf/version.rb +1 -1
- data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3328d9ead777bfb150d7588648ca5376fa46fa5fafa8ded0afdb9cc710043b3
|
4
|
+
data.tar.gz: 94203ac8481a5a5155987e5f060d6fd1c78cc9f3073dd84efcb597d1a21ff5c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 337c5f8eb9d149f27e7fc40f6e1228f7fdbc2606a8c352dbe8c942ee5f6ab081e5db039fb9b46e41a9dbaff017ddf7d004d02c7d8d272d3042cf892e5e68396e
|
7
|
+
data.tar.gz: b9d8896f85f1c98924c3472ad97648071bc8301854a0ea49fe7dde2472faafe54f035b27140928462de7e099aa95983cda21d52d928ad93698ccf7e1404265e2
|
data/lib/berkshelf/api_client.rb
CHANGED
@@ -5,15 +5,13 @@ module Berkshelf
|
|
5
5
|
require_relative "errors"
|
6
6
|
|
7
7
|
class ChefServerConnection
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@client = Berkshelf::RidleyCompat.new(*args)
|
12
|
-
@url = args[0][:server_url]
|
8
|
+
def initialize(**args)
|
9
|
+
@client = Berkshelf::RidleyCompat.new(**args)
|
10
|
+
@url = args[:server_url]
|
13
11
|
end
|
14
12
|
|
15
13
|
def universe
|
16
|
-
response = client.get("universe")
|
14
|
+
response = @client.get("universe")
|
17
15
|
|
18
16
|
[].tap do |cookbooks|
|
19
17
|
response.each do |name, versions|
|
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -644,7 +644,7 @@ module Berkshelf
|
|
644
644
|
FileUtils.mkdir_p(cookbook_destination)
|
645
645
|
|
646
646
|
# Dir.glob does not support backslash as a File separator
|
647
|
-
src = cookbook.path.to_s.tr(
|
647
|
+
src = cookbook.path.to_s.tr("\\", "/")
|
648
648
|
files = FileSyncer.glob(File.join(src, "**/*"))
|
649
649
|
|
650
650
|
# strip directories
|
data/lib/berkshelf/installer.rb
CHANGED
@@ -19,13 +19,13 @@ module Berkshelf
|
|
19
19
|
def build_universe
|
20
20
|
berksfile.sources.collect do |source|
|
21
21
|
Thread.new do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
|
23
|
+
Berkshelf.formatter.msg("Fetching cookbook index from #{source}...")
|
24
|
+
source.build_universe
|
25
|
+
rescue Berkshelf::APIClientError => ex
|
26
|
+
Berkshelf.formatter.warn "Error retrieving universe from source: #{source}"
|
27
|
+
Berkshelf.formatter.warn " * [#{ex.class}] #{ex}"
|
28
|
+
|
29
29
|
end
|
30
30
|
end.map(&:join)
|
31
31
|
end
|
@@ -20,7 +20,7 @@ module Berkshelf
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def trusted_certs_dir
|
23
|
-
config_dir = Berkshelf.config.chef.trusted_certs_dir.to_s.tr(
|
23
|
+
config_dir = Berkshelf.config.chef.trusted_certs_dir.to_s.tr("\\", "/")
|
24
24
|
if config_dir.empty? || !::File.exist?(config_dir)
|
25
25
|
File.join(ENV["HOME"], ".chef", "trusted_certs")
|
26
26
|
else
|
data/lib/berkshelf/uploader.rb
CHANGED
@@ -59,41 +59,41 @@ module Berkshelf
|
|
59
59
|
connection.get("users/#{Berkshelf.config.chef.node_name}") rescue nil
|
60
60
|
|
61
61
|
cookbooks.map do |cookbook|
|
62
|
+
|
63
|
+
compiled_metadata = cookbook.compile_metadata
|
64
|
+
cookbook.reload if compiled_metadata
|
65
|
+
cookbook_version = cookbook.cookbook_version
|
66
|
+
Berkshelf.log.debug " Uploading #{cookbook.cookbook_name}"
|
67
|
+
cookbook_version.freeze_version if options[:freeze]
|
68
|
+
|
69
|
+
# another two lines that are necessary for chef < 13.2 support (affects 11.x/12.x as well)
|
70
|
+
cookbook_version.metadata.maintainer "" if cookbook_version.metadata.maintainer.nil?
|
71
|
+
cookbook_version.metadata.maintainer_email "" if cookbook_version.metadata.maintainer_email.nil?
|
72
|
+
|
62
73
|
begin
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Chef::CookbookUploader.new(
|
75
|
-
[ cookbook_version ],
|
76
|
-
force: options[:force],
|
77
|
-
concurrency: 1, # sadly
|
78
|
-
rest: connection,
|
79
|
-
skip_syntax_check: options[:skip_syntax_check]
|
80
|
-
).upload_cookbooks
|
81
|
-
Berkshelf.formatter.uploaded(cookbook, connection)
|
82
|
-
rescue Chef::Exceptions::CookbookFrozen
|
83
|
-
if options[:halt_on_frozen]
|
84
|
-
raise FrozenCookbook.new(cookbook)
|
85
|
-
end
|
86
|
-
|
87
|
-
Berkshelf.formatter.skipping(cookbook, connection)
|
88
|
-
end
|
89
|
-
ensure
|
90
|
-
if compiled_metadata
|
91
|
-
# this is necessary on windows to clean up the ruby object that was pointing at the file
|
92
|
-
# so that we can reliably delete it. windows is terrible.
|
93
|
-
GC.start
|
94
|
-
File.unlink(compiled_metadata)
|
74
|
+
Chef::CookbookUploader.new(
|
75
|
+
[ cookbook_version ],
|
76
|
+
force: options[:force],
|
77
|
+
concurrency: 1, # sadly
|
78
|
+
rest: connection,
|
79
|
+
skip_syntax_check: options[:skip_syntax_check]
|
80
|
+
).upload_cookbooks
|
81
|
+
Berkshelf.formatter.uploaded(cookbook, connection)
|
82
|
+
rescue Chef::Exceptions::CookbookFrozen
|
83
|
+
if options[:halt_on_frozen]
|
84
|
+
raise FrozenCookbook.new(cookbook)
|
95
85
|
end
|
86
|
+
|
87
|
+
Berkshelf.formatter.skipping(cookbook, connection)
|
88
|
+
end
|
89
|
+
ensure
|
90
|
+
if compiled_metadata
|
91
|
+
# this is necessary on windows to clean up the ruby object that was pointing at the file
|
92
|
+
# so that we can reliably delete it. windows is terrible.
|
93
|
+
GC.start
|
94
|
+
File.unlink(compiled_metadata)
|
96
95
|
end
|
96
|
+
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
data/lib/berkshelf/version.rb
CHANGED
@@ -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
|
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.2.
|
4
|
+
version: 7.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-06-
|
15
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mixlib-shellout
|
@@ -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
|