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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31591ba212e06d1ebb683db519e436d810bb0a1b
4
- data.tar.gz: aba515c9bfd15a3fc0b20bacd87c2e3aa2f8c54e
3
+ metadata.gz: c10072b01c8f4841b522cd9161644601699af394
4
+ data.tar.gz: 019ce301127133ac4504158ba7ea0d8f63bd0c0a
5
5
  SHA512:
6
- metadata.gz: 6b819438c352a771ff384e6c7e66e78978db767677c7235f6c70dcfd33cd3be26ec21c9a40abfb19d7ca4765d97f96e85dea177e8ec538c44320b10f5c4d1516
7
- data.tar.gz: 23dc1faa314b3de340a4c4d9cc796eb806abda61bd8ce48ec8efb91289865fe7bf251f59ab425b162d50e54b00e247d3725290487762939c8a2321bd83cbb8de
6
+ metadata.gz: 40e9e2680692b1bf27877d63d86160bf581214a31ff2b304a72500a8bc7c158f6727f0c78f0e85d15026f02bbcb27b20cc427566db4d7530d18252a5f210a109
7
+ data.tar.gz: 24d5d8cb1c11e9783516b1ba15b091489fd245e9f2e7091d85f91be076ba866fb33e4b9954514bf70d1af223cd4b43abf7cb5643895f0b285851ba79ec2811dc
@@ -1,3 +1,8 @@
1
+ # 0.2.0
2
+
3
+ * Enhancements
4
+ * Validations will not be run for attributes who are dependent upon recipes when those recipes are not in the expanded run list of the node.
5
+
1
6
  # 0.1.6
2
7
 
3
8
  * Bug Fixes
@@ -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)
@@ -1,4 +1,4 @@
1
1
  class Chef; end;
2
2
  module Chef::Validation
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.0"
4
4
  end
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.1.6
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-13 00:00:00.000000000 Z
11
+ date: 2014-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef