berkshelf 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/berkshelf.gemspec +2 -3
  4. data/bin/berks +1 -1
  5. data/lib/berkshelf.rb +6 -7
  6. data/lib/berkshelf/api_client/remote_cookbook.rb +1 -1
  7. data/lib/berkshelf/berksfile.rb +1 -1
  8. data/lib/berkshelf/chef_config_compat.rb +1 -1
  9. data/lib/berkshelf/community_rest.rb +2 -2
  10. data/lib/berkshelf/config.rb +2 -2
  11. data/lib/berkshelf/cookbook_store.rb +2 -4
  12. data/lib/berkshelf/core_ext/file_utils.rb +1 -1
  13. data/lib/berkshelf/downloader.rb +5 -5
  14. data/lib/berkshelf/errors.rb +3 -0
  15. data/lib/berkshelf/file_syncer.rb +7 -12
  16. data/lib/berkshelf/locations/git.rb +6 -12
  17. data/lib/berkshelf/mixin/git.rb +2 -2
  18. data/lib/berkshelf/packager.rb +3 -5
  19. data/lib/berkshelf/shell.rb +1 -1
  20. data/lib/berkshelf/shell_out.rb +4 -3
  21. data/lib/berkshelf/source.rb +2 -2
  22. data/lib/berkshelf/source_uri.rb +1 -1
  23. data/lib/berkshelf/ssl_policies.rb +4 -6
  24. data/lib/berkshelf/validator.rb +2 -8
  25. data/lib/berkshelf/version.rb +1 -1
  26. data/lib/berkshelf/visualizer.rb +2 -2
  27. data/spec/spec_helper.rb +1 -1
  28. data/spec/unit/berkshelf/locations/git_spec.rb +2 -5
  29. data/spec/unit/berkshelf/ridley_compat_spec.rb +1 -1
  30. data/spec/unit/berkshelf/source_spec.rb +22 -12
  31. data/spec/unit/berkshelf/ssl_policies_spec.rb +0 -1
  32. data/spec/unit/berkshelf/validator_spec.rb +0 -13
  33. metadata +8 -23
  34. data/spec/tmp/berkshelf/cookbooks/dep-1.0.0/attributes/default.rb +0 -0
  35. data/spec/tmp/berkshelf/cookbooks/dep-1.0.0/files/default/file.h +0 -0
  36. data/spec/tmp/berkshelf/cookbooks/dep-1.0.0/metadata.rb +0 -2
  37. data/spec/tmp/berkshelf/cookbooks/dep-1.0.0/recipes/default.rb +0 -0
  38. data/spec/tmp/berkshelf/cookbooks/dep-1.0.0/templates/default/template.erb +0 -0
  39. data/spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/attributes/default.rb +0 -0
  40. data/spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/files/default/file.h +0 -0
  41. data/spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/metadata.rb +0 -3
  42. data/spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/recipes/default.rb +0 -0
  43. data/spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/templates/default/template.erb +0 -0
  44. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  45. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  46. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +0 -3
  47. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  48. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db4572fef41dd9da70dbc590f97cac73ff70ef9c5206ae82dca20145f2d64da7
4
- data.tar.gz: b31969725a11b43359027fa3e729381bc1515fdc8845601d473aac647f521b7e
3
+ metadata.gz: 62d08805f26730ed4eb3721de768e7361113fe5d877c485a60358161904db3f9
4
+ data.tar.gz: 9a3f0b74b8cbda7bc06a92febdf8881002d8b42a3427c9e7e21565a705f28a1c
5
5
  SHA512:
