diff options
author | Chris Doherty <randomcamel@users.noreply.github.com> | 2016-01-22 10:55:55 -0800 |
---|---|---|
committer | Chris Doherty <randomcamel@users.noreply.github.com> | 2016-01-22 10:55:55 -0800 |
commit | 92a55901496a5eb94bd5c84fed95ed7664540858 (patch) | |
tree | 29669c482e53380af8743fbbd65d5a34336b4060 | |
parent | 180dc06ba3ae6f005854a75abe248971c22509b6 (diff) | |
parent | a4b79360293ee2dedc119ed06aebe383d4012d82 (diff) | |
download | chef-zero-92a55901496a5eb94bd5c84fed95ed7664540858.tar.gz |
Merge pull request #191 from chef/cd/run-container-specs
Enable container specs.
-rw-r--r-- | lib/chef_zero/chef_data/default_creator.rb | 2 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/containers_endpoint.rb | 13 | ||||
-rw-r--r-- | lib/chef_zero/rest_base.rb | 2 | ||||
-rw-r--r-- | spec/run_oc_pedant.rb | 1 |
4 files changed, 15 insertions, 3 deletions
diff --git a/lib/chef_zero/chef_data/default_creator.rb b/lib/chef_zero/chef_data/default_creator.rb index 7b18d51..b066a25 100644 --- a/lib/chef_zero/chef_data/default_creator.rb +++ b/lib/chef_zero/chef_data/default_creator.rb @@ -162,7 +162,7 @@ module ChefZero 'users' => {}, 'org' => {}, - 'containers' => %w(clients containers cookbooks data environments groups nodes roles sandboxes policies cookbook_artifacts), + 'containers' => %w(clients containers cookbook_artifacts cookbooks data environments groups nodes policies policy_groups roles sandboxes), 'groups' => %w(admins billing-admins clients users), 'association_requests' => {} } diff --git a/lib/chef_zero/endpoints/containers_endpoint.rb b/lib/chef_zero/endpoints/containers_endpoint.rb index 3f7af87..931fe6c 100644 --- a/lib/chef_zero/endpoints/containers_endpoint.rb +++ b/lib/chef_zero/endpoints/containers_endpoint.rb @@ -8,6 +8,19 @@ module ChefZero 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? } + container_data_path = request.rest_path + container_path_suffix + create_data(request, container_data_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 diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb index 928d2e7..a03f4aa 100644 --- a/lib/chef_zero/rest_base.rb +++ b/lib/chef_zero/rest_base.rb @@ -200,7 +200,7 @@ module ChefZero end def json_response(response_code, json, request_version=0, response_version=0, opts={pretty: true}) - do_pretty_json = opts[:pretty] && true + do_pretty_json = !!opts[:pretty] # make sure we have a proper Boolean. already_json_response(response_code, FFI_Yajl::Encoder.encode(json, :pretty => do_pretty_json), request_version, response_version) end diff --git a/spec/run_oc_pedant.rb b/spec/run_oc_pedant.rb index b7a3619..a064618 100644 --- a/spec/run_oc_pedant.rb +++ b/spec/run_oc_pedant.rb @@ -126,7 +126,6 @@ begin '--skip-usags', # Chef 12 features not yet 100% supported by Chef Zero - '--skip-containers', '--skip-api-v1', # The universe endpoint is unlikely to ever make sense for Chef Zero |