berkshelf 7.0.9 → 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/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
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/Gemfile
CHANGED
@@ -2,19 +2,14 @@ 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
|
-
# these all deliberately float because berkshelf has a Gemfile.lock that
|
15
|
-
# equality pins them. temporarily pin as necessary for API breaks.
|
16
10
|
gem "chef-bin" # for the proxy tests
|
17
|
-
gem "aruba", "
|
11
|
+
gem "aruba", "~> 0.10" # Stay below 1 until aruba/in_process monkeypatching stops
|
12
|
+
gem "cucumber", "< 4.0" # until we identify what is generating the ~@no_run tag in CI
|
18
13
|
gem "cucumber-expressions", "= 5.0.13"
|
19
14
|
gem "chef-zero", ">= 4.0"
|
20
15
|
gem "dep_selector", ">= 1.0"
|
@@ -23,11 +18,7 @@ group :development do
|
|
23
18
|
gem "rspec-its", ">= 1.2"
|
24
19
|
gem "webmock", ">= 1.11"
|
25
20
|
gem "http", ">= 0.9.8"
|
26
|
-
gem "chefstyle"
|
27
|
-
end
|
28
|
-
|
29
|
-
group :docs do
|
30
|
-
gem "yard", ">= 0.8"
|
21
|
+
gem "chefstyle"
|
31
22
|
end
|
32
23
|
|
33
24
|
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
data/Rakefile
CHANGED
@@ -14,8 +14,8 @@ begin
|
|
14
14
|
require "cucumber"
|
15
15
|
require "cucumber/rake/task"
|
16
16
|
Cucumber::Rake::Task.new(:features) do |t|
|
17
|
-
if RUBY_PLATFORM =~ WINDOWS_PLATFORM
|
18
|
-
t.cucumber_opts = "--tags
|
17
|
+
if RUBY_PLATFORM =~ WINDOWS_PLATFORM || RUBY_PLATFORM =~ /darwin/
|
18
|
+
t.cucumber_opts = "--tags 'not @not-windows'"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
rescue LoadError
|
data/berkshelf.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require File.expand_path("../lib/berkshelf/version", __FILE__)
|
1
|
+
require File.expand_path("lib/berkshelf/version", __dir__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
4
|
s.authors = [
|
@@ -36,9 +35,9 @@ Gem::Specification.new do |s|
|
|
36
35
|
s.add_dependency "solve", "~> 4.0"
|
37
36
|
s.add_dependency "thor", ">= 0.20"
|
38
37
|
s.add_dependency "octokit", "~> 4.0"
|
39
|
-
s.add_dependency "mixlib-archive", ">=
|
38
|
+
s.add_dependency "mixlib-archive", ">= 1.1.4", "< 2.0" # needed for ruby 3.0 / Dir.chdir removal
|
40
39
|
s.add_dependency "concurrent-ruby", "~> 1.0"
|
41
|
-
s.add_dependency "chef", ">=
|
40
|
+
s.add_dependency "chef", ">= 15.7.32" # needed for --skip-syntax-check
|
42
41
|
s.add_dependency "chef-config"
|
43
42
|
# this is required for Mixlib::Config#from_json
|
44
43
|
s.add_dependency "mixlib-config", ">= 2.2.5"
|
data/bin/berks
CHANGED
data/lib/berkshelf.rb
CHANGED
@@ -10,14 +10,14 @@ rescue LoadError
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require "cleanroom"
|
13
|
-
require "digest/md5"
|
14
|
-
require "forwardable"
|
15
|
-
require "json"
|
16
|
-
require "pathname"
|
13
|
+
require "digest/md5" unless defined?(Digest::MD5)
|
14
|
+
require "forwardable" unless defined?(Forwardable)
|
15
|
+
require "json" unless defined?(JSON)
|
16
|
+
require "pathname" unless defined?(Pathname)
|
17
17
|
require "semverse"
|
18
18
|
require "solve"
|
19
|
-
require "thor"
|
20
|
-
require "uri"
|
19
|
+
require "thor" unless defined?(Thor)
|
20
|
+
require "uri" unless defined?(URI)
|
21
21
|
|
22
22
|
JSON.create_id = nil
|
23
23
|
|
@@ -169,7 +169,7 @@ module Berkshelf
|
|
169
169
|
raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.client_key"
|
170
170
|
end
|
171
171
|
|
172
|
-
RidleyCompat.new_client(ridley_options, &block)
|
172
|
+
RidleyCompat.new_client(**ridley_options, &block)
|
173
173
|
rescue ChefConnectionError, BerkshelfError
|
174
174
|
raise
|
175
175
|
rescue => ex
|
@@ -222,7 +222,6 @@ require_relative "berkshelf/lockfile"
|
|
222
222
|
require_relative "berkshelf/berksfile"
|
223
223
|
require_relative "berkshelf/cached_cookbook"
|
224
224
|
require_relative "berkshelf/cli"
|
225
|
-
require_relative "berkshelf/chef_config_compat"
|
226
225
|
require_relative "berkshelf/community_rest"
|
227
226
|
require_relative "berkshelf/cookbook_store"
|
228
227
|
require_relative "berkshelf/config"
|
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
@@ -500,7 +500,7 @@ module Berkshelf
|
|
500
500
|
latest = cookbooks.select do |cookbook|
|
501
501
|
(include_non_satisfying || dependency.version_constraint.satisfies?(cookbook.version)) &&
|
502
502
|
Semverse::Version.coerce(cookbook.version) > dependency.locked_version
|
503
|
-
end.
|
503
|
+
end.max_by(&:version)
|
504
504
|
|
505
505
|
unless latest.nil?
|
506
506
|
hash[name] ||= {
|
@@ -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
|
@@ -740,41 +740,41 @@ module Berkshelf
|
|
740
740
|
|
741
741
|
private
|
742
742
|
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
743
|
+
# Ensure the lockfile is present on disk.
|
744
|
+
#
|
745
|
+
# @raise [LockfileNotFound]
|
746
|
+
# if the lockfile does not exist on disk
|
747
|
+
#
|
748
|
+
# @return [true]
|
749
749
|
def validate_lockfile_present!
|
750
750
|
raise LockfileNotFound unless lockfile.present?
|
751
751
|
|
752
752
|
true
|
753
753
|
end
|
754
754
|
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
755
|
+
# Ensure that all dependencies defined in the Berksfile exist in this
|
756
|
+
# lockfile.
|
757
|
+
#
|
758
|
+
# @raise [LockfileOutOfSync]
|
759
|
+
# if there are dependencies specified in the Berksfile which do not
|
760
|
+
# exist (or are not satisifed by) the lockfile
|
761
|
+
#
|
762
|
+
# @return [true]
|
763
763
|
def validate_lockfile_trusted!
|
764
764
|
raise LockfileOutOfSync unless lockfile.trusted?
|
765
765
|
|
766
766
|
true
|
767
767
|
end
|
768
768
|
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
769
|
+
# Ensure that all dependencies in the lockfile are installed on this
|
770
|
+
# system. You should validate that the lockfile can be trusted before
|
771
|
+
# using this method.
|
772
|
+
#
|
773
|
+
# @raise [DependencyNotInstalled]
|
774
|
+
# if the dependency in the lockfile is not in the Berkshelf shelf on
|
775
|
+
# this system
|
776
|
+
#
|
777
|
+
# @return [true]
|
778
778
|
def validate_dependencies_installed!
|
779
779
|
lockfile.graph.locks.each do |_, dependency|
|
780
780
|
unless dependency.installed?
|
@@ -785,13 +785,13 @@ module Berkshelf
|
|
785
785
|
true
|
786
786
|
end
|
787
787
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
788
|
+
# Determine if any cookbooks were specified that aren't in our shelf.
|
789
|
+
#
|
790
|
+
# @param [Array<String>] names
|
791
|
+
# a list of cookbook names
|
792
|
+
#
|
793
|
+
# @raise [DependencyNotFound]
|
794
|
+
# if a cookbook name is given that does not exist
|
795
795
|
def validate_cookbook_names!(names)
|
796
796
|
missing = names - lockfile.graph.locks.keys
|
797
797
|
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -419,11 +419,11 @@ module Berkshelf
|
|
419
419
|
|
420
420
|
private
|
421
421
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
422
|
+
# Print a list of the given cookbooks. This is used by various
|
423
|
+
# methods like {list} and {contingent}.
|
424
|
+
#
|
425
|
+
# @param [Array<CachedCookbook>] cookbooks
|
426
|
+
#
|
427
427
|
def print_list(cookbooks)
|
428
428
|
Array(cookbooks).sort.each do |cookbook|
|
429
429
|
Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require "retryable"
|
2
|
-
require "mixlib/archive"
|
1
|
+
require "retryable" unless defined?(Retryable)
|
2
|
+
require "mixlib/archive" unless defined?(Mixlib::Archive)
|
3
3
|
|
4
4
|
module Berkshelf
|
5
5
|
class CommunityREST
|
@@ -75,7 +75,7 @@ module Berkshelf
|
|
75
75
|
@retries = options.delete(:retries)
|
76
76
|
@retry_interval = options.delete(:retry_interval)
|
77
77
|
|
78
|
-
@connection = Berkshelf::RidleyCompatJSON.new(options)
|
78
|
+
@connection = Berkshelf::RidleyCompatJSON.new(**options)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Download and extract target cookbook archive to the local file system,
|
data/lib/berkshelf/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require "mixlib/config"
|
2
|
-
require "openssl"
|
1
|
+
require "mixlib/config" unless defined?(Mixlib::Config)
|
2
|
+
require "openssl" unless defined?(OpenSSL)
|
3
3
|
|
4
4
|
# we need this method, but have to inject it into mixlib-config directly
|
5
5
|
# to have it available from config contexts
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
require "chef/exceptions"
|
3
3
|
|
4
4
|
module Berkshelf
|
@@ -49,9 +49,7 @@ module Berkshelf
|
|
49
49
|
|
50
50
|
# Destroy the contents of the initialized storage path.
|
51
51
|
def clean!
|
52
|
-
Dir.
|
53
|
-
FileUtils.rm_rf(Dir.glob("*"))
|
54
|
-
end
|
52
|
+
FileUtils.rm_rf(Dir.glob("#{storage_path}/*"))
|
55
53
|
end
|
56
54
|
|
57
55
|
# Import a cookbook found on the local filesystem into this instance of the cookbook store.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
|
3
3
|
module FileUtils
|
4
4
|
class << self
|
@@ -14,10 +14,10 @@ module FileUtils
|
|
14
14
|
# symlink on Linux
|
15
15
|
# @see {FileUtils::mv}
|
16
16
|
def mv(src, dest, options = {})
|
17
|
-
old_mv(src, dest, options)
|
17
|
+
old_mv(src, dest, **options)
|
18
18
|
rescue Errno::EACCES, Errno::ENOENT
|
19
19
|
options.delete(:force) if options.key?(:force)
|
20
|
-
FileUtils.cp_r(src, dest, options)
|
20
|
+
FileUtils.cp_r(src, dest, **options)
|
21
21
|
FileUtils.rm_rf(src)
|
22
22
|
end
|
23
23
|
end
|
data/lib/berkshelf/downloader.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "net/http"
|
2
|
-
require "mixlib/archive"
|
1
|
+
require "net/http" unless defined?(Net::HTTP)
|
2
|
+
require "mixlib/archive" unless defined?(Mixlib::Archive)
|
3
3
|
require_relative "ssl_policies"
|
4
|
-
require "faraday"
|
4
|
+
require "faraday" unless defined?(Faraday)
|
5
5
|
|
6
6
|
module Berkshelf
|
7
7
|
class Downloader
|
@@ -84,7 +84,7 @@ module Berkshelf
|
|
84
84
|
client_key: source.options[:client_key] || Berkshelf::Config.instance.chef.client_key,
|
85
85
|
ssl: source.options[:ssl],
|
86
86
|
}
|
87
|
-
RidleyCompat.new_client(credentials) do |conn|
|
87
|
+
RidleyCompat.new_client(**credentials) do |conn|
|
88
88
|
cookbook = Chef::CookbookVersion.load(name, version)
|
89
89
|
manifest = cookbook.cookbook_manifest
|
90
90
|
manifest.by_parent_directory.each do |segment, files|
|
@@ -145,7 +145,7 @@ module Berkshelf
|
|
145
145
|
|
146
146
|
File.join(unpack_dir, cookbook_directory)
|
147
147
|
when :uri
|
148
|
-
require "open-uri"
|
148
|
+
require "open-uri" unless defined?(OpenURI)
|
149
149
|
|
150
150
|
tmp_dir = Dir.mktmpdir
|
151
151
|
archive_path = Pathname.new(tmp_dir) + "#{name}-#{version}.tar.gz"
|
data/lib/berkshelf/errors.rb
CHANGED
@@ -91,6 +91,7 @@ module Berkshelf
|
|
91
91
|
|
92
92
|
class CookbookSyntaxError < BerkshelfError; set_status_code(107); end
|
93
93
|
class ConstraintNotSatisfied < BerkshelfError; set_status_code(111); end
|
94
|
+
|
94
95
|
class BerksfileReadError < BerkshelfError
|
95
96
|
set_status_code(113)
|
96
97
|
|
@@ -254,6 +255,7 @@ module Berkshelf
|
|
254
255
|
end
|
255
256
|
|
256
257
|
class UploadFailure < BerkshelfError; end
|
258
|
+
|
257
259
|
class FrozenCookbook < UploadFailure
|
258
260
|
set_status_code(126)
|
259
261
|
|
@@ -436,6 +438,7 @@ module Berkshelf
|
|
436
438
|
end
|
437
439
|
|
438
440
|
class DuplicateDemand < BerkshelfError; set_status_code(138); end
|
441
|
+
|
439
442
|
class LockfileNotFound < BerkshelfError
|
440
443
|
set_status_code(140)
|
441
444
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
|
3
3
|
module Berkshelf
|
4
4
|
module FileSyncer
|
@@ -24,8 +24,8 @@ module Berkshelf
|
|
24
24
|
# versions of windows points at 'C:\users'. Some users have their
|
25
25
|
# temp directory still referring to 'C:\Documents and Settings'.
|
26
26
|
#
|
27
|
-
def glob(pattern)
|
28
|
-
Dir.glob(pattern, File::FNM_DOTMATCH).sort.reject do |file|
|
27
|
+
def glob(pattern, **kwargs)
|
28
|
+
Dir.glob(pattern, File::FNM_DOTMATCH, **kwargs).sort.reject do |file|
|
29
29
|
basename = File.basename(file)
|
30
30
|
IGNORED_FILES.include?(basename)
|
31
31
|
end
|
@@ -65,11 +65,10 @@ module Berkshelf
|
|
65
65
|
[exclude, "#{exclude}/*"]
|
66
66
|
end.flatten
|
67
67
|
|
68
|
-
source_files =
|
69
|
-
glob("**/*").reject do |source_file|
|
68
|
+
source_files =
|
69
|
+
glob("**/*", base: source).reject do |source_file|
|
70
70
|
excludes.any? { |exclude| File.fnmatch?(exclude, source_file, File::FNM_DOTMATCH) }
|
71
71
|
end
|
72
|
-
end
|
73
72
|
|
74
73
|
# Ensure the destination directory exists
|
75
74
|
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
@@ -88,10 +87,11 @@ module Berkshelf
|
|
88
87
|
target = File.readlink(source_file)
|
89
88
|
|
90
89
|
destination = File.expand_path(destination)
|
91
|
-
|
92
|
-
FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
|
93
|
-
end
|
90
|
+
FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
|
94
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)
|
95
95
|
FileUtils.cp(source_file, "#{destination}/#{relative_path}")
|
96
96
|
else
|
97
97
|
type = File.ftype(source_file)
|
@@ -103,9 +103,7 @@ module Berkshelf
|
|
103
103
|
|
104
104
|
if options[:delete]
|
105
105
|
# Remove any files in the destination that are not in the source files
|
106
|
-
destination_files =
|
107
|
-
glob("**/*")
|
108
|
-
end
|
106
|
+
destination_files = glob("**/*", base: destination)
|
109
107
|
|
110
108
|
# Remove any extra files that are present in the destination, but are
|
111
109
|
# not in the source list
|