berkshelf 1.4.6 → 2.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +1 -5
  3. data/CONTRIBUTING.md +3 -1
  4. data/Gemfile +11 -1
  5. data/README.md +16 -0
  6. data/Thorfile +3 -1
  7. data/berkshelf.gemspec +26 -38
  8. data/features/apply_command.feature +32 -0
  9. data/features/configure_command.feature +31 -0
  10. data/features/contingent_command.feature +5 -5
  11. data/features/default_locations.feature +2 -2
  12. data/features/groups_install.feature +19 -20
  13. data/features/info_command.feature +13 -13
  14. data/features/install_command.feature +86 -83
  15. data/features/json_formatter.feature +60 -23
  16. data/features/list_command.feature +5 -11
  17. data/features/lockfile.feature +286 -6
  18. data/features/open_command.feature +8 -4
  19. data/features/outdated_command.feature +8 -15
  20. data/features/package_command.feature +39 -0
  21. data/features/show_command.feature +8 -9
  22. data/features/step_definitions/chef_server_steps.rb +20 -2
  23. data/features/step_definitions/cli_steps.rb +10 -2
  24. data/features/step_definitions/configure_cli_steps.rb +7 -0
  25. data/features/step_definitions/filesystem_steps.rb +19 -14
  26. data/features/step_definitions/json_steps.rb +22 -5
  27. data/features/step_definitions/utility_steps.rb +13 -1
  28. data/features/support/env.rb +10 -23
  29. data/features/update_command.feature +105 -24
  30. data/features/upload_command.feature +0 -14
  31. data/features/vendor_install.feature +3 -3
  32. data/generator_files/Vagrantfile.erb +11 -11
  33. data/lib/berkshelf.rb +6 -5
  34. data/lib/berkshelf/berksfile.rb +267 -99
  35. data/lib/berkshelf/cli.rb +70 -34
  36. data/lib/berkshelf/cli_commands/test_command.rb +11 -0
  37. data/lib/berkshelf/community_rest.rb +1 -1
  38. data/lib/berkshelf/config.rb +19 -2
  39. data/lib/berkshelf/cookbook_source.rb +41 -12
  40. data/lib/berkshelf/cookbook_store.rb +8 -4
  41. data/lib/berkshelf/errors.rb +61 -29
  42. data/lib/berkshelf/formatters.rb +13 -19
  43. data/lib/berkshelf/formatters/human_readable.rb +8 -0
  44. data/lib/berkshelf/formatters/json.rb +12 -1
  45. data/lib/berkshelf/formatters/null.rb +23 -0
  46. data/lib/berkshelf/init_generator.rb +22 -11
  47. data/lib/berkshelf/location.rb +8 -10
  48. data/lib/berkshelf/locations/chef_api_location.rb +4 -5
  49. data/lib/berkshelf/locations/git_location.rb +14 -12
  50. data/lib/berkshelf/locations/path_location.rb +16 -1
  51. data/lib/berkshelf/locations/site_location.rb +1 -3
  52. data/lib/berkshelf/lockfile.rb +230 -33
  53. data/lib/berkshelf/resolver.rb +2 -1
  54. data/lib/berkshelf/ui.rb +4 -8
  55. data/lib/berkshelf/version.rb +1 -1
  56. data/lib/thor/monkies/shell.rb +2 -5
  57. data/spec/fixtures/cassettes/Berkshelf_Resolver/{ClassMethods/_initialize → _initialize}/adds_the_dependencies_of_the_source_as_sources.yml +0 -0
  58. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +2 -0
  59. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +26 -0
  60. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +5 -0
  61. data/spec/fixtures/lockfiles/default.lock +11 -0
  62. data/spec/{config/knife.rb → knife.rb.sample} +2 -2
  63. data/spec/spec_helper.rb +15 -3
  64. data/spec/support/chef_api.rb +19 -5
  65. data/spec/support/chef_server.rb +4 -3
  66. data/spec/support/knife.rb +18 -0
  67. data/spec/unit/berkshelf/berksfile_spec.rb +332 -235
  68. data/spec/unit/berkshelf/cached_cookbook_spec.rb +40 -42
  69. data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +11 -15
  70. data/spec/unit/berkshelf/community_rest_spec.rb +16 -14
  71. data/spec/unit/berkshelf/config_spec.rb +36 -20
  72. data/spec/unit/berkshelf/cookbook_generator_spec.rb +6 -10
  73. data/spec/unit/berkshelf/cookbook_source_spec.rb +244 -183
  74. data/spec/unit/berkshelf/cookbook_store_spec.rb +72 -76
  75. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
  76. data/spec/unit/berkshelf/downloader_spec.rb +137 -157
  77. data/spec/unit/berkshelf/errors_spec.rb +1 -1
  78. data/spec/unit/berkshelf/formatters/null_spec.rb +17 -0
  79. data/spec/unit/berkshelf/formatters_spec.rb +83 -90
  80. data/spec/unit/berkshelf/git_spec.rb +219 -207
  81. data/spec/unit/berkshelf/init_generator_spec.rb +73 -73
  82. data/spec/unit/berkshelf/location_spec.rb +143 -162
  83. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +94 -89
  84. data/spec/unit/berkshelf/locations/git_location_spec.rb +75 -59
  85. data/spec/unit/berkshelf/locations/path_location_spec.rb +46 -30
  86. data/spec/unit/berkshelf/locations/site_location_spec.rb +4 -4
  87. data/spec/unit/berkshelf/lockfile_spec.rb +185 -1
  88. data/spec/unit/berkshelf/logger_spec.rb +6 -24
  89. data/spec/unit/berkshelf/mixin/logging_spec.rb +6 -8
  90. data/spec/unit/berkshelf/resolver_spec.rb +36 -38
  91. data/spec/unit/berkshelf/ui_spec.rb +9 -10
  92. data/spec/unit/berkshelf_spec.rb +41 -40
  93. data/spec/unit/chef/config_spec.rb +9 -11
  94. metadata +55 -203
  95. data/spec/config/berkshelf.pem +0 -27
  96. data/spec/config/validator.pem +0 -27
