summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-09-24 10:08:59 -0700
committerdanielsdeleo <dan@chef.io>2015-09-24 12:37:26 -0700
commit33509c1bbb7366d3e2a50f61d8d53161e51eb6fa (patch)
tree87c71e0b6b30214ee0ab675255f75f2cc71ba1cb
parent14d7baab6365e0b4146990a5306f80a7f0d09a82 (diff)
downloadchef-policyfile-bootstrap-integration.tar.gz
Add policyfile attributes to client builderpolicyfile-bootstrap-integration
-rw-r--r--lib/chef/knife/bootstrap/client_builder.rb12
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb11
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb
index 59b0cabd49..7eb1e22628 100644
--- a/lib/chef/knife/bootstrap/client_builder.rb
+++ b/lib/chef/knife/bootstrap/client_builder.rb
@@ -91,6 +91,16 @@ class Chef
knife_config[:run_list]
end
+ # @return [String] policy_name from the knife_config
+ def policy_name
+ knife_config[:policy_name]
+ end
+
+ # @return [String] policy_group from the knife_config
+ def policy_group
+ knife_config[:policy_group]
+ end
+
# @return [Hash,Array] Object representation of json first-boot attributes from the knife_config
def first_boot_attributes
knife_config[:first_boot_attributes]
@@ -141,6 +151,8 @@ class Chef
node.run_list(normalized_run_list)
node.normal_attrs = first_boot_attributes if first_boot_attributes
node.environment(environment) if environment
+ node.policy_name = policy_name if policy_name
+ node.policy_group = policy_group if policy_group
(knife_config[:tags] || []).each do |tag|
node.tags << tag
end
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 930ae8c9d3..e7232fe8d6 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -190,5 +190,16 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
expect(node).to receive(:run_list).with([])
client_builder.run
end
+
+ it "builds a node with policy_name and policy_group when given" do
+ knife_config[:policy_name] = "my-app"
+ knife_config[:policy_group] = "staging"
+
+ expect(node).to receive(:run_list).with([])
+ expect(node).to receive(:policy_name=).with("my-app")
+ expect(node).to receive(:policy_group=).with("staging")
+
+ client_builder.run
+ end
end
end