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.
- data/.gitignore +1 -0
- data/CHANGELOG.md +1 -5
- data/CONTRIBUTING.md +3 -1
- data/Gemfile +11 -1
- data/README.md +16 -0
- data/Thorfile +3 -1
- data/berkshelf.gemspec +26 -38
- data/features/apply_command.feature +32 -0
- data/features/configure_command.feature +31 -0
- data/features/contingent_command.feature +5 -5
- data/features/default_locations.feature +2 -2
- data/features/groups_install.feature +19 -20
- data/features/info_command.feature +13 -13
- data/features/install_command.feature +86 -83
- data/features/json_formatter.feature +60 -23
- data/features/list_command.feature +5 -11
- data/features/lockfile.feature +286 -6
- data/features/open_command.feature +8 -4
- data/features/outdated_command.feature +8 -15
- data/features/package_command.feature +39 -0
- data/features/show_command.feature +8 -9
- data/features/step_definitions/chef_server_steps.rb +20 -2
- data/features/step_definitions/cli_steps.rb +10 -2
- data/features/step_definitions/configure_cli_steps.rb +7 -0
- data/features/step_definitions/filesystem_steps.rb +19 -14
- data/features/step_definitions/json_steps.rb +22 -5
- data/features/step_definitions/utility_steps.rb +13 -1
- data/features/support/env.rb +10 -23
- data/features/update_command.feature +105 -24
- data/features/upload_command.feature +0 -14
- data/features/vendor_install.feature +3 -3
- data/generator_files/Vagrantfile.erb +11 -11
- data/lib/berkshelf.rb +6 -5
- data/lib/berkshelf/berksfile.rb +267 -99
- data/lib/berkshelf/cli.rb +70 -34
- data/lib/berkshelf/cli_commands/test_command.rb +11 -0
- data/lib/berkshelf/community_rest.rb +1 -1
- data/lib/berkshelf/config.rb +19 -2
- data/lib/berkshelf/cookbook_source.rb +41 -12
- data/lib/berkshelf/cookbook_store.rb +8 -4
- data/lib/berkshelf/errors.rb +61 -29
- data/lib/berkshelf/formatters.rb +13 -19
- data/lib/berkshelf/formatters/human_readable.rb +8 -0
- data/lib/berkshelf/formatters/json.rb +12 -1
- data/lib/berkshelf/formatters/null.rb +23 -0
- data/lib/berkshelf/init_generator.rb +22 -11
- data/lib/berkshelf/location.rb +8 -10
- data/lib/berkshelf/locations/chef_api_location.rb +4 -5
- data/lib/berkshelf/locations/git_location.rb +14 -12
- data/lib/berkshelf/locations/path_location.rb +16 -1
- data/lib/berkshelf/locations/site_location.rb +1 -3
- data/lib/berkshelf/lockfile.rb +230 -33
- data/lib/berkshelf/resolver.rb +2 -1
- data/lib/berkshelf/ui.rb +4 -8
- data/lib/berkshelf/version.rb +1 -1
- data/lib/thor/monkies/shell.rb +2 -5
- data/spec/fixtures/cassettes/Berkshelf_Resolver/{ClassMethods/_initialize → _initialize}/adds_the_dependencies_of_the_source_as_sources.yml +0 -0
- data/spec/fixtures/cookbooks/example_cookbook/.gitignore +2 -0
- data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +26 -0
- data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +5 -0
- data/spec/fixtures/lockfiles/default.lock +11 -0
- data/spec/{config/knife.rb → knife.rb.sample} +2 -2
- data/spec/spec_helper.rb +15 -3
- data/spec/support/chef_api.rb +19 -5
- data/spec/support/chef_server.rb +4 -3
- data/spec/support/knife.rb +18 -0
- data/spec/unit/berkshelf/berksfile_spec.rb +332 -235
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +40 -42
- data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +11 -15
- data/spec/unit/berkshelf/community_rest_spec.rb +16 -14
- data/spec/unit/berkshelf/config_spec.rb +36 -20
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +6 -10
- data/spec/unit/berkshelf/cookbook_source_spec.rb +244 -183
- data/spec/unit/berkshelf/cookbook_store_spec.rb +72 -76
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
- data/spec/unit/berkshelf/downloader_spec.rb +137 -157
- data/spec/unit/berkshelf/errors_spec.rb +1 -1
- data/spec/unit/berkshelf/formatters/null_spec.rb +17 -0
- data/spec/unit/berkshelf/formatters_spec.rb +83 -90
- data/spec/unit/berkshelf/git_spec.rb +219 -207
- data/spec/unit/berkshelf/init_generator_spec.rb +73 -73
- data/spec/unit/berkshelf/location_spec.rb +143 -162
- data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +94 -89
- data/spec/unit/berkshelf/locations/git_location_spec.rb +75 -59
- data/spec/unit/berkshelf/locations/path_location_spec.rb +46 -30
- data/spec/unit/berkshelf/locations/site_location_spec.rb +4 -4
- data/spec/unit/berkshelf/lockfile_spec.rb +185 -1
- data/spec/unit/berkshelf/logger_spec.rb +6 -24
- data/spec/unit/berkshelf/mixin/logging_spec.rb +6 -8
- data/spec/unit/berkshelf/resolver_spec.rb +36 -38
- data/spec/unit/berkshelf/ui_spec.rb +9 -10
- data/spec/unit/berkshelf_spec.rb +41 -40
- data/spec/unit/chef/config_spec.rb +9 -11
- metadata +55 -203
- data/spec/config/berkshelf.pem +0 -27
- data/spec/config/validator.pem +0 -27
data/lib/berkshelf/cli.rb
CHANGED
@@ -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
|
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:
|
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.
|
323
|
-
Berkshelf.ui.mute { berksfile.resolve }.sort.each do |cookbook|
|
324
|
-
Berkshelf.
|
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
|
-
|
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.
|
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.
|
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.
|
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.
|
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
|
+
|
data/lib/berkshelf/config.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
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
|
-
|
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[:
|
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
|
-
|
177
|
-
|
178
|
-
|
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[:
|
184
|
-
|
185
|
-
|
186
|
-
|
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
|
-
|
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
|
-
[]
|
46
|
-
|
47
|
-
|
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
|
data/lib/berkshelf/errors.rb
CHANGED
@@ -117,7 +117,39 @@ module Berkshelf
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
|
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
|
-
|
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
|