diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-28 11:17:10 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-01 08:02:05 -0700 |
commit | 5998cc7315507e649bb76f139c07715f6e590707 (patch) | |
tree | da543eeb9183ba63cfea376c51207b31ed104f65 | |
parent | 16dbca593b2fef74d952c5e119313efbe2288670 (diff) | |
download | chef-5998cc7315507e649bb76f139c07715f6e590707.tar.gz |
Make resource_name call provides
73 files changed, 93 insertions, 112 deletions
diff --git a/DOC_CHANGES.md b/DOC_CHANGES.md index b0a8e0aaaf..629ff147c2 100644 --- a/DOC_CHANGES.md +++ b/DOC_CHANGES.md @@ -6,15 +6,16 @@ Example Doc Change: Description of the required change. --> -### Resources must now use `provides` to declare recipe DSL +### Resources must now use `resource_name` (or `provides`) to declare recipe DSL Resources declared in `Chef::Resource` namespace will no longer get recipe DSL -automatically. Instead, explicit `provides` is required in order to have DSL: +automatically. Instead, `resource_name` is required in order to have DSL: ```ruby module MyModule class MyResource < Chef::Resource - provides :my_resource + resource_name :my_resource + provides :some_other_name, os: 'linux' # A second resource DSL, only on linux end end ``` diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 78f6a38b34..fdfa9766ab 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -886,15 +886,22 @@ class Chef # # The display name of this resource type, for printing purposes. # + # This also automatically calls "provides" to provide DSL with the given + # name. + # + # @param value [Symbol] The desired name of this resource type (e.g. + # `execute`). + # # @return [Symbol] The name of this resource type (e.g. `:execute`). # - attr_accessor :resource_name def resource_name(value=NULL_ARG) if value != NULL_ARG - self.resource_name = value.to_sym + @resource_name = value.to_sym + provides self.resource_name end @resource_name end + alias :resource_name= :resource_name # # The module where Chef should look for providers for this resource. @@ -1007,8 +1014,6 @@ class Chef def self.provides(name, *args, &block) result = super - # The first time `provides` is called on the class, it is used for resource_name - self.resource_name ||= name Chef::DSL::Resources.add_resource_dsl(name) result end diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb index 8326e651e5..eb61972b74 100644 --- a/lib/chef/resource/apt_package.rb +++ b/lib/chef/resource/apt_package.rb @@ -23,7 +23,7 @@ class Chef class Resource class AptPackage < Chef::Resource::Package - provides :apt_package + resource_name :apt_package provides :package, os: "linux", platform_family: [ "debian" ] def initialize(name, run_context=nil) diff --git a/lib/chef/resource/bash.rb b/lib/chef/resource/bash.rb index db8f5888af..2e21d3db69 100644 --- a/lib/chef/resource/bash.rb +++ b/lib/chef/resource/bash.rb @@ -22,7 +22,7 @@ require 'chef/provider/script' class Chef class Resource class Bash < Chef::Resource::Script - provides :bash + resource_name :bash def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/batch.rb b/lib/chef/resource/batch.rb index efe3f2205f..d79127e2f3 100644 --- a/lib/chef/resource/batch.rb +++ b/lib/chef/resource/batch.rb @@ -22,6 +22,7 @@ class Chef class Resource class Batch < Chef::Resource::WindowsScript + resource_name :batch provides :batch, os: "windows" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/bff_package.rb b/lib/chef/resource/bff_package.rb index 072db537f8..cd60b94cdd 100644 --- a/lib/chef/resource/bff_package.rb +++ b/lib/chef/resource/bff_package.rb @@ -22,7 +22,7 @@ require 'chef/provider/package/aix' class Chef class Resource class BffPackage < Chef::Resource::Package - provides :bff_package + resource_name :bff_package end end end diff --git a/lib/chef/resource/breakpoint.rb b/lib/chef/resource/breakpoint.rb index 177f8bdc39..3f09d1d442 100644 --- a/lib/chef/resource/breakpoint.rb +++ b/lib/chef/resource/breakpoint.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Breakpoint < Chef::Resource - provides :breakpoint + resource_name :breakpoint def initialize(action="break", *args) super(caller.first, *args) diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index 6fb20d7c09..b3c96fcbec 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -23,7 +23,7 @@ class Chef class Resource class ChefGem < Chef::Resource::Package::GemPackage - provides :chef_gem + resource_name :chef_gem def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/cookbook_file.rb b/lib/chef/resource/cookbook_file.rb index 7191a3cc39..b12735a56c 100644 --- a/lib/chef/resource/cookbook_file.rb +++ b/lib/chef/resource/cookbook_file.rb @@ -27,7 +27,7 @@ class Chef class CookbookFile < Chef::Resource::File include Chef::Mixin::Securable - provides :cookbook_file + resource_name :cookbook_file def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb index c57a6b05e3..70d4a26d53 100644 --- a/lib/chef/resource/cron.rb +++ b/lib/chef/resource/cron.rb @@ -27,7 +27,7 @@ class Chef state_attrs :minute, :hour, :day, :month, :weekday, :user - provides :cron + resource_name :cron def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/csh.rb b/lib/chef/resource/csh.rb index 53921e6906..7eae72d968 100644 --- a/lib/chef/resource/csh.rb +++ b/lib/chef/resource/csh.rb @@ -22,7 +22,7 @@ require 'chef/provider/script' class Chef class Resource class Csh < Chef::Resource::Script - provides :csh + resource_name :csh def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb index 2e930674e4..bfa3679c97 100644 --- a/lib/chef/resource/deploy.rb +++ b/lib/chef/resource/deploy.rb @@ -50,7 +50,7 @@ class Chef # release directory. Callback files can contain chef code (resources, etc.) # class Deploy < Chef::Resource - provides :deploy + resource_name :deploy provider_base Chef::Provider::Deploy diff --git a/lib/chef/resource/deploy_revision.rb b/lib/chef/resource/deploy_revision.rb index fddbea145b..ecb428018b 100644 --- a/lib/chef/resource/deploy_revision.rb +++ b/lib/chef/resource/deploy_revision.rb @@ -23,13 +23,13 @@ class Chef # deployment strategy (provider) class DeployRevision < Chef::Resource::Deploy - provides :deploy_revision + resource_name :deploy_revision end class DeployBranch < Chef::Resource::DeployRevision - provides :deploy_branch + resource_name :deploy_branch end diff --git a/lib/chef/resource/directory.rb b/lib/chef/resource/directory.rb index 8183a51f8b..d49e331639 100644 --- a/lib/chef/resource/directory.rb +++ b/lib/chef/resource/directory.rb @@ -32,7 +32,7 @@ class Chef include Chef::Mixin::Securable - provides :directory + resource_name :directory def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/dpkg_package.rb b/lib/chef/resource/dpkg_package.rb index 38adf24cf6..38210bcf41 100644 --- a/lib/chef/resource/dpkg_package.rb +++ b/lib/chef/resource/dpkg_package.rb @@ -23,6 +23,7 @@ class Chef class Resource class DpkgPackage < Chef::Resource::Package + resource_name :dpkg_package provides :dpkg_package, os: "linux" end diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb index dd3b84b58e..d86368b96e 100644 --- a/lib/chef/resource/dsc_resource.rb +++ b/lib/chef/resource/dsc_resource.rb @@ -21,6 +21,7 @@ class Chef class Resource
class DscResource < Chef::Resource
+ resource_name :dsc_resource
provides :dsc_resource, os: "windows"
include Chef::DSL::Powershell
diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb index 22b96104dd..f1aeb22885 100644 --- a/lib/chef/resource/dsc_script.rb +++ b/lib/chef/resource/dsc_script.rb @@ -22,6 +22,7 @@ class Chef class Resource class DscScript < Chef::Resource + resource_name :dsc_script provides :dsc_script, platform: "windows" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/easy_install_package.rb b/lib/chef/resource/easy_install_package.rb index dd205cd505..e6c9cd180d 100644 --- a/lib/chef/resource/easy_install_package.rb +++ b/lib/chef/resource/easy_install_package.rb @@ -22,7 +22,7 @@ class Chef class Resource class EasyInstallPackage < Chef::Resource::Package - provides :easy_install_package + resource_name :easy_install_package def easy_install_binary(arg=nil) set_or_return( diff --git a/lib/chef/resource/env.rb b/lib/chef/resource/env.rb index 91cfe2070d..f96db899e8 100644 --- a/lib/chef/resource/env.rb +++ b/lib/chef/resource/env.rb @@ -25,6 +25,7 @@ class Chef state_attrs :value + resource_name :env provides :env, os: "windows" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/erl_call.rb b/lib/chef/resource/erl_call.rb index 751e1ca341..8bf0ed19e6 100644 --- a/lib/chef/resource/erl_call.rb +++ b/lib/chef/resource/erl_call.rb @@ -23,7 +23,7 @@ require 'chef/provider/erl_call' class Chef class Resource class ErlCall < Chef::Resource - provides :erl_call + resource_name :erl_call # erl_call : http://erlang.org/doc/man/erl_call.html diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 2cdb38093a..7661fabd5c 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -23,7 +23,7 @@ require 'chef/provider/execute' class Chef class Resource class Execute < Chef::Resource - provides :execute + resource_name :execute identity_attr :command diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index 15bd76156c..607bc5d277 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -47,7 +47,7 @@ class Chef # @returns [String] Checksum of the file we actually rendered attr_accessor :final_checksum - provides :file + resource_name :file def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb index 21ffdba921..81b16dd846 100644 --- a/lib/chef/resource/freebsd_package.rb +++ b/lib/chef/resource/freebsd_package.rb @@ -29,7 +29,7 @@ class Chef class FreebsdPackage < Chef::Resource::Package include Chef::Mixin::ShellOut - provides :freebsd_package + resource_name :freebsd_package provides :package, platform: "freebsd" def after_created diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb index b4064a9439..45e9ab2ab7 100644 --- a/lib/chef/resource/gem_package.rb +++ b/lib/chef/resource/gem_package.rb @@ -22,7 +22,7 @@ class Chef class Resource class GemPackage < Chef::Resource::Package - provides :gem_package + resource_name :gem_package def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/git.rb b/lib/chef/resource/git.rb index dd757e6eaf..927bde5073 100644 --- a/lib/chef/resource/git.rb +++ b/lib/chef/resource/git.rb @@ -22,7 +22,7 @@ class Chef class Resource class Git < Chef::Resource::Scm - provides :git + resource_name :git def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/group.rb b/lib/chef/resource/group.rb index 97026ebe74..cc4690983b 100644 --- a/lib/chef/resource/group.rb +++ b/lib/chef/resource/group.rb @@ -25,7 +25,7 @@ class Chef state_attrs :members - provides :group + resource_name :group def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/homebrew_package.rb b/lib/chef/resource/homebrew_package.rb index cda9a90cf2..993f083359 100644 --- a/lib/chef/resource/homebrew_package.rb +++ b/lib/chef/resource/homebrew_package.rb @@ -25,7 +25,7 @@ class Chef class Resource class HomebrewPackage < Chef::Resource::Package - provides :homebrew_package + resource_name :homebrew_package provides :package, os: "darwin" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb index 211b368500..5fde286814 100644 --- a/lib/chef/resource/http_request.rb +++ b/lib/chef/resource/http_request.rb @@ -23,7 +23,7 @@ require 'chef/provider/http_request' class Chef class Resource class HttpRequest < Chef::Resource - provides :http_request + resource_name :http_request identity_attr :url diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb index a774992e76..2976484ea1 100644 --- a/lib/chef/resource/ifconfig.rb +++ b/lib/chef/resource/ifconfig.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Ifconfig < Chef::Resource - provides :ifconfig + resource_name :ifconfig identity_attr :device diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb index 6b04129a84..70c023d510 100644 --- a/lib/chef/resource/ips_package.rb +++ b/lib/chef/resource/ips_package.rb @@ -23,6 +23,7 @@ class Chef class Resource class IpsPackage < ::Chef::Resource::Package + resource_name :ips_package provides :ips_package, os: "solaris2" def initialize(name, run_context = nil) diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb index 77bc207c49..715e468625 100644 --- a/lib/chef/resource/link.rb +++ b/lib/chef/resource/link.rb @@ -25,7 +25,7 @@ class Chef class Link < Chef::Resource include Chef::Mixin::Securable - provides :link + resource_name :link identity_attr :target_file diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb index 2233d0129d..639493a795 100644 --- a/lib/chef/resource/log.rb +++ b/lib/chef/resource/log.rb @@ -23,7 +23,7 @@ require 'chef/provider/log' class Chef class Resource class Log < Chef::Resource - provides :log + resource_name :log identity_attr :message diff --git a/lib/chef/resource/macosx_service.rb b/lib/chef/resource/macosx_service.rb index f1ed4051cb..f2893d78da 100644 --- a/lib/chef/resource/macosx_service.rb +++ b/lib/chef/resource/macosx_service.rb @@ -22,6 +22,7 @@ class Chef class Resource class MacosxService < Chef::Resource::Service + resource_name :macosx_service provides :macosx_service, os: "darwin" provides :service, os: "darwin" diff --git a/lib/chef/resource/macports_package.rb b/lib/chef/resource/macports_package.rb index b41c53033c..583965a18a 100644 --- a/lib/chef/resource/macports_package.rb +++ b/lib/chef/resource/macports_package.rb @@ -20,7 +20,7 @@ class Chef class Resource class MacportsPackage < Chef::Resource::Package - provides :macports_package + resource_name :macports_package provides :package, os: "darwin" end end diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb index 232ca8b2ac..e30452a113 100644 --- a/lib/chef/resource/mdadm.rb +++ b/lib/chef/resource/mdadm.rb @@ -27,7 +27,7 @@ class Chef state_attrs :devices, :level, :chunk - provides :mdadm + resource_name :mdadm def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index ff5421a648..193be16c68 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -27,7 +27,7 @@ class Chef state_attrs :mount_point, :device_type, :fstype, :username, :password, :domain - provides :mount + resource_name :mount def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb index 314fa6526f..7451b1b84e 100644 --- a/lib/chef/resource/ohai.rb +++ b/lib/chef/resource/ohai.rb @@ -20,7 +20,7 @@ class Chef class Resource class Ohai < Chef::Resource - provides :ohai + resource_name :ohai identity_attr :name diff --git a/lib/chef/resource/openbsd_package.rb b/lib/chef/resource/openbsd_package.rb index 2544faca28..ad377afedd 100644 --- a/lib/chef/resource/openbsd_package.rb +++ b/lib/chef/resource/openbsd_package.rb @@ -28,7 +28,7 @@ class Chef class OpenbsdPackage < Chef::Resource::Package include Chef::Mixin::ShellOut - provides :openbsd_package + resource_name :openbsd_package provides :package, os: "openbsd" def after_created diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb index 4d9055f659..ec7e1e4862 100644 --- a/lib/chef/resource/package.rb +++ b/lib/chef/resource/package.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Package < Chef::Resource - provides :package + resource_name :package identity_attr :package_name diff --git a/lib/chef/resource/pacman_package.rb b/lib/chef/resource/pacman_package.rb index d5d3bd76ae..2f15655e52 100644 --- a/lib/chef/resource/pacman_package.rb +++ b/lib/chef/resource/pacman_package.rb @@ -22,6 +22,7 @@ class Chef class Resource class PacmanPackage < Chef::Resource::Package + resource_name :pacman_package provides :pacman_package, os: "linux" end diff --git a/lib/chef/resource/paludis_package.rb b/lib/chef/resource/paludis_package.rb index 47026373c7..67c1dbde0b 100644 --- a/lib/chef/resource/paludis_package.rb +++ b/lib/chef/resource/paludis_package.rb @@ -23,6 +23,7 @@ class Chef class Resource class PaludisPackage < Chef::Resource::Package + resource_name :paludis_package provides :paludis_package, os: "linux" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/perl.rb b/lib/chef/resource/perl.rb index d99b409901..d4c7de694b 100644 --- a/lib/chef/resource/perl.rb +++ b/lib/chef/resource/perl.rb @@ -22,7 +22,7 @@ require 'chef/provider/script' class Chef class Resource class Perl < Chef::Resource::Script - provides :perl + resource_name :perl def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb index f835e33c89..34e1e91c2e 100644 --- a/lib/chef/resource/portage_package.rb +++ b/lib/chef/resource/portage_package.rb @@ -21,7 +21,7 @@ require 'chef/resource/package' class Chef class Resource class PortagePackage < Chef::Resource::Package - provides :portage_package + resource_name :portage_package def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb index 065121abe3..abf59b80a9 100644 --- a/lib/chef/resource/powershell_script.rb +++ b/lib/chef/resource/powershell_script.rb @@ -21,6 +21,7 @@ class Chef class Resource class PowershellScript < Chef::Resource::WindowsScript + resource_name :powershell_script provides :powershell_script, os: "windows" def initialize(name, run_context=nil) diff --git a/lib/chef/resource/python.rb b/lib/chef/resource/python.rb index 2eae2562ba..3e9930ecab 100644 --- a/lib/chef/resource/python.rb +++ b/lib/chef/resource/python.rb @@ -21,7 +21,7 @@ require 'chef/provider/script' class Chef class Resource class Python < Chef::Resource::Script - provides :python + resource_name :python def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/reboot.rb b/lib/chef/resource/reboot.rb index 3c940ccd27..337418e8d6 100644 --- a/lib/chef/resource/reboot.rb +++ b/lib/chef/resource/reboot.rb @@ -24,7 +24,7 @@ require 'chef/resource' class Chef class Resource class Reboot < Chef::Resource - provides :reboot + resource_name :reboot def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb index 524ee6c034..ad57116d94 100644 --- a/lib/chef/resource/registry_key.rb +++ b/lib/chef/resource/registry_key.rb @@ -22,7 +22,7 @@ require 'chef/digester' class Chef class Resource class RegistryKey < Chef::Resource - provides :registry_key + resource_name :registry_key identity_attr :key state_attrs :values diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb index d0ad6366b6..9fd204cf85 100644 --- a/lib/chef/resource/remote_directory.rb +++ b/lib/chef/resource/remote_directory.rb @@ -26,7 +26,7 @@ class Chef class RemoteDirectory < Chef::Resource::Directory include Chef::Mixin::Securable - provides :remote_directory + resource_name :remote_directory identity_attr :path diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index 0910862142..3387ff36ab 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -28,7 +28,7 @@ class Chef class RemoteFile < Chef::Resource::File include Chef::Mixin::Securable - provides :remote_file + resource_name :remote_file def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb index 4baa95b4dd..805678a85a 100644 --- a/lib/chef/resource/route.rb +++ b/lib/chef/resource/route.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Route < Chef::Resource - provides :route + resource_name :route identity_attr :target diff --git a/lib/chef/resource/rpm_package.rb b/lib/chef/resource/rpm_package.rb index 85a71fd91b..ff4d087597 100644 --- a/lib/chef/resource/rpm_package.rb +++ b/lib/chef/resource/rpm_package.rb @@ -23,6 +23,7 @@ class Chef class Resource class RpmPackage < Chef::Resource::Package + resource_name :rpm_package provides :rpm_package, os: [ "linux", "aix" ] def initialize(name, run_context=nil) diff --git a/lib/chef/resource/ruby.rb b/lib/chef/resource/ruby.rb index ec7ab0f580..23c5931824 100644 --- a/lib/chef/resource/ruby.rb +++ b/lib/chef/resource/ruby.rb @@ -22,7 +22,7 @@ require 'chef/provider/script' class Chef class Resource class Ruby < Chef::Resource::Script - provides :ruby + resource_name :ruby def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/ruby_block.rb b/lib/chef/resource/ruby_block.rb index dce981c8cf..fb5a39f523 100644 --- a/lib/chef/resource/ruby_block.rb +++ b/lib/chef/resource/ruby_block.rb @@ -23,7 +23,7 @@ require 'chef/provider/ruby_block' class Chef class Resource class RubyBlock < Chef::Resource - provides :ruby_block + resource_name :ruby_block identity_attr :block_name diff --git a/lib/chef/resource/scm.rb b/lib/chef/resource/scm.rb index 059532a0a4..9326fcca45 100644 --- a/lib/chef/resource/scm.rb +++ b/lib/chef/resource/scm.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Scm < Chef::Resource - provides :scm + resource_name :scm identity_attr :destination diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index c968610271..6568d20ac5 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -23,7 +23,7 @@ require 'chef/provider/script' class Chef class Resource class Script < Chef::Resource::Execute - provides :script + resource_name :script # Chef-13: go back to using :name as the identity attr identity_attr :command diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index d515958d21..433c329356 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -22,7 +22,7 @@ require 'chef/resource' class Chef class Resource class Service < Chef::Resource - provides :service + resource_name :service identity_attr :service_name diff --git a/lib/chef/resource/smartos_package.rb b/lib/chef/resource/smartos_package.rb index 5bef54076f..71e0b98b82 100644 --- a/lib/chef/resource/smartos_package.rb +++ b/lib/chef/resource/smartos_package.rb @@ -23,7 +23,7 @@ class Chef class Resource class SmartosPackage < Chef::Resource::Package - provides :smartos_package + resource_name :smartos_package provides :package, os: "solaris2", platform_family: "smartos" end diff --git a/lib/chef/resource/solaris_package.rb b/lib/chef/resource/solaris_package.rb index b7ddd3e77a..f247290f95 100644 --- a/lib/chef/resource/solaris_package.rb +++ b/lib/chef/resource/solaris_package.rb @@ -24,7 +24,7 @@ class Chef class Resource class SolarisPackage < Chef::Resource::Package - provides :solaris_package + resource_name :solaris_package provides :package, os: "solaris2", platform_family: "nexentacore" provides :package, os: "solaris2", platform_family: "solaris2" do |node| # on >= Solaris 11 we default to IPS packages instead diff --git a/lib/chef/resource/subversion.rb b/lib/chef/resource/subversion.rb index a66f7c913d..7af42d30b0 100644 --- a/lib/chef/resource/subversion.rb +++ b/lib/chef/resource/subversion.rb @@ -22,7 +22,7 @@ require "chef/resource/scm" class Chef class Resource class Subversion < Chef::Resource::Scm - provides :subversion + resource_name :subversion def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 0c4f9c6257..6fb808127c 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -27,7 +27,7 @@ class Chef class Template < Chef::Resource::File include Chef::Mixin::Securable - provides :template + resource_name :template attr_reader :inline_helper_blocks attr_reader :inline_helper_modules diff --git a/lib/chef/resource/timestamped_deploy.rb b/lib/chef/resource/timestamped_deploy.rb index b2109db85c..6fa5544d77 100644 --- a/lib/chef/resource/timestamped_deploy.rb +++ b/lib/chef/resource/timestamped_deploy.rb @@ -21,10 +21,7 @@ class Chef # Convenience class for using the deploy resource with the timestamped # deployment strategy (provider) class TimestampedDeploy < Chef::Resource::Deploy - provides :timestamped_deploy - def initialize(*args, &block) - super(*args, &block) - end + resource_name :timestamped_deploy end end end diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb index 3e78503dbe..6566e52c99 100644 --- a/lib/chef/resource/user.rb +++ b/lib/chef/resource/user.rb @@ -26,7 +26,7 @@ class Chef state_attrs :uid, :gid, :home - provides :user + resource_name :user def initialize(name, run_context=nil) super diff --git a/lib/chef/resource/whyrun_safe_ruby_block.rb b/lib/chef/resource/whyrun_safe_ruby_block.rb index 3e76a63147..8c6cd69b1a 100644 --- a/lib/chef/resource/whyrun_safe_ruby_block.rb +++ b/lib/chef/resource/whyrun_safe_ruby_block.rb @@ -19,7 +19,8 @@ class Chef class Resource class WhyrunSafeRubyBlock < Chef::Resource::RubyBlock - provides :whyrun_safe_ruby_block + + resource_name :whyrun_safe_ruby_block end end diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index 2e1dda4c5a..9fe4cef2c9 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -26,6 +26,7 @@ class Chef class WindowsPackage < Chef::Resource::Package include Chef::Mixin::Uris + resource_name :windows_package provides :windows_package, os: "windows" provides :package, os: "windows" diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb index 93949772f7..eb748bd42b 100644 --- a/lib/chef/resource/windows_service.rb +++ b/lib/chef/resource/windows_service.rb @@ -25,6 +25,7 @@ class Chef # Until #1773 is resolved, you need to manually specify the windows_service resource # to use action :configure_startup and attribute startup_type + resource_name :windows_service provides :windows_service, os: "windows" provides :service, os: "windows" diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb index cdf3cc456d..ebafeeb25d 100644 --- a/lib/chef/resource/yum_package.rb +++ b/lib/chef/resource/yum_package.rb @@ -23,7 +23,7 @@ class Chef class Resource class YumPackage < Chef::Resource::Package - provides :yum_package + resource_name :yum_package provides :package, os: "linux", platform_family: [ "rhel", "fedora" ] def initialize(name, run_context=nil) diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb index ca8ca16e7a..5aa5dcb9b3 100644 --- a/spec/integration/recipes/provider_choice.rb +++ b/spec/integration/recipes/provider_choice.rb @@ -11,7 +11,7 @@ describe "Recipe DSL methods" do @action = :create @allowed_actions = [ :create ] end - provides :provider_thingy + resource_name :provider_thingy def to_s "provider_thingy resource class" end diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index b491f343c5..3d31b87ffb 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -84,7 +84,7 @@ describe "Recipe DSL methods" do before(:context) { class RecipeDSLSpecNamespace::BackcompatThingy < BaseThingy - provides :backcompat_thingy + resource_name :backcompat_thingy end } @@ -119,7 +119,7 @@ describe "Recipe DSL methods" do before(:context) { class RecipeDSLSpecNamespace::MySupplier < BaseThingy - provides :hemlock + resource_name :hemlock end } @@ -142,7 +142,7 @@ describe "Recipe DSL methods" do before(:context) { class RecipeDSLSpecNamespace::Thingy3 < BaseThingy - provides :thingy3 + resource_name :thingy3 end } @@ -158,7 +158,7 @@ describe "Recipe DSL methods" do before(:context) { class RecipeDSLSpecNamespace::Thingy4 < Chef::Resource - provides :thingy3 + resource_name :thingy3 end } @@ -183,7 +183,7 @@ describe "Recipe DSL methods" do before(:context) { class RecipeDSLSpecNamespace::Thingy5 < BaseThingy - provides :thingy5 + resource_name :thingy5 provides :twizzle provides :twizzle2 end @@ -215,10 +215,12 @@ describe "Recipe DSL methods" do context "With platform-specific resources 'my_super_thingy_foo' and 'my_super_thingy_bar'" do before(:context) { class MySuperThingyFoo < BaseThingy + resource_name :my_super_thingy_foo provides :my_super_thingy, platform: 'foo' end class MySuperThingyBar < BaseThingy + resource_name :my_super_thingy_bar provides :my_super_thingy, platform: 'bar' end } diff --git a/spec/support/lib/chef/resource/cat.rb b/spec/support/lib/chef/resource/cat.rb index 01dbe4a272..ac8ad2953f 100644 --- a/spec/support/lib/chef/resource/cat.rb +++ b/spec/support/lib/chef/resource/cat.rb @@ -19,7 +19,7 @@ class Chef class Resource class Cat < Chef::Resource - provides :cat + resource_name :cat attr_accessor :action diff --git a/spec/support/lib/chef/resource/one_two_three_four.rb b/spec/support/lib/chef/resource/one_two_three_four.rb index 9199b0e247..52fe8be54d 100644 --- a/spec/support/lib/chef/resource/one_two_three_four.rb +++ b/spec/support/lib/chef/resource/one_two_three_four.rb @@ -19,7 +19,7 @@ class Chef class Resource class OneTwoThreeFour < Chef::Resource - provides :one_two_three_four + resource_name :one_two_three_four attr_reader :i_can_count diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb index c4f3f44d88..bbeeeaaeb7 100644 --- a/spec/support/lib/chef/resource/zen_follower.rb +++ b/spec/support/lib/chef/resource/zen_follower.rb @@ -21,7 +21,7 @@ require 'chef/json_compat' class Chef class Resource class ZenFollower < Chef::Resource - provides :zen_follower + resource_name :zen_follower provides :follower, platform: "zen" diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb index 18661dc05c..8f3ff7b72d 100644 --- a/spec/support/lib/chef/resource/zen_master.rb +++ b/spec/support/lib/chef/resource/zen_master.rb @@ -22,7 +22,7 @@ require 'chef/json_compat' class Chef class Resource class ZenMaster < Chef::Resource - provides :zen_master + resource_name :zen_master attr_reader :peace diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index accf52ba26..2e0a88f555 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -338,29 +338,6 @@ describe Chef::Resource do describe "self.resource_name" do context "When resource_name is not set" do - it "and there is a provides line, it is used for resource_name" do - c = Class.new(Chef::Resource) do - provides :self_resource_name_test_1 - end - - r = c.new('hi') - r.declared_type = :d - expect(c.resource_name).to eq :self_resource_name_test_1 - expect(r.resource_name).to eq :self_resource_name_test_1 - expect(r.declared_type).to eq :d - end - it "and multiple provides lines, the first line is used for resource_name" do - c = Class.new(Chef::Resource) do - provides :self_resource_name_test_2 - provides :self_resource_name_test_3 - end - - r = c.new('hi') - r.declared_type = :d - expect(c.resource_name).to eq :self_resource_name_test_2 - expect(r.resource_name).to eq :self_resource_name_test_2 - expect(r.declared_type).to eq :d - end it "and there are no provides lines, resource_name is nil" do c = Class.new(Chef::Resource) do end @@ -398,7 +375,7 @@ describe Chef::Resource do expect(r.resource_name).to eq :blah expect(r.declared_type).to eq :d end - it "setting class.resource_name with 'resource_name = blah' overrides and declared_type" do + it "setting class.resource_name with 'resource_name = blah' overrides declared_type" do c = Class.new(Chef::Resource) do provides :self_resource_name_test_2 end @@ -410,7 +387,7 @@ describe Chef::Resource do expect(r.resource_name).to eq :blah expect(r.declared_type).to eq :d end - it "setting class.resource_name with 'resource_name blah' overrides provides and declared_type" do + it "setting class.resource_name with 'resource_name blah' overrides declared_type" do c = Class.new(Chef::Resource) do resource_name :blah provides :self_resource_name_test_3 @@ -422,21 +399,6 @@ describe Chef::Resource do expect(r.resource_name).to eq :blah expect(r.declared_type).to eq :d end - it "setting @resource_name overrides provides and declared_type" do - c = Class.new(Chef::Resource) do - provides :self_resource_name_test_4 - def initialize(*args, &block) - @resource_name = :blah - super - end - end - - r = c.new('hi') - r.declared_type = :d - expect(c.resource_name).to eq :self_resource_name_test_4 - expect(r.resource_name).to eq :blah - expect(r.declared_type).to eq :d - end end describe "is" do |