diff options
author | Thom May <thom@may.lt> | 2016-01-21 11:14:49 +0000 |
---|---|---|
committer | Thom May <thom@may.lt> | 2016-01-21 11:14:49 +0000 |
commit | b2287acca8df58079205979ab2ba956d0e281fe5 (patch) | |
tree | 471e241d05effbe9d2b470588c1ff0f647952741 /lib/chef | |
parent | 38e4b8ad4a1d701878595c7822636f3cbb7f7af9 (diff) | |
parent | 3458740dc59959e0eaa88543883756d041435d56 (diff) | |
download | chef-b2287acca8df58079205979ab2ba956d0e281fe5.tar.gz |
Merge pull request #4423 from chef/tm/rest_deprecation
Add deprecation warnings to Chef::REST and all json_creates
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/api_client.rb | 3 | ||||
-rw-r--r-- | lib/chef/chef_fs/data_handler/data_handler_base.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb | 2 | ||||
-rw-r--r-- | lib/chef/cookbook_version.rb | 1 | ||||
-rw-r--r-- | lib/chef/data_bag.rb | 1 | ||||
-rw-r--r-- | lib/chef/data_bag_item.rb | 1 | ||||
-rw-r--r-- | lib/chef/environment.rb | 4 | ||||
-rw-r--r-- | lib/chef/key.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/core/object_loader.rb | 2 | ||||
-rw-r--r-- | lib/chef/node.rb | 1 | ||||
-rw-r--r-- | lib/chef/org.rb | 5 | ||||
-rw-r--r-- | lib/chef/rest.rb | 2 | ||||
-rw-r--r-- | lib/chef/role.rb | 1 | ||||
-rw-r--r-- | lib/chef/user.rb | 5 | ||||
-rw-r--r-- | lib/chef/user_v1.rb | 5 |
16 files changed, 28 insertions, 14 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/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index 53936979e3..41c5dd13e2 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -117,7 +117,7 @@ class Chef # Turn a JSON hash into a bona fide Chef object (like Chef::Node). # def chef_object(object) - chef_class.json_create(object) + chef_class.from_hash(object) end # diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb index 18bf748d87..fb3c185145 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb @@ -188,7 +188,7 @@ class Chef old_retry_count = Chef::Config[:http_retry_count] begin Chef::Config[:http_retry_count] = 0 - @chef_object ||= Chef::CookbookVersion.json_create(root.get_json(api_path)) + @chef_object ||= Chef::CookbookVersion.from_hash(root.get_json(api_path)) ensure Chef::Config[:http_retry_count] = old_retry_count end diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb index 692b6cfc73..cfc9e43955 100644 --- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb @@ -102,7 +102,7 @@ class Chef def chef_object # REST will inflate the Chef object using json_class - data_handler.json_class.json_create(read) + data_handler.json_class.from_hash(read) end def minimize_value(value) 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/key.rb b/lib/chef/key.rb index ba5613e35e..141a444d57 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -222,8 +222,9 @@ class Chef Chef::Key.from_hash(Chef::JSONCompat.from_json(json)) end - class << self - alias_method :json_create, :from_json + def self.json_create(json) + Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.") + Chef::Key.from_json(json) end def self.list_by_user(actor, inflate=false) 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/org.rb b/lib/chef/org.rb index 33a986dc3b..434113e315 100644 --- a/lib/chef/org.rb +++ b/lib/chef/org.rb @@ -124,8 +124,9 @@ class Chef Chef::Org.from_hash(Chef::JSONCompat.from_json(json)) end - class <<self - alias_method :json_create, :from_json + def self.json_create(json) + Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::Org#from_json or Chef::Org#load.") + Chef::Org.from_json(json) end def self.load(org_name) 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 diff --git a/lib/chef/user.rb b/lib/chef/user.rb index 37a104a537..bcbce76bf2 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -154,8 +154,9 @@ class Chef Chef::User.from_hash(Chef::JSONCompat.from_json(json)) end - class << self - alias_method :json_create, :from_json + def self.json_create(json) + Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::User#from_json or Chef::User#load.") + Chef::User.from_json(json) end def self.list(inflate=false) diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index 133087a089..bb594e3564 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -276,8 +276,9 @@ class Chef Chef::UserV1.from_hash(Chef::JSONCompat.from_json(json)) end - class << self - alias_method :json_create, :from_json + def self.json_create(json) + Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::UserV1#from_json or Chef::UserV1#load.") + Chef::UserV1.from_json(json) end def self.list(inflate=false) |