diff options
author | AJ Christensen <aj@opscode.com> | 2009-07-29 15:19:07 +1200 |
---|---|---|
committer | AJ Christensen <aj@opscode.com> | 2009-07-29 15:19:07 +1200 |
commit | ff40456f566669df619ab8af5c381a2aa44d1630 (patch) | |
tree | 07fd0efd23288f232cb828cc0cd62714c2a1370a | |
parent | 94b6530e69f3f50dcce11990a922ec7a5bd02706 (diff) | |
download | chef-ff40456f566669df619ab8af5c381a2aa44d1630.tar.gz |
CHEF-448: Chef Server URL metaconfiguration option
Adds -S to chef-client for chef-server-url
Adds chef_server_url configuration option for client.rb to set the
values of registration_url, openid_url, template_url, remotefile_url,
search_url and role_url
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | chef/lib/chef/application/client.rb | 8 | ||||
-rw-r--r-- | chef/lib/chef/config.rb | 19 | ||||
-rw-r--r-- | chef/spec/unit/config_spec.rb | 35 |
4 files changed, 63 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 1887f64bf6..ee6b386eef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.autotest coverage doc .DS_Store diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb index ffc2ed9fea..1ef1307499 100644 --- a/chef/lib/chef/application/client.rb +++ b/chef/lib/chef/application/client.rb @@ -95,6 +95,12 @@ class Chef::Application::Client < Chef::Application :description => "The splay time for running at intervals, in seconds", :proc => lambda { |s| s.to_i } + option :chef_server_url, + :short => "-S CHEFSERVERURL", + :long => "--server CHEFSERVERURL", + :description => "The chef server URL", + :proc => nil + option :validation_token, :short => "-t TOKEN", :long => "--token TOKEN", @@ -112,6 +118,8 @@ class Chef::Application::Client < Chef::Application # Re-open the JSON attributes and load them into the node def reconfigure super + + Chef::Config[:chef_server_url] = config[:chef_server_url] if config.has_key? :chef_server_url if Chef::Config[:daemonize] Chef::Config[:interval] ||= 1800 diff --git a/chef/lib/chef/config.rb b/chef/lib/chef/config.rb index 395d8c024c..977786a37d 100644 --- a/chef/lib/chef/config.rb +++ b/chef/lib/chef/config.rb @@ -41,6 +41,24 @@ class Chef newkey end + + # Override the config dispatch to set the value of multiple server options simultaneously + # + # === Parameters + # url<String>:: String to be set for all of the chef-server-api URL's + # + def self.chef_server_url=(url) + configure do |c| + [ :registration_url, + :openid_url, + :template_url, + :remotefile_url, + :search_url, + :role_url ].each do |u| + c[u] = url + end + end + end # Override the config dispatch to set the value of log_location configuration option # # === Parameters @@ -61,6 +79,7 @@ class Chef authorized_openid_identifiers nil authorized_openid_providers nil + chef_server_url nil cookbook_path [ "/var/chef/site-cookbooks", "/var/chef/cookbooks" ] couchdb_database "chef" couchdb_url "http://localhost:5984" diff --git a/chef/spec/unit/config_spec.rb b/chef/spec/unit/config_spec.rb index 0a68391304..d2fde90133 100644 --- a/chef/spec/unit/config_spec.rb +++ b/chef/spec/unit/config_spec.rb @@ -19,6 +19,36 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) describe Chef::Config do + describe "class method: chef_server_url" do + before do + Chef::Config.chef_server_url = "https://junglist.gen.nz" + end + + it "should set the registration url" do + Chef::Config.registration_url.should == "https://junglist.gen.nz" + end + + it "should set the openid url" do + Chef::Config.openid_url.should == "https://junglist.gen.nz" + end + + it "should set the template url" do + Chef::Config.template_url.should == "https://junglist.gen.nz" + end + + it "should set the remotefile url" do + Chef::Config.remotefile_url.should == "https://junglist.gen.nz" + end + + it "should set the search url" do + Chef::Config.search_url.should == "https://junglist.gen.nz" + end + + it "should set the role url" do + Chef::Config.role_url.should == "https://junglist.gen.nz" + end + end + describe "class method: manage_secret_key" do before do Chef::FileCache.stub!(:has_key?).with("chef_server_cookie_id").and_return(false) @@ -33,6 +63,11 @@ describe Chef::Config do before do Chef::FileCache.stub!(:has_key?).with("chef_server_cookie_id").and_return(true) end + + it "should not generate and store a chef server cookie id" do + Chef::FileCache.should_not_receive(:store).with("chef_server_cookie_id", /\w{40}/).and_return(true) + Chef::Config.manage_secret_key + end end end |