-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
@chef/lob @manderson26 I still have to test against pushy-pedant (and maybe add a test there) but I wanted to get this out for review. This is the "just make it work with the current code" version of this fix. I think we could probably extract some of this out into a common library for use in other projects (pushy_http_common is probably a good starting point for a generic erchef_client and most of the code here: https://github.com/chef/opscode-pushy-server/pull/111/files#diff-6c2407c0c1779021963948964504cee0R177 could probably be moved into a chef_authn function that provides a nice API). Overall I think we do eventually need a better endpoint than principals (principals is fine, it just doesn't really do what we need), but I'd prefer to put some thought into that rather than push it through quickly. |
65e65f5
to
bfcec7c
Compare
Plan of record:
|
bfcec7c
to
8a5d16b
Compare
I've been looking at reporting and while it uses the principals endpoint for the same purpose, it's HTTP client implementation is a bit different as it includes a caching layer. |
Version = ej:get({"response_version"}, EJ), | ||
binary_to_integer(Version); | ||
response_version_from_headers([_H|T]) -> | ||
response_version_from_headers(T). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response_version_from_headers/1
could be more concisely implemented with lists:keyfind/3
:
case lists:keyfind("X-Ops-Server-API-Version", 1, Headers) of ->
{"X-Ops-Server-API-Version", VersionJSON} ->
% do something to return version
ok;
false ->
0
end,
After all that review, there's nothing major here. This looks good. Nice! |
👍 Looks good, there's some tech debt here I need to clean up later, but that shouldn't be a blocker. |
The v1 principals endpoint returns multiple principal records for a single request if the user has multiple key or if a user and client share the same name. To support this we: - add a pushy_http_common:unauthenticated_request method that understands how to recognize versioned responses. - replace pushy_principals:fetch_principal with fetch_principals which returns an array of principals. - modify pushy_chef_wm to pass an array of public key data to chef_authn.
8a5d16b
to
bb42da1
Compare
@sdelano @manderson26 Alrighty, I addressed the code review comments. I also backed out some of the changes I made where I converted functions to return error tuples rather than throw them. The changes were unnecessary cruft from an initial refactoring idea and they were not playing nicely with dialyzer. I turned off dialyzer's
I think I could probably resolve this by putting 'undefined' in the type specs for the record definition and maybe a few other places; but since we have this off in our other erlang projects I figured I would just turn off the warnings here too. |
CI failed for this on RHEL7 but the failure looks unrelated: http://wilson.ci.chef.co/job/opscode-push-jobs-server-test/342/ @manderson26 any thoughts there? Otherwise this is ready to merge. |
No description provided.