/usr/lib/ruby/vendor_ruby/chef_zero/endpoints/containers_endpoint.rb is in chef-zero 4.5.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | require 'ffi_yajl'
require 'chef_zero/endpoints/rest_list_endpoint'
module ChefZero
module Endpoints
# /organizations/ORG/containers
class ContainersEndpoint < RestListEndpoint
def initialize(server)
super(server, %w(id containername))
end
# create a container.
# input: {"containername"=>"new-container", "containerpath"=>"/"}
def post(request)
data = parse_json(request.body)
# if they don't match, id wins.
container_name = data["id"] || data["containername"]
container_path_suffix = data["containerpath"].split("/").reject { |o| o.empty? }
create_data(request, request.rest_path, container_name, to_json({}), :create_dir)
json_response(201, { uri: build_uri(request.base_uri, request.rest_path + container_path_suffix + [container_name]) })
end
end
end
end
|