summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-09-25 15:27:04 -0700
committerdanielsdeleo <dan@chef.io>2015-09-25 15:27:04 -0700
commit73b0f10117549f74a001354b71596aa4b6106131 (patch)
tree68e87407aabfa2e5452172d5ae8018c35ded3cf9
parenta37c95afa90666574e6335f8212e0f8fcd4b6f4c (diff)
downloadchefdk-empty-config-context.tar.gz
Create empty config context for chefdkchefdk-empty-config-context
Allows `knife` and such to parse config files with `chefdk.settting` in them without error.
-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