diff options
author | John Keiser <jkeiser@opscode.com> | 2013-10-09 13:40:21 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-10-09 13:40:21 -0700 |
commit | c13e335c6d87c50212589fdac75e46c62712ed97 (patch) | |
tree | 80bbedcdaab9e33e76cd5bf86a82a926ec876376 | |
parent | a5337fcad5ed979078b6cf57c7e1e6ec8f0b76cf (diff) | |
download | chef-c13e335c6d87c50212589fdac75e46c62712ed97.tar.gz |
Add "get_json" helper to upload/download root dir for people who want json
-rw-r--r-- | lib/chef/chef_fs/file_system/acl_dir.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/acls_dir.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/chef_server_root_dir.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbook_dir.rb | 6 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbook_file.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbook_subdir.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbooks_dir.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/data_bags_dir.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/nodes_dir.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/rest_list_dir.rb | 6 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/rest_list_entry.rb | 6 |
11 files changed, 9 insertions, 37 deletions
diff --git a/lib/chef/chef_fs/file_system/acl_dir.rb b/lib/chef/chef_fs/file_system/acl_dir.rb index 96708de8a0..c2354d478d 100644 --- a/lib/chef/chef_fs/file_system/acl_dir.rb +++ b/lib/chef/chef_fs/file_system/acl_dir.rb @@ -58,10 +58,6 @@ class Chef def rest parent.rest end - - def rest_json - parent.rest_json - end end end end diff --git a/lib/chef/chef_fs/file_system/acls_dir.rb b/lib/chef/chef_fs/file_system/acls_dir.rb index a4d39a63a5..938bf73fb2 100644 --- a/lib/chef/chef_fs/file_system/acls_dir.rb +++ b/lib/chef/chef_fs/file_system/acls_dir.rb @@ -62,10 +62,6 @@ class Chef def rest parent.rest end - - def rest_json - parent.rest_json - end end end end diff --git a/lib/chef/chef_fs/file_system/chef_server_root_dir.rb b/lib/chef/chef_fs/file_system/chef_server_root_dir.rb index 0287c7ab20..0083ee4cfa 100644 --- a/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server_root_dir.rb @@ -60,8 +60,8 @@ class Chef Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key, :raw_output => true) end - def rest_json - Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key) + def get_json(path) + Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key).get(path) end def chef_rest diff --git a/lib/chef/chef_fs/file_system/cookbook_dir.rb b/lib/chef/chef_fs/file_system/cookbook_dir.rb index 3f5bffe264..d7411e1c74 100644 --- a/lib/chef/chef_fs/file_system/cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/cookbook_dir.rb @@ -172,10 +172,6 @@ class Chef parent.rest end - def rest_json - parent.rest_json - end - def chef_object # We cheat and cache here, because it seems like a good idea to keep # the cookbook view consistent with the directory structure. @@ -195,7 +191,7 @@ class Chef old_retry_count = Chef::Config[:http_retry_count] begin Chef::Config[:http_retry_count] = 0 - @chef_object ||= Chef::CookbookVersion.json_create(rest_json.get(api_path)) + @chef_object ||= Chef::CookbookVersion.json_create(root.get_json(api_path)) ensure Chef::Config[:http_retry_count] = old_retry_count end diff --git a/lib/chef/chef_fs/file_system/cookbook_file.rb b/lib/chef/chef_fs/file_system/cookbook_file.rb index 57f2ca3f64..6673ad73f4 100644 --- a/lib/chef/chef_fs/file_system/cookbook_file.rb +++ b/lib/chef/chef_fs/file_system/cookbook_file.rb @@ -56,10 +56,6 @@ class Chef parent.rest end - def rest_json - parent.rest_json - end - def compare_to(other) other_value = nil if other.respond_to?(:checksum) diff --git a/lib/chef/chef_fs/file_system/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/cookbook_subdir.rb index 33f0072378..73c709e01e 100644 --- a/lib/chef/chef_fs/file_system/cookbook_subdir.rb +++ b/lib/chef/chef_fs/file_system/cookbook_subdir.rb @@ -48,10 +48,6 @@ class Chef def rest parent.rest end - - def rest_json - parent.rest_json - end end end end diff --git a/lib/chef/chef_fs/file_system/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/cookbooks_dir.rb index 793f31d060..a58bfdd1f2 100644 --- a/lib/chef/chef_fs/file_system/cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/cookbooks_dir.rb @@ -53,13 +53,13 @@ class Chef @children ||= begin if Chef::Config[:versioned_cookbooks] result = [] - rest_json.get("#{api_path}/?num_versions=all").each_pair do |cookbook_name, cookbooks| + root.get_json("#{api_path}/?num_versions=all").each_pair do |cookbook_name, cookbooks| cookbooks['versions'].each do |cookbook_version| result << CookbookDir.new("#{cookbook_name}-#{cookbook_version['version']}", self, :exists => true) end end else - result = rest_json.get(api_path).keys.map { |cookbook_name| CookbookDir.new(cookbook_name, self, :exists => true) } + result = root.get_json(api_path).keys.map { |cookbook_name| CookbookDir.new(cookbook_name, self, :exists => true) } end result.sort_by(&:name) end diff --git a/lib/chef/chef_fs/file_system/data_bags_dir.rb b/lib/chef/chef_fs/file_system/data_bags_dir.rb index 7c9d822f08..6d0685d3b7 100644 --- a/lib/chef/chef_fs/file_system/data_bags_dir.rb +++ b/lib/chef/chef_fs/file_system/data_bags_dir.rb @@ -34,7 +34,7 @@ class Chef def children begin - @children ||= rest_json.get(api_path).keys.sort.map do |entry| + @children ||= root.get_json(api_path).keys.sort.map do |entry| DataBagDir.new(entry, self, true) end rescue Timeout::Error => e diff --git a/lib/chef/chef_fs/file_system/nodes_dir.rb b/lib/chef/chef_fs/file_system/nodes_dir.rb index 9f4466b16f..c3c48377cd 100644 --- a/lib/chef/chef_fs/file_system/nodes_dir.rb +++ b/lib/chef/chef_fs/file_system/nodes_dir.rb @@ -32,7 +32,7 @@ class Chef # Identical to RestListDir.children, except supports environments def children begin - @children ||= rest_json.get(env_api_path).keys.sort.map do |key| + @children ||= root.get_json(env_api_path).keys.sort.map do |key| _make_child_entry("#{key}.json", true) end rescue Timeout::Error => e diff --git a/lib/chef/chef_fs/file_system/rest_list_dir.rb b/lib/chef/chef_fs/file_system/rest_list_dir.rb index 3a0ea4f37e..b7ee51d284 100644 --- a/lib/chef/chef_fs/file_system/rest_list_dir.rb +++ b/lib/chef/chef_fs/file_system/rest_list_dir.rb @@ -45,7 +45,7 @@ class Chef def children begin - @children ||= rest_json.get(api_path).keys.sort.map do |key| + @children ||= root.get_json(api_path).keys.sort.map do |key| _make_child_entry("#{key}.json", true) end rescue Timeout::Error => e @@ -106,10 +106,6 @@ class Chef parent.rest end - def rest_json - parent.rest_json - end - def _make_child_entry(name, exists = nil) RestListEntry.new(name, self, exists) end diff --git a/lib/chef/chef_fs/file_system/rest_list_entry.rb b/lib/chef/chef_fs/file_system/rest_list_entry.rb index 3963afb8da..0d5557de1d 100644 --- a/lib/chef/chef_fs/file_system/rest_list_entry.rb +++ b/lib/chef/chef_fs/file_system/rest_list_entry.rb @@ -86,7 +86,7 @@ class Chef def _read_hash begin # Minimize the value (get rid of defaults) so the results don't look terrible - minimize_value(rest_json.get(api_path)) + minimize_value(root.get_json(api_path)) rescue Timeout::Error => e raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e), "Timeout reading: #{e}" rescue Net::HTTPServerException => e @@ -143,10 +143,6 @@ class Chef parent.rest end - def rest_json - parent.rest_json - end - def write(file_contents) begin object = JSON.parse(file_contents, :create_additions => false) |