Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement rfc090 for named nodes endpoint #264

Merged
merged 5 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cache: bundler
script:
- bundle update
- bundle exec rake pedant
env:
global:
- "PEDANT_OPTS=\"--skip-oc_id\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should just land in https://github.com/chef/chef-zero/blob/master/spec/run_oc_pedant.rb#L149 since it'll always be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - makes sense!


matrix:
include:
Expand Down
4 changes: 4 additions & 0 deletions lib/chef_zero/endpoints/node_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def put(request)
super(request)
end

def head(request)
head_request(request)
end

def populate_defaults(request, response_json)
node = FFI_Yajl::Parser.parse(response_json)
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
Expand Down
10 changes: 10 additions & 0 deletions lib/chef_zero/rest_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ def text_response(response_code, text)
[response_code, { "Content-Type" => "text/plain" }, text]
end

# rfc090 returns 404 error or 200 with an emtpy body
# @param [ChefZero::RestRequest] request The HTTP request object
#
# @return (see #json_response)
#
def head_request(request)
get_data(request) # will raise 404 if non-existant
json_response(200, nil)
end

# Returns an Array with the response code, HTTP headers, and JSON body.
#
# @param [Fixnum] response_code The HTTP response code
Expand Down