@@ -79,9 +79,13 @@ module Berkshelf
79
79
  type: :boolean,
80
80
  default: false,
81
81
  desc: "create a new configuration file even if one already exists."
82
+ method_option :path,
83
+ type: :string,
84
+ default: Berkshelf::Config.path,
85
+ desc: 'The path to save the configuration file'
82
86
  desc "configure", "Create a new configuration file to customize Berkshelf's behavior"
83
- def configure(path = Berkshelf::Config.path)
84
- path = File.expand_path(path)
87
+ def configure
88
+ path = File.expand_path(options[:path])
85
89
 
86
90
  if File.exist?(path) && !options[:force]
87
91
  raise Berkshelf::ConfigExists, "A configuration file already exists. Re-run with the --force flag if you wish to overwrite it."
@@ -145,7 +149,7 @@ module Berkshelf
145
149
  aliases: "-o"
146
150
  method_option :berksfile,
147
151
  type: :string,
148
- default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
152
+ default: Berkshelf::DEFAULT_FILENAME,
149
153
  desc: "Path to a Berksfile to operate off of.",
150
154
  aliases: "-b",
151
155
  banner: "PATH"
@@ -236,6 +240,24 @@ module Berkshelf
236
240
  berksfile.upload(upload_options)
237
241
  end
238
242
 
243
+ method_option :berksfile,
244
+ type: :string,
245
+ default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
246
+ desc: "Path to a Berksfile to operate off of.",
247
+ aliases: "-b",
248
+ banner: "PATH"
249
+ method_option :ssl_verify,
250
+ type: :boolean,
251
+ default: nil,
252
+ desc: "Disable/Enable SSL verification when locking cookbooks."
253
+ desc "apply ENVIRONMENT", "Apply cookbook locks of your Berksfile.lock to the target Chef environment."
254
+ def apply(environment_name)
255
+ berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
256
+ lock_options = Hash[options].symbolize_keys
257
+
258
+ berksfile.apply(environment_name, lock_options)
259
+ end
260
+
239
261
  method_option :berksfile,
240
262
  type: :string,
241
263
  default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
@@ -273,27 +295,6 @@ module Berkshelf
273
295
  end
274
296
  end
275
297
 
