summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-11-05 17:29:18 -0800
committerdanielsdeleo <dan@chef.io>2015-11-05 17:29:18 -0800
commit2e9789882242f62d60dc687a68b31c4b2488def7 (patch)
tree64751578e09d6c76519e5cb99deb0a45edaeb2c8
parent2e09c06915ca8602223d83bf351d439d5c7e9e4f (diff)
downloadchef-nil-run-list-bootstrap.tar.gz
Handle nil run list option in knife bootstrapnil-run-list-bootstrap
-rw-r--r--lib/chef/knife/bootstrap.rb10
-rw-r--r--spec/unit/knife/bootstrap_spec.rb15
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 8502ccb8eb..6830342b89 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -455,7 +455,15 @@ class Chef
# True if policy_name and run_list are both given
def policyfile_and_run_list_given?
- !config[:run_list].empty? && !!config[:policy_name]
+ run_list_given? && policyfile_options_given?
+ end
+
+ def run_list_given?
+ !config[:run_list].nil? && !config[:run_list].empty?
+ end
+
+ def policyfile_options_given?
+ !!config[:policy_name]
end
# True if one of policy_name or policy_group was given, but not both
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 342c1878f1..8c5a62e6f0 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -472,6 +472,21 @@ describe Chef::Knife::Bootstrap do
end
+ # https://github.com/chef/chef/issues/4131
+ # Arguably a bug in the plugin: it shouldn't be setting this to nil, but it
+ # worked before, so make it work now.
+ context "when a plugin sets the run list option to nil" do
+
+ before do
+ knife.config[:run_list] = nil
+ end
+
+ it "passes options validation" do
+ expect { knife.validate_options! }.to_not raise_error
+ end
+
+ end
+
end
describe "when configuring the underlying knife ssh command" do