berkshelf 7.2.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/berkshelf.gemspec +6 -1
- data/lib/berkshelf/api_client/chef_server_connection.rb +4 -6
- data/lib/berkshelf/api_client.rb +2 -2
- data/lib/berkshelf/berksfile.rb +3 -3
- data/lib/berkshelf/installer.rb +7 -7
- data/lib/berkshelf/location.rb +1 -1
- data/lib/berkshelf/locations/github.rb +1 -1
- data/lib/berkshelf/ssl_policies.rb +1 -1
- data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
- data/lib/berkshelf/uploader.rb +32 -32
- data/lib/berkshelf/version.rb +1 -1
- data/spec/config/knife.rb +1 -1
- data/spec/support/git.rb +1 -1
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
- data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
- data/spec/unit/berkshelf/dependency_spec.rb +1 -1
- data/spec/unit/berkshelf/location_spec.rb +1 -1
- metadata +24 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99d23b6a2d3692b3124db831c84e4038aac41cc9a21848b65a38256995f687a0
|
4
|
+
data.tar.gz: ff21e7c229ce9564ad1dd589556ed8a89488cb66788e4c4268751036ead8b949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 539e905ff46b5d587ccb1911678c1ca8ae547e4bdd9e3c78e5a0aa69d9552f4f16eca2422659b5b2c3f6d1996276d6c0599af6edad81e0cdcd4c06aac7b390f3
|
7
|
+
data.tar.gz: 883c28941e1735a37c102e7d175b634cf6a7ced2994508c5da3611b3d9a73b0fcdcc51bd3fea0c3a671a226e490e41e2808643a6ce51709983d33f4b1c62c46d
|
data/Gemfile
CHANGED
@@ -7,7 +7,6 @@ group :build do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
group :development do
|
10
|
-
gem "chef-bin" # for the proxy tests
|
11
10
|
gem "aruba", "~> 0.10" # Stay below 1 until aruba/in_process monkeypatching stops
|
12
11
|
gem "cucumber", "< 4.0" # until we identify what is generating the ~@no_run tag in CI
|
13
12
|
gem "cucumber-expressions", "= 5.0.13"
|
data/berkshelf.gemspec
CHANGED
@@ -25,8 +25,13 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.name = "berkshelf"
|
26
26
|
s.require_paths = ["lib"]
|
27
27
|
s.version = Berkshelf::VERSION
|
28
|
-
s.required_ruby_version = ">= 2.
|
28
|
+
s.required_ruby_version = ">= 2.7.0"
|
29
29
|
s.required_rubygems_version = ">= 2.0.0"
|
30
|
+
s.metadata = {
|
31
|
+
"bug_tracker_uri" => "https://github.com/chef/berkshelf/issues",
|
32
|
+
"source_code_uri" => "https://github.com/chef/berkshelf",
|
33
|
+
"changelog_uri" => "https://github.com/chef/berkshelf/blob/main/CHANGELOG.md",
|
34
|
+
}
|
30
35
|
|
31
36
|
s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
|
32
37
|
s.add_dependency "cleanroom", "~> 1.0"
|
@@ -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/api_client.rb
CHANGED
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -118,7 +118,7 @@ module Berkshelf
|
|
118
118
|
# cookbook 'artifact', path: '/Users/reset/code/artifact'
|
119
119
|
#
|
120
120
|
# @example a cookbook dependency that will be retrieved from a Git server
|
121
|
-
# cookbook 'artifact', git: '
|
121
|
+
# cookbook 'artifact', git: 'https://github.com/chef/artifact-cookbook.git'
|
122
122
|
#
|
123
123
|
# @overload cookbook(name, version_constraint, options = {})
|
124
124
|
# @param [#to_s] name
|
@@ -156,7 +156,7 @@ module Berkshelf
|
|
156
156
|
options[:group] += @active_group
|
157
157
|
end
|
158
158
|
|
159
|
-
add_dependency(name, constraint, options)
|
159
|
+
add_dependency(name, constraint, **options)
|
160
160
|
end
|
161
161
|
expose :cookbook
|
162
162
|
|
@@ -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
|
data/lib/berkshelf/location.rb
CHANGED
@@ -9,7 +9,7 @@ module Berkshelf
|
|
9
9
|
# is returned.
|
10
10
|
#
|
11
11
|
# @example Create a git location
|
12
|
-
# Location.init(dependency, git: '
|
12
|
+
# Location.init(dependency, git: 'https://github.com/berkshelf/berkshelf.git')
|
13
13
|
#
|
14
14
|
# @example Create a GitHub location
|
15
15
|
# Location.init(dependency, github: 'berkshelf/berkshelf')
|
@@ -9,7 +9,7 @@ module Berkshelf
|
|
9
9
|
when :https
|
10
10
|
options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
|
11
11
|
when :git
|
12
|
-
options[:git] = "
|
12
|
+
options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
|
13
13
|
else
|
14
14
|
# if some bizarre value is provided, treat it as :https
|
15
15
|
options[:git] = "https://#{HOST}/#{options.delete(:github)}.git"
|
@@ -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
data/spec/config/knife.rb
CHANGED
@@ -4,7 +4,7 @@ node_name "berkshelf"
|
|
4
4
|
client_key File.expand_path("spec/config/berkshelf.pem")
|
5
5
|
validation_client_name "validator"
|
6
6
|
validation_key File.expand_path("spec/config/validator.pem")
|
7
|
-
chef_server_url "http://
|
7
|
+
chef_server_url "http://127.0.0.1:26310"
|
8
8
|
cache_type "BasicFile"
|
9
9
|
cache_options( path: "#{ENV["HOME"]}/.chef/checksums" )
|
10
10
|
cookbook_path []
|
data/spec/support/git.rb
CHANGED
@@ -5,7 +5,7 @@ module Berkshelf
|
|
5
5
|
include Berkshelf::RSpec::PathHelpers
|
6
6
|
|
7
7
|
def git_origin_for(repo, options = {})
|
8
|
-
"file://#{generate_fake_git_remote("git@github.com/
|
8
|
+
"file://#{generate_fake_git_remote("git@github.com/chef/#{repo}.git", options)}/.git"
|
9
9
|
end
|
10
10
|
|
11
11
|
def generate_fake_git_remote(uri, options = {})
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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
|
@@ -35,7 +35,7 @@ describe Berkshelf::Dependency do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
context "given a location key :git" do
|
38
|
-
let(:url) { "
|
38
|
+
let(:url) { "https://url_to_git" }
|
39
39
|
let(:source) { described_class.new(berksfile, cookbook_name, git: url) }
|
40
40
|
|
41
41
|
it "initializes a GitLocation for location" do
|
@@ -11,7 +11,7 @@ module Berkshelf
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "finds a :git location by key" do
|
14
|
-
instance = described_class.init(dependency, git: "
|
14
|
+
instance = described_class.init(dependency, git: "https://foo.com/meats/bacon.git")
|
15
15
|
expect(instance).to be_a(GitLocation)
|
16
16
|
end
|
17
17
|
|
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:
|
4
|
+
version: 8.0.1
|
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:
|
15
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mixlib-shellout
|
@@ -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
|
@@ -358,7 +374,10 @@ files:
|
|
358
374
|
homepage: https://docs.chef.io/berkshelf.html
|
359
375
|
licenses:
|
360
376
|
- Apache-2.0
|
361
|
-
metadata:
|
377
|
+
metadata:
|
378
|
+
bug_tracker_uri: https://github.com/chef/berkshelf/issues
|
379
|
+
source_code_uri: https://github.com/chef/berkshelf
|
380
|
+
changelog_uri: https://github.com/chef/berkshelf/blob/main/CHANGELOG.md
|
362
381
|
post_install_message:
|
363
382
|
rdoc_options: []
|
364
383
|
require_paths:
|
@@ -367,14 +386,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
367
386
|
requirements:
|
368
387
|
- - ">="
|
369
388
|
- !ruby/object:Gem::Version
|
370
|
-
version: 2.
|
389
|
+
version: 2.7.0
|
371
390
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
372
391
|
requirements:
|
373
392
|
- - ">="
|
374
393
|
- !ruby/object:Gem::Version
|
375
394
|
version: 2.0.0
|
376
395
|
requirements: []
|
377
|
-
rubygems_version: 3.2.
|
396
|
+
rubygems_version: 3.2.3
|
378
397
|
signing_key:
|
379
398
|
specification_version: 4
|
380
399
|
summary: Manages a Chef cookbook's dependencies
|