diff options
author | Tyler Fitch <tfitch@getchef.com> | 2015-10-28 07:40:48 -0700 |
---|---|---|
committer | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-10-28 16:26:23 -0400 |
commit | 1b6237afc672615e8a831b9513258744d23ff9bb (patch) | |
tree | b2542a1d50441c5cbea0380d5ead0d35ff40b81b | |
parent | 255e6bb153e159805562096f8bf5fe8777ab7e26 (diff) | |
download | chef-1b6237afc672615e8a831b9513258744d23ff9bb.tar.gz |
Update knife bootstrap command to honor --no-color flag in chef-client run that is part of the bootstrap process.
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 1 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 15 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 8613a50cb4..fca3b0a90e 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -129,6 +129,7 @@ CONFIG s = "#{client_path} -j /etc/chef/first-boot.json" s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2 s << " -E #{bootstrap_environment}" unless bootstrap_environment.nil? + s << " --no-color" unless @config[:color] s end diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 4d69d6300a..9ab933aaae 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -39,13 +39,20 @@ describe Chef::Knife::Core::BootstrapContext do end it "runs chef with the first-boot.json with no environment specified" do - expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json" + expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json --no-color" end describe "when in verbosity mode" do let(:config) { {:verbosity => 2} } it "adds '-l debug' when verbosity is >= 2" do - expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug" + expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json -l debug --no-color" + end + end + + describe "when in color is true" do + let(:config) { {:color => true} } + it "removes '--no-color' when color is true" do + expect(bootstrap_context.start_chef).to eq "chef-client -j /etc/chef/first-boot.json" end end @@ -70,7 +77,7 @@ EXPECTED describe "alternate chef-client path" do let(:chef_config){ {:chef_client_path => '/usr/local/bin/chef-client'} } it "runs chef-client from another path when specified" do - expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json" + expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json --no-color" end end @@ -93,7 +100,7 @@ EXPECTED describe "when bootstrapping into a specific environment" do let(:config){ {:environment => "prodtastic"} } it "starts chef in the configured environment" do - expect(bootstrap_context.start_chef).to eq('chef-client -j /etc/chef/first-boot.json -E prodtastic') + expect(bootstrap_context.start_chef).to eq('chef-client -j /etc/chef/first-boot.json -E prodtastic --no-color') end end |