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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4950e40e68a8fa20ad29aa5d589f27e4dd3fa0d7966abaedae2a9fc81398bc42
4
- data.tar.gz: 706ca0ccbf4033186ac0adb6b1da988a55028fa1ccfae5c09a02c2ac414d31b4
3
+ metadata.gz: a3328d9ead777bfb150d7588648ca5376fa46fa5fafa8ded0afdb9cc710043b3
4
+ data.tar.gz: 94203ac8481a5a5155987e5f060d6fd1c78cc9f3073dd84efcb597d1a21ff5c6
5
5
  SHA512:
6
- metadata.gz: a4207838b3b203d6446a6f4d529e2d74a67a4109dadb206011be3e9f34a7bd3ca5373df4e3ec5e07994da54571d6c9d91c7c245cd45b4afdbe5b6481c5db9aec
7
- data.tar.gz: 4a57a2691d696385dbf46aa141b69b5dcd619a920f9abfb3a8b4ce0f5c3155591216b7c1267a804f3f80c8b805875253824b67686a1141df0107e772329fb3dc
6
+ metadata.gz: 337c5f8eb9d149f27e7fc40f6e1228f7fdbc2606a8c352dbe8c942ee5f6ab081e5db039fb9b46e41a9dbaff017ddf7d004d02c7d8d272d3042cf892e5e68396e
7
+ data.tar.gz: b9d8896f85f1c98924c3472ad97648071bc8301854a0ea49fe7dde2472faafe54f035b27140928462de7e099aa95983cda21d52d928ad93698ccf7e1404265e2
@@ -16,8 +16,8 @@ module Berkshelf
16
16
  Connection.new(*args)
17
17
  end
18
18
 
19
- def chef_server(*args)
20
- ChefServerConnection.new(*args)
19
+ def chef_server(**args)
20
+ ChefServerConnection.new(**args)
21
21
  end
22
22
  end
23
23
  end
@@ -5,15 +5,13 @@ module Berkshelf
5
5
  require_relative "errors"
6
6
 
7
7
  class ChefServerConnection
8
- attr_reader :client
9
-
10
- def initialize(*args)
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|
@@ -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
@@ -19,13 +19,13 @@ module Berkshelf
19
19
  def build_universe
20
20
  berksfile.sources.collect do |source|
21
21
  Thread.new do
22
- begin
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
- end
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
@@ -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
- 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
-
73
- begin
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
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "7.2.1".freeze
2
+ VERSION = "7.2.2".freeze
3
3
  end
@@ -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.1
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 00:00:00.000000000 Z
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