diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-11 13:19:58 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-12-15 11:16:20 -0800 |
commit | b743fcdbd172862386d172b42bbbc31cfe2f4239 (patch) | |
tree | aeb3a60c86bbd98c5502b86483848a5cc5122fc3 /lib/chef/resource/package.rb | |
parent | 44494c91587ff0313d328d9c4ec016e6fcf5f830 (diff) | |
download | chef-b743fcdbd172862386d172b42bbbc31cfe2f4239.tar.gz |
Use properties in package resourcesjk/package-properties
Diffstat (limited to 'lib/chef/resource/package.rb')
-rw-r--r-- | lib/chef/resource/package.rb | 76 |
1 files changed, 11 insertions, 65 deletions
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb index c73810a118..d190479a29 100644 --- a/lib/chef/resource/package.rb +++ b/lib/chef/resource/package.rb @@ -22,79 +22,25 @@ require 'chef/resource' class Chef class Resource class Package < Chef::Resource - identity_attr :package_name - - state_attrs :version, :options + resource_name :package default_action :install allowed_actions :install, :upgrade, :remove, :purge, :reconfig - def initialize(name, run_context=nil) + def initialize(name, *args) + # We capture name here, before it gets coerced to name + package_name name super - options nil - package_name name - response_file nil - response_file_variables Hash.new - source nil - version nil - timeout nil - end - - def package_name(arg=nil) - set_or_return( - :package_name, - arg, - :kind_of => [ String, Array ] - ) end - def version(arg=nil) - set_or_return( - :version, - arg, - :kind_of => [ String, Array ] - ) - end + property :package_name, [ String, Array ], identity: true - def response_file(arg=nil) - set_or_return( - :response_file, - arg, - :kind_of => [ String ] - ) - end - - def response_file_variables(arg=nil) - set_or_return( - :response_file_variables, - arg, - :kind_of => [ Hash ] - ) - end - - def source(arg=nil) - set_or_return( - :source, - arg, - :kind_of => [ String ] - ) - end - - def options(arg=nil) - set_or_return( - :options, - arg, - :kind_of => [ String ] - ) - end - - def timeout(arg=nil) - set_or_return( - :timeout, - arg, - :kind_of => [String, Integer] - ) - end + property :version, [ String, Array ] + property :options, String + property :response_file, String, desired_state: false + property :response_file_variables, Hash, default: lazy { {} }, desired_state: false + property :source, String, desired_state: false + property :timeout, [ String, Integer ], desired_state: false end end |