6
- metadata.gz: f760c4eca41839953b82dc30c4cb50ef60aff3ec7fc7c13a80d313f72d4d0ce775a61ae4c49b95de52d5a29f963d6a0d70d5a511af37d8aca900f05f72ef7f7d
7
- data.tar.gz: 40f5a28f40e62e91c0b69ac8020611f9513cf03fc4e376c3edb1d60ad327288ecb3060daf4b4fd3e392e2a068838ccc7b0e9da72d3be6a0620835bbc9e0783fa
6
+ metadata.gz: d2b5c48cbdb73b61b318cf679098d036d53da85c4f3308c01b51711bdcfe9d073f7a482a87285d684a874054ae1ebe00e0162ef032582243a9b333cecbe744be
7
+ data.tar.gz: dd118413d20ac879b40e92c4ea78055686fc0823d0ee1bcbe58ab9d799cb7c1fc48b0326018988737b9c9952989531a3ef6711cdad26476198b5f120c4cba34b
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 ~@not-windows"
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
- # -*- encoding: utf-8; mode: ruby -*-
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,7 +35,7 @@ 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", ">= 0.4", "< 2.0"
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
40
  s.add_dependency "chef", ">= 15.7.32" # needed for --skip-syntax-check
42
41
  s.add_dependency "chef-config"
data/bin/berks CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $:.push File.expand_path("../../lib", __FILE__)
2
+ $:.push File.expand_path("../lib", __dir__)
3
3
  require "berkshelf/cli"
4
4
 
5
5
  Berkshelf::Cli::Runner.new(ARGV.dup).execute!
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
 
@@ -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"
@@ -1,4 +1,4 @@
1
- require "json"
1
+ require "json" unless defined?(JSON)
2
2
  require "chef/mash"
3
3
 
4
4
  module Berkshelf
@@ -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.sort_by(&:version).last
503
+ end.max_by(&:version)
504
504
 
505
505
  unless latest.nil?
