chef-validation 0.1.6 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/chef/validation/validator.rb +16 -0
- data/lib/chef/validation/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: c10072b01c8f4841b522cd9161644601699af394
|
4
|
+
data.tar.gz: 019ce301127133ac4504158ba7ea0d8f63bd0c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e9e2680692b1bf27877d63d86160bf581214a31ff2b304a72500a8bc7c158f6727f0c78f0e85d15026f02bbcb27b20cc427566db4d7530d18252a5f210a109
|
7
|
+
data.tar.gz: 24d5d8cb1c11e9783516b1ba15b091489fd245e9f2e7091d85f91be076ba866fb33e4b9954514bf70d1af223cd4b43abf7cb5643895f0b285851ba79ec2811dc
|
data/CHANGELOG.md
CHANGED
@@ -37,6 +37,11 @@ module Chef::Validation
|
|
37
37
|
value = HashExt.dig(node.attributes, name, ATTR_SEPARATOR)
|
38
38
|
errors = []
|
39
39
|
|
40
|
+
if rules["recipes"].present?
|
41
|
+
if rules["recipes"].select { |recipe| recipe_present?(node, recipe) }.empty?
|
42
|
+
return errors
|
43
|
+
end
|
44
|
+
end
|
40
45
|
if rules["required"].present?
|
41
46
|
errors += validate_required(value, name)
|
42
47
|
end
|
@@ -60,6 +65,17 @@ module Chef::Validation
|
|
60
65
|
BOOLEAN = "boolean".freeze
|
61
66
|
NUMERIC = "numeric".freeze
|
62
67
|
|
68
|
+
def recipe_present?(node, recipe)
|
69
|
+
cookbook, name = recipe.split("::", 2)
|
70
|
+
if name.blank?
|
71
|
+
# Check for default recipe by both of it's names.
|
72
|
+
expanded = "#{cookbook}::default"
|
73
|
+
node.recipe?(recipe) || node.recipe?(expanded)
|
74
|
+
else
|
75
|
+
node.recipe?(recipe)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
63
79
|
def validate_choice(value, choices, name)
|
64
80
|
errors = []
|
65
81
|
unless choices.include?(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|