summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-01-18 15:14:31 +0000
committerThom May <thom@chef.io>2016-01-18 15:14:31 +0000
commit0ef0ab07531ae78cb4052242037227b0fb5365dc (patch)
tree64100fafb9164d7af2f94475c28a53f65c9b422f /lib
parent808fe8b34254c2747d333205f7f7cdb4224cf8aa (diff)
downloadchef-0ef0ab07531ae78cb4052242037227b0fb5365dc.tar.gz
add deprecation warnings
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/api_client.rb3
-rw-r--r--lib/chef/cookbook_version.rb1
-rw-r--r--lib/chef/data_bag.rb1
-rw-r--r--lib/chef/data_bag_item.rb1
-rw-r--r--lib/chef/environment.rb4
-rw-r--r--lib/chef/knife/core/object_loader.rb2
-rw-r--r--lib/chef/node.rb1
-rw-r--r--lib/chef/rest.rb2
-rw-r--r--lib/chef/role.rb1
9 files changed, 13 insertions, 3 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index 9def6199b7..cea9dd8176 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -141,6 +141,7 @@ class Chef
end
def self.json_create(data)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::ApiClient#from_hash")
from_hash(data)
end
@@ -176,7 +177,7 @@ class Chef
if response.kind_of?(Chef::ApiClient)
response
else
- json_create(response)
+ from_hash(response)
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 28f817c8ba..19150464ba 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -476,6 +476,7 @@ class Chef
end
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::CookbookVersion#from_hash")
from_hash(o)
end
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index 66771d325f..38b3d4fdf5 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -80,6 +80,7 @@ class Chef
# Create a Chef::Role from JSON
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::DataBag#from_hash")
from_hash(o)
end
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 8688693568..facf6c89f4 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -142,6 +142,7 @@ class Chef
# Create a Chef::DataBagItem from JSON
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::DataBagItem#from_hash")
from_hash(o)
end
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index e41f2b66ac..042cde5bd5 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -217,6 +217,7 @@ class Chef
end
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Environment#from_hash")
from_hash(o)
end
@@ -260,7 +261,8 @@ class Chef
if File.exists?(js_file)
# from_json returns object.class => json_class in the JSON.
- Chef::JSONCompat.from_json(IO.read(js_file))
+ hash = Chef::JSONCompat.parse(IO.read(js_file))
+ from_hash(hash)
elsif File.exists?(rb_file)
environment = Chef::Environment.new
environment.name(name)
diff --git a/lib/chef/knife/core/object_loader.rb b/lib/chef/knife/core/object_loader.rb
index 69c2428bd4..063c192728 100644
--- a/lib/chef/knife/core/object_loader.rb
+++ b/lib/chef/knife/core/object_loader.rb
@@ -93,7 +93,7 @@ class Chef
if @klass == Chef::DataBagItem
r
else
- @klass.json_create(r)
+ @klass.from_hash(r)
end
when /\.rb$/
r = klass.new
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index d7b0bf5948..b9ef200e91 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -532,6 +532,7 @@ class Chef
# Create a Chef::Node from JSON
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Node#from_hash")
from_hash(o)
end
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
index 96a563e034..73cd0d68a9 100644
--- a/lib/chef/rest.rb
+++ b/lib/chef/rest.rb
@@ -59,6 +59,8 @@ class Chef
# HTTP GET request to http://localhost:4000/nodes
def initialize(url, client_name=Chef::Config[:node_name], signing_key_filename=Chef::Config[:client_key], options={})
+ Chef.log_deprecation("Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI.")
+
signing_key_filename = nil if chef_zero_uri?(url)
options = options.dup
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index fa76129af2..d607a1be98 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -171,6 +171,7 @@ class Chef
# Create a Chef::Role from JSON
def self.json_create(o)
+ Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Role#from_hash")
from_hash(o)
end