summaryrefslogtreecommitdiff
path: root/lib/chef/recipe.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-06-11 18:02:10 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-02-14 10:38:38 -0800
commit6805006207c78f48961d24336be2054095a8bd68 (patch)
treee3991700623dabf67b2a8bea88714dab54a084d5 /lib/chef/recipe.rb
parent5a9f64b83e4605ee4d23190a3afcf08b000e3da1 (diff)
downloadchef-6805006207c78f48961d24336be2054095a8bd68.tar.gz
parse yaml recipes
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/recipe.rb')
-rw-r--r--lib/chef/recipe.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 154072827e..95b69532f8 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -85,6 +85,22 @@ class Chef
end
end
+ def from_array(array)
+ array.each { |e| from_hash(e) }
+ end
+
+ def from_hash(hash)
+ hash["resources"].each do |rhash|
+ type = rhash.delete("type").to_sym
+ name = rhash.delete("name")
+ res = declare_resource(type, name)
+ rhash.each do |key, value|
+ # FIXME?: we probably need a way to instance_exec a string that contains block code against the property?
+ res.send(key, value)
+ end
+ end
+ end
+
def to_s
"cookbook: #{cookbook_name ? cookbook_name : "(none)"}, recipe: #{recipe_name ? recipe_name : "(none)"} "
end