summaryrefslogtreecommitdiff
path: root/chef-config
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-09-25 15:27:04 -0700
committerdanielsdeleo <dan@chef.io>2015-09-25 17:36:25 -0700
commit8d32fdd4377476a9f7dc36a864ccdaa17c32b3a1 (patch)
tree827d39e4c92a554772797096fc6c22803b97bb35 /chef-config
parent3952953b82ddc2bd98bcfd777699d8c5699fb38d (diff)
downloadchef-8d32fdd4377476a9f7dc36a864ccdaa17c32b3a1.tar.gz
Create empty config context for chefdk
Allows `knife` and such to parse config files with `chefdk.settting` in them without error.
Diffstat (limited to 'chef-config')
-rw-r--r--chef-config/lib/chef-config/config.rb8
-rw-r--r--chef-config/spec/unit/config_spec.rb8
2 files changed, 16 insertions, 0 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 2405b127f3..069f0ed6c0 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -690,6 +690,14 @@ module ChefConfig
default :watchdog_timeout, 2 * (60 * 60) # 2 hours
end
+ # Add an empty and non-strict config_context for chefdk. This lets the user
+ # have code like `chefdk.generator_cookbook "/path/to/cookbook"` in their
+ # config.rb, and it will be ignored by tools like knife and ohai. ChefDK
+ # itself can define the config options it accepts and enable strict mode,
+ # and that will only apply when running `chef` commands.
+ config_context :chefdk do
+ end
+
# Chef requires an English-language UTF-8 locale to function properly. We attempt
# to use the 'locale -a' command and search through a list of preferences until we
# find one that we can use. On Ubuntu systems we should find 'C.UTF-8' and be
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index bc35fbee69..d99ff428fb 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -561,6 +561,14 @@ RSpec.describe ChefConfig::Config do
end
end
+ describe "allowing chefdk configuration outside of chefdk" do
+
+ it "allows arbitrary settings in the chefdk config context" do
+ expect { ChefConfig::Config.chefdk.generator_cookbook("/path") }.to_not raise_error
+ end
+
+ end
+
describe "Treating deprecation warnings as errors" do
context "when using our default RSpec configuration" do