summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chef_zero/chef_data/default_creator.rb2
-rw-r--r--lib/chef_zero/endpoints/containers_endpoint.rb13
-rw-r--r--lib/chef_zero/rest_base.rb2
3 files changed, 15 insertions, 2 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