276
- method_option :foodcritic,
277
- type: :boolean,
278
- desc: "Creates a Thorfile with Foodcritic support to lint test your cookbook"
279
- method_option :scmversion,
280
- type: :boolean,
281
- desc: "Creates a Thorfile with SCMVersion support to manage versions for continuous integration"
282
- method_option :no_bundler,
283
- type: :boolean,
284
- desc: "Skips generation of a Gemfile and other Bundler specific support"
285
- method_option :vagrant,
286
- type: :boolean,
287
- hide: true
288
- method_option :skip_vagrant,
289
- type: :boolean,
290
- desc: "Skips adding a Vagrantfile and adding supporting gems to the Gemfile"
291
- method_option :git,
292
- type: :boolean,
293
- hide: true
294
- method_option :skip_git,
295
- type: :boolean,
296
- desc: "Skips adding a .gitignore and running git init in the cookbook directory"
297
298
  desc "init [PATH]", "Prepare a local path to have its Cookbook dependencies managed by Berkshelf"
298
299
  def init(path = Dir.pwd)
299
300
  Berkshelf.formatter.deprecation "--git is now the default" if options[:git]
@@ -308,6 +309,7 @@ module Berkshelf
308
309
 
309
310
  ::Berkshelf.formatter.msg "Successfully initialized"
310
311
  end
312
+ tasks["init"].options = Berkshelf::InitGenerator.class_options
311
313
 
312
314
  method_option :berksfile,
313
315
  type: :string,
@@ -319,9 +321,9 @@ module Berkshelf
319
321
  def list
320
322
  berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
321
323
 
322
- Berkshelf.ui.say "Cookbooks installed by your Berksfile:"
323
- Berkshelf.ui.mute { berksfile.resolve }.sort.each do |cookbook|
324
- Berkshelf.ui.say " * #{cookbook.cookbook_name} (#{cookbook.version})"
324
+ Berkshelf.formatter.msg "Cookbooks installed by your Berksfile:"
325
+ Berkshelf.ui.mute { berksfile.resolve(berksfile.sources)[:solution] }.sort.each do |cookbook|
326
+ Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
325
327
  end
326
328
  end
327
329
 
@@ -334,10 +336,14 @@ module Berkshelf
334
336
  desc "show COOKBOOK", "Display the source path on the local file system for the given cookbook"
335
337
  def show(name)
336
338
  berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
337
- cookbook = Berkshelf.ui.mute { berksfile.resolve }.find{ |cookbook| cookbook.cookbook_name == name }
339
+ source = berksfile.find(name)
340
+
341
+ cookbook = Berkshelf.ui.mute {
342
+ berksfile.resolve(source)[:solution].first
343
+ }
338
344
 
339
345
  raise CookbookNotFound, "Cookbook '#{name}' was not installed by your Berksfile" unless cookbook
340
- Berkshelf.ui.say(cookbook.path)
346
+ Berkshelf.formatter.msg(cookbook.path)
341
347
  end
342
348
 
343
349
  method_option :version,
@@ -353,7 +359,7 @@ module Berkshelf
353
359
  end
354
360
 
355
361
  raise CookbookNotFound, "Cookbook '#{name}' was not installed by your Berksfile" if cookbook.nil?
356
- Berkshelf.ui.say(cookbook.pretty_print)
362
+ Berkshelf.formatter.msg(cookbook.pretty_print)
357
363
  end
358
364
 
359
365
  method_option :berksfile,
@@ -366,14 +372,40 @@ module Berkshelf
366
372
  def contingent(name)
367
373
  berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
368
374
 
369
- Berkshelf.ui.say "Cookbooks contingent upon #{name}:"
370
- sources = Berkshelf.ui.mute { berksfile.resolve }.sort.each do |cookbook|
375
+ Berkshelf.formatter.msg "Cookbooks contingent upon #{name}:"
376
+ sources = Berkshelf.ui.mute { berksfile.resolve(berksfile.sources)[:solution] }.sort.each do |cookbook|
371
377
  if cookbook.dependencies.include?(name)
372
- Berkshelf.ui.say " * #{cookbook.cookbook_name} (#{cookbook.version})"
378
+ Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
373
379
  end
374
380
  end
375
381
  end
376
382
 
