diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef_zero/dist.rb | 9 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/controls_endpoint.rb | 5 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/version_endpoint.rb | 3 | ||||
-rw-r--r-- | lib/chef_zero/rspec.rb | 4 | ||||
-rw-r--r-- | lib/chef_zero/server.rb | 7 | ||||
-rw-r--r-- | lib/chef_zero/socketless_server_map.rb | 3 |
6 files changed, 22 insertions, 9 deletions
diff --git a/lib/chef_zero/dist.rb b/lib/chef_zero/dist.rb new file mode 100644 index 0000000..6ef8aca --- /dev/null +++ b/lib/chef_zero/dist.rb @@ -0,0 +1,9 @@ +module ChefZero + class Dist + # When referencing a product directly + PRODUCT = "Chef Zero".freeze + + # The binary alias + CLIENT = "chef-zero".freeze + end +end diff --git a/lib/chef_zero/endpoints/controls_endpoint.rb b/lib/chef_zero/endpoints/controls_endpoint.rb index 5790d7f..b7021af 100644 --- a/lib/chef_zero/endpoints/controls_endpoint.rb +++ b/lib/chef_zero/endpoints/controls_endpoint.rb @@ -1,14 +1,15 @@ +require "chef_zero/dist" module ChefZero module Endpoints # /organizations/ORG/controls class ControlsEndpoint < RestBase # ours is not to wonder why; ours is but to make the pedant specs pass. def get(request) - error(410, "Server says 410, chef-zero says 410.") + error(410, "Server says 410, #{ChefZero::Dist::CLIENT} says 410.") end def post(request) - error(410, "Server says 410, chef-zero says 410.") + error(410, "Server says 410, #{ChefZero::Dist::CLIENT} says 410.") end end end diff --git a/lib/chef_zero/endpoints/version_endpoint.rb b/lib/chef_zero/endpoints/version_endpoint.rb index c51e893..3ec687e 100644 --- a/lib/chef_zero/endpoints/version_endpoint.rb +++ b/lib/chef_zero/endpoints/version_endpoint.rb @@ -1,11 +1,12 @@ require "chef_zero/rest_base" +require "chef_zero/dist" module ChefZero module Endpoints # /version class VersionEndpoint < RestBase def get(request) - text_response(200, "chef-zero #{ChefZero::VERSION}\n") + text_response(200, "#{ChefZero::Dist::CLIENT} #{ChefZero::VERSION}\n") end end end diff --git a/lib/chef_zero/rspec.rb b/lib/chef_zero/rspec.rb index e1fdfcc..496cea5 100644 --- a/lib/chef_zero/rspec.rb +++ b/lib/chef_zero/rspec.rb @@ -42,7 +42,7 @@ module ChefZero extend RSpecClassMethods def when_the_chef_server(description, *tags, &block) - context "When the Chef server #{description}", *tags do + context "When the #{ChefZero::Dist::PRODUCT} server #{description}", *tags do extend WhenTheChefServerClassMethods include WhenTheChefServerInstanceMethods @@ -69,7 +69,7 @@ module ChefZero if chef_server_options[:server_scope] != self.class.chef_server_options[:server_scope] raise "server_scope: #{chef_server_options[:server_scope]} will not be honored: it can only be set on when_the_chef_server!" end - Log.info("Starting Chef server with options #{chef_server_options}") + Log.info("Starting #{ChefZero::Dist::PRODUCT} server with options #{chef_server_options}") ChefZero::RSpec.set_server_options(chef_server_options) diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 9800913..0c60f78 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -35,6 +35,7 @@ require "chef_zero/data_store/memory_store_v2" require "chef_zero/data_store/v1_to_v2_adapter" require "chef_zero/data_store/default_facade" require "chef_zero/version" +require "chef_zero/dist.rb" require "chef_zero/endpoints/rest_list_endpoint" require "chef_zero/endpoints/authenticate_user_endpoint" @@ -231,7 +232,7 @@ module ChefZero if publish output = publish.respond_to?(:puts) ? publish : STDOUT output.puts <<-EOH.gsub(/^ {10}/, "") - >> Starting Chef Zero (v#{ChefZero::VERSION})... + >> Starting #{ChefZero::Dist::PRODUCT} (v#{ChefZero::VERSION})... EOH end @@ -248,7 +249,7 @@ module ChefZero %w{INT TERM}.each do |signal| Signal.trap(signal) do - puts "\n>> Stopping Chef Zero..." + puts "\n>> Stopping #{ChefZero::Dist::PRODUCT}..." @server.shutdown end end @@ -362,7 +363,7 @@ module ChefZero end rescue Timeout::Error if @thread - ChefZero::Log.error("Chef Zero did not stop within #{wait} seconds! Killing...") + ChefZero::Log.error("#{ChefZero::Dist::PRODUCT} did not stop within #{wait} seconds! Killing...") @thread.kill SocketlessServerMap.deregister(port) end diff --git a/lib/chef_zero/socketless_server_map.rb b/lib/chef_zero/socketless_server_map.rb index 28b7b59..1e7c1e2 100644 --- a/lib/chef_zero/socketless_server_map.rb +++ b/lib/chef_zero/socketless_server_map.rb @@ -18,6 +18,7 @@ require "thread" require "singleton" +require "chef_zero/dist" module ChefZero @@ -83,7 +84,7 @@ module ChefZero def request(port, request_env) server = @servers_by_port[port] - raise ServerNotFound, "No socketless chef-zero server on given port #{port.inspect}" unless server + raise ServerNotFound, "No socketless #{ChefZero::Dist::PRODUCT} server on given port #{port.inspect}" unless server server.handle_socketless_request(request_env) end |