berkshelf 6.3.4 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +10 -0
  4. data/.travis.yml +6 -8
  5. data/CHANGELOG.md +7 -19
  6. data/Gemfile +10 -0
  7. data/Gemfile.lock +68 -103
  8. data/Thorfile +2 -2
  9. data/berkshelf.gemspec +6 -8
  10. data/features/commands/info.feature +50 -8
  11. data/features/commands/shelf/show.feature +10 -40
  12. data/features/commands/upload.feature +73 -0
  13. data/features/commands/vendor.feature +43 -0
  14. data/features/json_formatter.feature +1 -1
  15. data/features/step_definitions/chef_server_steps.rb +2 -2
  16. data/features/step_definitions/filesystem_steps.rb +16 -0
  17. data/features/support/env.rb +11 -10
  18. data/lib/berkshelf.rb +15 -20
  19. data/lib/berkshelf/berksfile.rb +57 -47
  20. data/lib/berkshelf/cached_cookbook.rb +120 -19
  21. data/lib/berkshelf/chef_config_compat.rb +50 -0
  22. data/lib/berkshelf/chef_repo_universe.rb +2 -2
  23. data/lib/berkshelf/cli.rb +3 -42
  24. data/lib/berkshelf/community_rest.rb +40 -61
  25. data/lib/berkshelf/config.rb +92 -118
  26. data/lib/berkshelf/cookbook_store.rb +3 -2
  27. data/lib/berkshelf/core_ext/file.rb +1 -1
  28. data/lib/berkshelf/dependency.rb +1 -10
  29. data/lib/berkshelf/downloader.rb +19 -7
  30. data/lib/berkshelf/errors.rb +3 -0
  31. data/lib/berkshelf/location.rb +1 -1
  32. data/lib/berkshelf/locations/base.rb +1 -1
  33. data/lib/berkshelf/lockfile.rb +17 -13
  34. data/lib/berkshelf/logger.rb +62 -1
  35. data/lib/berkshelf/packager.rb +1 -1
  36. data/lib/berkshelf/resolver.rb +1 -1
  37. data/lib/berkshelf/ridley_compat.rb +22 -3
  38. data/lib/berkshelf/uploader.rb +76 -48
  39. data/lib/berkshelf/version.rb +1 -1
  40. data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
  41. data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
  42. data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
  43. data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
  44. data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
  45. data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
  46. data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
  47. data/spec/spec_helper.rb +2 -2
  48. data/spec/support/chef_api.rb +4 -4
  49. data/spec/support/chef_server.rb +1 -1
  50. data/spec/support/matchers/file_system_matchers.rb +1 -3
  51. data/spec/support/path_helpers.rb +1 -1
  52. data/spec/unit/berkshelf/berksfile_spec.rb +3 -24
  53. data/spec/unit/berkshelf/cached_cookbook_spec.rb +13 -15
  54. data/spec/unit/berkshelf/community_rest_spec.rb +3 -12
  55. data/spec/unit/berkshelf/config_spec.rb +4 -4
  56. data/spec/unit/berkshelf/downloader_spec.rb +6 -11
  57. data/spec/unit/berkshelf/lockfile_spec.rb +10 -7
  58. data/spec/unit/berkshelf/source_spec.rb +1 -1
  59. data/spec/unit/berkshelf/ssl_policies_spec.rb +2 -5
  60. data/spec/unit/berkshelf/uploader_spec.rb +60 -10
  61. data/spec/unit/berkshelf/visualizer_spec.rb +2 -2
  62. metadata +49 -102
  63. data/features/commands/cookbook.feature +0 -35
  64. data/features/commands/init.feature +0 -27
  65. data/features/config.feature +0 -111
  66. data/lib/berkshelf/base_generator.rb +0 -42
  67. data/lib/berkshelf/cookbook_generator.rb +0 -133
  68. data/lib/berkshelf/init_generator.rb +0 -195
  69. data/lib/berkshelf/streaming_file_adapter.rb +0 -22
  70. data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -108
  71. data/spec/unit/berkshelf/init_generator_spec.rb +0 -265
