diff options
Diffstat (limited to 'lib/chef/resource/_rest_resource.rb')
-rw-r--r-- | lib/chef/resource/_rest_resource.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/resource/_rest_resource.rb b/lib/chef/resource/_rest_resource.rb index f14e586eb2..8e72073b88 100644 --- a/lib/chef/resource/_rest_resource.rb +++ b/lib/chef/resource/_rest_resource.rb @@ -15,6 +15,7 @@ # limitations under the License. # +require "addressable/template" unless defined?(Addressable::Template) require "rest-client" unless defined?(RestClient) require "jmespath" unless defined?(JMESPath) require "chef/dsl/rest_resource" unless defined?(Chef::DSL::RestResource) @@ -221,7 +222,9 @@ action_class do response = rest_postprocess(response) first_only = current_resource.class.rest_api_document_first_element_only - first_only && response.is_a?(Array) ? response.first : response + response.data = response.data.first if first_only && response.data.is_a?(Array) + + response rescue RestClient::Exception => e rest_errorhandler(e) end |