diff options
author | tylercloke <tylercloke@gmail.com> | 2015-06-04 12:23:55 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-06-05 13:47:44 -0700 |
commit | 58048d42caeadc290876a02aaec7eec6f305920a (patch) | |
tree | ea9743fc860b69f2c4c20bb26b7f58a5d2f6f44f /lib/chef/user.rb | |
parent | 4f2400c8cce57e68f14cb9d4b756ab82b23dd69d (diff) | |
download | chef-58048d42caeadc290876a02aaec7eec6f305920a.tar.gz |
Better API version error handling helper code.
Renamed Chef::Mixin::ApiVersionRequestHandling.handle_version_http_exception -> server_client_api_version_intersection and made it do much more useful / sane things. See comments for details.
Diffstat (limited to 'lib/chef/user.rb')
-rw-r--r-- | lib/chef/user.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/chef/user.rb b/lib/chef/user.rb index 1b5f454099..717deb63c3 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -36,7 +36,7 @@ class Chef include Chef::Mixin::FromFile include Chef::Mixin::ParamsValidate - include Chef::ApiVersionRequestHandling + include Chef::Mixin::ApiVersionRequestHandling SUPPORTED_API_VERSIONS = [0,1] @@ -169,7 +169,8 @@ class Chef end rescue Net::HTTPServerException => e # rescue API V0 if 406 and the server supports V0 - raise e unless handle_version_http_exception(e, SUPPORTED_API_VERSIONS[0], SUPPORTED_API_VERSIONS[-1]) + supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS) + raise e unless supported_versions && supported_versions.include?(0) payload = { :username => @username, :display_name => @display_name, @@ -212,7 +213,8 @@ class Chef raise e end else # for other types of errors, test for API versioning errors right away - raise e unless handle_version_http_exception(e, SUPPORTED_API_VERSIONS[0], SUPPORTED_API_VERSIONS[-1]) + supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS) + raise e unless supported_versions && supported_versions.include?(0) end updated_user = chef_root_rest_v0.put("users/#{username}", payload) end |