@@ -1,5 +1,8 @@
1
1
  require_relative "packager"
2
2
 
3
+ require "chef/cookbook/chefignore"
4
+ require "chef/util/path_helper"
5
+
3
6
  module Berkshelf
4
7
  class Berksfile
5
8
  class << self
@@ -9,7 +12,8 @@ module Berkshelf
9
12
  # @param (see Berksfile#initialize)
10
13
  def from_options(options = {})
11
14
  options[:berksfile] ||= File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME)
12
- from_file(options[:berksfile], options.slice(:except, :only, :delete))
15
+ symbolized = Hash[options.map { |k, v| [k.to_sym, v] }]
16
+ from_file(options[:berksfile], symbolized.select { |k,| [:except, :only, :delete].include? k })
13
17
  end
14
18
 
15
19
  # @param [#to_s] file
@@ -31,7 +35,7 @@ module Berkshelf
31
35
 
32
36
  # Don't vendor VCS files.
33
37
  # Reference GNU tar --exclude-vcs: https://www.gnu.org/software/tar/manual/html_section/tar_49.html
34
- EXCLUDED_VCS_FILES_WHEN_VENDORING = [".arch-ids", "{arch}", ".bzr", ".bzrignore", ".bzrtags", "CVS", ".cvsignore", "_darcs", ".git", ".hg", ".hgignore", ".hgrags", "RCS", "SCCS", ".svn", "**/.git"].freeze
38
+ EXCLUDED_VCS_FILES_WHEN_VENDORING = [".arch-ids", "{arch}", ".bzr", ".bzrignore", ".bzrtags", "CVS", ".cvsignore", "_darcs", ".git", ".hg", ".hgignore", ".hgrags", "RCS", "SCCS", ".svn", "**/.git", "**/.svn"].freeze
35
39
 
36
40
  include Mixin::Logging
37
41
  include Cleanroom
@@ -173,8 +177,11 @@ module Berkshelf
173
177
  # path to the metadata file
174
178
  def metadata(options = {})
175
179
  path = options[:path] || File.dirname(filepath)
176
- metadata_path = File.expand_path(File.join(path, "metadata.rb"))
177
- metadata = Ridley::Chef::Cookbook::Metadata.from_file(metadata_path)
180
+
181
+ loader = Chef::Cookbook::CookbookVersionLoader.new(path)
182
+ loader.load_cookbooks
183
+ cookbook_version = loader.cookbook_version
184
+ metadata = cookbook_version.metadata
178
185
 
179
186
  add_dependency(metadata.name, nil, path: path, metadata: true)
180
187
  end
@@ -253,35 +260,6 @@ module Berkshelf
253
260
  sources.find { |source| source.cookbook(name, version) }
254
261
  end
255
262
 
256
- # @todo remove in Berkshelf 4.0
257
- #
258
- # @raise [DeprecatedError]
259
- def site(*args)
260
- if args.first == :opscode
261
- Berkshelf.formatter.deprecation "Your Berksfile contains a site location pointing to the Opscode Community " +
262
- "Site (site :opscode). Site locations have been replaced by the source location. Change this to: " +
263
- "'source \"https://supermarket.chef.io\"' to remove this warning. For more information visit " +
264
- "https://github.com/berkshelf/berkshelf/wiki/deprecated-locations"
265
- source(DEFAULT_API_URL)
266
- return
267
- end
268
-
269
- raise DeprecatedError.new "Your Berksfile contains a site location. Site locations have been " +
270
- " replaced by the source location. Please remove your site location and try again. For more information " +
271
- " visit https://github.com/berkshelf/berkshelf/wiki/deprecated-locations"
272
- end
273
- expose :site
274
-
275
- # @todo remove in Berkshelf 4.0
276
- #
277
- # @raise [DeprecatedError]
278
- def chef_api(*args)
279
- raise DeprecatedError.new "Your Berksfile contains a chef_api location. Chef API locations have " +
280
- " been replaced by the source location. Please remove your site location and try again. For more " +
281
- " information visit https://github.com/berkshelf/berkshelf/wiki/deprecated-locations"
282
- end
283
- expose :chef_api
284
-
285
263
  # Add a dependency of the given name and constraint to the array of dependencies.