383
+ method_option :berksfile,
384
+ type: :string,
385
+ default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
386
+ desc: "Path to a Berksfile to operate off of.",
387
+ aliases: "-b",
388
+ banner: "PATH"
389
+ method_option :output,
390
+ type: :string,
391
+ default: Dir.pwd,
392
+ desc: "Path to output the tarball",
393
+ aliases: "-o",
394
+ banner: "PATH"
395
+ method_option :skip_dependencies,
396
+ type: :boolean,
397
+ desc: "Skip packaging dependent cookbook(s).",
398
+ default: false
399
+ method_option :ignore_chefignore,
400
+ type: :boolean,
401
+ desc: "Do not apply the chefignore to the packaged contents",
402
+ default: false
403
+ desc "package [COOKBOOK]", "Package this cookbook and all it's dependencies in a tarball"
404
+ def package(name = nil)
405
+ berksfile = Berkshelf::Berksfile.from_file(options[:berksfile])
406
+ berksfile.package(name, options)
407
+ end
408
+
377
409
  desc "version", "Display version and copyright information"
378
410
  def version
379
411
  Berkshelf.formatter.msg version_header
@@ -392,7 +424,6 @@ module Berkshelf
392
424
  desc: "Creates a Thorfile with SCMVersion support to manage versions for continuous integration"
393
425
  method_option :license,
394
426
  type: :string,
395
- default: "reserved",
396
427
  desc: "License for cookbook (apachev2, gplv2, gplv3, mit, reserved)",
397
428
  aliases: "-L"
398
429
  method_option :maintainer,
@@ -441,3 +472,8 @@ module Berkshelf
441
472
  end
442
473
  end
443
474
  end
475
+
476
+ Dir["#{File.dirname(__FILE__)}/cli_commands/*.rb"].sort.each do |path|
477
+ require "berkshelf/cli_commands/#{File.basename(path, '.rb')}"
478
+ end
479
+
@@ -0,0 +1,11 @@
1
+ require 'kitchen/cli'
2
+
3
+ module Berkshelf
4
+ class TestCommand < Kitchen::CLI
5
+ namespace "test"
6
+ end
7
+
8
+ class Cli
9
+ register(TestCommand, 'test', 'test [COMMAND]', 'Testing tasks for your cookbook')
10
+ end
11
+ end
@@ -74,7 +74,7 @@ module Berkshelf
74
74
  @retry_interval = options[:retry_interval]
75
75
 
76
76
  builder = Faraday::Builder.new do |b|
77
- b.response :parse_json
77
+ b.response :json
78
78
  b.request :retry,
79
79
  max: @retries,
80
80
  interval: @retry_interval,
@@ -4,12 +4,29 @@ module Berkshelf
4
4
  # @author Justin Campbell <justin.campbell@riotgames.com>
5
5
  # @author Jamie Winsor <reset@riotgames.com>
6
6
  class Config < Chozo::Config::JSON
7
- FILENAME = "config.json".freeze
7
+ LOCATIONS = [
8
+ File.join('.', '.berkshelf', 'config.json').freeze,
9
+ File.join('.', 'berkshelf', 'config.json').freeze,
10
+ File.join('.', 'berkshelf-config.json').freeze,
11
+ File.join('.', 'config.json').freeze
12
+ ].freeze
8
13
 
9
14
  class << self
15
+ # @return [String]
16
+ def default_location
17
+ File.join(Berkshelf.berkshelf_path, 'config.json')
18
+ end
19
+
10
20
  # @return [String]
11
21
  def path
12
- @path || File.join(Berkshelf.berkshelf_path, FILENAME)
22
+ @path ||= begin
23
+ location = LOCATIONS.find do |file|
24
+ path = File.expand_path(file)
25
+ File.exists?(path)
26
+ end
27
+
28
+ File.expand_path(location || default_location)
29
+ end
13
30
  end
14
31
 
15
32
  # @param [String] new_path
@@ -66,14 +66,18 @@ module Berkshelf
66
66
  end
67
67
  end
68
68
 
69
- extend Forwardable
69
+ DEFAULT_CONSTRAINT = '>= 0.0.0'
70
70
 
71
71
  # @return [Berkshelf::Berksfile]
72
72
  attr_reader :berksfile
73
73
  # @return [String]
74
74
  attr_reader :name
75
+ # @return [Array<String,Symbol>]
76
+ attr_reader :groups
77
+ # @return [Berkshelf::Location]
78
+ attr_reader :location
75
79
  # @return [Solve::Constraint]
