diff options
author | John Keiser <john@johnkeiser.com> | 2016-01-15 10:44:34 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-01-15 13:31:44 -0800 |
commit | 33ad78efb84af54cb5d7dae0bee8b491dbc394a7 (patch) | |
tree | 85a1f9e48d133b1547b92313146f142c0ed2ae99 | |
parent | aa1f0797f90c322c8ebec640a798f82c95d7e558 (diff) | |
download | chef-zero-33ad78efb84af54cb5d7dae0bee8b491dbc394a7.tar.gz |
Rename cookbook artifacts
-rw-r--r-- | lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb (renamed from lib/chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint.rb) | 2 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb (renamed from lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb) | 9 | ||||
-rw-r--r-- | lib/chef_zero/server.rb | 8 |
3 files changed, 10 insertions, 9 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint.rb b/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb index 841f0c9..e17fea2 100644 --- a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint.rb +++ b/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb @@ -2,7 +2,7 @@ require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints - class CookbookArtifactsCookbookEndpoint < RestBase + class CookbookArtifactEndpoint < RestBase # GET /organizations/ORG/cookbook_artifacts/COOKBOOK def get(request) cookbook_name = request.rest_path.last diff --git a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb b/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb index 0dda65e..b70e2c4 100644 --- a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb +++ b/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb @@ -2,7 +2,7 @@ require 'chef_zero/chef_data/data_normalizer' module ChefZero module Endpoints - class CookbookArtifactsCookbookIdentifierEndpoint < ChefZero::Endpoints::CookbookVersionEndpoint + class CookbookArtifactIdentifierEndpoint < ChefZero::Endpoints::CookbookVersionEndpoint # these endpoints are almost, but not quite, not entirely unlike the corresponding /cookbooks endpoints. # it could all be refactored for maximum reuse, but they're short REST methods with well-defined # behavioral specs (pedant), so there's not a huge benefit. @@ -36,9 +36,10 @@ module ChefZero # if this was the last revision, delete the directory so future requests will 404, instead of # returning 200 with an empty list. - artifact_path = request.rest_path[0..-2] - if list_data(request, artifact_path).size == 0 - delete_data_dir(request, artifact_path) + # Last one out turns out the lights: delete /organizations/ORG/cookbooks/COOKBOOK if it no longer has versions + cookbook_path = request.rest_path[0..3] + if exists_data_dir?(request, cookbook_path) && list_data(request, cookbook_path).size == 0 + delete_data_dir(request, cookbook_path) end json_response(200, identified_cookbook_data) diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 3326420..df97c88 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -45,9 +45,9 @@ require 'chef_zero/endpoints/actor_endpoint' require 'chef_zero/endpoints/cookbooks_endpoint' require 'chef_zero/endpoints/cookbook_endpoint' require 'chef_zero/endpoints/cookbook_version_endpoint' -require 'chef_zero/endpoints/cookbook_artifacts_cookbook_endpoint' -require 'chef_zero/endpoints/cookbook_artifacts_cookbook_identifier' require 'chef_zero/endpoints/cookbook_artifacts_endpoint' +require 'chef_zero/endpoints/cookbook_artifact_endpoint' +require 'chef_zero/endpoints/cookbook_artifact_identifier_endpoint' require 'chef_zero/endpoints/containers_endpoint' require 'chef_zero/endpoints/container_endpoint' require 'chef_zero/endpoints/dummy_endpoint' @@ -567,8 +567,8 @@ module ChefZero [ "/organizations/*/cookbooks/*", CookbookEndpoint.new(self) ], [ "/organizations/*/cookbooks/*/*", CookbookVersionEndpoint.new(self) ], [ "/organizations/*/cookbook_artifacts", CookbookArtifactsEndpoint.new(self) ], - [ "/organizations/*/cookbook_artifacts/*", CookbookArtifactsCookbookEndpoint.new(self) ], - [ "/organizations/*/cookbook_artifacts/*/*", CookbookArtifactsCookbookIdentifierEndpoint.new(self) ], + [ "/organizations/*/cookbook_artifacts/*", CookbookArtifactEndpoint.new(self) ], + [ "/organizations/*/cookbook_artifacts/*/*", CookbookArtifactIdentifierEndpoint.new(self) ], [ "/organizations/*/data", DataBagsEndpoint.new(self) ], [ "/organizations/*/data/*", DataBagEndpoint.new(self) ], [ "/organizations/*/data/*/*", DataBagItemEndpoint.new(self) ], |