286
264
  #
287
265
  # @param [String] name
@@ -309,9 +287,10 @@ module Berkshelf
309
287
  end
310
288
  end
311
289
 
312
- if options[:path]
313
- metadata_file = File.join(options[:path], "metadata.rb")
314
- end
290
+ # this appears to be dead code
291
+ #if options[:path]
292
+ # metadata_file = File.join(options[:path], "metadata.rb")
293
+ #end
315
294
 
316
295
  options[:constraint] = constraint
317
296
 
@@ -621,6 +600,25 @@ module Berkshelf
621
600
  outdir
622
601
  end
623
602
 
603
+ # backcompat with ridley lookup of chefignore
604
+ def find_chefignore(path)
605
+ filename = "chefignore"
606
+
607
+ Pathname.new(path).ascend do |dir|
608
+ next unless dir.directory?
609
+
610
+ [
611
+ dir.join(filename),
612
+ dir.join("cookbooks", filename),
613
+ dir.join(".chef", filename),
614
+ ].each do |possible|
615
+ return possible.expand_path.to_s if possible.exist?
616
+ end
617
+ end
618
+
619
+ nil
620
+ end
621
+
624
622
  # Install the Berksfile or Berksfile.lock and then sync the cached cookbooks
625
623
  # into directories within the given destination matching their name.
626
624
  #
@@ -631,31 +629,43 @@ module Berkshelf
631
629
  # the expanded path cookbooks were vendored to or nil if nothing was vendored
632
630
  def vendor(destination)
633
631
  Dir.mktmpdir("vendor") do |scratch|
634
- chefignore = nil
635
632
  cached_cookbooks = install
636
- raw_metadata_files = []
637
633
 
638
634
  return nil if cached_cookbooks.empty?
639
635
 
640
636
  cached_cookbooks.each do |cookbook|
641
637
  Berkshelf.formatter.vendor(cookbook, destination)
638
+
639
+ # compile the metadata early before we do the file list
640
+ cookbook.compile_metadata
641
+ cookbook.reload
642
+
642
643
  cookbook_destination = File.join(scratch, cookbook.cookbook_name)
643
644
  FileUtils.mkdir_p(cookbook_destination)
644
645
 
645
646
  # Dir.glob does not support backslash as a File separator
646
647
  src = cookbook.path.to_s.tr('\\', "/")
647
- files = FileSyncer.glob(File.join(src, "*"))
648
+ files = FileSyncer.glob(File.join(src, "**/*"))
648
649
 
649
- chefignore = Ridley::Chef::Chefignore.new(cookbook.path.to_s) rescue nil
650
- chefignore.apply!(files) if chefignore
650
+ # strip directories
651
+ files.reject! { |file_path| File.directory?(file_path) }
651
652
 
652
- unless cookbook.compiled_metadata?
653
- cookbook.compile_metadata(cookbook_destination)
654
- end
653
+ # convert to relative Pathname objects for chefignore
654
+ files.map! { |file_path| Chef::Util::PathHelper.relative_path_from(cookbook.path.to_s, file_path) }
655
655
 
656
- raw_metadata_files << File.join(cookbook.cookbook_name, "metadata.rb")
656
+ chefignore = Chef::Cookbook::Chefignore.new(find_chefignore(cookbook.path.to_s) || cookbook.path.to_s)
657
657
 
658
- FileUtils.cp_r(files, cookbook_destination)
658
+ # apply chefignore
659
+ files.reject! { |file_path| chefignore.ignored?(file_path) }
660
+
661
+ # convert Pathname objects back to strings
662
+ files.map! { |f| f.to_s }
663
+
664
+ # copy each file to destination
665
+ files.each do |rpath|
666
+ FileUtils.mkdir_p( File.join(cookbook_destination, File.dirname(rpath)) )
667
+ FileUtils.cp( File.join(cookbook.path.to_s, rpath), File.join(cookbook_destination, rpath) )
668
+ end
659
669
  end
