chef-validation 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b29af6d04d2912a53945dd0e0397c742759e80a
4
- data.tar.gz: aa651f92089bf1f9b5c3b664b6b9de062ebe515b
3
+ metadata.gz: 6ef3435c33e89c5cc6869e0698f5c5b5e21de1e5
4
+ data.tar.gz: 8aef1ac842fdeb3c599875243f2a5647d923f21b
5
5
  SHA512:
6
- metadata.gz: a4015182c4d51a8e2a05805397fb743579ad7cd3f25a688379e6798ebf28443b0e01946613dafcaaa2b98d7838149888dc4114589ee2d29ca2d06be0b604319e
7
- data.tar.gz: 74d31befe91e602d5b2a177bb5ce9a3a51221ac961deac61b921a5bb6a1db818d901c33e22dadf6fed9ce54f26c2f7666ace95acbb9f6f26612f2a5ae0f027f4
6
+ metadata.gz: 9de30d6d0c1c2ca4833edb902df7d4f70a12de74ebc6d2f00a993789bb7d4aaeeaafa4b443032fa41143498a4bca0bc3bbfd3a0fe5294cccad4308d45b8c4dc1
7
+ data.tar.gz: 71e82ceb8fca3e7bb89c7e92a9aad38a22e1ad610ecd5c7375330b3ace9c90806c8031d309605fb05dc116166999341ee1d3914f9f6ad75d446fbd12d4af57d3
@@ -1,3 +1,9 @@
1
+ # 0.2.2
2
+
3
+ * Bug Fixes
4
+ * Allow `optional` and `recommended` to be passed in for `required` attribute rule
5
+ * Display name of cookbook in error when cookbook not in run list
6
+
1
7
  # 0.2.1
2
8
 
3
9
  * Bug Fixes
@@ -60,7 +60,7 @@ module Chef::Validation
60
60
  def validate_one(node, name)
61
61
  total_errors = {}
62
62
  unless cookbook = ContextExt.cookbook(node.run_context, name)
63
- raise "Cookbook not found: #{cookbook}"
63
+ raise "Cookbook not found in run_context: #{name}"
64
64
  end
65
65
  reload_metadata(cookbook)
66
66
  unless (errors = Validator.run(node, cookbook.metadata)).empty?
@@ -43,7 +43,7 @@ module Chef::Validation
43
43
  end
44
44
  end
45
45
  if rules["required"].present?
46
- errors += validate_required(value, name)
46
+ errors += validate_required(rules["required"], value)
47
47
  end
48
48
  if rules["type"].present?
49
49
  errors += validate_type(value, rules["type"], name)
@@ -84,10 +84,15 @@ module Chef::Validation
84
84
  errors
85
85
  end
86
86
 
87
- def validate_required(value, name)
87
+ def validate_required(required, value)
88
88
  errors = []
89
89
  return errors if value.is_a?(TrueClass) || value.is_a?(FalseClass)
90
90
 
91
+ if ['optional', 'recommended'].include?(required)
92
+ return errors
93
+ end
94
+
95
+ # Only required gets here
91
96
  if value.blank?
92
97
  errors << "Required attribute but was not present."
93
98
  end
@@ -1,4 +1,4 @@
1
1
  class Chef; end;
2
2
  module Chef::Validation
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
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.2.1
4
+ version: 0.2.2
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-14 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef