summaryrefslogtreecommitdiff
path: root/lib/chef/resource_collection
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-03-14 16:22:51 +0000
committerThom May <thom@chef.io>2017-03-14 16:22:51 +0000
commitb0cb79f89d7ed5efafd81e01d28dcce1014f41b3 (patch)
treee3b79811ce7c78e90343e0f81241136777ca67b8 /lib/chef/resource_collection
parent12c54fbf916fcd4cd80cab3f3598a03da7d96fd1 (diff)
downloadchef-b0cb79f89d7ed5efafd81e01d28dcce1014f41b3.tar.gz
Kill JSON auto inflate with firetm/remove_json_autoinflate
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/resource_collection')
-rw-r--r--lib/chef/resource_collection/resource_collection_serialization.rb9
-rw-r--r--lib/chef/resource_collection/resource_list.rb6
-rw-r--r--lib/chef/resource_collection/resource_set.rb8
3 files changed, 22 insertions, 1 deletions
diff --git a/lib/chef/resource_collection/resource_collection_serialization.rb b/lib/chef/resource_collection/resource_collection_serialization.rb
index 647d28dfd0..4da1ad5048 100644
--- a/lib/chef/resource_collection/resource_collection_serialization.rb
+++ b/lib/chef/resource_collection/resource_collection_serialization.rb
@@ -15,6 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+require "chef/json_compat"
+
class Chef
class ResourceCollection
module ResourceCollectionSerialization
@@ -39,13 +42,17 @@ class Chef
end
module ClassMethods
- def json_create(o)
+ def from_hash(o)
collection = new()
o["instance_vars"].each do |k, v|
collection.instance_variable_set(k.to_sym, v)
end
collection
end
+
+ def from_json(j)
+ from_hash(Chef::JSONCompat.parse(j))
+ end
end
def is_chef_resource!(arg)
diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb
index 9fe012d4c3..75305f63a6 100644
--- a/lib/chef/resource_collection/resource_list.rb
+++ b/lib/chef/resource_collection/resource_list.rb
@@ -95,6 +95,12 @@ class Chef
end
end
+ def self.from_hash(o)
+ collection = new()
+ resources = o["instance_vars"]["@resources"].map { |r| Chef::Resource.from_hash(r) }
+ collection.instance_variable_set(:@resources, resources)
+ collection
+ end
end
end
end
diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb
index 1a73818790..2c7c0a0b91 100644
--- a/lib/chef/resource_collection/resource_set.rb
+++ b/lib/chef/resource_collection/resource_set.rb
@@ -132,6 +132,14 @@ class Chef
end
end
+ def self.from_hash(o)
+ collection = new()
+ rl = o["instance_vars"]["@resources_by_key"]
+ resources = rl.merge(rl) { |k, r| Chef::Resource.from_hash(r) }
+ collection.instance_variable_set(:@resources_by_key, resources)
+ collection
+ end
+
private
def create_key(resource_type, instance_name)