summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-04-15 13:29:41 -0700
committerDaniel DeLeo <dan@opscode.com>2011-04-15 13:29:41 -0700
commit67121064a561859e2dea61e3a9eadf2a9e49e251 (patch)
tree08d9904401e2ead9ba27694046dc563069922a5f
parent5cd334a687fbb644ab30ce80f5e80c1cbd9266a0 (diff)
parentca32d8a28c126776767ff954b23eceab7a257110 (diff)
downloadchef-67121064a561859e2dea61e3a9eadf2a9e49e251.tar.gz
Merge branch 'master' of github.com:opscode/chef
-rw-r--r--chef-server-webui/app/controllers/application.rb4
-rw-r--r--chef-server-webui/app/controllers/search.rb2
-rw-r--r--chef/lib/chef/knife/bootstrap.rb38
-rw-r--r--chef/lib/chef/knife/bootstrap/archlinux-gems.erb3
-rw-r--r--chef/lib/chef/knife/bootstrap/centos5-gems.erb5
-rw-r--r--chef/lib/chef/knife/bootstrap/fedora13-gems.erb3
-rw-r--r--chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb4
-rw-r--r--chef/spec/unit/knife/bootstrap_spec.rb66
8 files changed, 116 insertions, 9 deletions
diff --git a/chef-server-webui/app/controllers/application.rb b/chef-server-webui/app/controllers/application.rb
index 34e1d75236..159ead9733 100644
--- a/chef-server-webui/app/controllers/application.rb
+++ b/chef-server-webui/app/controllers/application.rb
@@ -252,7 +252,7 @@ class Application < Merb::Controller
#for showing search result
def determine_name(type, object)
case type
- when :node, :role, :client
+ when :node, :role, :client, :environment
object.name
else
params[:id]
@@ -260,7 +260,7 @@ class Application < Merb::Controller
end
def list_available_recipes_for(environment)
- Chef::Environment.load_filtered_recipe_list(environment)
+ Chef::Environment.load_filtered_recipe_list(environment).sort!
end
def convert_newline_to_br(string)
diff --git a/chef-server-webui/app/controllers/search.rb b/chef-server-webui/app/controllers/search.rb
index 1d5ce51b64..ccc2707097 100644
--- a/chef-server-webui/app/controllers/search.rb
+++ b/chef-server-webui/app/controllers/search.rb
@@ -40,7 +40,7 @@ class Search < Application
@s = Chef::Search::Query.new
query = (params[:q].nil? || params[:q].empty?) ? "*:*" : URI.escape(params[:q], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
@results = @s.search(params[:id], query)
- @type = if params[:id].to_s == "node" || params[:id].to_s == "role" || params[:id].to_s == "client"
+ @type = if params[:id].to_s == "node" || params[:id].to_s == "role" || params[:id].to_s == "client" || params[:id].to_s == "environment"
params[:id]
else
"databag"
diff --git a/chef/lib/chef/knife/bootstrap.rb b/chef/lib/chef/knife/bootstrap.rb
index e12a63d99e..62d70b5392 100644
--- a/chef/lib/chef/knife/bootstrap.rb
+++ b/chef/lib/chef/knife/bootstrap.rb
@@ -17,6 +17,7 @@
#
require 'chef/knife'
+require 'erubis'
class Chef
class Knife
@@ -25,7 +26,6 @@ class Chef
deps do
require 'chef/json_compat'
require 'tempfile'
- require 'erubis'
require 'highline'
require 'net/ssh'
require 'net/ssh/multi'
@@ -65,6 +65,11 @@ class Chef
:long => "--prerelease",
:description => "Install the pre-release chef gems"
+ option :bootstrap_version,
+ :long => "--bootstrap-version",
+ :description => "The version of Chef to install",
+ :proc => lambda { |v| Chef::Config[:bootstrap_version] = v }
+
option :distro,
:short => "-d DISTRO",
:long => "--distro DISTRO",
@@ -188,7 +193,36 @@ class Chef
command
end
+ module TemplateHelper
+
+ #
+ # == Chef::Knife::Bootstrap::TemplateHelper
+ #
+ # The methods in the TemplateHelper module expect to have access to
+ # the instance varialbles set above as part of the context in the
+ # Chef::Knife::Bootstrap#render_context method. Those instance
+ # variables are:
+ #
+ # * @config - a hash of knife's config values
+ # * @run_list - the run list for the node to boostrap
+ #
+
+ ::Erubis::Context.send(:include, Chef::Knife::Bootstrap::TemplateHelper)
+
+ def bootstrap_version_string(type=nil)
+ version = Chef::Config[:bootstrap_version] || Chef::VERSION
+ case type
+ when :gems
+ if @config[:prerelease]
+ "--prerelease"
+ else
+ "--version #{version}"
+ end
+ else
+ version
+ end
+ end
+ end
end
end
end
-
diff --git a/chef/lib/chef/knife/bootstrap/archlinux-gems.erb b/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
index 6ba89c18ef..5b131b8f43 100644
--- a/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
@@ -3,7 +3,8 @@ if [ ! -f /usr/bin/chef-client ]; then
pacman -Syy
pacman -S --noconfirm ruby ntp base-devel
ntpdate -u pool.ntp.org
- gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
+ gem install ohai --no-rdoc --no-ri --verbose
+ gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string(:gems) %>
fi
mkdir -p /etc/chef
diff --git a/chef/lib/chef/knife/bootstrap/centos5-gems.erb b/chef/lib/chef/knife/bootstrap/centos5-gems.erb
index 4f1256c173..fd1998cc63 100644
--- a/chef/lib/chef/knife/bootstrap/centos5-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/centos5-gems.erb
@@ -12,7 +12,10 @@ if [ ! -f /usr/bin/chef-client ]; then
ruby setup.rb --no-format-executable
fi
-gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
+gem update --system
+gem update
+gem install ohai --no-rdoc --no-ri --verbose
+gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string(:gems) %>
mkdir -p /etc/chef
diff --git a/chef/lib/chef/knife/bootstrap/fedora13-gems.erb b/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
index c0b78f6323..63cb465f5a 100644
--- a/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
@@ -3,7 +3,8 @@ yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
gem update --system
gem update
-gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
+gem install ohai --no-rdoc --no-ri --verbose
+gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string(:gems) %>
mkdir -p /etc/chef
diff --git a/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb b/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
index 31bb54d834..9782726e68 100644
--- a/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
@@ -8,7 +8,9 @@ if [ ! -f /usr/bin/chef-client ]; then
cd rubygems-1.3.7
ruby setup.rb --no-format-executable
fi
-gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
+
+gem install ohai --no-rdoc --no-ri --verbose
+gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string(:gems) %>
mkdir -p /etc/chef
diff --git a/chef/spec/unit/knife/bootstrap_spec.rb b/chef/spec/unit/knife/bootstrap_spec.rb
index 7c6d88c1d7..678e40f47b 100644
--- a/chef/spec/unit/knife/bootstrap_spec.rb
+++ b/chef/spec/unit/knife/bootstrap_spec.rb
@@ -150,4 +150,70 @@ describe Chef::Knife::Bootstrap do
end
+ describe "render_template" do
+
+ end
+
+end
+
+describe Chef::Knife::Bootstrap::TemplateHelper do
+ before(:each) do
+ @context = Erubis::Context.new({
+ :config => Hash.new
+ })
+ end
+
+ describe "bootstrap_version_string" do
+ after(:each) do
+ Chef::Config.delete :bootstrap_version
+ end
+
+ formats = {
+ :gems => /^--version \d+\.\d+\.\d+/,
+ :nil => '\d+\.\d+\.\d+'
+ }
+
+ context "by default" do
+ formats.each do |sym, format|
+ it "should return the current version of Chef for :#{sym.to_s}" do
+ @context.bootstrap_version_string(sym).should include Chef::VERSION
+ end
+
+ it "should match the correct output format for :#{sym.to_s}" do
+ @context.bootstrap_version_string(sym).should match format
+ end
+ end
+ end
+
+ context "with Chef::Config[:bootstrap_version] set" do
+ before(:each) do
+ @config_version = "0.9.12"
+ Chef::Config[:bootstrap_version] = @config_version
+ end
+
+ formats.each do |sym, format|
+ it "should return the specified bootstrap version for :#{sym.to_s}" do
+ @context.bootstrap_version_string(sym).should include @config_version
+ end
+
+ it "should match the correct output format for :#{sym.to_s}" do
+ @context.bootstrap_version_string(sym).should match format
+ end
+ end
+ end
+
+ context "with config[:prerelease] set" do
+ before(:each) do
+ @context[:config][:prerelease] = true
+ end
+
+ it "should return --prerelease only for :gems" do
+ formats.each do |sym, format|
+ version_string = @context.bootstrap_version_string(sym)
+ version_string.should == "--prerelease" if sym == :gems
+ version_string.should_not == "--prerelease" if sym != :gems
+ end
+ end
+ end
+ end
end