76
- attr_reader :version_constraint
80
+ attr_accessor :version_constraint
77
81
  # @return [Berkshelf::CachedCookbook]
78
82
  attr_accessor :cached_cookbook
79
83
 
@@ -100,12 +104,14 @@ module Berkshelf
100
104
  # same as tag
101
105
  # @option options [String] :locked_version
102
106
  def initialize(berksfile, name, options = {})
107
+ @options = options
108
+
103
109
  self.class.validate_options(options)
104
110
 
105
111
  @berksfile = berksfile
106
112
  @name = name
107
113
  @locked_version = Solve::Version.new(options[:locked_version]) if options[:locked_version]
108
- @version_constraint = Solve::Constraint.new(options[:locked_version] || options[:constraint] || ">= 0.0.0")
114
+ @version_constraint = Solve::Constraint.new(options[:constraint] || DEFAULT_CONSTRAINT)
109
115
 
110
116
  @cached_cookbook, @location = cached_and_location(options)
111
117
 
@@ -173,21 +179,44 @@ module Berkshelf
173
179
  end
174
180
 
175
181
  def to_s
176
- msg = "#{self.name} (#{self.version_constraint}) groups: #{self.groups}"
177
- msg << " location: #{self.location}" if self.location
178
- msg
182
+ "#<Berkshelf::CookbookSource: #{name} (#{version_constraint})>"
183
+ end
184
+
185
+ def inspect
186
+ '#<Berkshelf::CookbookSource: ' << [
187
+ "#{name} (#{version_constraint})",
188
+ "locked_version: #{locked_version.inspect}",
189
+ "groups: #{groups}",
190
+ "location: #{location || 'default'}>"
191
+ ].join(', ')
179
192
  end
180
193
 
181
194
  def to_hash
182
195
  {}.tap do |h|
183
- h[:name] = self.name
184
- h[:locked_version] = self.locked_version
185
- h[:location] = self.location.to_hash if self.location
186
- end
196
+ h[:locked_version] = locked_version.to_s
197
+
198
+ unless version_constraint.to_s == DEFAULT_CONSTRAINT
199
+ h[:constraint] = version_constraint.to_s
200
+ end
201
+
202
+ if location.kind_of?(SiteLocation) && location.api_uri != CommunityREST::V1_API
203
+ h[:site] = location.api_uri
204
+ end
205
+
206
+ if location.kind_of?(GitLocation)
207
+ h[:git] = location.uri
208
+ h[:ref] = location.ref
209
+ end
210
+
211
+ # Path is intentionally left relative here for cross-team compatibility
212
+ if @options[:path]
213
+ h[:path] = @options[:path].to_s
214
+ end
215
+ end.reject { |k,v| v.blank? }
187
216
  end
188
217
 
189
- def to_json
190
- MultiJson.dump(self.to_hash, pretty: true)
218
+ def to_json(options = {})
219
+ JSON.pretty_generate(to_hash, options)
191
220
  end
192
221
 
193
222
  private
@@ -42,16 +42,20 @@ module Berkshelf
42
42
  #
43
43
  # @return [Array<Berkshelf::CachedCookbook>]
44
44
  def cookbooks(filter = nil)
45
- [].tap do |cookbooks|
46
- storage_path.each_child do |p|
47
- cached_cookbook = CachedCookbook.from_store_path(p)
45
+ cookbooks = []
46
+
47
+ storage_path.each_child.map do |path|
48
+ Celluloid::Future.new do
49
+ cached_cookbook = CachedCookbook.from_store_path(path)
48
50
 
49
51
  next unless cached_cookbook
50
52
  next if filter && cached_cookbook.cookbook_name != filter
51
53
 
52
54
  cookbooks << cached_cookbook
53
55
  end
54
- end
56
+ end.each(&:value)
57
+
58
+ cookbooks
55
59
  end
56
60
 
57
61
  # Returns an expanded path to the location on disk where the Cookbook
@@ -117,7 +117,39 @@ module Berkshelf
117
117
  end
118
118
  end
119
119
 
120
- class AmbiguousCookbookName < BerkshelfError; status_code(114); end
120
+ # @author Seth Vargo <sethvargo@gmail.com>
121
+ class MismatchedCookbookName < BerkshelfError
122
+ status_code(114)
123
+
124
+ # @return [Berkshelf::Location]
125
+ attr_reader :location
126
+
127
+ # @return [Berkshelf::CachedCookbook]
128
+ attr_reader :cached_cookbook
129
+
130
+ # @param [Berkshelf::Location] location
131
+ # the location that is mismatched
132
+ # @param [Berkshelf::CachedCookbook] cached_cookbook
133
+ # the cached_cookbook that is mismatched
134
+ def initialize(location, cached_cookbook)
135
+ @location = location
136
+ @cached_cookbook = cached_cookbook
137
+ end
138
+
139
+ def to_s
140
+ [
141
+ "In your Berksfile, you have:",
142
+ "",
143
+ " cookbook '#{location.name}'",
144
+ "",
145
+ "But that cookbook is actually named '#{cached_cookbook.cookbook_name}'.",
146
+ "",
147
+ "This can cause potentially unwanted side-effects in the future.",
148
+ "",
149
+ "NOTE: If you don't explicitly set the `name` attribute in the metadata, the name of the directory will be used!"
150
+ ].join("\n")
151
+ end
152
+ end
121
153
 
122
154
  class InvalidConfiguration < BerkshelfError
123
155
  status_code(115)
@@ -147,7 +179,32 @@ module Berkshelf
147
179
  class ValidationFailed < BerkshelfError; status_code(121); end
148
180
  class InvalidVersionConstraint < BerkshelfError; status_code(122); end
149
181
  class CommunitySiteError < BerkshelfError; status_code(123); end
150
- class CookbookValidationFailure < BerkshelfError; status_code(124); end
182
+
183
+ class CookbookValidationFailure < BerkshelfError
184
+ status_code(124)
185
+
186
+ # @param [Berkshelf::Location] location
187
+ # the location (or any subclass) raising this validation error
188
+ # @param [Berkshelf::CachedCookbook] cached_cookbook
189
+ # the cached_cookbook that does not satisfy the constraint
190
+ def initialize(location, cached_cookbook)
191
+ @location = location
192
+ @cached_cookbook = cached_cookbook
193
+ end
194
+
195
+ def to_s
196
+ [
197
+ "The cookbook downloaded from #{@location.to_s}:",
198
+ " #{@cached_cookbook.cookbook_name} (#{@cached_cookbook.version})",
199
+ "",
200
+ "does not satisfy the version constraint:",
201
+ " #{@cached_cookbook.cookbook_name} (#{@location.version_constraint})",
202
+ "",
203
+ "This occurs when the Chef Server has a cookbook with a missing/mis-matched version number in its `metadata.rb`."
204
+ ].join("\n")
205
+ end
206
+ end
207
+
151
208
  class ClientKeyFileNotFound < BerkshelfError; status_code(125); end
152
209
 
153
210
  class UploadFailure < BerkshelfError; end
@@ -155,6 +212,8 @@ module Berkshelf
155
212
  class InvalidSiteShortnameError < BerkshelfError
156
213
  status_code(127)
157
214
 
215
+ # @param [String,Symbol] shortname
216
+ # the shortname for the site (see SiteLocation::SHORTNAMES)
158
217
  def initialize(shortname)
159
218
  @shortname = shortname
160
219
  end
@@ -222,33 +281,6 @@ module Berkshelf
222
281
  def to_s
223
282
  "The file at '#{@destination}' is not a known compression type!"
224
283
  end
225
- end
226
284
 
227
- # @author Seth Vargo <sethvargo@gmail.com>
228
- #
229
- # Raised when a cookbook or its recipes contain a space or invalid
230
- # character in the path.
231
- #
232
- # @param [Berkshelf::CachedCookbook] cookbook
233
- # the cookbook that failed validation
234
- # @param [Array<#to_s>] files
235
- # the list of files that were not valid
236
- class InvalidCookbookFiles < BerkshelfError
237
- status_code(132)
238
-
239
- def initialize(cookbook, files)
240
- @cookbook = cookbook
241
- @files = files
242
- end
243
-
244
- def to_s
245
- [
246
- "The cookbook '#{@cookbook.cookbook_name}' has invalid filenames:",
247
- "",
248
- " " + @files.map(&:to_s).join("\n "),
249
- "",
250
- "Please note, spaces are not a valid character in filenames."
251
- ].join("\n")
252
- end
253
285
  end
254
286
  end