Commit fe7cd7db authored by sdelano's avatar sdelano
Browse files

Merge branch 'CHEF-2195' into 0.9-stable

parents 2963f82b 4e70c50d
......@@ -59,6 +59,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",
......@@ -179,7 +184,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
......@@ -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
......
......@@ -6,7 +6,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
......
......@@ -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
......
......@@ -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
......
......@@ -148,4 +148,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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment