summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-15 11:35:25 -0500
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-15 11:35:25 -0500
commit504161a341b7b2188359b793696333037ebf8404 (patch)
tree7498c60fd2ac4b9d44359f29f27834472154c81f /lib
parentb086721ca70750277c407fd0cc573a08f076649f (diff)
parent2be8ab342b55a0be79f8836dd717b586e8ea0d5b (diff)
downloadchef-504161a341b7b2188359b793696333037ebf8404.tar.gz
Merge pull request #3360 from chef/jdm/resource-semantics
Add check_resource_semantics! lifecycle method to provider
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider.rb5
-rw-r--r--lib/chef/provider/package.rb6
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 3ab4d4d2b1..99d09d0507 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -83,6 +83,9 @@ class Chef
new_resource.cookbook_name
end
+ def check_resource_semantics!
+ end
+
def load_current_resource
raise Chef::Exceptions::Override, "You must override load_current_resource in #{self.to_s}"
end
@@ -108,6 +111,8 @@ class Chef
# TODO: it would be preferable to get the action to be executed in the
# constructor...
+ check_resource_semantics!
+
# user-defined LWRPs may include unsafe load_current_resource methods that cannot be run in whyrun mode
if !whyrun_mode? || whyrun_supported?
load_current_resource
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 6b429a400d..bdc96cd070 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -43,6 +43,12 @@ class Chef
true
end
+ def check_resource_semantics!
+ if new_resource.package_name.is_a?(Array) && new_resource.source != nil
+ raise Chef::Exceptions::InvalidResourceSpecification, "You may not specify both multipackage and source"
+ end
+ end
+
def load_current_resource
end