berkshelf 7.2.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -10
- 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/file_syncer.rb +3 -0
- 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 +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74b3f02281f737a99b466bb6e902b83e14dc4753eca57e4c53ebcc9d18147c4b
|
4
|
+
data.tar.gz: e8c566401ba73574604f2427b91a414af8a10e04d20d6c78df0e5cac58bc9ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad41f78382168194e5e7289a58ddb2213724839c64a5cf033551d874f935af0b2f6343a64499649499aed797a63b5d5d261298733cd4131e56b072a1671e55ee
|
7
|
+
data.tar.gz: 19735889f013e0c9afca6ae0ab3b4496d2d35d09dc85592fb2b6d549a5e1224f19dc76926021f7ec5be735ff44d49299f0b6a69122e27f719a72611a91424dda
|
data/Gemfile
CHANGED
@@ -2,16 +2,11 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :changelog do
|
6
|
-
gem "github_changelog_generator"
|
7
|
-
end
|
8
|
-
|
9
5
|
group :build do
|
10
6
|
gem "rake", ">= 10.1"
|
11
7
|
end
|
12
8
|
|
13
9
|
group :development do
|
14
|
-
gem "chef-bin" # for the proxy tests
|
15
10
|
gem "aruba", "~> 0.10" # Stay below 1 until aruba/in_process monkeypatching stops
|
16
11
|
gem "cucumber", "< 4.0" # until we identify what is generating the ~@no_run tag in CI
|
17
12
|
gem "cucumber-expressions", "= 5.0.13"
|
@@ -22,11 +17,7 @@ group :development do
|
|
22
17
|
gem "rspec-its", ">= 1.2"
|
23
18
|
gem "webmock", ">= 1.11"
|
24
19
|
gem "http", ">= 0.9.8"
|
25
|
-
gem "chefstyle"
|
26
|
-
end
|
27
|
-
|
28
|
-
group :docs do
|
29
|
-
gem "yard", ">= 0.8"
|
20
|
+
gem "chefstyle"
|
30
21
|
end
|
31
22
|
|
32
23
|
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
@@ -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
|
@@ -89,6 +89,9 @@ module Berkshelf
|
|
89
89
|
destination = File.expand_path(destination)
|
90
90
|
FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
|
91
91
|
when :file
|
92
|
+
# TODO: Workaround issue related to [1] which impacts running ChefSpec on Github Actions
|
93
|
+
# [1] https://github.com/docker/for-linux/issues/1015
|
94
|
+
FileUtils.touch(source_file)
|
92
95
|
FileUtils.cp(source_file, "#{destination}/#{relative_path}")
|
93
96
|
else
|
94
97
|
type = File.ftype(source_file)
|
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.0
|
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-04-29 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
|
@@ -374,7 +390,7 @@ 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.
|
393
|
+
rubygems_version: 3.3.7
|
378
394
|
signing_key:
|
379
395
|
specification_version: 4
|
380
396
|
summary: Manages a Chef cookbook's dependencies
|