summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-08-10 11:58:10 -0700
committerTim Smith <tsmith@chef.io>2017-08-10 11:58:10 -0700
commitba70aadaa0b2a3a74b72fc1374b479d852a44181 (patch)
treef876e715314dacdfbeec951b2cc82d3116e5719f
parent87a613bbc2603dab378cef904b749a1978cf9c74 (diff)
downloadchef-backwards_apt_pref.tar.gz
Maintain backwards compatibility with apt_preferencebackwards_apt_pref
Remove did not previously require the pin and pin_priority. Also it doesn't make sense to require those for a remove action. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/apt_preference.rb4
-rw-r--r--lib/chef/resource/apt_preference.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/provider/apt_preference.rb b/lib/chef/provider/apt_preference.rb
index d3958ea6fa..3bb10cac32 100644
--- a/lib/chef/provider/apt_preference.rb
+++ b/lib/chef/provider/apt_preference.rb
@@ -37,6 +37,10 @@ class Chef
end
action :add do
+ # raise within the action vs. requiring the resource so :remove doesn't fail w/o pin & pin_priority
+ raise "pin property required for apt_preference when using the :add action" if new_resource.pin.nil?
+ raise "pin property required for apt_preference when using the :add action" if new_resource.pin_priority.nil?
+
preference = build_pref(
new_resource.glob || new_resource.package_name,
new_resource.pin,
diff --git a/lib/chef/resource/apt_preference.rb b/lib/chef/resource/apt_preference.rb
index 603766d76b..ccc73db709 100644
--- a/lib/chef/resource/apt_preference.rb
+++ b/lib/chef/resource/apt_preference.rb
@@ -26,8 +26,8 @@ class Chef
property :package_name, String, name_property: true, regex: [/^([a-z]|[A-Z]|[0-9]|_|-|\.|\*|\+)+$/]
property :glob, String
- property :pin, String, required: true
- property :pin_priority, [String, Integer], required: true
+ property :pin, String
+ property :pin_priority, [String, Integer]
default_action :add
allowed_actions :add, :remove