summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs/file_system
Commit message (Collapse)AuthorAgeFilesLines
* Align all our comments with the codeTim Smith2020-05-063-3/+3
| | | | | | Autocorrected with chefstyle after enabling that cop. It was very hard to read some complex autocorrected blocks w/o this. Signed-off-by: Tim Smith <tsmith@chef.io>
* Logging consistency fixes.lcg/chef-16-logging-fixedLamont Granquist2020-04-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The doc formatter is now Chef::Config[:log_location]-aware and will log to files as well - There is now consistency where doc formatter output never surprisingly changes to log formatter based on destination - The "cli" log_location and the "config" log_location are now treated separately, so a log_location in the client.rb will always force output to a logfile, in addition to output to STDOUT if necessary - The logic around STDOUT is now simplified, if its open we log to it, if its closed we don't, if you're daemonized we assume you're capturing STDOUT via your process manager - The log_location variables are now Arrays Things not done: - The cli can't specify an array, it would be nice to support an accumulator pattern here. Would also need to support disabling STDOUT logging though. - Using the syslog or winevt logging devices requires the use of the logger, which precludes using the formatter. - Some people may want to have log-formatter style output to the log file and doc formatter style output to STDOUT which is not very possible right now. Right now we are consistent in that you get either the logger both places or the formatter both places. This use case is complicated by the fact that they will want :info level logging for the logger, but :warn level logging for the doc formatter and that is another global. - To do that latter thing right would probably require sending log messages to the formatter, and supporting a different log level in the formatter vs. the logger and then supporting the STDOUT/cli loggging being the formatter, while the log_location/config logging being the logger. Those were way out of scope for what I could get done for Chef-16. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-1365-65/+65
| | | | | | | | 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>
* Fix typoVivek Singh2020-04-062-2/+2
| | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Merge pull request #8986 from ↵Lamont Granquist2020-02-241-2/+6
|\ | | | | | | | | MsysTechnologiesllc/VSingh/fix-knife-download-environments ChefFS & knife environment matching the output
| * ChefFS and knife environment matching the outputVivek Singh2019-10-141-2/+6
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Use .load! in the Cookbook loader not .load_cookbooksTim Smith2020-01-235-5/+5
| | | | | | | | | | | | We added a deprecation warning to load_cookbooks and this is going to cause a ton of console spam for end users. Signed-off-by: Tim Smith <tsmith@chef.io>
* | Added client side validation to validate presence of metadata files and ↵Vasu11052019-12-201-0/+1
| | | | | | | | | | | | validate name field Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
* | Updated code to make sure temporary directory gets deleted after the uploadVasu11052019-12-181-16/+22
| | | | | | | | Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
* | Fixed specs and chefstyle errorVasu11052019-12-161-1/+1
| | | | | | | | Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
* | Updated knife cookbook upload and knife upload code to create temporary ↵Vasu11052019-12-161-28/+16
| | | | | | | | | | | | directory and copies all cookbooks into it and then generate metadata.json if it does not exist and load it to upload on Chef server Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
* | Genrates metadata.json if not present and uploads it to chef server and ↵Vasu11052019-12-161-5/+27
| | | | | | | | | | | | deletes the local copy of it from chef repo Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
* | Add chef-utils gem with various recipe DSL helpersLamont Granquist2019-11-084-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Chefstyle fixesVivek Singh2019-10-283-3/+3
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Invoke chefignore for cookbook_dir itselfVivek Singh2019-10-285-5/+5
| | | | | | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Fix knife cookbook site share chefignore lookupVivek Singh2019-10-281-3/+4
| | | | | | | | | | | | | | | | Fix cookbook syntax_check dir path error if cookbook_path is an array Fix invalid error if cookbook_path set to nil or empty Array and TypeError: no implicit conversion of nil into String Chefignore for each cookbooks/:cookbook Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* | Add chefignore method to ChefRepositoryFileSystemCookbookDirVivek Singh2019-10-281-0/+6
|/ | | | Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* Style/SymbolProcLamont Granquist2019-07-057-7/+7
| | | | | | enforce pretzels. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/StringLiteralsInInterpolationLamont Granquist2019-07-053-4/+4
| | | | | | since we use double quotes, be consistent everywhere. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/ClassCheckLamont Granquist2019-07-051-1/+1
| | | | | | convert kind_of? to is_a? Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/NegatedIfLamont Granquist2019-07-0512-22/+22
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Layout/MultilineMethodCallIndentationLamont Granquist2019-07-021-2/+2
| | | | | | | | Layout/MultilineMethodCallIndentation: Enabled: true EnforcedStyle: indented Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolArrayLamont Granquist2019-07-021-1/+1
| | | | | | start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/EmptyLineAfterGuardClauseLamont Granquist2019-07-0213-0/+31
| | | | | | | 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>
* This hits the ones that are most frequently required.lcg/require-idempotencyLamont Granquist2019-05-203-3/+3
| | | | | | | | | 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>
* Change some more require to require_relativeLamont Granquist2019-05-102-2/+2
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Convert require to require_relativeLamont Granquist2019-05-0873-231/+231
| | | | | | | 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>
* Fixes for extra cookbook_path chef-soloVivek Singh2019-02-051-1/+2
| | | | | | - Create directory recursively instead to assume that parent dir should exist. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
* changes for rubocop engine upgrades.lcg/rubocop-upgradesLamont Granquist2019-01-152-7/+8
| | | | | | | this is the result of changes to rules we already previously had enabled. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* change HTTPServerException to HTTPClientException for ruby 2.6Lamont Granquist2019-01-0313-23/+23
| | | | | | includes backcompat for 2.5 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/MutableConstantLamont Granquist2018-07-024-4/+4
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/PreferredHashMethodsLamont Granquist2018-07-021-1/+1
| | | | | | | 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 Style/UnneededInterpolationLamont Granquist2018-07-021-1/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/DotPositionLamont Granquist2018-07-023-9/+9
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/HashSyntaxLamont Granquist2018-07-026-7/+7
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* mechanical conversion of most debug log statements to traceThom May2018-03-262-3/+3
| | | | Signed-off-by: Thom May <thom@chef.io>
* prepping for rubocop 0.52.1lcg/rubocop-0.52.1Lamont Granquist2018-01-172-4/+4
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* RFC 67: Remove cookbook segmentsThom May2017-04-046-36/+34
| | | | | | | | | This implements RFC 67, which removes cookbook segments, and moves to a single list of all the files contained in a cookbook. This allows us to move forward with better audit modes and also proper shipping of ohai plugins. Signed-off-by: Thom May <thom@chef.io>
* invalidate @this_object_cache also in writeJeremy J. Miller2017-03-101-0/+3
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* rename target_object to this_object_cacheJeremy J. Miller2017-03-091-5/+5
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* free up target_object on deleteJeremy J. Miller2017-03-091-0/+2
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* moved commentJeremy J. Miller2017-03-091-1/+1
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* add target_object cacheJeremy J. Miller2017-03-081-3/+6
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* testing short circuiting _read_jsonJeremy J. Miller2017-03-081-2/+3
| | | | Signed-off-by: Jeremy J. Miller <jm@chef.io>
* fix specs: RedundantReturn, RedundantSelf, RedundantBeginLamont Granquist2017-02-1313-161/+136
| | | | | | department of redundancy department Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Grant Administrators group permissions to nodes directory under chef-solo ↵Tom Duffield2017-02-062-0/+5
| | | | | (#5781) Signed-off-by: Tom Duffield <tom@chef.io>
* Fix error thrown by solo when run on Windows as SYSTEMScott Christopherson2017-01-032-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Chef::ReservedNames::Win32::Security::SID.current_user` throws an error when `chef-solo` is being run as a `SYSTEM` user: ``` ================================================================================ Chef encountered an error attempting to load the node data for "WIN-00P0BGAA4IV" ================================================================================ Unknown Server Error: --------------------- The server had a fatal error attempting to load the node data. Server Response: ---------------- Exception raised! #<Chef::Exceptions::Win32APIError: No mapping between account names and security IDs was done. ---- Begin Win32 API output ---- System Error Code: 1332 System Error Message: No mapping between account names and security IDs was done. ---- End Win32 API output ---- > c:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.17.44-universal-mingw32/lib/chef/win32/error.rb:81:in `raise!' c:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.17.44-universal-mingw32/lib/chef/win32/security.rb:383:in `lookup_account_name' c:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.17.44-universal-mingw32/lib/chef/win32/security/sid.rb:44:in `from_account' c:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.17.44-universal-mingw32/lib/chef/win32/security/sid.rb:241:in `current_user' c:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.17.44-universal-mingw32/lib/chef/chef_fs/file_system/repository/nodes_dir.rb:41:in `create_child' ``` This commit modfies these calls to use `SID.default_security_object_owner` instead which will return `SID.Administrators` for users such as `SYSTEM` and then returns `SID.current_user` for everyone else. Signed-off-by: Scott Christopherson <scott@chef.io>
* [cheffs] Don't iterate parent object on exist? callssd/chef-fs-n-squaredSteven Danna2016-12-131-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, this code determined if an object existed by doing the following: parent.children.any? { |child| child.api_child_name == api_child_name } For organizations and object types with a small number of total objects, this wasn't problematic; however, it has very bad worst-case behavior. For example, if a user was attempting to restore an organization with 30k client records to an empty organization, each client upload would do the following: 1. Run GET /clients 2. Iterate the list returned in (1) normalizing the clients names along the way. 3. Upload the client via POST when exist? returned false. When the clients don't exist, this means step (2) will always iterate over every member returned in step (1). By the time you get into the 1000s of clients, this iteration dominates the running time of the process. For instance, consider the following ruby profile data: Measure Mode: wall_time Thread ID: 16939380 Fiber ID: 22163920 Total: 109.860468 Sort by: self_time %self total self wait child calls name 26.83 29.475 29.475 0.000 0.000 500 <Class::IO>#select 8.60 38.876 9.446 0.000 29.430 464125 <Class::Chef::ChefFS::PathUtils>#join 7.02 12.226 7.717 0.000 4.509 928750 Chef::ChefFS::FileSystem::ChefServer::RestListEntry#api_child_name 6.79 7.459 7.459 0.000 0.000 930250 String#gsub 5.31 5.834 5.834 0.000 0.000 2320625 <Class::Chef::ChefFS::PathUtils>#regexp_path_separator 3.33 3.654 3.654 0.000 0.000 500 OpenSSL::X509::Store#set_default_paths 3.28 42.482 3.606 0.000 38.876 464125 Chef::ChefFS::FileSystem::BaseFSObject#initialize 2.95 3.244 3.244 0.000 0.000 930250 <Class::File>#extname 2.29 48.421 2.513 0.000 45.908 483375 *Class#new 38 wall clock seconds spent in PathUtils.join (part of the name normalization during the list walk) Note, an alternative might be to skip the exist? check completely, opting to blindly POST and then rescuing the 409 and retry with a PUT. Experimentation shows that PathUtils.join can also be improved substantially; however, I'll leave those for a follow-up PR. Signed-off-by: Steven Danna <steve@chef.io>
* Ensure chef-solo creates node files w/ correct permissionsCOOL-604/chef-solo-node-permissionsScott Christopherson2016-12-062-1/+31
| | | | | | | This commit ensures that the `nodes` dir and the node files within it are created with the correct permissions by chef-solo. Signed-off-by: Scott Christopherson <scott@chef.io>
* Fixed knife download cookbooks issue which used to corrupt the certificate ↵aliasgar162016-10-271-7/+3
| | | | | | files each time the command was fired. Signed-off-by: aliasgar16 <aliasgar.batterywala@msystechnologies.com>