summaryrefslogtreecommitdiff
path: root/lib/chef/provider.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove the "Core" DSL for Chef-16Lamont Granquist2020-02-271-3/+2
| | | | | | | | | | | | | | | | | | | | | | This lets us avoid using declare_resource in old style core resources. As everything gets converted over to custom resources this is going away anyway. We haven't seen any issues from using the recipe DSL in custom resources in core. Clearly this is potentially breaking since any references to Chef::DSL::Core need to be changed to Chef::DSL::Recipe (although I'm not sure who would have done that other than maybe us somewhere, I had a note in there that nobody should probably touch the Core DSL). This greatly simplifies the major DSLs down to two: Recipe DSL - things that only make sense in a context where there is a resource_collection Universal DSL - things that apply everywhere Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Fix most Ruby 2.7 test failureslcg/ruby-2.7.0Lamont Granquist2020-01-211-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Add chef-utils gem with various recipe DSL helpersLamont Granquist2019-11-081-0/+2
| | | | | | | | | | | | | This is the implementation of [RFC-087](https://github.com/chef-boneyard/chef-rfc/blob/master/rfc087-distro-sugar-helpers.md) although some of the specifics have been iterated on and changed. The documentation will be in the [README.md](https://github.com/chef/chef/tree/master/chef-utils/README.md) once this is merged. While this PR mostly moves chef-sugar utilities into core-chef via this chef-utils gem, the scope of the chef-utils gem should be considered larger than just that. As an example this PR moves the Mash class into this gem for reuse in ohai as well. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix comverge_if_changed to compare default valueslcg/converge-if-changedLamont Granquist2019-09-231-8/+14
| | | | | | | | Fixes #6300. This may be a breaking change. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Add unified_mode switch for resourcesLamont Granquist2019-08-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This is inspired by "use_inline_resources". Setting `unified_mode false` in a resource would be the existing behavior with separate compile/converge phases. Setting `unified_mode true` in a resource will eliminate the converge phase. Reverse notifications and delayed notifications will still fire. The resource action will behave like all resources are executing at compile time. As a aside, notifications have never worked for resources firing at compile time. This implementation gets that behavior correct so that notifications will work. Of course forward immediate notifications to resources not yet declared will not be possible. Setting `resource_unified_mode_default true` in `Chef::Config` would turn off the split compile/converge mode for every custom resource. NOTE: This does not affect recipe mode at all. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolProcLamont Granquist2019-07-051-5/+5
| | | | | | enforce pretzels. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/NegatedIfLamont Granquist2019-07-051-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/EmptyMethodLamont Granquist2019-07-021-6/+3
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* This hits the ones that are most frequently required.lcg/require-idempotencyLamont Granquist2019-05-201-1/+1
| | | | | | | | | Stops the kernel from scanning through all the activated gems every time in order to resolve names into pathnames. See rubygems/rubygems#2762 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Convert require to require_relativeLamont Granquist2019-05-081-15/+15
| | | | | | | This gives a speed boost since rubygems does not have to scan through every gem in the gemset in order to find the file. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Add misc YARD commentsyard3Tim Smith2019-03-111-6/+17
| | | | | | A pile of misc yard I added as I was reading things. Signed-off-by: Tim Smith <tsmith@chef.io>
* add delegator for property_is_set? to providersLamont Granquist2018-04-051-0/+5
| | | | | | | | | | | | | This was dropped in Chef 14.0.190 by chef/chef#6952 as a side effect of stripping out all the Chef::Resource automagic delegators. People were using this one inside of provider code, and it seems fine to continue to use it. Moving it to inject it directly into the Provider class instead of just custom resource action_classes to make our API more consistent. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* ensure that providers inherit loggers from the run contextThom May2018-03-261-2/+9
| | | | Signed-off-by: Thom May <thom@chef.io>
* remove deprecated proprety namespace collisionslcg/remove-deprecated-namespace-collisionsLamont Granquist2018-03-051-35/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | require writing `new_resource.my_property` instead of just `my_property` in provider code. a surprise in this code was that methods directly on the resource are all injected into the provider, and we never deprecated that, because we didn't know about it. that makes `action_class {}` helpers unnecessary, but causes additional namespace pollution, but at least the methods declared in the resource will lose to DSL methods (i.e. `def execute` will not work). but that also means that resources which are injected into the DSL which overwrite resource methods in other cookbooks may break their use in that cookbooks providers/action_classes. we should probably deprecate that as well, but we didn't and people probably found this behavior and used it. i cleaned it up a bit and removed the methods on Chef::Resource directly which polluted the provider class with all kinds of bizzare crap methods (not_if and only_if were getting injected into the provider, etc). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* actions can have descriptions and be introducedThom May2018-02-121-0/+14
| | | | Signed-off-by: Thom May <thom@chef.io>
* Merge pull request #6749 from chef/lcg/rubocop-0.52.1Thom May2018-01-211-3/+2
|\ | | | | prepping for rubocop 0.52.1
| * prepping for rubocop 0.52.1lcg/rubocop-0.52.1Lamont Granquist2018-01-171-3/+2
| | | | | | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* | Revert "Enable the deprecation for use_inline_resource"Tim Smith2018-01-181-8/+2
|/ | | | This reverts commit aab192e2b5df57d13213f8e89ce6fccc74a01db1.
* Enable the deprecation for use_inline_resourceTim Smith2018-01-041-2/+8
| | | | | | Toss in some yard while I'm in here as well Signed-off-by: Tim Smith <tsmith@chef.io>
* Hide sensitive properties in converge_if_changed.Chris Arnold2017-11-271-3/+9
| | | | Signed-off-by: Chris Arnold <cma.arnold@gmail.com>
* remove FIXME since its deprecated nowlcg/deprecate-resource-namespace-magicLamont Granquist2017-06-081-2/+0
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Deprecate property namespace magicLamont Granquist2017-06-081-0/+2
| | | | | | | This forces everyone to starting using new_resource.property_name instead of just property_name. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Make use_inline_resources a no-op to allow for easier support of 12 and 13 ↵Noah Kantrowitz2017-04-051-1/+2
| | | | | | | | in a single cookbook codebase. The test is left in pending mode so it will automatically remind us by failing in six months. Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Add a deprecation warning when using use_inline_resources.Noah Kantrowitz2017-04-041-0/+7
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Make use_inline_resources always active.Noah Kantrowitz2017-04-041-78/+34
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Try removing the const-ificiation of DSL-based resources/providers.Noah Kantrowitz2017-04-031-27/+0
| | | | Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Make ActionClass a classLamont Granquist2017-03-291-3/+19
| | | | | | | | | | | | since any ActionClass literally is-a Chef::Provider it should just use inheritance and then we don't have to use the hacky hooks for class methods in modules and it becomes more clear from the ActionClass source what it is and what it does. Bonus starts the deprecation of properties being injected into the provider namespace. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Chef-13: Simplify DSL creationLamont Granquist2017-03-211-10/+5
| | | | | | | | | | | | | | we did actually have tests around creating actions with spaces and hyphens in their names. we had fallback code for properties, but it was broken and threw a "private method define_resource called" and then it created a closure and didn't have the `name` in the binding so it called itself and blew up the stack. this change walks that back. it does prove that we still support UTF-8 in property names, actions and DSL names, which i'd argue is more than enough. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* support why-run by defaultlcg/default-whyrun-supportedLamont Granquist2017-03-011-2/+2
| | | | | | | this should fix several bugs in providers that look like they should support whyrun but fail to declare it. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Structure deprecations with additional metadatatm/deprecation_with_urlThom May2016-11-161-1/+1
| | | | | | | | This adds URLs to each class of deprecation, and correctly prints and formats them for maximum user efficiency. We also provide the URL to the data collector for Visibility to ingest. Signed-off-by: Thom May <thom@chef.io>
* Fix converge_if_changed (#5508)Akos Vandra2016-11-081-3/+3
| | | sensitive is the property of the resource, not the provider.
* no more missing constants for LWRP classpraj/FLOW-927/s3cmdPrajakta Purohit2016-06-091-5/+4
|
* add better resource manipulation APILamont Granquist2016-04-151-7/+8
| | | | | deprecates chef_rewind functionality completely and adds a few more features
* allow use_inline_resources for core chef providersLamont Granquist2016-03-211-3/+0
| | | | | | | | | | | | | * removes the DSL from InlineResources class * ActionClass is now responsible for mixing the DSL into action classes * apt_update provider converted over to use new syntax - does not need to mixin DeclareResource DSL - declares use_inline_resources - uses declare_resource instead of build_resource - converts def action_stuff to action :stuff - uses an execute resource instead of shell_out! - does not need the converge_by to update the action
* rearrange dsl mixinslcg/dsl-rearrangementLamont Granquist2016-03-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | - creates Chef::DSL::MethodMissing which will be nuked in Chef 13 - creates Chef::DSL::Core which is the mixins into core providers - adds build_resource/define_resource to core providers The intent here is to create Chef::DSL::Core which is intended to become the DSL minus method_missing and things that are only intended for recipes. Right now I've only added build_resource/declare_resource to core providers. We should probably push more into the "Core" DSL so that core providers could do things like use the search API. I would have moved everything other than resources and definitions over but the audit mode stuff is really only appropriate for recipes and not provider code and probably should not be moved over. We should probably have an intermediate mixin which is the "Custom Provider" DSL that has Resources and Definitions mixed into it, but which does not mix in the audit stuff that should only go into the Recipe DSL. There may also be a "Resources DSL" which has mixins for use with not_if/only_if and I'm unclear if that should be the "Core DSL" or another fourth mixin of DSL files.
* deprecate Chef::DSL::Recipe::FullDSLlcg/deprecate-fulldslLamont Granquist2016-03-161-1/+1
| | | | | | | | this module was created out of a bit of excessive paranoia instead of simply adding mixins that we always use with Chef::DSL::Recipe directly to Chef::DSL::Recipe. lets try and YAGNI this class and just add it directly. these modules are already injected into everyone's recipes and providers, so I can't imagine a huge amount of backcompat breaks.
* autofixing whitespace copsLamont Granquist2016-02-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | 4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
* Update all auth email address from opscode.com and getchef.com to chef.io.Noah Kantrowitz2016-02-021-2/+2
| | | Generated via git ls-files | xargs perl -pi -e "s/(Author.*?<[^@]+@)(?:opscode\\.com|getchef\\.com)(>)/\\1chef.io\\2/gi"
* Copyright year update for 2016 and massive cleanup.Noah Kantrowitz2016-02-021-1/+1
| | | Generated via git ls-files | xargs perl -pi -e "s/[Cc]opyright (?:\([Cc]\) )?((?\!$(date +%Y))\\d{4})(-\\d{4})?([, ][ \d]+)*(,|(?= ))/Copyright \\1-$(date +%Y),/g"
* Use double quotes by defaultThom May2016-01-141-21/+21
| | | | | | | This is an entirely mechanically generated (chefstyle -a) change, to go along with chef/chefstyle#5 . We should pick something and use it consistently, and my opinion is that double quotes are the appropriate thing.
* really fix copslcg/really-fix-copsLamont Granquist2016-01-121-17/+17
|
* chefstyle: fix Lint/StringConversionInInterpolationLamont Granquist2016-01-121-3/+3
| | | | useless use of `"#{foo.to_s}"`
* Fix resource `super` (broken because of test :focus)jk/fix-resource-superJohn Keiser2015-12-061-1/+12
|
* Converge actions all together instead of in action :x (fixes #4124)jk/4124John Keiser2015-12-021-34/+15
|
* Change plural to singularJohn Keiser2015-10-271-2/+2
|
* tests and styleChase Bolt2015-10-271-2/+2
|
* removing @sensitive in favor of sensitiveChase Bolt2015-10-271-3/+3
|
* suppressing sensitive properties, refactoredChase Bolt2015-10-271-7/+20
|
* Fix forward module.to_sjk/forwarder-to_sJohn Keiser2015-10-051-1/+1
|
* Rename log.deprecation to log_deprecationJohn Keiser2015-09-011-1/+1
|