660
670
 
661
671
  # Don't vendor the raw metadata (metadata.rb). The raw metadata is
@@ -673,7 +683,7 @@ module Berkshelf
673
683
  #
674
684
  # * https://tickets.opscode.com/browse/CHEF-4811
675
685
  # * https://tickets.opscode.com/browse/CHEF-4810
676
- FileSyncer.sync(scratch, destination, exclude: raw_metadata_files + EXCLUDED_VCS_FILES_WHEN_VENDORING, delete: @delete)
686
+ FileSyncer.sync(scratch, destination, exclude: EXCLUDED_VCS_FILES_WHEN_VENDORING, delete: @delete)
677
687
  end
678
688
 
679
689
  destination
@@ -1,5 +1,10 @@
1
+ require "chef/cookbook/cookbook_version_loader"
2
+ require "chef/cookbook/syntax_check"
3
+ require "berkshelf/errors"
4
+ require "chef/json_compat"
5
+
1
6
  module Berkshelf
2
- class CachedCookbook < Ridley::Chef::Cookbook
7
+ class CachedCookbook
3
8
  class << self
4
9
  # @param [#to_s] path
5
10
  # a path on disk to the location of a Cookbook downloaded by the Downloader
@@ -15,38 +20,108 @@ module Berkshelf
15
20
  loaded_cookbooks[path.to_s] ||= from_path(path)
16
21
  end
17
22
 
23
+ # Creates a new instance of Berkshelf::CachedCookbook from a path on disk containing
24
+ # a Cookbook.
25
+ #
26
+ # The name of the Cookbook is determined by the value of the name attribute set in
27
+ # the cookbooks' metadata. If the name attribute is not present the name of the loaded
28
+ # cookbook is determined by directory containing the cookbook.
29
+ #
30
+ # @param [#to_s] path
31
+ # a path on disk to the location of a Cookbook
32
+ #
33
+ # @raise [IOError] if the path does not contain a metadata.rb or metadata.json file
34
+ #
35
+ # @return [Ridley::Chef::Cookbook]
36
+ def from_path(path)
37
+ path = Pathname.new(path)
38
+
39
+ new(path)
40
+ end
41
+
42
+ def checksum(filepath)
43
+ Chef::Digester.generate_md5_checksum_for_file(filepath)
44
+ end
45
+
18
46
  private
19
47
 
20
- # @return [Hash<String, CachedCookbook>]
48
+ # @return [Hash<String, CachedCookbook>]
21
49
  def loaded_cookbooks
22
50
  @loaded_cookbooks ||= {}
23
51
  end
24
52
  end
25
53
 
54
+ attr_writer :metadata
55
+ attr_accessor :path
56
+ attr_writer :cookbook_version
57
+
58
+ def initialize(path)
59
+ @path = path
60
+ # eagerly load to force throwing on bad metadata while constructing
61
+ cookbook_name
62
+ metadata
63
+ end
64
+
65
+ def loader
66
+ @loader ||=
67
+ begin
68
+ loader = Chef::Cookbook::CookbookVersionLoader.new(@path)
69
+ loader.load_cookbooks
70
+ loader
71
+ end
72
+ end
73
+
74
+ def cookbook_version
75
+ @cookbook_version ||= loader.cookbook_version
76
+ end
77
+
78
+ def cookbook_name
79
+ @cookbook_name ||= cookbook_version.name
80
+ end
81
+
82
+ def metadata
83
+ @metadata ||= cookbook_version.metadata
84
+ end
85
+
86
+ def reload
87
+ @metadata = nil
88
+ @cookbook_name = nil
89
+ @cookbook_version = nil
90
+ @loader = nil
91
+ end
92
+
93
+ def <=>(other)
94
+ [cookbook_name, version] <=> [other.cookbook_name, other.version]
95
+ end
96
+
26
97
  DIRNAME_REGEXP = /^(.+)-(.+)$/
