diff options
author | danielsdeleo <dan@getchef.com> | 2015-01-22 19:08:29 -0800 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2015-01-27 12:46:14 -0800 |
commit | 2f817d8d00135abadc9a279e20a448f9ffe91a1c (patch) | |
tree | 7922a9cd1916b6f4dc2ddb3016d5758408d5c088 /lib/chef/policy_builder | |
parent | 4fafa081d8418e40b29c8b6fae92ff850a8191f1 (diff) | |
download | chef-2f817d8d00135abadc9a279e20a448f9ffe91a1c.tar.gz |
Add policyfile native support to policy builder
Diffstat (limited to 'lib/chef/policy_builder')
-rw-r--r-- | lib/chef/policy_builder/policyfile.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 0df3dd5dd2..ff8e067bf6 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -237,7 +237,12 @@ class Chef end def policyfile_location - "data/policyfiles/#{deployment_group}" + if Chef::Config[:policy_document_native_api] + validate_policy_config! + "policies/#{policy_group}/#{policy_name}" + else + "data/policyfiles/#{deployment_group}" + end end # Do some mimimal validation of the policyfile we fetched from the @@ -281,6 +286,22 @@ class Chef raise ConfigurationError, "Setting `deployment_group` is not configured." end + def validate_policy_config! + policy_group or + raise ConfigurationError, "Setting `policy_group` is not configured." + + policy_name or + raise ConfigurationError, "Setting `policy_name` is not configured." + end + + def policy_group + Chef::Config[:policy_group] + end + + def policy_name + Chef::Config[:policy_name] + end + # Builds a 'cookbook_hash' map of the form # "COOKBOOK_NAME" => "IDENTIFIER" # |