File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
cookbooks/fb_helpers/libraries Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -78,12 +78,28 @@ def from_json_file(filename)
7878
7979 def from_json ( string )
8080 res = JSONCompat . from_json ( string )
81- unless res . is_a? ( Hash ) && res . key? ( "resources" )
82- raise ArgumentError , "JSON recipe '#{ source_file } ' must contain a top-level 'resources' hash"
81+ unless res . is_a? ( Hash ) && ( res . key? ( "resources" ) || res . key? ( "include_recipes" ) )
82+ raise ArgumentError , "JSON recipe '#{ source_file } ' must contain a top-level 'resources' or 'include_recipes' hash key "
8383 end
8484
8585 from_hash ( res )
8686 end
87+
88+
89+ def from_hash ( hash )
90+ hash [ "resources" ] &.each do |rhash |
91+ type = rhash . delete ( "type" ) . to_sym
92+ name = rhash . delete ( "name" )
93+ res = declare_resource ( type , name )
94+ rhash . each do |key , value |
95+ # FIXME?: we probably need a way to instance_exec a string that contains block code against the property?
96+ res . send ( key , value )
97+ end
98+ end
99+ hash [ "include_recipes" ] &.each do |recipe |
100+ run_context . include_recipe recipe
101+ end
102+ end
87103 end
88104end
89105
You can’t perform that action at this time.
0 commit comments