27
98
 
28
99
  extend Forwardable
100
+
101
+ def_delegator :cookbook_version, :version
102
+ def_delegator :metadata, :name, :cookbook_name
29
103
  def_delegator :metadata, :description
30
104
  def_delegator :metadata, :maintainer
31
105
  def_delegator :metadata, :maintainer_email
32
106
  def_delegator :metadata, :license
33
107
  def_delegator :metadata, :platforms
108
+ def_delegator :metadata, :name
34
109
 
35
110
  # @return [Hash]
36
111
  def dependencies
37
- metadata.recommendations.merge(metadata.dependencies)
112
+ metadata.dependencies
38
113
  end
39
114
 
40
115
  def pretty_print
41
116
  [].tap do |a|
42
- a.push " Name: #{cookbook_name}" unless name.blank?
43
- a.push " Version: #{version}" unless version.blank?
44
- a.push " Description: #{metadata.description}" unless metadata.description.blank?
45
- a.push " Author: #{metadata.maintainer}" unless metadata.maintainer.blank?
46
- a.push " Email: #{metadata.maintainer_email}" unless metadata.maintainer_email.blank?
47
- a.push " License: #{metadata.license}" unless metadata.license.blank?
48
- a.push " Platforms: #{pretty_map(metadata.platforms, 14)}" unless metadata.platforms.blank?
49
- a.push "Dependencies: #{pretty_map(dependencies, 14)}" unless dependencies.blank?
117
+ a.push " Name: #{cookbook_name}" if name && name =~ /\S/
118
+ a.push " Version: #{version}" if version && version =~ /\S/
119
+ a.push " Description: #{metadata.description}" if metadata.description && metadata.description =~ /\S/
120
+ a.push " Author: #{metadata.maintainer}" if metadata.maintainer && metadata.maintainer =~ /\S/
121
+ a.push " Email: #{metadata.maintainer_email}" if metadata.maintainer_email && metadata.maintainer_email =~ /\S/
122
+ a.push " License: #{metadata.license}" if metadata.license && metadata.license =~ /\S/
123
+ a.push " Platforms: #{pretty_map(metadata.platforms, 14)}" if metadata.platforms && !metadata.platforms.empty?
124
+ a.push "Dependencies: #{pretty_map(dependencies, 14)}" if dependencies && !dependencies.empty?
50
125
  end.join("\n")
51
126
  end
52
127
 
@@ -62,17 +137,43 @@ module Berkshelf
62
137
  # @return [Hash]
63
138
  def pretty_hash
64
139
  {}.tap do |h|
65
- h[:name] = cookbook_name unless cookbook_name.blank?
66
- h[:version] = version unless version.blank?
67
- h[:description] = description unless description.blank?
68
- h[:author] = maintainer unless maintainer.blank?
69
- h[:email] = maintainer_email unless maintainer_email.blank?
70
- h[:license] = license unless license.blank?
71
- h[:platforms] = platforms.to_hash unless platforms.blank?
72
- h[:dependencies] = dependencies.to_hash unless dependencies.blank?
140
+ h[:name] = cookbook_name if cookbook_name && cookbook_name =~ /\S/
141
+ h[:version] = version if version && version =~ /\S/
142
+ h[:description] = description if description && description =~ /\S/
143
+ h[:author] = maintainer if maintainer && maintainer =~ /\S/
144
+ h[:email] = maintainer_email if maintainer_email && maintainer_email =~ /\S/
145
+ h[:license] = license if license && license =~ /\S/
146
+ h[:platforms] = platforms.to_hash if platforms && !platforms.empty?
147
+ h[:dependencies] = dependencies.to_hash if dependencies && !dependencies.empty?
73
148
  end
74
149
  end
75
150
 
151
+ def validate
152
+ raise IOError, "No Cookbook found at: #{path}" unless path.exist?
153
+
154
+ syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cookbook_name, path)
155
+ unless syntax_checker.validate_ruby_files
156
+ raise Berkshelf::Errors::CookbookSyntaxError, "Invalid ruby files in cookbook: #{cookbook_name} (#{version})."
157
+ end
158
+ unless syntax_checker.validate_templates
159
+ raise Berkshelf::Errors::CookbookSyntaxError, "Invalid template files in cookbook: #{cookbook_name} (#{version})."
160
+ end
161
+
162
+ true
163
+ end
164
+
165
+ def compile_metadata
166
+ json_file = "#{path}/metadata.json"
167
+ rb_file = "#{path}/metadata.rb"
168
+ return nil if File.exist?(json_file)
169
+ md = Chef::Cookbook::Metadata.new
170
+ md.from_file(rb_file)
171
+ f = File.open(json_file, "w")
172
+ f.write(Chef::JSONCompat.to_json_pretty(md))
173
+ f.close
174
+ f.path
175
+ end
176
+
76
177
  private
77
178
 
78
179
  def pretty_map(hash, padding)
@@ -0,0 +1,50 @@
1
+ require "chef-config/config"
2
+ require "chef-config/workstation_config_loader"
3
+ require "socket" # FIXME: why?
4
+
5
+ module Berkshelf
6
+ class ChefConfigCompat
7
+ # Create a new Chef Config object.
8
+ #
9
+ # @param [#to_s] path
10
+ # the path to the configuration file
11
+ # @param [Hash] options
12
+ def initialize(path, options = {})
13
+ ChefConfig::WorkstationConfigLoader.new(path).load
14
+ ChefConfig::Config.merge!(options)
15
+ ChefConfig::Config.export_proxies # Set proxy settings as environment variables
16
+ end
17
+
18
+ # Keep defaults that aren't in ChefConfig::Config
19
+ def cookbook_copyright(*args, &block)
20
+ ChefConfig::Config.cookbook_copyright(*args, &block) || "YOUR_NAME"
21
+ end
22
+
23
+ def cookbook_email(*args, &block)
24
+ ChefConfig::Config.cookbook_email(*args, &block) || "YOUR_EMAIL"
25
+ end
26
+
27
+ def cookbook_license(*args, &block)
28
+ ChefConfig::Config.cookbook_license(*args, &block) || "reserved"
29
+ end
30
+
31
+ # The configuration as a hash
32
+ def to_hash
33
+ ChefConfig::Config.save(true)
34
+ end
35
+
36
+ # Load from a file
37
+ def self.from_file(file)
38
+ new(file)
39
+ end
40
+
41
+ # Behave just like ChefConfig::Config in general
42
+ def method_missing(name, *args, &block)
43
+ ChefConfig::Config.send(name, *args, &block)
44
+ end
45
+
46
+ def respond_to_missing?(name)
47
+ ChefConfig::Config.respond_to?(name)
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  require "berkshelf/api_client/remote_cookbook"
2
- require "ridley/chef/cookbook"
2
+ require "berkshelf/cached_cookbook"
3
3
 
4
4
  module Berkshelf
5
5
  # Shim to look like a Berkshelf::APIClient but for a chef repo folder.
@@ -18,7 +18,7 @@ module Berkshelf
18
18
  entry_path = "#{cookbooks_path}/#{entry}"
19
19
  next unless File.directory?(entry_path) # Skip non-dirs.
20
20
  cookbook = begin
21
- Ridley::Chef::Cookbook.from_path(entry_path)
21
+ Berkshelf::CachedCookbook.from_path(entry_path)
22
22
  rescue IOError
23
23
  next # It wasn't a cookbook.
24
24
  end
@@ -1,7 +1,5 @@
1
1
  require "berkshelf"
2
2
  require_relative "config"
3
- require_relative "init_generator"
4
- require_relative "cookbook_generator"
5
3
  require_relative "commands/shelf"
6
4
 
7
5
  module Berkshelf
@@ -28,7 +26,7 @@ module Berkshelf
28
26
  Berkshelf.ui.error e
29
27
  Berkshelf.ui.error "\t" + e.backtrace.join("\n\t") if ENV["BERKSHELF_DEBUG"]
30
28
  @kernel.exit(e.status_code)
31
- rescue Ridley::Errors::RidleyError => e
29
+ rescue => e
32
30
  Berkshelf.ui.error "#{e.class} #{e}"
33
31
  Berkshelf.ui.error "\t" + e.backtrace.join("\n\t") if ENV["BERKSHELF_DEBUG"]
34
32
  @kernel.exit(47)
@@ -129,13 +127,6 @@ module Berkshelf
129
127
  hide: true
130
128
  desc "install", "Install the cookbooks specified in the Berksfile"
131
129
  def install
132
- if options[:path]
133
- # TODO: Remove in Berkshelf 4.0
134
- Berkshelf.formatter.deprecation "`berks install --path [PATH]` has been replaced by `berks vendor`."
135
- Berkshelf.formatter.deprecation "Re-run your command as `berks vendor [PATH]` or see `berks help vendor`."
136
- exit(1)
137
- end
138
-
139
130
  berksfile = Berksfile.from_options(options)
140
131
  berksfile.install
141
132
  end
@@ -201,8 +192,7 @@ module Berkshelf
201
192
 
202
193
  options[:freeze] = !options[:no_freeze]
203
194
  options[:validate] = false if options[:skip_syntax_check]
204
-
205
- berksfile.upload(names, options.symbolize_keys)
195
+ berksfile.upload(names, options.each_with_object({}) { |(k, v), m| m[k.to_sym] = v })
206
196
  end
207
197
 
208
198
  method_option :envfile,
@@ -226,7 +216,7 @@ module Berkshelf
226
216
  end
227
217
 
228
218
  lockfile = Lockfile.from_file(options[:lockfile])
229
- lock_options = Hash[options].symbolize_keys
219
+ lock_options = Hash[options].each_with_object({}) { |(k, v), m| m[k.to_sym] = v }
230
220
 
231
221
  lockfile.apply(environment_name, lock_options)
232
222
  end
@@ -264,21 +254,6 @@ module Berkshelf
264
254
  Berkshelf.formatter.search(cookbooks)
265
255
  end
266
256
 
267
- desc "init [PATH]", "Initialize Berkshelf in the given directory"
268
- def init(path = ".")
269
- Berkshelf.formatter.deprecation <<EOF
270
- This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
271
- Please use `chef generate cookbook` instead of this command.
272
- EOF
273
- Berkshelf.formatter.deprecation "--git is now the default" if options[:git]
274
- Berkshelf.formatter.deprecation "--vagrant is now the default" if options[:vagrant]
275
-
276
- Berkshelf::InitGenerator.new([path], options).invoke_all
277
-
278
- Berkshelf.formatter.msg "Successfully initialized"
279
- end
280
- tasks["init"].options = Berkshelf::InitGenerator.class_options
281
-
282
257
  method_option :berksfile,
283
258
  type: :string,
284
259
  default: nil,
@@ -437,20 +412,6 @@ EOF
437
412
  Berkshelf.formatter.version
438
413
  end
439
414
 
440
- desc "cookbook NAME [PATH]", "Create a skeleton for a new cookbook"
441
- def cookbook(name, path = nil)
442
- Berkshelf.formatter.deprecation <<EOF
443
- This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
444
- Please use `chef generate cookbook` instead of this command.
445
- EOF
446
- path = File.join(Dir.pwd, name) if path.nil?
447
- Berkshelf.formatter.deprecation "--git is now the default" if options[:git]
448
- Berkshelf.formatter.deprecation "--vagrant is now the default" if options[:vagrant]
449
-
450
- Berkshelf::CookbookGenerator.new([path, name], options).invoke_all
451
- end
452
- tasks["cookbook"].options = Berkshelf::CookbookGenerator.class_options
453
-
454
415
  private
455
416
 
456
417
  # Print a list of the given cookbooks. This is used by various