summaryrefslogtreecommitdiff
path: root/lib/chef/node.rb
Commit message (Collapse)AuthorAgeFilesLines
* Expose Chef::Node#data_for_save as publicMarc A. Paradise2021-06-091-18/+19
| | | | | | | | This will provide callers (such as event dispatch handlers) with a means to capture node data that has been filtered based on attribute whitelist/blacklist rules. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Do not show blacklist deprecation for whitelistMarc A. Paradise2021-06-091-1/+1
| | | | | | | This adds a new AttributeWhitelistConfiguration deprecation so that we don't report use of whitelist as blacklist. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
* Stop the endless File.exists? spam from chef/nodeLamont Granquist2021-05-041-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Rename Attribute Whitelist/Blacklist to Allowlist/BlocklistTim Smith2020-07-231-12/+36
| | | | | | This is an overdue change. These are not terms we should be using as a company or community. To quote our Code of Conduct (https://community.chef.io/code-of-conduct/). "Be careful in the words that you choose. Be kind to others. Practice empathy." This change aims to do exactly that, while maintaining a level of backwards compatibility so we can transition existing users off the legacy configs. Signed-off-by: Tim Smith <tsmith@chef.io>
* Fix platform_version Chef::VersionString APILamont Granquist2020-04-161-5/+17
| | | | | | | The consumption of ohai attributes by the ohai segment plugin code was breaking this feature. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-131-1/+1
| | | | | | | | Legally incredibly dubious, particularly since we don't follow it strictly as policy, and we have git history instead, which does it right. This is just a waste of time and a cargo cult. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Convert the node[:platform_version] to a Chef::VersionStringlcg/platform_version_sugarLamont Granquist2020-02-261-2/+2
| | | | | | | | | | | `node[:platform_version] =~ "~> 1.2"` will now just work. This might conceivably be breaking if people are doing really weird things by the class changing (Chef::VersionString still inherits from String though, so it'll have to be weirdness on par with the bad `thing.class.to_s == "Mash"` kind of comparisons that were in ohai). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Fix node[:cookbooks] attributeLamont Granquist2019-08-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | closes #8817 Note that if any calling code winds up seeing this error message: ``` NoMethodError: undefined method `set_cookbook_attribute' for nil:NilClass ``` That means that the cookbook_collection was set before the node was set on the run_context. That wouldn't be a bug in core chef, that must be fixed in the caller to reverse the order of operations. Since I only made the positional arguments to the run_context constructor optional in Chef-15.0 though I don't expect this breaks any existing code written in the past month or two, but if anything crops up in the future, consider this a definitive statement that the caller must reverse the order of their operations and this error being thrown is a feature not a bug to be fixed. (The fact that we silently aborted rather than threw a NoMethodError on NilClass meant that we shipped this defect -- sometimes defensive programming can be overly defensive and swallow real errors). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Consistently use NOT_PASSED over alternativesLamont Granquist2019-08-071-7/+5
| | | | | | | | | | | | | | We have four different versions of this now, and this converts to just using the one convention in `lib/chef/constants.rb` Interestingly `Chef::NIL_ARGUMENT` is used nowhere in the codebase, that probably got refactored out in 12.5.1. Node objects still use `NIL` but that is a different kind of `Object.new` which really is semantically private to the implementation of attributes. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix 4 copsLamont Granquist2019-07-051-1/+2
| | | | | | | | | | | | | | - Layout/MultilineMethodCallBraceLayout - Layout/ClosingParenthesisIndentation - Layout/IndentFirstArgument EnforcedStyle: consistent - Layout/BlockEndNewline the first of these autocorrected to horrible looking code which exposed that we really needed the other three as well, which also cleaned up a bunch of other terrible looking code. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolProcLamont Granquist2019-07-051-1/+1
| | | | | | enforce pretzels. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/ClassCheckLamont Granquist2019-07-051-2/+2
| | | | | | convert kind_of? to is_a? Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/EmptyLiteralLamont Granquist2019-07-051-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/EmptyLineAfterGuardClauseLamont Granquist2019-07-021-0/+8
| | | | | | | i like this one, gives visual priority to returns or raises that are buried in the middle of things. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/AlignArgumentslcg/new-chefstyleLamont Granquist2019-07-021-5/+5
| | | | | | | | | | | | | | this is using: Layout/AlignArguments: Enabled: true EnforcedStyle: with_fixed_indentation the default style can use really excessive whitespace. on starting lines which are already long, it fully indents across to where the arguments start and then begins the line there. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* This hits the ones that are most frequently required.lcg/require-idempotencyLamont Granquist2019-05-201-2/+2
| | | | | | | | | 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-16/+16
| | | | | | | 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>
* fix default/override attribute blacklists and whitelistslcg/fix-the-blacklistLamont Granquist2019-04-181-12/+9
| | | | | | | | | | | | | looks like these have been broken for some time, the tests were only testing automatic level (which has no "combined" hash version) and the specs were injecting a plain old hash, so were failing to catch this error on multiple different levels. since the automatic level worked and since mostly people use automatic blacklisting to remove junk from ohai it was very uncommon to hit this bug. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Allow empty strings in -o to result in empty override run listlcg/empty-override-runlistLamont Granquist2019-04-121-3/+27
| | | | | | | | | | | | | | | | | Previously this was not possible. Now you can do this: ``` chef-client -o "" ./foo.rb ``` And it will only run foo.rb and not any of the recipes in your run_list at all. Node will not be saved at the end. Useful to one-shot something like keyrotation (which still needs keys and needs to talk to the chef server API, so this is a different use case from simple chef-apply). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Extract Action Collection from Data CollectorLamont Granquist2019-03-111-2/+22
| | | | | | See the PR for details on this change. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* change HTTPServerException to HTTPClientException for ruby 2.6Lamont Granquist2019-01-031-4/+4
| | | | | | includes backcompat for 2.5 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/PreferredHashMethodsLamont Granquist2018-07-021-9/+9
| | | | | | | absolutely hard requirement on the fixes that went into chef-config 2.2.11, so the floor of that gem is bumped up. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/LeadingCommentSpaceLamont Granquist2018-07-021-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/AlignHash caused by Style/HashSyntaxLamont Granquist2018-07-021-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/HashSyntaxLamont Granquist2018-07-021-5/+5
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Switch Node#role? to use the attributes expansion instead of the run list.Noah Kantrowitz2018-05-081-1/+4
| | | | | This means it understands nested roles, avoiding a common footgun. Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
* Merge pull request #7016 from chef/tm/chef_guidThom May2018-03-211-0/+1
|\ | | | | Save the node's UUID as an attribute
| * Save the node's UUID as an attributetm/chef_guidThom May2018-03-211-0/+1
| | | | | | | | | | | | | | We generate the UUID as part of the data collector report, but we didn't make that available to the node or the chef server otherwise. Signed-off-by: Thom May <thom@chef.io>
* | Add the ability to inject log objectstm/inject_logThom May2018-03-191-8/+14
|/ | | | | | meaning that we can have inheritable metadata Signed-off-by: Thom May <thom@chef.io>
* RFC 106: expose name and chef_environment as attrstm/chef_environmentThom May2018-03-091-4/+13
| | | | | | | We also now set chef_environment the same as policy group when that's appropriate Signed-off-by: Thom May <thom@chef.io>
* Chef-14 Breaking: remove node.set and node.set_unlesslcg/remove-node-setLamont Granquist2018-01-221-5/+0
| | | | | | been deprecated since late-12. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* prepping for rubocop 0.52.1lcg/rubocop-0.52.1Lamont Granquist2018-01-171-4/+3
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* RFC 59: Load Ohai pluginstm/ohai_plugins_2Thom May2017-04-051-0/+4
| | | | | | This adds a new phase in the compilation of the run context. Signed-off-by: Thom May <thom@chef.io>
* Kill JSON auto inflate with firetm/remove_json_autoinflateThom May2017-03-141-6/+0
| | | | Signed-off-by: Thom May <thom@chef.io>
* Add the ability to blacklist attributesRobert Mullins2017-03-081-0/+8
| | | | Signed-off-by: Robert Mullins <rmullins@secureworks.com>
* remove policyfile fallback API for old Chef ServersLamont Granquist2017-02-281-6/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix specs: RedundantReturn, RedundantSelf, RedundantBeginLamont Granquist2017-02-131-8/+8
| | | | | | department of redundancy department Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/NonNilCheckLamont Granquist2016-12-061-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Structure deprecations with additional metadatatm/deprecation_with_urlThom May2016-11-161-2/+2
| | | | | | | | 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>
* add attribute_changed hook to event handlersLamont Granquist2016-10-281-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* remove breadcrumb stateLamont Granquist2016-10-251-4/+0
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fixes Style/OpMethod copLamont Granquist2016-08-161-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Attributes v1.1 changeslcg/attributes-v1.1Lamont Granquist2016-06-271-32/+13
| | | | | | | | | | | - fixes *_unless behavior and set_unless_value_present hack from Chef 12 - simplifies rm_* code - introduces functional read/write/unlink/exist? API - deprecates method_missing access to attributes for Chef 13 - deprecates set/set_unless aliases for Chef 14 - removes MultiMash mess that I wrote for Chef 13 https://github.com/chef/chef/pull/5029 for more details
* create 'universal' DSLLamont Granquist2016-05-161-2/+2
| | | | this is for DSL methods that get mixed in everywhere.
* flip multiline function arguments aroundlcg/rubocop-0.37.2Lamont Granquist2016-02-191-3/+3
| | | | no enforced trailing comma on arguments...
* deal with 0.37.2 renamed copsLamont Granquist2016-02-181-2/+2
| | | | | | | | | | | | | | | 252 Style/TrailingCommaInLiteral 84 Style/TrailingCommaInArguments 15 Style/SpaceAroundKeyword -- 351 Total We already dealt with SpaceAroundKeyword under its old name SpaceBeforeModifierKeyword, it looks like it got stricter about spaces after keywords. TrailingComma also got split, and it looks like the TrailingCommaInArguments behavior is new?
* autofixing auto-inserted delimiterslcg/chefstyle-batchLamont Granquist2016-02-091-1/+1
|
* auto fixing some rubocopsLamont Granquist2016-02-091-1/+1
| | | | | | | | | Style/NegatedWhile Style/ParenthesesAroundCondition Style/WhileUntilDo Style/WordArray Performance/ReverseEach Style/ColonMethodCall
* autofixing whitespace copsLamont Granquist2016-02-051-16/+16
| | | | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | Generated via git ls-files | xargs perl -pi -e "s/(Author.*?<[^@]+@)(?:opscode\\.com|getchef\\.com)(>)/\\1chef.io\\2/gi"