diff options
author | Claire McQuin <claire@getchef.com> | 2015-07-10 11:45:29 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2015-07-10 11:45:29 -0700 |
commit | 95dcde19be7902090c2c63a7e2b00868581f81fa (patch) | |
tree | 730cad042a78dc20b23ed5cc94be7a403ec9cf80 | |
parent | 018e919fe4648de5dd3e32e0ee8547b25faf4577 (diff) | |
download | chef-mcquin/first-boot-environment.tar.gz |
first_boot_attributes is JSON, use Stringsmcquin/first-boot-environment
-rw-r--r-- | lib/chef/knife/bootstrap/client_builder.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap/client_builder_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb index 64958c6a56..7a739844b2 100644 --- a/lib/chef/knife/bootstrap/client_builder.rb +++ b/lib/chef/knife/bootstrap/client_builder.rb @@ -84,7 +84,7 @@ class Chef def environment # prefer environment from cli over environment from first-boot attributes knife_config[:environment] || - (first_boot_attributes[:chef_environment] if first_boot_attributes) || + (first_boot_attributes['chef_environment'] if first_boot_attributes) || chef_config[:environment] end @@ -143,7 +143,7 @@ class Chef node.run_list(normalized_run_list) if first_boot_attributes scrubbed_first_boot_attributes = first_boot_attributes.dup - scrubbed_first_boot_attributes.delete(:chef_environment) + scrubbed_first_boot_attributes.delete('chef_environment') unless scrubbed_first_boot_attributes.empty? node.normal_attrs = scrubbed_first_boot_attributes end diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 2bccc06d0e..ae79485051 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -47,7 +47,7 @@ class Chef # environment is set in the config file being used. However, # @config[:environment] is not polluted by @chef_config[:environment]. @config[:environment] || - (@config[:first_boot_attributes][:chef_environment] if @config[:first_boot_attributes]) || + (@config[:first_boot_attributes]['chef_environment'] if @config[:first_boot_attributes]) || @chef_config[:environment] || '_default' end diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb index 879fac71ca..7ec4d40bbd 100644 --- a/spec/unit/knife/bootstrap/client_builder_spec.rb +++ b/spec/unit/knife/bootstrap/client_builder_spec.rb @@ -162,14 +162,14 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end it "builds a node with first_boot_attributes if they're given" do - knife_config[:first_boot_attributes] = {:baz => :quux} - expect(node).to receive(:normal_attrs=).with({:baz=>:quux}) + knife_config[:first_boot_attributes] = { 'baz' => 'quux' } + expect(node).to receive(:normal_attrs=).with({ 'baz' => 'quux' }) expect(node).to receive(:run_list).with([]) client_builder.run end shared_examples "first-boot environment" do - let(:first_boot_attributes) {{ chef_environment: first_boot_environment }} + let(:first_boot_attributes) {{ 'chef_environment' => first_boot_environment }} let(:first_boot_environment) { "first_boot_environment" } @@ -193,11 +193,11 @@ describe Chef::Knife::Bootstrap::ClientBuilder do end context "when environment is not the only first-boot attribute" do - let(:first_boot_attributes) {{ chef_environment: first_boot_environment, - baz: :quux }} + let(:first_boot_attributes) {{ 'chef_environment' => first_boot_environment, + 'baz' => 'quux' }} it "saves the first-boot attributes, but does not save environment" do - expect(node).to receive(:normal_attrs=).with({ baz: :quux }) + expect(node).to receive(:normal_attrs=).with({ 'baz' => 'quux' }) allow(node).to receive(:environment) client_builder.run end diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index cd83ffa6da..1777b51795 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -98,14 +98,14 @@ EXPECTED end describe "when JSON attributes are given" do - let(:first_boot_attributes) { {baz: :quux} } + let(:first_boot_attributes) {{ 'baz' => 'quux' }} let(:config) { {:first_boot_attributes => first_boot_attributes} } it "adds the attributes to first_boot" do expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:baz => :quux, :run_list => run_list})) end context "when an environment is specified" do - let(:first_boot_attributes) { {chef_environment: "proderption"} } + let(:first_boot_attributes) {{ 'chef_environment' => 'proderption' }} it "starts chef in the configured environment" do expect(bootstrap_context.start_chef).to eq('chef-client -j /etc/chef/first-boot.json -E proderption') end |