compat_resource 12.7.0 → 12.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/files/lib/chef_compat/copied_from_chef/chef/constants.rb +1 -1
- data/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +1 -1
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +3 -3
- data/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +22 -11
- data/files/lib/chef_compat/copied_from_chef/chef/property.rb +8 -3
- data/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +1 -1
- data/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +1 -1
- data/files/lib/compat_resource/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6888adceb67911ef0f109a36965fd4b90b5893
|
4
|
+
data.tar.gz: 142976c791c1aeb52b229d6706ef6dfc348411ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb80a7307a55629f9cfa319fe42cca4564ba5fbb030d927a6fafba254788b520883ca2870512c1bf5c1d4ea6be6b87689f5757db217d97d489a949255f65695
|
7
|
+
data.tar.gz: a31e50b0ce19d91b80d9fe2eda606fa867d25ca3ad8df043569c45a1dd100b3bf1a4de6a3ecd855f6090932c453c3dede2aca152967a6723468eb25fcf57d452
|
@@ -4,7 +4,7 @@ module ::ChefCompat
|
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
6
|
# Author:: John Keiser <jkeiser@chef.io>
|
7
|
-
# Copyright:: Copyright
|
7
|
+
# Copyright:: Copyright 2015-2016, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -4,7 +4,7 @@ module ::ChefCompat
|
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
6
|
# Author:: John Keiser <jkeiser@chef.io>
|
7
|
-
# Copyright:: Copyright
|
7
|
+
# Copyright:: Copyright 2015-2016, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -3,9 +3,9 @@ class Chef
|
|
3
3
|
module ::ChefCompat
|
4
4
|
module CopiedFromChef
|
5
5
|
#--
|
6
|
-
# Author:: Adam Jacob (<adam@
|
7
|
-
# Author:: Christopher Walters (<cw@
|
8
|
-
# Copyright:: Copyright
|
6
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
7
|
+
# Author:: Christopher Walters (<cw@chef.io>)
|
8
|
+
# Copyright:: Copyright 2008-2016, 2009-2015 Chef Software, Inc.
|
9
9
|
# License:: Apache License, Version 2.0
|
10
10
|
#
|
11
11
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -3,8 +3,8 @@ class Chef
|
|
3
3
|
module ::ChefCompat
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
|
-
# Author:: Adam Jacob (<adam@
|
7
|
-
# Copyright:: Copyright
|
6
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
7
|
+
# Copyright:: Copyright 2008-2016, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -406,23 +406,34 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
406
406
|
return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym)
|
407
407
|
value = _pv_opts_lookup(opts, key)
|
408
408
|
to_be = [ to_be ].flatten(1)
|
409
|
-
|
409
|
+
errors = []
|
410
|
+
passed = to_be.any? do |tb|
|
410
411
|
case tb
|
411
412
|
when Proc
|
412
413
|
raise CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
|
413
|
-
|
414
|
+
instance_exec(value, &tb)
|
414
415
|
when Property
|
415
|
-
|
416
|
-
|
416
|
+
begin
|
417
|
+
validate(opts, { key => tb.validation_options })
|
418
|
+
true
|
419
|
+
rescue Exceptions::ValidationFailed
|
420
|
+
# re-raise immediately if there is only one "is" so we get a better stack
|
421
|
+
raise if to_be.size == 1
|
422
|
+
errors << $!
|
423
|
+
false
|
424
|
+
end
|
417
425
|
else
|
418
|
-
|
426
|
+
tb === value
|
419
427
|
end
|
420
428
|
end
|
421
|
-
|
422
|
-
|
423
|
-
raise Exceptions::ValidationFailed, "Option #{key} must be one of: #{to_be.join(", ")}! You passed #{value.inspect}."
|
429
|
+
if passed
|
430
|
+
true
|
424
431
|
else
|
425
|
-
|
432
|
+
message = "Property #{key} must be one of: #{to_be.map { |v| v.inspect }.join(", ")}! You passed #{value.inspect}."
|
433
|
+
unless errors.empty?
|
434
|
+
message << " Errors:\n#{errors.map { |m| "- #{m}" }.join("\n")}"
|
435
|
+
end
|
436
|
+
raise Exceptions::ValidationFailed, message
|
426
437
|
end
|
427
438
|
end
|
428
439
|
|
@@ -4,7 +4,7 @@ module ::ChefCompat
|
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
6
|
# Author:: John Keiser <jkeiser@chef.io>
|
7
|
-
# Copyright:: Copyright
|
7
|
+
# Copyright:: Copyright 2015-2016, John Keiser.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -131,7 +131,7 @@ super if defined?(::Chef::Property)
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def to_s
|
134
|
-
"#{name}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
|
134
|
+
"#{name || "<property type>"}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
|
135
135
|
end
|
136
136
|
|
137
137
|
#
|
@@ -465,7 +465,12 @@ super if defined?(::Chef::Property)
|
|
465
465
|
def validate(resource, value)
|
466
466
|
# If we have no default value, `nil` is never coerced or validated
|
467
467
|
unless value.nil? && !has_default?
|
468
|
-
|
468
|
+
if resource
|
469
|
+
resource.validate({ name => value }, { name => validation_options })
|
470
|
+
else
|
471
|
+
name = self.name || :property_type
|
472
|
+
Chef::Mixin::ParamsValidate.validate({ name => value }, { name => validation_options })
|
473
|
+
end
|
469
474
|
end
|
470
475
|
end
|
471
476
|
|
@@ -4,7 +4,7 @@ module ::ChefCompat
|
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
6
|
# Author:: John Keiser (<jkeiser@chef.io)
|
7
|
-
# Copyright:: Copyright
|
7
|
+
# Copyright:: Copyright 2015-2016, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -4,7 +4,7 @@ module ::ChefCompat
|
|
4
4
|
module CopiedFromChef
|
5
5
|
#
|
6
6
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
7
|
-
# Copyright:: Copyright
|
7
|
+
# Copyright:: Copyright 2015-2016, Chef Software, Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compat_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.7.
|
4
|
+
version: 12.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: files/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|