summaryrefslogtreecommitdiff
path: root/lib/chef/formatters
diff options
context:
space:
mode:
authortylercloke <tylercloke@gmail.com>2015-05-27 14:32:24 -0700
committertylercloke <tylercloke@gmail.com>2015-06-05 10:38:48 -0700
commit9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee (patch)
tree226227e7e32f421a0dde0f1ad2046059eff449c3 /lib/chef/formatters
parent20f7e1c78c55d2a16d5033bc2bbe5904d225adb0 (diff)
downloadchef-9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee.tar.gz
Added versioned Chef Object API support code and repaired Chef::User.create.
Also added Chef::User.create V1 API support. Chef::User.create will attempt to use V1 of the server API, and if it fails, it will fall back to V0.
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index ec25f4e903..d68b38e41f 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -68,13 +68,16 @@ E
end
def describe_406_error(error_description, response)
- if Chef::JSONCompat.from_json(response.body)["error"] == "invalid-x-ops-server-api-version"
- min_version = Chef::JSONCompat.from_json(response.body)["min_version"]
- max_version = Chef::JSONCompat.from_json(response.body)["max_version"]
+ if response["x-ops-server-api-version"]
+ version_header = Chef::JSONCompat.from_json(response["x-ops-server-api-version"])
+ client_api_version = version_header["request_version"]
+ min_server_version = version_header["min_version"]
+ max_server_version = version_header["max_version"]
+
error_description.section("Incompatible server API version:",<<-E)
-This version of Chef is not supported by the Chef server you sent this request to
-This version of Chef requires a server API version of #{Chef::HTTP::Authenticator::SERVER_API_VERSION}
-The Chef server you sent the request to supports a min API version of #{min_version} and a max API version of #{max_version}
+This version of the API that this Chef request specified is not supported by the Chef server you sent this request to
+The Chef server you sent the request to supports a min API version of #{min_server_version} and a max API version of #{max_server_version}
+Chef just made a request with an API version of #{client_api_version}
Please either update your Chef client or server to be a compatible set
E
else