506
506
  hash[name] ||= {
@@ -1,6 +1,6 @@
1
1
  require "chef-config/config"
2
2
  require "chef-config/workstation_config_loader"
3
- require "socket" # FIXME: why?
3
+ require "socket" unless defined?(Socket) # FIXME: why?
4
4
 
5
5
  module Berkshelf
6
6
  class ChefConfigCompat
@@ -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
@@ -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.chdir(storage_path) do
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
@@ -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"
@@ -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 = Dir.chdir(source) do
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,9 +87,7 @@ module Berkshelf
88
87
  target = File.readlink(source_file)
89
88
 
90
89
  destination = File.expand_path(destination)
91
- Dir.chdir(destination) do
92
- FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
93
- end
90
+ FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
94
91
  when :file
95
92
  FileUtils.cp(source_file, "#{destination}/#{relative_path}")
96
93
  else
@@ -103,9 +100,7 @@ module Berkshelf
103
100
 
104
101
  if options[:delete]
105
102
  # Remove any files in the destination that are not in the source files
106
- destination_files = Dir.chdir(destination) do
107
- glob("**/*")
108
- end
103
+ destination_files = glob("**/*", base: destination)
109
104
 
110
105
  # Remove any extra files that are present in the destination, but are
111
106
  # not in the source list
@@ -37,28 +37,22 @@ module Berkshelf
37
37
  scratch_path = Pathname.new(Dir.mktmpdir)
38
38
 
39
39
  if cached?
40
- Dir.chdir(cache_path) do
41
- git %{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}
42
- end
40
+ git(%{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}, cwd: cache_path.to_s)
43
41
  else
44
42
  git %{clone #{uri} "#{cache_path}" --bare --no-hardlinks}
45
43
  end
46
44
 
47
- Dir.chdir(cache_path) do
48
- @revision ||= git %{rev-parse #{@rev_parse}}
49
- end
45
+ @revision ||= git(%{rev-parse #{@rev_parse}}, cwd: cache_path.to_s)
50
46
 
51
47
  # Clone into a scratch directory for validations
52
48
  git %{clone --no-checkout "#{cache_path}" "#{scratch_path}"}
53
49
 
54
50
  # Make sure the scratch directory is up-to-date and account for rel paths
55
- Dir.chdir(scratch_path) do
56
- git %{fetch --force --tags "#{cache_path}"}
57
- git %{reset --hard #{@revision}}
51
+ git(%{fetch --force --tags "#{cache_path}"}, cwd: scratch_path.to_s)
52
+ git(%{reset --hard #{@revision}}, cwd: scratch_path.to_s)
58
53
 
59
- if rel
60
- git %{filter-branch --subdirectory-filter "#{rel}" --force}
61
- end
54
+ if rel
55
+ git(%{filter-branch --subdirectory-filter "#{rel}" --force}, cwd: scratch_path.to_s)
62
56
  end
63
57
 
64
58
  # Validate the scratched path is a valid cookbook
@@ -13,12 +13,12 @@ module Berkshelf
13
13
  #
14
14
  # @raise [String]
15
15
  # the +$stdout+ from the command
16
- def git(command, error = true)
16
+ def git(command, error = true, **kwargs)
17
17
  unless Berkshelf.which("git") || Berkshelf.which("git.exe") || Berkshelf.which("git.bat")
18
18
  raise GitNotInstalled.new
19
19
  end
20
20
 
21
- response = shell_out(%{git #{command}})
21
+ response = shell_out(%{git #{command}}, **kwargs)
22
22
 
23
23
  if response.error?
24
24
  raise GitCommandError.new(command, cache_path, response.stderr)
@@ -1,5 +1,5 @@
1
1
  require "archive/tar/minitar"
2
- require "zlib"
2
+ require "zlib" unless defined?(Zlib)
3
3
 
4
4
  module Berkshelf
5
5
  # A class for archiving and compressing directory containing one or more cookbooks.
@@ -40,10 +40,8 @@ module Berkshelf
40
40
  # @return [String]
41
41
  # path to the generated archive
42
42
  def run(source)
43
- Dir.chdir(source.to_s) do |dir|
44
- tgz = Zlib::GzipWriter.new(File.open(out_file, "wb"))
45
- Archive::Tar::Minitar.pack(Dir.glob("*"), tgz)
46
- end
43
+ tgz = Zlib::GzipWriter.new(File.open(out_file, "wb"))
44
+ Archive::Tar::Minitar.pack(Dir.glob("#{source}/*"), tgz)
47
45
 
48
46
  out_file
49
47
  rescue SystemCallError => ex
@@ -1,4 +1,4 @@
1
- require "thor"
1
+ require "thor" unless defined?(Thor)
2
2
 
3
3
  module Berkshelf
4
4
  # Subclass the current shell (which is different based on the OS)
@@ -1,4 +1,4 @@
1
- require "mixlib/shellout"
1
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
2
2
 
3
3
  module Berkshelf
4
4
  module ShellOut
@@ -8,8 +8,9 @@ module Berkshelf
8
8
  cmd
9
9
  end
10
10
 
11
- def shell_out!(*args)
12
- cmd = shell_out(*args)
11
+ def shell_out!(*args, **options)
12
+ cmd = Mixlib::ShellOut.new(*args, **options)
13
+ cmd.run_command
13
14
  cmd.error!
14
15
  cmd
15
16
  end
@@ -1,7 +1,7 @@
1
1
  require_relative "api-client"
2
2
  require_relative "chef_repo_universe"
3
3
  require_relative "ssl_policies"
4
- require "openssl"
4
+ require "openssl" unless defined?(OpenSSL)
5
5
 
6
6
  module Berkshelf
7
7
  class Source
@@ -132,7 +132,7 @@ module Berkshelf
132
132
  #
133
133
  # @return [APIClient::RemoteCookbook]
134
134
  def latest(name)
135
- versions(name).sort.last
135
+ versions(name).max
136
136
  end
137
137
 
138
138
  # @param [String] name
@@ -1,4 +1,4 @@
1
- require "addressable/uri"
1
+ require "addressable/uri" unless defined?(Addressable::URI)
2
2
 
3
3
  module Berkshelf
4
4
  class SourceURI < Addressable::URI
@@ -1,4 +1,4 @@
1
- require "openssl"
1
+ require "openssl" unless defined?(OpenSSL)
2
2
 
3
3
  module Berkshelf
4
4
  class SSLPolicy
@@ -29,11 +29,9 @@ module Berkshelf
29
29
  end
30
30
 
31
31
  def set_custom_certs
32
- Dir.chdir(trusted_certs_dir) do
33
- ::Dir.glob("{*.crt,*.pem}").each do |cert|
34
- cert = OpenSSL::X509::Certificate.new(IO.read(cert))
35
- add_trusted_cert(cert)
36
- end
32
+ ::Dir.glob("#{trusted_certs_dir}/{*.crt,*.pem}").each do |cert|
33
+ cert = OpenSSL::X509::Certificate.new(IO.read(cert))
34
+ add_trusted_cert(cert)
37
35
  end
38
36
  end
39
37
  end
@@ -22,15 +22,9 @@ module Berkshelf
22
22
  # the Cookbook(s) to validate
23
23
  def validate_files(cookbooks)
24
24
  Array(cookbooks).each do |cookbook|
25
- path = cookbook.path.to_s
25
+ base, name = Pathname.new(cookbook.path.to_s).split
26
26
 
27
- files = Dir.chdir(path) do
28
- Dir.glob(File.join("**", "*.rb")).select do |f|
29
- f = File.join(path, f)
30
- parent = Pathname.new(path).dirname.to_s
31
- f.gsub(parent, "") =~ /[[:space:]]/
32
- end
33
- end
27
+ files = Dir.glob("#{name}/**/*.rb", base: base.to_s).select { |f| f =~ /[[:space:]]/ }
34
28
 
35
29
  raise InvalidCookbookFiles.new(cookbook, files) unless files.empty?
36
30
  end
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "7.1.0".freeze
2
+ VERSION = "7.2.0".freeze
3
3
  end
@@ -1,5 +1,5 @@
1
- require "set"
2
- require "tempfile"
1
+ require "set" unless defined?(Set)
2
+ require "tempfile" unless defined?(Tempfile)
3
3
  require_relative "shell_out"
4
4
 
5
5
  module Berkshelf
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ def windows?
2
2
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
3
3
  end
4
4
 
5
- BERKS_SPEC_DATA = File.expand_path("../data", __FILE__)
5
+ BERKS_SPEC_DATA = File.expand_path("data", __dir__)
6
6
 
7
7
  require "rspec"
8
8
  require "cleanroom/rspec"
@@ -104,11 +104,10 @@ module Berkshelf
104
104
 
105
105
  context "when the repository is cached" do
106
106
  it "pulls a new version" do
107
- allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
108
-
107
+ cache_path = subject.send(:cache_path)
109
108
  allow(subject).to receive(:cached?).and_return(true)
110
109
  expect(subject).to receive(:git).with(
111
- 'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"'
110
+ 'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"', cwd: cache_path.to_s
112
111
  )
113
112
  subject.install
114
113
  end
@@ -116,8 +115,6 @@ module Berkshelf
116
115
 
117
116
  context "when the revision is not cached" do
118
117
  it "clones the repository" do
119
- allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
120
-
121
118
  cache_path = subject.send(:cache_path)
122
119
  allow(subject).to receive(:cached?).and_return(false)
123
120
  expect(subject).to receive(:git).with(
@@ -4,7 +4,7 @@ require "chef/cookbook_manifest"
4
4
  describe Berkshelf::RidleyCompat do
5
5
  let(:opts) { {} }
6
6
 
7
- subject { described_class.new(opts) }
7
+ subject { described_class.new(**opts) }
8
8
 
9
9
  context "default" do
10
10
  it "has a cookbook version_class" do
@@ -4,8 +4,9 @@ module Berkshelf
4
4
  describe Source do
5
5
  let(:berksfile) { double("Berksfile", filepath: "/test/Berksfile") }
6
6
  let(:arguments) { [] }
7
+ let(:kwargs) { {} }
7
8
  let(:config) { Config.new }
8
- subject(:instance) { described_class.new(berksfile, *arguments) }
9
+ subject(:instance) { described_class.new(berksfile, *arguments, **kwargs) }
9
10
  before do
10
11
  allow(Berkshelf::Config).to receive(:instance).and_return(config)
11
12
  end
@@ -19,7 +20,8 @@ module Berkshelf
19
20
  end
20
21
 
21
22
  context "with a string argument and options" do
22
- let(:arguments) { ["https://example.com", { key: "value" }] }
23
+ let(:arguments) { ["https://example.com" ] }
24
+ let(:kwargs) { { key: "value" } }
23
25
  it { is_expected.to eq :supermarket }
24
26
  end
25
27
 
@@ -29,7 +31,8 @@ module Berkshelf
29
31
  end
30
32
 
31
33
  context "with a symbol argument and options" do
32
- let(:arguments) { [:chef_server, { key: "value" }] }
34
+ let(:arguments) { [:chef_server ] }
35
+ let(:kwargs) { { key: "value" } }
33
36
  it { is_expected.to eq :chef_server }
34
37
  end
35
38
 
@@ -44,7 +47,8 @@ module Berkshelf
44
47
  end
45
48
 
46
49
  context "with a hash argument and disconnected options" do
47
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
50
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
51
+ let(:kwargs) { { key: "value" } }
48
52
  it { is_expected.to eq :artifactory }
49
53
  end
50
54
  end
@@ -58,7 +62,8 @@ module Berkshelf
58
62
  end
59
63
 
60
64
  context "with a string argument and options" do
61
- let(:arguments) { ["https://example.com", { key: "value" }] }
65
+ let(:arguments) { ["https://example.com" ] }
66
+ let(:kwargs) { { key: "value" } }
62
67
  it { is_expected.to eq "https://example.com" }
63
68
  end
64
69
 
@@ -69,7 +74,8 @@ module Berkshelf
69
74
  end
70
75
 
71
76
  context "with a symbol argument and options" do
72
- let(:arguments) { [:chef_server, { key: "value" }] }
77
+ let(:arguments) { [:chef_server] }
78
+ let(:kwargs) { { key: "value" } }
73
79
  before { config.chef.chef_server_url = "https://chefserver/" }
74
80
  it { is_expected.to eq "https://chefserver/" }
75
81
  end
@@ -85,7 +91,8 @@ module Berkshelf
85
91
  end
86
92
 
87
93
  context "with a hash argument and disconnected options" do
88
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
94
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" } ] }
95
+ let(:kwargs) { { key: "value" } }
89
96
  it { is_expected.to eq "https://example.com/api/chef/chef-virtual" }
90
97
  end
91
98
 
@@ -96,7 +103,7 @@ module Berkshelf
96
103
 
97
104
  context "with a chef_repo source" do
98
105
  let(:arguments) { [{ chef_repo: "." }] }
99
- it { is_expected.to eq(windows? ? "file://C/test" : "file:///test") }
106
+ it { is_expected.to eq(windows? ? "file://D/test" : "file:///test") }
100
107
  end
101
108
  end
102
109
 
@@ -119,7 +126,8 @@ module Berkshelf
119
126
  end
120
127
 
121
128
  context "with a string argument and options" do
122
- let(:arguments) { ["https://example.com", { key: "value" }] }
129
+ let(:arguments) { ["https://example.com"] }
130
+ let(:kwargs) { { key: "value" } }
123
131
  its([:key]) { is_expected.to eq "value" }
124
132
  end
125
133
 
@@ -129,7 +137,8 @@ module Berkshelf
129
137
  end
130
138
 
131
139
  context "with a symbol argument and options" do
132
- let(:arguments) { [:chef_server, { key: "value" }] }
140
+ let(:arguments) { [:chef_server] }
141
+ let(:kwargs) { { key: "value" } }
133
142
  its([:key]) { is_expected.to eq "value" }
134
143
  end
135
144
 
@@ -144,7 +153,8 @@ module Berkshelf
144
153
  end
145
154
 
146
155
  context "with a hash argument and disconnected options" do
147
- let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
156
+ let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" } ] }
157
+ let(:kwargs) { { key: "value" } }
148
158
  its([:key]) { is_expected.to eq "value" }
149
159
  end
150
160
 
@@ -156,7 +166,7 @@ module Berkshelf
156
166
 
157
167
  context "with a chef_repo source" do
158
168
  let(:arguments) { [{ chef_repo: "." }] }
159
- its([:path]) { is_expected.to eq(windows? ? "C:/test" : "/test") }
169
+ its([:path]) { is_expected.to eq(windows? ? "D:/test" : "/test") }
160
170
  end
161
171
  end
162
172
 
@@ -73,7 +73,6 @@ describe Berkshelf::SSLPolicy do
73
73
  before do
74
74
  allow(chef_config).to receive_messages(trusted_certs_dir: self_signed_crt_path_windows_backslashes)
75
75
  allow(File).to receive(:exist?).with(self_signed_crt_path_windows_forwardslashes).and_return(true)
76
- allow(Dir).to receive(:chdir).with(self_signed_crt_path_windows_forwardslashes)
77
76
  end
78
77
 
79
78
  it "replaces the backslashes in trusted_certs_dir from Berkshelf config with forwardslashes" do
@@ -4,10 +4,6 @@ describe Berkshelf::Validator do
4
4
  describe "#validate_files" do
5
5
  let(:cookbook) { double("cookbook", cookbook_name: "cookbook", path: "path") }
6
6
 
7
- before do
8
- allow(Dir).to receive(:chdir) { |&block| block.call }
9
- end
10
-
11
7
  it "raises an error when the cookbook has spaces in the files" do
12
8
  allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
13
9
  expect do
@@ -21,14 +17,5 @@ describe Berkshelf::Validator do
21
17
  subject.validate_files(cookbook)
22
18
  end.to_not raise_error
23
19
  end
24
-
25
- it "does not raise an exception with spaces in the path" do
26
- allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
27
- allow_any_instance_of(Pathname).to receive(:dirname).and_return("/there are/spaces/in this")
28
-
29
- expect do
30
- subject.validate_files(cookbook)
31
- end.to_not raise_error
32
- end
33
20
  end
34
21
  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.1.0
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,10 +9,10 @@ authors:
9
9
  - Michael Ivey
10
10
  - Justin Campbell
11
11
  - Seth Vargo
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-06-25 00:00:00.000000000 Z
15
+ date: 2021-02-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: '0.4'
133
+ version: 1.1.4
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: '0.4'
143
+ version: 1.1.4
144
144
  - - "<"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '2.0'
@@ -314,21 +314,6 @@ 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/dep-1.0.0/attributes/default.rb
318
- - spec/tmp/berkshelf/cookbooks/dep-1.0.0/files/default/file.h
319
- - spec/tmp/berkshelf/cookbooks/dep-1.0.0/metadata.rb
320
- - spec/tmp/berkshelf/cookbooks/dep-1.0.0/recipes/default.rb
321
- - spec/tmp/berkshelf/cookbooks/dep-1.0.0/templates/default/template.erb
322
- - spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/attributes/default.rb
323
- - spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/files/default/file.h
324
- - spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/metadata.rb
325
- - spec/tmp/berkshelf/cookbooks/ekaf-1.0.0/recipes/default.rb
326
- - spec/tmp/berkshelf/cookbooks/ekaf-1.0.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
332
317
  - spec/unit/berkshelf/berksfile_spec.rb
333
318
  - spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb
334
319
  - spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb
@@ -374,7 +359,7 @@ homepage: https://docs.chef.io/berkshelf.html
374
359
  licenses:
375
360
  - Apache-2.0
376
361
  metadata: {}
377
- post_install_message:
362
+ post_install_message:
378
363
  rdoc_options: []
379
364
  require_paths:
380
365
  - lib
@@ -389,8 +374,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
389
374
  - !ruby/object:Gem::Version
390
375
  version: 2.0.0
391
376
  requirements: []
392
- rubygems_version: 3.1.2
393
- signing_key:
377
+ rubygems_version: 3.1.4
378
+ signing_key:
394
379
  specification_version: 4
395
380
  summary: Manages a Chef cookbook's dependencies
396
381
  test_files: []
@@ -1,2 +0,0 @@
1
- name 'dep'
2
- version '1.0.0'
@@ -1,3 +0,0 @@
1
- name 'ekaf'
2
- version '1.0.0'
3
- depends 'dep', '~> 1.0.0'
@@ -1,3 +0,0 @@
1
- name 'fake'
2
- version '1.0.0'
3
- depends 'dep', '~> 1.0.0'