summaryrefslogtreecommitdiff
path: root/lib/chef/config.rb
diff options
context:
space:
mode:
authortylercloke <tylercloke@gmail.com>2015-04-27 16:12:53 -0700
committertylercloke <tylercloke@gmail.com>2015-04-28 13:20:01 -0700
commite60111f2773b60309db41581a98a66b5ed7cdad6 (patch)
tree0fd93edba7e1dbc298995f6f24be610201c6b985 /lib/chef/config.rb
parent518abd416b05c81c168cbae081f290c6e6300b05 (diff)
downloadchef-e60111f2773b60309db41581a98a66b5ed7cdad6.tar.gz
Set chef_server_root config value to sane defaults.
If chef_server_url matches /\/organizations\/\S*$/ aka .../organizations/someorg, then strip /organizations/someorg and use that as the chef_server_root default. Otherwise, just use whatever chef_server_url is as the default.
Diffstat (limited to 'lib/chef/config.rb')
-rw-r--r--lib/chef/config.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 25557b077f..d73bcf8e6e 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -319,7 +319,17 @@ class Chef
default :host, 'localhost'
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
end
+
default :chef_server_url, "https://localhost:443"
+ default(:chef_server_root) do
+ # if the chef_server_url is a path to an organization, aka
+ # 'some_url.../organizations/*' then remove the '/organization/*' by default
+ if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/
+ self.configuration[:chef_server_url].split('/')[0..-3].join('/')
+ else # default to whatever chef_server_url is
+ self.configuration[:chef_server_url]
+ end
+ end
default :rest_timeout, 300
default :yum_timeout, 900