summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-12-08 16:18:26 -0800
committerClaire McQuin <claire@getchef.com>2014-12-08 16:18:26 -0800
commit0c285f221e2139c98a7ad5ef0fa95005305df430 (patch)
tree2b3a33913265a672813966f0a2708793901a960f
parentac166598eb9a96b61e5a997b3a1c267579d174af (diff)
parentc6e5654a18f236dd75bb59472e80887c27310d99 (diff)
downloadchef-mcquin/audit_event_proxy_spec.tar.gz
Merge branch 'audit-mode' of github.com:opscode/chef into mcquin/audit_event_proxy_specmcquin/audit_event_proxy_spec
-rw-r--r--.travis.yml20
-rw-r--r--CHANGELOG.md14
-rw-r--r--DOC_CHANGES.md4
-rw-r--r--MAINTAINERS.md110
-rw-r--r--README.md4
-rw-r--r--RELEASE_NOTES.md16
-rwxr-xr-xbin/shef35
-rw-r--r--chef.gemspec6
-rw-r--r--distro/common/html/_static/searchtools.js2
-rw-r--r--distro/common/markdown/man1/knife-bootstrap.mkd2
-rw-r--r--distro/common/markdown/man1/knife-cookbook-site.mkd2
-rw-r--r--distro/common/markdown/man1/knife-data-bag.mkd2
-rw-r--r--distro/common/markdown/man1/knife-environment.mkd2
-rw-r--r--distro/common/markdown/man1/knife.mkd2
-rw-r--r--kitchen-tests/.kitchen.travis.yml2
-rw-r--r--lib/chef.rb7
-rw-r--r--lib/chef/application.rb3
-rw-r--r--lib/chef/application/agent.rb18
-rw-r--r--lib/chef/application/knife.rb3
-rw-r--r--lib/chef/application/solo.rb18
-rw-r--r--lib/chef/application/windows_service.rb1
-rw-r--r--lib/chef/applications.rb1
-rw-r--r--lib/chef/audit/audit_event_proxy.rb2
-rw-r--r--lib/chef/audit/audit_reporter.rb9
-rw-r--r--lib/chef/audit/control_group_data.rb33
-rw-r--r--lib/chef/audit/runner.rb2
-rw-r--r--lib/chef/config.rb5
-rw-r--r--lib/chef/cookbook/metadata.rb6
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb1
-rw-r--r--lib/chef/cookbook_version.rb1
-rw-r--r--lib/chef/dsl/audit.rb13
-rw-r--r--lib/chef/dsl/reboot_pending.rb2
-rw-r--r--lib/chef/event_dispatch/base.rb2
-rw-r--r--lib/chef/http.rb1
-rw-r--r--lib/chef/knife.rb16
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb4
-rw-r--r--lib/chef/knife/node_run_list_remove.rb14
-rw-r--r--lib/chef/mixin/command.rb2
-rw-r--r--lib/chef/mixin/deep_merge.rb62
-rw-r--r--lib/chef/mixin/params_validate.rb4
-rw-r--r--lib/chef/monkey_patches/file.rb26
-rw-r--r--lib/chef/monkey_patches/fileutils.rb65
-rw-r--r--lib/chef/monkey_patches/numeric.rb15
-rw-r--r--lib/chef/monkey_patches/object.rb9
-rw-r--r--lib/chef/monkey_patches/pathname.rb32
-rw-r--r--lib/chef/monkey_patches/regexp.rb34
-rw-r--r--lib/chef/monkey_patches/string.rb49
-rw-r--r--lib/chef/monkey_patches/tempfile.rb64
-rw-r--r--lib/chef/monkey_patches/uri.rb70
-rw-r--r--lib/chef/node.rb23
-rw-r--r--lib/chef/node/attribute.rb75
-rw-r--r--lib/chef/node/attribute_collections.rb5
-rw-r--r--lib/chef/node/immutable_collections.rb4
-rw-r--r--lib/chef/provider/deploy.rb3
-rw-r--r--lib/chef/provider/package/rubygems.rb5
-rw-r--r--lib/chef/provider/package/yum-dump.py4
-rw-r--r--lib/chef/provider/remote_directory.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb2
-rw-r--r--lib/chef/provider/user/dscl.rb2
-rw-r--r--lib/chef/provider_resolver.rb4
-rw-r--r--lib/chef/recipe.rb2
-rw-r--r--lib/chef/resource/remote_file.rb1
-rw-r--r--lib/chef/resource_definition.rb2
-rw-r--r--lib/chef/run_list/run_list_expansion.rb4
-rw-r--r--lib/chef/shef/ext.rb19
-rw-r--r--lib/chef/util/file_edit.rb4
-rw-r--r--lib/chef/workstation_config_loader.rb2
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb2
-rw-r--r--spec/support/pedant/pedant_config.rb4
-rw-r--r--spec/support/shared/functional/file_resource.rb4
-rw-r--r--spec/support/shared/functional/http.rb2
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb2
-rw-r--r--spec/unit/application/knife_spec.rb8
-rw-r--r--spec/unit/config_spec.rb4
-rw-r--r--spec/unit/cookbook/metadata_spec.rb2
-rw-r--r--spec/unit/cookbook_version_spec.rb12
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb8
-rw-r--r--spec/unit/handler_spec.rb2
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb14
-rw-r--r--spec/unit/knife/node_run_list_remove_spec.rb21
-rw-r--r--spec/unit/knife_spec.rb7
-rw-r--r--spec/unit/lwrp_spec.rb2
-rw-r--r--spec/unit/mixin/deep_merge_spec.rb26
-rw-r--r--spec/unit/monkey_patches/string_spec.rb37
-rw-r--r--spec/unit/node/attribute_spec.rb28
-rw-r--r--spec/unit/node/immutable_collections_spec.rb2
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb8
-rw-r--r--spec/unit/resource_definition_spec.rb2
-rw-r--r--spec/unit/resource_spec.rb2
-rw-r--r--spec/unit/run_list/run_list_expansion_spec.rb4
-rw-r--r--spec/unit/shell_spec.rb2
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb2
-rw-r--r--spec/unit/workstation_config_loader_spec.rb2
93 files changed, 476 insertions, 713 deletions
diff --git a/.travis.yml b/.travis.yml
index 3a81eb8881..e9e7c2cdc2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,6 @@
-# Temporary workaround for issue with rubygems 2.2.0 with bundler 1.5 on ruby
-# 1.8.7.
-#
-# A fix has been merged to rubygems but not yet released. See:
-# https://github.com/rubygems/rubygems/commit/f8e0f1d5f67cfc4e1966cc1e2db367aebf8a09e4
-#
-# See also CHEF-4916
-#
-# This workaround should be removed when that fix is released.
+# Early warning system to catch if Rubygems breaks something
before_install:
-- gem update --system 2.1.11
-- gem --version
+ gem update --system
branches:
only:
@@ -35,14 +26,13 @@ env:
matrix:
include:
- - rvm: 1.9.3
- rvm: 2.0.0
- - rvm: 2.1.1
- - rvm: 2.1.1
+ - rvm: 2.1.5
+ - rvm: 2.1.5
gemfile: pedant.gemfile
script: bundle exec rake pedant
### START TEST KITCHEN ONLY ###
- - rvm: 2.1.1
+ - rvm: 2.1.5
gemfile: kitchen-tests/Gemfile
before_install:
- echo -n $DO_KEY_CHUNK_{0..30} >> ~/.ssh/id_aws.base64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e85a727c37..06ad8087b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,8 +8,19 @@
removed securerandom patch
* [**Scott Bonds**](https://github.com/bonds)
add package support for OpenBSD
+* [**Lucy Wyman**](https://github.com/lucywyman)
+ Added support for handling empty version strings to rubygems provider.
+* [**Yulian Kuncheff**](https://github.com/Daegalus)
+ Correctly set the pre-release identifier during knife bootstrap.
+* [**Anshul Sharma**](https://github.com/justanshulsharma)
+ `knife node run_list remove` now accepts run_list options in the same form as add
+* [**Veres Lajos**](https://github.com/vlajos)
+ Typo fixes
+* [**Tim Smith**](https://github.com/tas50)
+ Typo fixes
### Chef Contributions
+* ruby 1.9.3 support is dropped
* Update Chef to use RSpec 3.
## 12.0.0
@@ -160,6 +171,7 @@
### Chef Contributions
+* ruby 1.9.3 support is dropped
* Added RFC-023 Chef 12 Attribute Changes (https://github.com/opscode/chef-rfc/blob/master/rfc023-chef-12-attributes-changes.md)
* Added os/platform_family options to provides syntax on the Chef::Resource DSL
* Added provides methods to the Chef::Provider DSL
@@ -309,7 +321,7 @@
* [**Nikhil Benesch**](https://github.com/benesch):
Implemented a threaded download queue for synchronizing cookbooks. (CHEF-4423)
* [**Chulki Lee**](https://github.com/chulkilee):
- Raise an error when source is accidently passed to apt_package (CHEF-5113)
+ Raise an error when source is accidentally passed to apt_package (CHEF-5113)
* [**Cam Cope**](https://github.com/ccope):
Add an open_timeout when opening an http connection (CHEF-5152)
* [**Sander van Harmelen**](https://github.com/svanharmelen):
diff --git a/DOC_CHANGES.md b/DOC_CHANGES.md
index 7eb85eb894..22294a3e39 100644
--- a/DOC_CHANGES.md
+++ b/DOC_CHANGES.md
@@ -165,7 +165,7 @@ and receive
# snip other Ubuntu nodes
]
```
-If instead you wanted all the languages data (remember, `"languages"` is only one tiny piece of information the Chef Server stores about your node), you would have `:filter_result => {"languages" => ["laguages"]}` in your search query.
+If instead you wanted all the languages data (remember, `"languages"` is only one tiny piece of information the Chef Server stores about your node), you would have `:filter_result => {"languages" => ["languages"]}` in your search query.
For backwards compatibility, a `partial_search` method has been added to `Chef::Search::Query` which can be used in the same way as the `partial_search` method from the [partial_search cookbook](https://supermarket.getchef.com/cookbooks/partial_search). Note that this method has been deprecated and will be removed in future versions of Chef.
@@ -539,7 +539,7 @@ For the`batch` resource, the `guard_interpreter` attribute it is set to `:batch`
that if a string is supplied to an `only_if` or `not_if` attribute of a `batch` resource, the 64-bit version of the Windows
default command interpreter, `cmd.exe`, will be used to evaluate the guard. It also means that other features available to the guard
when `guard_interpreter` is set to something other than `:default`, such as inheritance of attributes and the specification of
-process architectur of the guard process (i.e. 32-bit or 64-bit process) are available by default.
+process architecture of the guard process (i.e. 32-bit or 64-bit process) are available by default.
In versions of Chef prior to Chef 12, the value of the attribute was `:default` by default, which means the 32-bit version of the
`cmd.exe` (batch script language) shell would be used to evaluate strings supplied to guards.
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000000..6f1b2e6f4f
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,110 @@
+# Maintainers
+
+This file lists how the Chef project is maintained. When making changes to the system, this
+file tells you who needs to review your patch - you need a simple majority of maintainers
+for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need
+to not receive a veto from a Lieutenant or the Project Lead.
+
+Check out [How Chef is Maintained](https://github.com/opscode/chef-rfc/blob/master/rfc030-maintenance-policy.md#how-the-project-is-maintained) for details on the process, how to become
+a maintainer, lieutenant, or the project lead.
+
+# Project Lead
+
+[Adam Jacob](http://github.com/adamhjk)
+
+# Components
+
+## Chef Core
+
+Handles the core parts of the Chef DSL, base resource and provider
+infrastructure, and the Chef applications. Includes anything not covered by
+another component.
+
+### Lieutenant
+
+### Maintainers
+
+* [Jon Cowie](http://github.com/jonlives)
+* [Phil Dibowitz](https://github.com/jaymzh)
+* [Lamont Granquist](http://github.com/lamont-granquist)
+* [Tyler Ball](https://github.com/tyler-ball)
+* [Daniel DeLeo](https://github.com/danielsdeleo)
+* [Claire McQuin](https://github.com/mcquin)
+
+## Dev Tools
+
+Chef Zero, Knife, Chef Apply and Chef Shell.
+
+### Lieutenant
+
+### Maintainers
+
+* [Steven Danna](https://github.com/stevendanna/)
+* [Joshua Timberman](https://github.com/jtimberman)
+* [Lamont Granquist](http://github.com/lamont-granquist)
+* [Daniel DeLeo](https://github.com/danielsdeleo)
+
+## Test Tools
+
+### ChefSpec
+
+#### Lieutenant
+
+[Seth Vargo](https://github.com/sethvargo)
+
+#### Maintainers
+
+* [Joshua Timberman](https://github.com/jtimberman)
+* [Lamont Granquist](http://github.com/lamont-granquist)
+
+## Platform Specific Components
+
+The specific components of Chef related to a given platform - including (but not limited to) resources, providers, and the core DSL.
+
+## Enterprise Linux
+
+### Lieutenant
+
+### Maintainers
+
+* [Jon Cowie](http://github.com/jonlives)
+* [Lamont Granquist](http://github.com/lamont-granquist)
+
+## Ubuntu
+
+### Lieutenant
+
+### Maintainers
+
+* [Lamont Granquist](http://github.com/lamont-granquist)
+
+## Windows
+
+### Lieutenant
+
+### Maintainers
+
+## Solaris
+
+### Lieutenant
+
+### Maintainers
+
+* [Lamont Granquist](http://github.com/lamont-granquist)
+
+## AIX
+
+### Lieutenant
+
+### Maintainers
+
+* [Lamont Granquist](http://github.com/lamont-granquist)
+
+## Mac OS X
+
+### Lieutenant
+
+### Maintainers
+
+* [Joshua Timberman](https://github.com/jtimberman)
+* [Tyler Ball](https://github.com/tyler-ball)
diff --git a/README.md b/README.md
index 306baba163..93665ee991 100644
--- a/README.md
+++ b/README.md
@@ -31,9 +31,9 @@ Install these via your platform's preferred method (apt, yum, ports,
emerge, etc.):
* git
-* C compiler, header files, etc. On Ubuntu/debian, use the
+* C compiler, header files, etc. On Ubuntu/Debian, use the
`build-essential` package.
-* ruby 1.9.3 or later
+* ruby 2.0.0 or later
* rubygems
* bundler
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index c20b486f43..630aa737df 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -57,7 +57,7 @@ deprecated and config.rb will be preferred.
Chef Client 12 introduces a set of changes to `knife bootstrap`. Here is the list of changes:
* Unused / untested bootstrap templates that install Chef Client from rubygems are removed. The recommended installation path for Chef Client is to use the omnibus packages. `chef-full` template (which is the default) installs Chef Client using omnibus packages on all the supported platforms.
-* `--distro` & `--template-file` options are deprecated in Chef 12 in favor of `--boostrap-template` option. This option can take a boostrap template name (e.g. 'chef-full') or the full path to a bootstrap template.
+* `--distro` & `--template-file` options are deprecated in Chef 12 in favor of `--boostrap-template` option. This option can take a bootstrap template name (e.g. 'chef-full') or the full path to a bootstrap template.
* Chef now configures `:ssl_verify_mode` & `:verify_api_cert` config options on the node that is being bootstrapped. This setting can be controlled by `:node_ssl_verify_mode` & `:node_verify_api_cert` CLI options. If these are not specified the configured value will be inferred from knife config.
## Solaris Mount Provider
@@ -238,12 +238,12 @@ manifest for the cookbook will be deleted from the cookbook file cache.
## When given an override run list Chef does not clean the file_cache
-In order to avoid redownloading the file_cache for all the cookbooks and files that are skipped when an
+In order to avoid re-downloading the file_cache for all the cookbooks and files that are skipped when an
override run list is used, when an override run list is set the file cache is not cleaned at all.
-## Dropped Support For Ruby 1.8.7/1.9.1/1.9.2
+## Dropped Support For Ruby 1.8 and 1.9
-Ruby 1.8.7, 1.9.1 and 1.9.2 are no longer supported.
+Ruby 1.8.7, 1.9.1, 1.9.2 and 1.9.3 are no longer supported.
## Changed no_lazy_load config default to True
@@ -288,9 +288,9 @@ Informational messages from knife are now sent to stderr, allowing you to pipe t
The `data_bag_item` dsl method can be used to load encrypted data bag items when an additional `secret` String parameter is included.
If no `secret` is provided but the data bag item is encrypted, `Chef::Config[:encrypted_data_bag_secret]` will be checked.
-## 'group' provider on OSX properly uses 'dscl' to determine existing groups
+## 'group' provider on OS X properly uses 'dscl' to determine existing groups
-On OSX, the 'group' provider would use 'etc' to determine existing groups,
+On OS X, the 'group' provider would use 'etc' to determine existing groups,
but 'dscl' to add groups, causing broken idempotency if something existed
in /etc/group. The provider now uses 'dscl' for both idempotenty checks and
modifications.
@@ -334,7 +334,7 @@ error when `client_fork false` is set.
## Interval sleep occurs before converge
When running chef-client or chef-solo at intervals, the application will perform splay and interval sleep
-before converging chef. (In previous releases, splay sleep occurred first, then convergance, then interval sleep).
+before converging chef. (In previous releases, splay sleep occurred first, then convergence, then interval sleep).
## `--dry-run` option for knife cookbook site share
"knife cookbook site share" command now accepts a new command line option `--dry-run`. When this option is specified, command
@@ -408,7 +408,7 @@ process behavior by supplying an architecture attribute to the guard as follows:
```ruby
# The not_if will be evaluated with 64-bit cmd.exe by default,
-# so you can verride it with the :architecture guard option to
+# so you can override it with the :architecture guard option to
# make it 32-bit as it is in Chef 11
batch 'make_safe_backup' do
code 'copy %USERPROFILE%\\data\\nodes.json %SYSTEMROOT%\\system32\\data\\nodes.bak'
diff --git a/bin/shef b/bin/shef
deleted file mode 100755
index 0862198e53..0000000000
--- a/bin/shef
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env ruby
-#
-# ./chef-shell - Run the Chef REPL (Shell)
-#
-# Author:: Daniel DeLeo (<dan@kallistec.com>)
-# Copyright:: Copyright (c) 2009
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-begin
- require "rubygems"
-rescue LoadError
-end
-
-require "irb"
-require "irb/completion"
-require 'irb/ext/save-history'
-
-$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
-
-require "chef/shell"
-
-Chef::Log.warn("DEPRECATED: The 'shef' program is renamed to 'chef-shell'")
-Shell.start
diff --git a/chef.gemspec b/chef.gemspec
index 6f3039f589..eb7528e630 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -13,14 +13,14 @@ Gem::Specification.new do |s|
s.email = "adam@getchef.com"
s.homepage = "http://www.getchef.com"
- s.required_ruby_version = ">= 1.9.3"
+ s.required_ruby_version = ">= 2.0.0"
s.add_dependency "mixlib-config", "~> 2.0"
s.add_dependency "mixlib-cli", "~> 1.4"
s.add_dependency "mixlib-log", "~> 1.3"
s.add_dependency "mixlib-authentication", "~> 1.3"
s.add_dependency "mixlib-shellout", ">= 2.0.0.rc.0", "< 3.0"
- s.add_dependency "ohai", ">= 7.6.0.rc.0"
+ s.add_dependency "ohai", "~> 8.0"
s.add_dependency "ffi-yajl", "~> 1.2"
s.add_dependency "net-ssh", "~> 2.6"
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake", "~> 10.1.0"
s.bindir = "bin"
- s.executables = %w( chef-client chef-solo knife chef-shell shef chef-apply )
+ s.executables = %w( chef-client chef-solo knife chef-shell chef-apply )
s.require_path = 'lib'
s.files = %w(Rakefile LICENSE README.md CONTRIBUTING.md) + Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
diff --git a/distro/common/html/_static/searchtools.js b/distro/common/html/_static/searchtools.js
index 6e1f06bd1b..fec94539f9 100644
--- a/distro/common/html/_static/searchtools.js
+++ b/distro/common/html/_static/searchtools.js
@@ -594,7 +594,7 @@ var Search = {
* helper function to return a node containing the
* search summary for a given text. keywords is a list
* of stemmed words, hlwords is the list of normal, unstemmed
- * words. the first one is used to find the occurance, the
+ * words. the first one is used to find the occurrence, the
* latter for highlighting it.
*/
makeSearchSummary : function(text, keywords, hlwords) {
diff --git a/distro/common/markdown/man1/knife-bootstrap.mkd b/distro/common/markdown/man1/knife-bootstrap.mkd
index 5c5e456023..cb292de311 100644
--- a/distro/common/markdown/man1/knife-bootstrap.mkd
+++ b/distro/common/markdown/man1/knife-bootstrap.mkd
@@ -84,7 +84,7 @@ When this is complete, the bootstrapped node will have:
- Latest Chef version installed from RubyGems or APT Packages from Opscode. This may be a later version than the local system.
- Be validated with the configured Chef Server.
- - Have run Chef with its default run list if one is specfied.
+ - Have run Chef with its default run list if one is specified.
Additional custom bootstrap templates can be created and stored in
`.chef/bootstrap/DISTRO.erb`, replacing __DISTRO__ with the value passed
diff --git a/distro/common/markdown/man1/knife-cookbook-site.mkd b/distro/common/markdown/man1/knife-cookbook-site.mkd
index 7c2b0fe31b..9496cf1765 100644
--- a/distro/common/markdown/man1/knife-cookbook-site.mkd
+++ b/distro/common/markdown/man1/knife-cookbook-site.mkd
@@ -26,7 +26,7 @@ repository. Running `knife cookbook site install` does the following:
upstream;
2. All existing cookbooks are removed from the branch;
3. The cookbook is downloaded from the cookbook site in tarball form;
-4. The downloaded cookbook is untarred, and its contents commited via git;
+4. The downloaded cookbook is untarred, and its contents committed via git;
5. The pristine copy branch is merged into the master branch.
By installing cookbook with this process, you can locally modify the
diff --git a/distro/common/markdown/man1/knife-data-bag.mkd b/distro/common/markdown/man1/knife-data-bag.mkd
index 67ec02158c..53abf95272 100644
--- a/distro/common/markdown/man1/knife-data-bag.mkd
+++ b/distro/common/markdown/man1/knife-data-bag.mkd
@@ -90,7 +90,7 @@ formatted according to the --format option.
## ENCRYPTION SUPPORT
Data Bag Items may be encrypted to keep their contents secret. This may
-be desireable when storing sensitive information such as database
+be desirable when storing sensitive information such as database
passwords, API keys, etc.
Data Bag Item encryption uses the AES-256 CBC symmetric key algorithm.
diff --git a/distro/common/markdown/man1/knife-environment.mkd b/distro/common/markdown/man1/knife-environment.mkd
index 2eebffbce6..98ca4997bd 100644
--- a/distro/common/markdown/man1/knife-environment.mkd
+++ b/distro/common/markdown/man1/knife-environment.mkd
@@ -73,7 +73,7 @@ represented as a single JSON object, like this:
{"apache2": ">= 1.5.0"}
-In the Ruby format, the cookbook version contraints for an environment
+In the Ruby format, the cookbook version constraints for an environment
are represented as a Ruby Hash, like this:
{"apache2" => ">= 1.5.0"}
diff --git a/distro/common/markdown/man1/knife.mkd b/distro/common/markdown/man1/knife.mkd
index 61e0c7f8b9..c3add163f9 100644
--- a/distro/common/markdown/man1/knife.mkd
+++ b/distro/common/markdown/man1/knife.mkd
@@ -174,7 +174,7 @@ recommended though, and git fits with a lot of the workflow paradigms.
## ENVIRONMENT
* `EDITOR`:
The text editor to use for editing data. The --editor option takes
- precedence over this value, and the --disable-editing option supresses
+ precedence over this value, and the --disable-editing option suppresses
data editing entirely.
## SEE ALSO
diff --git a/kitchen-tests/.kitchen.travis.yml b/kitchen-tests/.kitchen.travis.yml
index 66bbe23f64..15795e033a 100644
--- a/kitchen-tests/.kitchen.travis.yml
+++ b/kitchen-tests/.kitchen.travis.yml
@@ -9,7 +9,7 @@ provisioner:
name: chef_zero
github: <%= ENV['TRAVIS_REPO_SLUG'] %>
branch: <%= ENV['TRAVIS_COMMIT'] %>
- require_chef_omnibus: true
+ require_chef_omnibus: 12.0.0-rc.2
data_path: test/fixtures
# disable file provider diffs so we don't overflow travis' line limit
client_rb:
diff --git a/lib/chef.rb b/lib/chef.rb
index 0d5fb3de2c..7f54b91f14 100644
--- a/lib/chef.rb
+++ b/lib/chef.rb
@@ -32,10 +32,3 @@ require 'chef/run_status'
require 'chef/handler'
require 'chef/handler/json_file'
-require 'chef/monkey_patches/tempfile'
-require 'chef/monkey_patches/string'
-require 'chef/monkey_patches/numeric'
-require 'chef/monkey_patches/object'
-require 'chef/monkey_patches/file'
-require 'chef/monkey_patches/uri'
-
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index a2718e7556..5a67fc9091 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -17,6 +17,7 @@
# limitations under the License.
require 'pp'
+require 'uri'
require 'socket'
require 'chef/config'
require 'chef/config_fetcher'
@@ -226,7 +227,7 @@ class Chef
private
def can_fork?
# win32-process gem exposes some form of :fork for Process
- # class. So we are seperately ensuring that the platform we're
+ # class. So we are separately ensuring that the platform we're
# running on is not windows before forking.
Chef::Config[:client_fork] && Process.respond_to?(:fork) && !Chef::Platform.windows?
end
diff --git a/lib/chef/application/agent.rb b/lib/chef/application/agent.rb
deleted file mode 100644
index 66b0c25cbf..0000000000
--- a/lib/chef/application/agent.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@opscode.comz>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'chef/application'
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index d3e2f55757..1a19a45598 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -20,7 +20,6 @@ require 'chef/application'
require 'mixlib/log'
require 'ohai/config'
require 'chef/monkey_patches/net_http.rb'
-require 'chef/monkey_patches/uri.rb'
class Chef::Application::Knife < Chef::Application
@@ -64,7 +63,7 @@ class Chef::Application::Knife < Chef::Application
:long => "--disable-editing",
:description => "Do not open EDITOR, just accept the data as is",
:boolean => true,
- :defaut => false
+ :default => false
option :help,
:short => "-h",
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 798834304c..c3f5444ef7 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -160,6 +160,11 @@ class Chef::Application::Solo < Chef::Application
:description => 'Enable whyrun mode',
:boolean => true
+ option :ez,
+ :long => '--ez',
+ :description => 'A memorial for Ezra Zygmuntowicz',
+ :boolean => true
+
option :environment,
:short => '-E ENVIRONMENT',
:long => '--environment ENVIRONMENT',
@@ -216,6 +221,7 @@ class Chef::Application::Solo < Chef::Application
end
def run_application
+ for_ezra if Chef::Config[:ez]
if !Chef::Config[:client_fork] || Chef::Config[:once]
# Run immediately without interval sleep or splay
begin
@@ -230,7 +236,19 @@ class Chef::Application::Solo < Chef::Application
end
end
+
private
+
+ def for_ezra
+ puts <<-EOH
+For Ezra Zygmuntowicz:
+ The man who brought you Chef Solo
+ Early contributor to Chef
+ Kind hearted open source advocate
+ Rest in peace, Ezra.
+EOH
+ end
+
def interval_run_chef_client
if Chef::Config[:daemonize]
Chef::Daemon.daemonize("chef-client")
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index bea5e9fcdc..ba7c6dab5a 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -26,6 +26,7 @@ require 'chef/log'
require 'chef/rest'
require 'mixlib/cli'
require 'socket'
+require 'uri'
require 'win32/daemon'
require 'chef/mixin/shell_out'
diff --git a/lib/chef/applications.rb b/lib/chef/applications.rb
index 6160bb96cd..6a1a2e8a92 100644
--- a/lib/chef/applications.rb
+++ b/lib/chef/applications.rb
@@ -1,4 +1,3 @@
-require 'chef/application/agent'
require 'chef/application/client'
require 'chef/application/knife'
require 'chef/application/solo'
diff --git a/lib/chef/audit/audit_event_proxy.rb b/lib/chef/audit/audit_event_proxy.rb
index 6d5591d943..36160db9bb 100644
--- a/lib/chef/audit/audit_event_proxy.rb
+++ b/lib/chef/audit/audit_event_proxy.rb
@@ -43,7 +43,7 @@ class Chef
described_class = example.metadata[:described_class]
if described_class
resource_type = described_class.class.name.split(':')[-1]
- # TODO submit github PR to expose this
+ # TODO https://github.com/serverspec/serverspec/pull/493
resource_name = described_class.instance_variable_get(:@name)
end
diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb
index 21ffb62829..d022ac0c47 100644
--- a/lib/chef/audit/audit_reporter.rb
+++ b/lib/chef/audit/audit_reporter.rb
@@ -28,7 +28,7 @@ class Chef
attr_reader :rest_client, :audit_data, :ordered_control_groups, :run_status
private :rest_client, :audit_data, :ordered_control_groups, :run_status
- PROTOCOL_VERSION = '0.1.0'
+ PROTOCOL_VERSION = '0.1.1'
def initialize(rest_client)
@rest_client = rest_client
@@ -36,6 +36,10 @@ class Chef
@ordered_control_groups = Hash.new
end
+ def run_context
+ run_status.run_context
+ end
+
def audit_phase_start(run_status)
Chef::Log.debug("Audit Reporter starting")
@audit_data = AuditData.new(run_status.node.name, run_status.run_id)
@@ -71,7 +75,8 @@ class Chef
if ordered_control_groups.has_key?(name)
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
- ordered_control_groups.store(name, ControlGroupData.new(name))
+ metadata = run_context.audits[name].metadata
+ ordered_control_groups.store(name, ControlGroupData.new(name, metadata))
end
def control_example_success(control_group_name, example_data)
diff --git a/lib/chef/audit/control_group_data.rb b/lib/chef/audit/control_group_data.rb
index e221ae94cc..42a91ef5a7 100644
--- a/lib/chef/audit/control_group_data.rb
+++ b/lib/chef/audit/control_group_data.rb
@@ -28,19 +28,20 @@ class Chef
end
class ControlGroupData
- attr_reader :name, :status, :number_success, :number_failed, :controls
+ attr_reader :name, :status, :number_succeeded, :number_failed, :controls, :metadata
- def initialize(name)
+ def initialize(name, metadata={})
@status = "success"
@controls = []
- @number_success = 0
+ @number_succeeded = 0
@number_failed = 0
@name = name
+ @metadata = metadata
end
def example_success(control_data)
- @number_success += 1
+ @number_succeeded += 1
control = create_control(control_data)
control.status = "success"
controls << control
@@ -64,24 +65,18 @@ class Chef
h = {
:name => name,
:status => status,
- :number_success => number_success,
+ :number_succeeded => number_succeeded,
:number_failed => number_failed,
:controls => controls.collect { |c| c.to_hash }
}
- add_display_only_data(h)
+ # If there is a duplicate key, metadata will overwrite it
+ add_display_only_data(h).merge(metadata)
end
private
def create_control(control_data)
- name = control_data[:name]
- resource_type = control_data[:resource_type]
- resource_name = control_data[:resource_name]
- context = control_data[:context]
- line_number = control_data[:line_number]
- # TODO make this smarter with splat arguments so if we start passing in more control_data
- # I don't have to modify code in multiple places
- ControlData.new(name, resource_type, resource_name, context, line_number)
+ ControlData.new(control_data)
end
# The id and control sequence number are ephemeral data - they are not needed
@@ -103,12 +98,10 @@ class Chef
attr_reader :name, :resource_type, :resource_name, :context, :line_number
attr_accessor :status, :details
- def initialize(name, resource_type, resource_name, context, line_number)
- @context = context
- @name = name
- @resource_type = resource_type
- @resource_name = resource_name
- @line_number = line_number
+ def initialize(control_data={})
+ control_data.each do |k, v|
+ self.instance_variable_set("@#{k}", v)
+ end
end
def to_hash
diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb
index 306212989a..51c007d1d0 100644
--- a/lib/chef/audit/runner.rb
+++ b/lib/chef/audit/runner.rb
@@ -142,7 +142,7 @@ class Chef
def register_controls
add_example_group_methods
run_context.audits.each do |name, group|
- ctl_grp = RSpec::Core::ExampleGroup.__controls__(*group[:args], &group[:block])
+ ctl_grp = RSpec::Core::ExampleGroup.__controls__(*group.args, &group.block)
RSpec.world.register(ctl_grp)
end
end
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index 2a9d44a3c5..957db845b0 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -271,7 +271,7 @@ class Chef
# * :fatal
# These work as you'd expect. There is also a special `:auto` setting.
# When set to :auto, Chef will auto adjust the log verbosity based on
- # context. When a tty is available (usually becase the user is running chef
+ # context. When a tty is available (usually because the user is running chef
# in a console), the log level is set to :warn, and output formatters are
# used as the primary mode of output. When a tty is not available, the
# logger is the primary mode of output, and the log level is set to :info
@@ -317,6 +317,7 @@ class Chef
default :why_run, false
default :color, false
default :client_fork, true
+ default :ez, false
default :enable_reporting, true
default :enable_reporting_url_fatals, false
# Possible values for :audit_mode
@@ -635,7 +636,7 @@ class Chef
#
# For example, on CentOS 6 with ENV['LANG'] = "en_US.UTF-8",
# `locale -a`.split fails with ArgumentError invalid UTF-8 encoding.
- locales = shell_out_with_systems_locale("locale -a").stdout.split
+ locales = shell_out_with_systems_locale!("locale -a").stdout.split
case
when locales.include?('C.UTF-8')
'C.UTF-8'
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 54e930135d..781d3b40b0 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -227,11 +227,11 @@ class Chef
)
end
- # Sets the current cookbook version, or returns it. Can be two or three digits, seperated
+ # Sets the current cookbook version, or returns it. Can be two or three digits, separated
# by dots. ie: '2.1', '1.5.4' or '0.9'.
#
# === Parameters
- # version<String>:: The curent version, as a string
+ # version<String>:: The current version, as a string
#
# === Returns
# version<String>:: Returns the current version
@@ -246,7 +246,7 @@ class Chef
# Sets the name of the cookbook, or returns it.
#
# === Parameters
- # name<String>:: The curent cookbook name.
+ # name<String>:: The current cookbook name.
#
# === Returns
# name<String>:: Returns the current cookbook name.
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index c444c8251b..879a578e15 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -18,6 +18,7 @@
# limitations under the License.
#
+require 'uri'
require 'net/http'
require 'mixlib/authentication/signedheaderauth'
require 'openssl'
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 505b403e65..3bf19296c9 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -24,7 +24,6 @@ require 'chef/cookbook/file_vendor'
require 'chef/cookbook/metadata'
require 'chef/version_class'
require 'pathname'
-require 'chef/monkey_patches/pathname'
require 'chef/digester'
class Chef
diff --git a/lib/chef/dsl/audit.rb b/lib/chef/dsl/audit.rb
index a11d9039ef..022bbcce01 100644
--- a/lib/chef/dsl/audit.rb
+++ b/lib/chef/dsl/audit.rb
@@ -30,11 +30,20 @@ class Chef
name = args[0]
if name.nil? || name.empty?
raise Chef::Exceptions::AuditNameMissing
- elsif run_context.controls.has_key?(name)
+ elsif run_context.audits.has_key?(name)
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
- run_context.audits[name] = { :args => args, :block => block }
+ # This DSL will only work in the Recipe class because that exposes the cookbook_name
+ cookbook_name = self.cookbook_name
+ metadata = {
+ cookbook_name: cookbook_name,
+ cookbook_version: self.run_context.cookbook_collection[cookbook_name].version,
+ recipe_name: self.recipe_name,
+ line_number: block.source_location[1]
+ }
+
+ run_context.audits[name] = Struct.new(:args, :block, :metadata).new(args, block, metadata)
end
end
diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb
index a81debce99..7af67e94a5 100644
--- a/lib/chef/dsl/reboot_pending.rb
+++ b/lib/chef/dsl/reboot_pending.rb
@@ -47,7 +47,7 @@ class Chef
# Vista + Server 2008 and newer may have reboots pending from CBS
registry_key_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired') ||
- # The mere existance of the UpdateExeVolatile key should indicate a pending restart for certain updates
+ # The mere existence of the UpdateExeVolatile key should indicate a pending restart for certain updates
# http://support.microsoft.com/kb/832475
(registry_key_exists?('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile') &&
!registry_get_values('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').select { |v| v[:name] == "Flags" }[0].nil? &&
diff --git a/lib/chef/event_dispatch/base.rb b/lib/chef/event_dispatch/base.rb
index a1306364b7..695e31cf2e 100644
--- a/lib/chef/event_dispatch/base.rb
+++ b/lib/chef/event_dispatch/base.rb
@@ -193,7 +193,7 @@ class Chef
def definition_file_load_failed(path, exception)
end
- # Called when resource defintions are done loading
+ # Called when resource definitions are done loading
def definition_load_complete
end
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index ee951bd675..8d00a38dc1 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -25,7 +25,6 @@ require 'tempfile'
require 'net/https'
require 'uri'
require 'chef/http/basic_client'
-require 'chef/monkey_patches/string'
require 'chef/monkey_patches/net_http'
require 'chef/config'
require 'chef/platform/query_helpers'
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 0c079792a4..3f234d7ce3 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -72,6 +72,11 @@ class Chef
ui.msg(msg)
end
+ def self.reset_config_loader!
+ @@chef_config_dir = nil
+ @config_loader = nil
+ end
+
def self.reset_subcommands!
@@subcommands = {}
@subcommands_by_category = nil
@@ -162,12 +167,15 @@ class Chef
# Shared with subclasses
@@chef_config_dir = nil
+ def self.config_loader
+ @config_loader ||= WorkstationConfigLoader.new(nil, Chef::Log)
+ end
+
def self.load_config(explicit_config_file)
- config_loader = WorkstationConfigLoader.new(explicit_config_file, Chef::Log)
+ config_loader.explicit_config_file = explicit_config_file
config_loader.load
ui.warn("No knife configuration file found") if config_loader.no_config_found?
- @@chef_config_dir = config_loader.chef_config_dir
config_loader
rescue Exceptions::ConfigurationError => e
@@ -176,7 +184,7 @@ class Chef
end
def self.chef_config_dir
- @@chef_config_dir
+ @@chef_config_dir ||= config_loader.chef_config_dir
end
# Run knife for the given +args+ (ARGV), adding +options+ to the list of
@@ -252,7 +260,7 @@ class Chef
OFFICIAL_PLUGINS = %w[ec2 rackspace windows openstack terremark bluebox]
# :nodoc:
- # Error out and print usage. probably becuase the arguments given by the
+ # Error out and print usage. probably because the arguments given by the
# user could not be resolved to a subcommand.
def self.subcommand_not_found!(args)
ui.fatal("Cannot find sub command for: '#{args.join(' ')}'")
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index e681d7a49b..ffc36436ec 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -23,7 +23,7 @@ class Chef
class Knife
module Core
# Instances of BootstrapContext are the context objects (i.e., +self+) for
- # bootstrap templates. For backwards compatability, they +must+ set the
+ # bootstrap templates. For backwards compatibility, they +must+ set the
# following instance variables:
# * @config - a hash of knife's config values
# * @run_list - the run list for the node to boostrap
@@ -135,7 +135,7 @@ CONFIG
def latest_current_chef_version_string
installer_version_string = nil
if @config[:prerelease]
- installer_version_string = "-p"
+ installer_version_string = ["-p"]
else
chef_version_string = if knife_config[:bootstrap_version]
knife_config[:bootstrap_version]
diff --git a/lib/chef/knife/node_run_list_remove.rb b/lib/chef/knife/node_run_list_remove.rb
index 8519fd590a..4b8953a264 100644
--- a/lib/chef/knife/node_run_list_remove.rb
+++ b/lib/chef/knife/node_run_list_remove.rb
@@ -27,11 +27,20 @@ class Chef
require 'chef/json_compat'
end
- banner "knife node run_list remove [NODE] [ENTRIES] (options)"
+ banner "knife node run_list remove [NODE] [ENTRY[,ENTRY]] (options)"
def run
node = Chef::Node.load(@name_args[0])
- entries = @name_args[1].split(',')
+
+ if @name_args.size > 2
+ # Check for nested lists and create a single plain one
+ entries = @name_args[1..-1].map do |entry|
+ entry.split(',').map { |e| e.strip }
+ end.flatten
+ else
+ # Convert to array and remove the extra spaces
+ entries = @name_args[1].split(',').map { |e| e.strip }
+ end
entries.each { |e| node.run_list.remove(e) }
@@ -45,4 +54,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb
index c92315e718..d9a9c4f006 100644
--- a/lib/chef/mixin/command.rb
+++ b/lib/chef/mixin/command.rb
@@ -82,7 +82,7 @@ class Chef
end
# works same as above, except that it returns stdout and stderr
- # requirement => platforms like solaris 9,10 has wierd issues where
+ # requirement => platforms like solaris 9,10 has weird issues where
# even in command failure the exit code is zero, so we need to lookup stderr.
def run_command_and_return_stdout_stderr(args={})
command_output = ""
diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb
index a8a4737758..825406a93e 100644
--- a/lib/chef/mixin/deep_merge.rb
+++ b/lib/chef/mixin/deep_merge.rb
@@ -27,17 +27,6 @@ class Chef
# http://trac.misuse.org/science/wiki/DeepMerge
module DeepMerge
- class InvalidSubtractiveMerge < ArgumentError; end
-
-
- OLD_KNOCKOUT_PREFIX = "!merge:".freeze
-
- # Regex to match the "knockout prefix" that was used to indicate
- # subtractive merging in Chef 10.x and previous. Subtractive merging is
- # removed as of Chef 11, but we detect attempted use of it and raise an
- # error (see: raise_if_knockout_used!)
- OLD_KNOCKOUT_MATCH = %r[!merge].freeze
-
extend self
def merge(first, second)
@@ -47,15 +36,6 @@ class Chef
DeepMerge.deep_merge(second, first)
end
- # Inherited roles use the knockout_prefix array subtraction functionality
- # This is likely to go away in Chef >= 0.11
- def role_merge(first, second)
- first = Mash.new(first) unless first.kind_of?(Mash)
- second = Mash.new(second) unless second.kind_of?(Mash)
-
- DeepMerge.deep_merge(second, first)
- end
-
class InvalidParameter < StandardError; end
# Deep Merge core documentation.
@@ -78,8 +58,6 @@ class Chef
dest = source; return dest
end
- raise_if_knockout_used!(source)
- raise_if_knockout_used!(dest)
case source
when nil
dest
@@ -89,7 +67,6 @@ class Chef
if dest[src_key]
dest[src_key] = deep_merge!(src_value, dest[src_key])
else # dest[src_key] doesn't exist so we take whatever source has
- raise_if_knockout_used!(src_value)
dest[src_key] = src_value
end
end
@@ -128,11 +105,19 @@ class Chef
# If there are two Hashes, recursively merge.
if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
merge_with.each do |key, merge_with_value|
- merge_onto[key] = if merge_onto.has_key?(key)
- hash_only_merge(merge_onto[key], merge_with_value)
- else
- merge_with_value
- end
+ value =
+ if merge_onto.has_key?(key)
+ hash_only_merge(merge_onto[key], merge_with_value)
+ else
+ merge_with_value
+ end
+
+ if merge_onto.respond_to?(:public_method_that_only_deep_merge_should_use)
+ # we can't call ImmutableMash#[]= because its immutable, but we need to mutate it to build it in-place
+ merge_onto.public_method_that_only_deep_merge_should_use(key, value)
+ else
+ merge_onto[key] = value
+ end
end
merge_onto
@@ -146,27 +131,6 @@ class Chef
end
end
- # Checks for attempted use of subtractive merge, which was removed for
- # Chef 11.0. If subtractive merge use is detected, will raise an
- # InvalidSubtractiveMerge exception.
- def raise_if_knockout_used!(obj)
- if uses_knockout?(obj)
- raise InvalidSubtractiveMerge, "subtractive merge with !merge is no longer supported"
- end
- end
-
- # Checks for attempted use of subtractive merge in +obj+.
- def uses_knockout?(obj)
- case obj
- when String
- obj =~ OLD_KNOCKOUT_MATCH
- when Array
- obj.any? {|element| element.respond_to?(:gsub) && element =~ OLD_KNOCKOUT_MATCH }
- else
- false
- end
- end
-
def deep_merge(source, dest)
deep_merge!(safe_dup(source), safe_dup(dest))
end
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index bedc67f357..78d72dc801 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -42,8 +42,8 @@ class Chef
# method names.
# :required:: Raise an exception if this parameter is missing. Valid values are true or false,
# by default, options are not required.
- # :regex:: Match the value of the paramater against a regular expression.
- # :equal_to:: Match the value of the paramater with ==. An array means it can be equal to any
+ # :regex:: Match the value of the parameter against a regular expression.
+ # :equal_to:: Match the value of the parameter with ==. An array means it can be equal to any
# of the values.
def validate(opts, map)
#--
diff --git a/lib/chef/monkey_patches/file.rb b/lib/chef/monkey_patches/file.rb
deleted file mode 100644
index acc0ca73fe..0000000000
--- a/lib/chef/monkey_patches/file.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-if !File.respond_to?(:realpath)
- require 'pathname'
- class File
- def self.realpath(path)
- Pathname.new(path).realpath.to_s
- end
- end
-end
diff --git a/lib/chef/monkey_patches/fileutils.rb b/lib/chef/monkey_patches/fileutils.rb
deleted file mode 100644
index f18bead144..0000000000
--- a/lib/chef/monkey_patches/fileutils.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Author:: Stephen Delano (<stephen@opscode.com>)
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# == FileUtils::Entry_ (Patch)
-# On Ruby 1.9.3 and earlier, FileUtils.cp_r(foo, bar, :preserve => true) fails
-# when attempting to copy a directory containing symlinks. This has been
-# patched in the trunk of Ruby, and this is a monkey patch of the offending
-# code.
-
-unless RUBY_VERSION =~ /^2/
- require 'fileutils'
-
- class FileUtils::Entry_
- def copy_metadata(path)
- st = lstat()
- if !st.symlink?
- File.utime st.atime, st.mtime, path
- end
- begin
- if st.symlink?
- begin
- File.lchown st.uid, st.gid, path
- rescue NotImplementedError
- end
- else
- File.chown st.uid, st.gid, path
- end
- rescue Errno::EPERM
- # clear setuid/setgid
- if st.symlink?
- begin
- File.lchmod st.mode & 01777, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode & 01777, path
- end
- else
- if st.symlink?
- begin
- File.lchmod st.mode, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode, path
- end
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/numeric.rb b/lib/chef/monkey_patches/numeric.rb
deleted file mode 100644
index f4612fdbf3..0000000000
--- a/lib/chef/monkey_patches/numeric.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-unless 0.respond_to?(:fdiv)
- class Numeric
- def fdiv(other)
- to_f / other
- end
- end
-end
-
-# String elements referenced with [] <= 1.8.6 return a Fixnum. Cheat to allow
-# for the simpler "test"[2].ord construct
-class Numeric
- def ord
- return self
- end
-end
diff --git a/lib/chef/monkey_patches/object.rb b/lib/chef/monkey_patches/object.rb
deleted file mode 100644
index 017a4b7938..0000000000
--- a/lib/chef/monkey_patches/object.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Object
- unless new.respond_to?(:tap)
- def tap
- yield self
- return self
- end
- end
-end
-
diff --git a/lib/chef/monkey_patches/pathname.rb b/lib/chef/monkey_patches/pathname.rb
deleted file mode 100644
index c0255ae7ea..0000000000
--- a/lib/chef/monkey_patches/pathname.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'pathname'
-
-if RUBY_VERSION.to_f < 1.9
- class Pathname
- @@old_each_filename = instance_method(:each_filename)
-
- def each_filename(&block)
- if block_given?
- EachFilenameEnumerable.new(self).each(&block)
- else
- EachFilenameEnumerable.new(self)
- end
- end
-
- def old_each_filename(&block)
- @@old_each_filename.bind(self).call(&block)
- end
-
- class EachFilenameEnumerable
- include Enumerable
- attr_reader :pathname
-
- def initialize(pathname)
- @pathname = pathname
- end
-
- def each(&block)
- @pathname.old_each_filename(&block)
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/regexp.rb b/lib/chef/monkey_patches/regexp.rb
deleted file mode 100644
index 8a7ee77cb5..0000000000
--- a/lib/chef/monkey_patches/regexp.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2009 Marc-Andre Lafortune
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Regexp
- # Standard in Ruby 1.8.7+. See official documentation[http://www.ruby-doc.org/core-1.8.7/classes/Regexp.html]
- class << self
- unless (union(%w(a b)) rescue false)
- alias :union_without_array_argument :union
-
- def union(*arg)
- return union_without_array_argument(*arg) unless arg.size == 1
- union_without_array_argument(*arg.first)
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/string.rb b/lib/chef/monkey_patches/string.rb
deleted file mode 100644
index f91e27ddc5..0000000000
--- a/lib/chef/monkey_patches/string.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# == String (Patch)
-# On ruby 1.9, Strings are aware of multibyte characters, so +size+ and +length+
-# give the actual number of characters. In Chef::REST, we need the bytesize
-# so we can correctly set the Content-Length headers, but ruby 1.8.6 and lower
-# don't define String#bytesize. Monkey patching time!
-
-begin
- require 'enumerator'
-rescue LoadError
-end
-
-class String
- unless method_defined?(:bytesize)
- alias :bytesize :size
- end
-
- unless method_defined?(:lines)
- def lines
- enum_for(:each)
- end
- end
-end
-
-# <= 1.8.6 needs some ord!
-class String
- unless method_defined?(:ord)
- def ord
- self.unpack('C').first
- end
- end
-end
diff --git a/lib/chef/monkey_patches/tempfile.rb b/lib/chef/monkey_patches/tempfile.rb
deleted file mode 100644
index b9179f182b..0000000000
--- a/lib/chef/monkey_patches/tempfile.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# == Tempfile (Patch)
-# Tempfile has a horrible bug where it causes an IOError: closed stream in its
-# finalizer, leading to intermittent application crashes with confusing stack
-# traces. Here we monkey patch the fix into place. You can track the bug on
-# ruby's redmine: http://redmine.ruby-lang.org/issues/show/3119
-#
-# The patch is slightly different for Ruby 1.8 and Ruby 1.9, both patches are
-# included here.
-class Tempfile # :nodoc:
- # Tempfile has changes between 1.8.x and 1.9.x
- # so we monkey patch separately
- if RUBY_VERSION =~ /^1\.8/
- def unlink
- # keep this order for thread safeness
- begin
- File.unlink(@tmpname) if File.exist?(@tmpname)
- @@cleanlist.delete(@tmpname)
- @tmpname = nil
- ObjectSpace.undefine_finalizer(self)
- rescue Errno::EACCES
- # may not be able to unlink on Windows; just ignore
- end
- end
- alias delete unlink
-
-
- # There is a patch for this, to be merged into 1.9 at some point.
- # When that happens, we'll want to also check the RUBY_PATCHLEVEL
- elsif RUBY_VERSION =~ /^1\.9/
- def unlink
- # keep this order for thread safeness
- return unless @tmpname
- begin
- if File.exist?(@tmpname)
- File.unlink(@tmpname)
- end
- # remove tmpname from remover
- @data[0] = @data[2] = nil
- @tmpname = nil
- rescue Errno::EACCES
- # may not be able to unlink on Windows; just ignore
- end
- end
- alias delete unlink
- end
-end
diff --git a/lib/chef/monkey_patches/uri.rb b/lib/chef/monkey_patches/uri.rb
deleted file mode 100644
index 158285e395..0000000000
--- a/lib/chef/monkey_patches/uri.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
-# You can redistribute it and/or modify it under either the terms of the
-# 2-clause BSDL (see the file BSDL), or the conditions below:
-#
-# 1. You may make and give away verbatim copies of the source form of the
-# software without restriction, provided that you duplicate all of the
-# original copyright notices and associated disclaimers.
-#
-# 2. You may modify your copy of the software in any way, provided that
-# you do at least ONE of the following:
-#
-# a) place your modifications in the Public Domain or otherwise
-# make them Freely Available, such as by posting said
-# modifications to Usenet or an equivalent medium, or by allowing
-# the author to include your modifications in the software.
-#
-# b) use the modified software only within your corporation or
-# organization.
-#
-# c) give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d) make other distribution arrangements with the author.
-#
-# 3. You may distribute the software in object code or binary form,
-# provided that you do at least ONE of the following:
-#
-# a) distribute the binaries and library files of the software,
-# together with instructions (in the manual page or equivalent)
-# on where to get the original distribution.
-#
-# b) accompany the distribution with the machine-readable source of
-# the software.
-#
-# c) give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d) make other distribution arrangements with the author.
-#
-# 4. You may modify and include the part of the software into any other
-# software (possibly commercial). But some files in the distribution
-# are not written by the author, so that they are not under these terms.
-#
-# For the list of those files and their copying conditions, see the
-# file LEGAL.
-#
-# 5. The scripts and library files supplied as input to or produced as
-# output from the software do not automatically fall under the
-# copyright of the software, but belong to whomever generated them,
-# and may be sold commercially, and may be aggregated with this
-# software.
-#
-# 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE.
-
-require 'uri'
-
-unless URI::Generic.instance_methods.map {|m| m.to_s}.include?("hostname")
-
- class URI::Generic
- # Copied from the MRI source for Ruby 1.9.3
- # File lib/uri/generic.rb, line 659
- def hostname
- v = self.host
- /\A\[(.*)\]\z/ =~ v ? $1 : v
- end
- end
-end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index dbb7852586..6055f0e1e9 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -127,6 +127,7 @@ class Chef
# Set a normal attribute of this node, but auto-vivify any Mashes that
# might be missing
def normal
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = false
attributes.normal
end
@@ -136,14 +137,17 @@ class Chef
# Set a normal attribute of this node, auto-vivifying any mashes that are
# missing, but if the final value already exists, don't set it
def normal_unless
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = true
attributes.normal
end
+
alias_method :set_unless, :normal_unless
# Set a default of this node, but auto-vivify any Mashes that might
# be missing
def default
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = false
attributes.default
end
@@ -151,6 +155,7 @@ class Chef
# Set a default attribute of this node, auto-vivifying any mashes that are
# missing, but if the final value already exists, don't set it
def default_unless
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = true
attributes.default
end
@@ -158,6 +163,7 @@ class Chef
# Set an override attribute of this node, but auto-vivify any Mashes that
# might be missing
def override
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = false
attributes.override
end
@@ -165,35 +171,30 @@ class Chef
# Set an override attribute of this node, auto-vivifying any mashes that
# are missing, but if the final value already exists, don't set it
def override_unless
+ attributes.top_level_breadcrumb = nil
attributes.set_unless_value_present = true
attributes.override
end
- def override_attrs
- attributes.override
- end
+ alias :override_attrs :override
+ alias :default_attrs :default
+ alias :normal_attrs :normal
def override_attrs=(new_values)
attributes.override = new_values
end
- def default_attrs
- attributes.default
- end
-
def default_attrs=(new_values)
attributes.default = new_values
end
- def normal_attrs
- attributes.normal
- end
-
def normal_attrs=(new_values)
attributes.normal = new_values
end
def automatic_attrs
+ attributes.top_level_breadcrumb = nil
+ attributes.set_unless_value_present = false
attributes.automatic
end
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index 6130925aea..3c48f653eb 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -175,6 +175,19 @@ class Chef
# return the automatic level attribute component
attr_reader :automatic
+ # This is used to track the top level key as we descend through method chaining into
+ # a precedence level (e.g. node.default['foo']['bar']['baz']= results in 'foo' here). We
+ # need this so that when we hit the end of a method chain which results in a mutator method
+ # that we can invalidate the whole top-level deep merge cache for the top-level key. It is
+ # the responsibility of the accessor on the Chef::Node object to reset this to nil, and then
+ # the first VividMash#[] call can ||= and set this to the first key we encounter.
+ attr_accessor :top_level_breadcrumb
+
+ # Cache of deep merged values by top-level key. This is a simple hash which has keys that are the
+ # top-level keys of the node object, and we save the computed deep-merge for that key here. There is
+ # no cache of subtrees.
+ attr_accessor :deep_merge_cache
+
def initialize(normal, default, override, automatic)
@set_unless_present = false
@@ -195,6 +208,8 @@ class Chef
@merged_attributes = nil
@combined_override = nil
@combined_default = nil
+ @top_level_breadcrumb = nil
+ @deep_merge_cache = {}
end
# Debug what's going on with an attribute. +args+ is a path spec to the
@@ -230,51 +245,75 @@ class Chef
@set_unless_present = setting
end
+ # Invalidate a key in the deep_merge_cache. If called with nil, or no arg, this will invalidate
+ # the entire deep_merge cache. In the case of the user doing node.default['foo']['bar']['baz']=
+ # that eventually results in a call to reset_cache('foo') here. A node.default=hash_thing call
+ # must invalidate the entire cache and re-deep-merge the entire node object.
+ def reset_cache(path = nil)
+ if path.nil?
+ @deep_merge_cache = {}
+ else
+ deep_merge_cache.delete(path)
+ end
+ end
+
+ alias :reset :reset_cache
+
# Set the cookbook level default attribute component to +new_data+.
def default=(new_data)
+ reset
@default = VividMash.new(self, new_data)
end
# Set the role level default attribute component to +new_data+
def role_default=(new_data)
+ reset
@role_default = VividMash.new(self, new_data)
end
# Set the environment level default attribute component to +new_data+
def env_default=(new_data)
+ reset
@env_default = VividMash.new(self, new_data)
end
# Set the force_default (+default!+) level attributes to +new_data+
def force_default=(new_data)
+ reset
@force_default = VividMash.new(self, new_data)
end
# Set the normal level attribute component to +new_data+
def normal=(new_data)
+ reset
@normal = VividMash.new(self, new_data)
end
# Set the cookbook level override attribute component to +new_data+
def override=(new_data)
+ reset
@override = VividMash.new(self, new_data)
end
# Set the role level override attribute component to +new_data+
def role_override=(new_data)
+ reset
@role_override = VividMash.new(self, new_data)
end
# Set the environment level override attribute component to +new_data+
def env_override=(new_data)
+ reset
@env_override = VividMash.new(self, new_data)
end
def force_override=(new_data)
+ reset
@force_override = VividMash.new(self, new_data)
end
def automatic=(new_data)
+ reset
@automatic = VividMash.new(self, new_data)
end
@@ -284,6 +323,7 @@ class Chef
# clears attributes from all precedence levels
def rm(*args)
+ reset(args[0])
# just easier to compute our retval, rather than collect+merge sub-retvals
ret = args.inject(merged_attributes) do |attr, arg|
if attr.nil? || !attr.respond_to?(:[])
@@ -314,6 +354,7 @@ class Chef
#
# equivalent to: force_default!['foo']['bar'].delete('baz')
def rm_default(*args)
+ reset(args[0])
remove_from_precedence_level(force_default!(autovivify: false), *args)
end
@@ -321,6 +362,7 @@ class Chef
#
# equivalent to: normal!['foo']['bar'].delete('baz')
def rm_normal(*args)
+ reset(args[0])
remove_from_precedence_level(normal!(autovivify: false), *args)
end
@@ -328,6 +370,7 @@ class Chef
#
# equivalent to: force_override!['foo']['bar'].delete('baz')
def rm_override(*args)
+ reset(args[0])
remove_from_precedence_level(force_override!(autovivify: false), *args)
end
@@ -337,35 +380,51 @@ class Chef
# sets default attributes without merging
def default!(opts={})
+ # FIXME: do not flush whole cache
+ reset
MultiMash.new(self, @default, [], opts)
end
# sets normal attributes without merging
def normal!(opts={})
+ # FIXME: do not flush whole cache
+ reset
MultiMash.new(self, @normal, [], opts)
end
# sets override attributes without merging
def override!(opts={})
+ # FIXME: do not flush whole cache
+ reset
MultiMash.new(self, @override, [], opts)
end
# clears from all default precedence levels and then sets force_default
def force_default!(opts={})
+ # FIXME: do not flush whole cache
+ reset
MultiMash.new(self, @force_default, [@default, @env_default, @role_default], opts)
end
# clears from all override precedence levels and then sets force_override
def force_override!(opts={})
+ # FIXME: do not flush whole cache
+ reset
MultiMash.new(self, @force_override, [@override, @env_override, @role_override], opts)
end
#
- # Accessing merged attributes
+ # Accessing merged attributes.
+ #
+ # Note that merged_attributes('foo', 'bar', 'baz') can be called to compute only the
+ # deep merge of node['foo']['bar']['baz'], but in practice we currently always compute
+ # all of node['foo'] even if the user only requires node['foo']['bar']['baz'].
#
def merged_attributes(*path)
- immutablize(merge_all(path))
+ # immutablize(
+ merge_all(path)
+ # )
end
def combined_override(*path)
@@ -377,7 +436,13 @@ class Chef
end
def [](key)
- merged_attributes(key)
+ if deep_merge_cache.has_key?(key)
+ # return the cache of the deep merged values by top-level key
+ deep_merge_cache[key]
+ else
+ # save all the work of computing node[key]
+ deep_merge_cache[key] = merged_attributes(key)
+ end
end
def []=(key, value)
@@ -480,7 +545,9 @@ class Chef
safe_dup(component)
end
- components.inject(nil) do |merged, component|
+ return nil if components.compact.empty?
+
+ components.inject(ImmutableMash.new({})) do |merged, component|
Chef::Mixin::DeepMerge.hash_only_merge!(merged, component)
end
end
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index 3b19a14d1c..333f4864c6 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -63,6 +63,7 @@ class Chef
MUTATOR_METHODS.each do |mutator|
class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
def #{mutator}(*args, &block)
+ root.reset_cache(root.top_level_breadcrumb)
super
end
METHOD_DEFN
@@ -127,6 +128,7 @@ class Chef
MUTATOR_METHODS.each do |mutator|
class_eval(<<-METHOD_DEFN, __FILE__, __LINE__)
def #{mutator}(*args, &block)
+ root.reset_cache(root.top_level_breadcrumb)
super
end
METHOD_DEFN
@@ -138,6 +140,7 @@ class Chef
end
def [](key)
+ root.top_level_breadcrumb ||= key
value = super
if !key?(key)
value = self.class.new(root)
@@ -148,9 +151,11 @@ class Chef
end
def []=(key, value)
+ root.top_level_breadcrumb ||= key
if set_unless? && key?(key)
self[key]
else
+ root.reset_cache(root.top_level_breadcrumb)
super
end
end
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb
index af04ef26d4..56b8fed3b7 100644
--- a/lib/chef/node/immutable_collections.rb
+++ b/lib/chef/node/immutable_collections.rb
@@ -155,6 +155,10 @@ class Chef
end
end
+ def public_method_that_only_deep_merge_should_use(key, value)
+ internal_set(key, immutablize(value))
+ end
+
alias :attribute? :has_key?
# Redefine all of the methods that mutate a Hash to raise an error when called.
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index b30f7ed17e..19e7c01ab1 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -18,7 +18,6 @@
require "chef/mixin/command"
require "chef/mixin/from_file"
-require "chef/monkey_patches/fileutils"
require "chef/provider/git"
require "chef/provider/subversion"
require "chef/dsl/recipe"
@@ -126,7 +125,7 @@ class Chef
# * Move release_path directory before deploy and move it back when error occurs
# * Rollback to previous commit
# * Do nothing - because deploy is force, it will be retried in short time
- # Because last is simpliest, keep it
+ # Because last is simplest, keep it
deploy
end
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 6304a7ef63..1f33cc5a9b 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -17,6 +17,7 @@
# limitations under the License.
#
+require 'uri'
require 'chef/provider/package'
require 'chef/mixin/command'
require 'chef/resource/package'
@@ -130,7 +131,7 @@ class Chef
##
# Determines the candidate version for a gem from a .gem file on disk
- # and checks if it matches the version contraints in +gem_dependency+
+ # and checks if it matches the version constraints in +gem_dependency+
# === Returns
# Gem::Version a singular gem version object is returned if the gem
# is available
@@ -536,7 +537,7 @@ class Chef
else
src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org"
end
- if version
+ if !version.nil? && version.length > 0
shell_out!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
else
shell_out!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
diff --git a/lib/chef/provider/package/yum-dump.py b/lib/chef/provider/package/yum-dump.py
index 8b09dedbf0..c9f6a1fcea 100644
--- a/lib/chef/provider/package/yum-dump.py
+++ b/lib/chef/provider/package/yum-dump.py
@@ -23,7 +23,7 @@
# and dump the results to stdout.
#
# yum-dump invokes yum similarly to the command line interface which makes it
-# subject to most of the configuration paramaters in yum.conf. yum-dump will
+# subject to most of the configuration parameters in yum.conf. yum-dump will
# also load yum plugins in the same manor as yum - these can affect the output.
#
# Can be run as non root, but that won't update the cache.
@@ -70,7 +70,7 @@ def setup(yb, options):
else:
yb.doConfigSetup(errorlevel=0, debuglevel=0)
except yum.Errors.ConfigError, e:
- # supresses an ignored exception at exit
+ # suppresses an ignored exception at exit
yb.preconf = None
print >> sys.stderr, "yum-dump Config Error: %s" % e
return 1
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 9a7416e318..eaccce46cf 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -44,7 +44,7 @@ class Chef
# Transfer files
files_to_transfer.each do |cookbook_file_relative_path|
create_cookbook_file(cookbook_file_relative_path)
- # parent directories and file being transfered are removed from the purge list
+ # parent directories and file being transferred are removed from the purge list
Pathname.new(Chef::Util::PathHelper.cleanpath(::File.join(@new_resource.path, cookbook_file_relative_path))).descend do |d|
files_to_purge.delete(d.to_s)
end
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 3a3ddb2385..8d4aa41035 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -41,7 +41,7 @@ class Chef
# In chef, when we ask a service to start, we expect it to have started before performing the next step
# since we have top down dependencies. Which is to say we may follow witha resource next that requires
# that service to be running. According to [2] we can trust that sending a 'goal' such as start will not
- # return until that 'goal' is reached, or some error has occured.
+ # return until that 'goal' is reached, or some error has occurred.
#
# [1] http://upstart.ubuntu.com/wiki/JobStates
# [2] http://www.netsplit.com/2008/04/27/upstart-05-events/
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 84f5145c52..39746f0018 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -39,7 +39,7 @@ class Chef
# > 10.7 => password shadow calculation format SALTED-SHA512-PBKDF2
# => stored in: /var/db/dslocal/nodes/Default/users/#{name}.plist
# => shadow binary length 128 bytes
- # => Salt / Iterations are stored seperately in the same file
+ # => Salt / Iterations are stored separately in the same file
#
# This provider only supports Mac OSX versions 10.7 and above
class Dscl < Chef::Provider::User
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb
index 247102f191..d83a3e0468 100644
--- a/lib/chef/provider_resolver.rb
+++ b/lib/chef/provider_resolver.rb
@@ -34,7 +34,7 @@ class Chef
# return a deterministically sorted list of Chef::Provider subclasses
def providers
- @providers ||= Chef::Provider.descendants.sort {|a,b| a.to_s <=> b.to_s }
+ @providers ||= Chef::Provider.descendants
end
def resolve
@@ -48,7 +48,7 @@ class Chef
@enabled_handlers ||=
providers.select do |klass|
klass.provides?(node, resource)
- end
+ end.sort {|a,b| a.to_s <=> b.to_s }
end
# this cut looks at if the provider can handle the specific resource and action
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index b4046e4f16..621d93099b 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -84,7 +84,7 @@ class Chef
run_context.resource_collection.find(*args)
end
- # This was moved to Chef::Node#tag, redirecting here for compatability
+ # This was moved to Chef::Node#tag, redirecting here for compatibility
def tag(*tags)
run_context.node.tag(*tags)
end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 46516fd3fb..7ba98b9d3b 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -17,6 +17,7 @@
# limitations under the License.
#
+require 'uri'
require 'chef/resource/file'
require 'chef/provider/remote_file'
require 'chef/mixin/securable'
diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb
index 278114e209..9d6844129c 100644
--- a/lib/chef/resource_definition.rb
+++ b/lib/chef/resource_definition.rb
@@ -54,7 +54,7 @@ class Chef
end
# When we do the resource definition, we're really just setting new values for
- # the paramaters we prototyped at the top. This method missing is as simple as
+ # the parameters we prototyped at the top. This method missing is as simple as
# it gets.
def method_missing(symbol, *args)
@params[symbol] = args.length == 1 ? args[0] : args
diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb
index 73665f39e7..46b45f1d9e 100644
--- a/lib/chef/run_list/run_list_expansion.rb
+++ b/lib/chef/run_list/run_list_expansion.rb
@@ -96,8 +96,8 @@ class Chef
end
def apply_role_attributes(role)
- @default_attrs = Chef::Mixin::DeepMerge.role_merge(@default_attrs, role.default_attributes)
- @override_attrs = Chef::Mixin::DeepMerge.role_merge(@override_attrs, role.override_attributes)
+ @default_attrs = Chef::Mixin::DeepMerge.merge(@default_attrs, role.default_attributes)
+ @override_attrs = Chef::Mixin::DeepMerge.merge(@override_attrs, role.override_attributes)
end
def applied_role?(role_name)
diff --git a/lib/chef/shef/ext.rb b/lib/chef/shef/ext.rb
deleted file mode 100644
index 8f03de2d04..0000000000
--- a/lib/chef/shef/ext.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#--
-# Author:: Joshua Timberman (<joshua@opscode.com>)
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/shell/ext'
diff --git a/lib/chef/util/file_edit.rb b/lib/chef/util/file_edit.rb
index 92cefb4bb4..4d2a9c03eb 100644
--- a/lib/chef/util/file_edit.rb
+++ b/lib/chef/util/file_edit.rb
@@ -47,7 +47,7 @@ class Chef
end
#search the file line by line and match each line with the given regex
- #if matched, replace the match (all occurances) with the replace parameter
+ #if matched, replace the match (all occurrences) with the replace parameter
def search_file_replace(regex, replace)
@changes = (editor.replace(regex, replace) > 0) || @changes
end
@@ -59,7 +59,7 @@ class Chef
end
#search the file line by line and match each line with the given regex
- #if matched, delete the match (all occurances) from the line
+ #if matched, delete the match (all occurrences) from the line
def search_file_delete(regex)
search_file_replace(regex, '')
end
diff --git a/lib/chef/workstation_config_loader.rb b/lib/chef/workstation_config_loader.rb
index 6715d4eec2..dd02ad9a66 100644
--- a/lib/chef/workstation_config_loader.rb
+++ b/lib/chef/workstation_config_loader.rb
@@ -25,7 +25,7 @@ class Chef
class WorkstationConfigLoader
# Path to a config file requested by user, (e.g., via command line option). Can be nil
- attr_reader :explicit_config_file
+ attr_accessor :explicit_config_file
# TODO: initialize this with a logger for Chef and Knife
def initialize(explicit_config_file, logger=nil)
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index 3d3234f0f7..19b65ca2a0 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -28,7 +28,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
# Platform specific validation routines.
def service_should_be_started(file_name)
- # The existance of this file indicates that the service was started.
+ # The existence of this file indicates that the service was started.
expect(File.exists?("/tmp/#{file_name}")).to be_truthy
end
diff --git a/spec/support/pedant/pedant_config.rb b/spec/support/pedant/pedant_config.rb
index f7d14d8f17..3f8219fc59 100644
--- a/spec/support/pedant/pedant_config.rb
+++ b/spec/support/pedant/pedant_config.rb
@@ -26,7 +26,7 @@
# If you are doing development testing, you can specify the address of
# the Solr server. The presence of this parameter will enable tests
-# to force commits to Solr, greatly decreasing the amout of time
+# to force commits to Solr, greatly decreasing the amount of time
# needed for testing the search endpoint. This is only an
# optimization for development! If you are testing a "live" Chef
# Server, or otherwise do not have access to the Solr server from your
@@ -36,7 +36,7 @@
#search_server "http://localhost:8983"
# Related to the 'search_server' parameter, this specifies the maximum
-# amout of time (in seconds) that search endpoint requests should be
+# amount of time (in seconds) that search endpoint requests should be
# retried before giving up. If not explicitly set, it will default to
# 65 seconds; only set it if you know that your Solr commit interval
# differs significantly from this.
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index bcc2a7da25..4f8e2f5b71 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -813,7 +813,7 @@ shared_examples_for "a configured file resource" do
# Regression test for http://tickets.opscode.com/browse/CHEF-4082
context "when notification is configured" do
- describe "when path is specified with normal seperator" do
+ describe "when path is specified with normal separator" do
before do
@notified_resource = Chef::Resource.new("punk", resource.run_context)
resource.notifies(:run, @notified_resource, :immediately)
@@ -826,7 +826,7 @@ shared_examples_for "a configured file resource" do
end
end
- describe "when path is specified with windows seperator", :windows_only do
+ describe "when path is specified with windows separator", :windows_only do
let(:path) {
File.join(test_file_dir, make_tmpname(file_base)).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)
}
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 9a3389306d..963fbf1c5b 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -131,7 +131,7 @@ module ChefHTTPShared
}
#
- # in the presense of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
+ # in the presence of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
#
# (expected_content should be uncompressed)
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index e85fa971e9..29faa07f29 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -23,7 +23,7 @@
# runs without error, but don't make assertions about the output. This is
# because aspects such as how information gets formatted, what's included, etc.
# are still in flux. When testing an inspector, change the outputter to use
-# STDOUT and manually check the ouput.
+# STDOUT and manually check the output.
shared_examples_for "an api error inspector" do
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 806a596a61..3c215eac7f 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -33,6 +33,11 @@ describe Chef::Application::Knife do
end
end
+ after(:each) do
+ # reset some really nasty global state
+ NoopKnifeCommand.reset_config_loader!
+ end
+
before(:each) do
# Prevent code from getting loaded on every test invocation.
allow(Chef::Knife).to receive(:load_commands)
@@ -109,7 +114,6 @@ describe Chef::Application::Knife do
end
expect(Chef::Config[:client_key]).to eq(full_path)
end
-
end
describe "with environment configuration" do
@@ -168,6 +172,6 @@ describe Chef::Application::Knife do
@knife.run
end
end
-
end
+
end
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 58fb229c96..ed2003e8bf 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -426,7 +426,7 @@ describe Chef::Config do
let(:locales) { locale_array.join("\n") }
before do
- allow(Chef::Config).to receive(:shell_out_with_systems_locale).with("locale -a").and_return(shell_out)
+ allow(Chef::Config).to receive(:shell_out_with_systems_locale!).with("locale -a").and_return(shell_out)
end
shared_examples_for "a suitable locale" do
@@ -493,7 +493,7 @@ describe Chef::Config do
let(:locale_array) { [] }
before do
- allow(Chef::Config).to receive(:shell_out_with_systems_locale).and_raise("THIS IS AN ERROR")
+ allow(Chef::Config).to receive(:shell_out_with_systems_locale!).and_raise("THIS IS AN ERROR")
end
it "should default to 'en_US.UTF-8'" do
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index a1903a1948..760ae5dd2a 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -441,7 +441,7 @@ describe Chef::Cookbook::Metadata do
}.not_to raise_error
end
- it "should let type be hash (backwards compatability only)" do
+ it "should let type be hash (backwards compatibility only)" do
expect {
metadata.attribute("db/mysql/databases", :type => "hash")
}.not_to raise_error
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index 3d0348553b..6dd3429ffc 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -396,7 +396,7 @@ describe Chef::CookbookVersion do
expect(@cookbook_version).to have_template_for_node(@node, ["test.erb"])
end
- it "should see a template using an array lookup with non-existant elements" do
+ it "should see a template using an array lookup with non-existent elements" do
expect(@cookbook_version).to have_template_for_node(@node, ["missing.txt", "test.erb"])
end
@@ -408,23 +408,23 @@ describe Chef::CookbookVersion do
expect(@cookbook_version).to have_cookbook_file_for_node(@node, ["test.txt"])
end
- it "should see a file using an array lookup with non-existant elements" do
+ it "should see a file using an array lookup with non-existent elements" do
expect(@cookbook_version).to have_cookbook_file_for_node(@node, ["missing.txt", "test.txt"])
end
- it "should not see a non-existant template" do
+ it "should not see a non-existent template" do
expect(@cookbook_version).not_to have_template_for_node(@node, "missing.erb")
end
- it "should not see a non-existant template using an array lookup" do
+ it "should not see a non-existent template using an array lookup" do
expect(@cookbook_version).not_to have_template_for_node(@node, ["missing.erb"])
end
- it "should not see a non-existant file" do
+ it "should not see a non-existent file" do
expect(@cookbook_version).not_to have_cookbook_file_for_node(@node, "missing.txt")
end
- it "should not see a non-existant file using an array lookup" do
+ it "should not see a non-existent file using an array lookup" do
expect(@cookbook_version).not_to have_cookbook_file_for_node(@node, ["missing.txt"])
end
diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
index ee957ed450..a42d234601 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -114,20 +114,20 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
describe "recipe_snippet" do
before do
# fake code to run through #recipe_snippet
- source_file = [ "if true", "var = non_existant", "end" ]
+ source_file = [ "if true", "var = non_existent", "end" ]
allow(IO).to receive(:readlines).and_return(source_file)
allow(File).to receive(:exists?).and_return(true)
end
it "parses a Windows path" do
- source_line = "C:/Users/btm/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existant' for main:Object (NameError)"
+ source_line = "C:/Users/btm/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)"
@resource.source_line = source_line
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
expect(@inspector.recipe_snippet).to match(/^# In C:\/Users\/btm/)
end
it "parses a unix path" do
- source_line = "/home/btm/src/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existant' for main:Object (NameError)"
+ source_line = "/home/btm/src/chef/chef/spec/unit/fake_file.rb:2: undefined local variable or method `non_existent' for main:Object (NameError)"
@resource.source_line = source_line
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
expect(@inspector.recipe_snippet).to match(/^# In \/home\/btm/)
@@ -145,7 +145,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
expect(@inspector.recipe_snippet).to be_nil
end
- it "does not raise an exception trying to load a non-existant file (CHEF-3411)" do
+ it "does not raise an exception trying to load a non-existent file (CHEF-3411)" do
@resource.source_line = "/somewhere/in/space"
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
expect { @inspector.recipe_snippet }.not_to raise_error
diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb
index a9aa0e0b50..e7f67405fc 100644
--- a/spec/unit/handler_spec.rb
+++ b/spec/unit/handler_spec.rb
@@ -84,7 +84,7 @@ describe Chef::Handler do
end
it "has a shortcut for the success? and failed? predicates" do
- expect(@handler.success?).to be_falsey # becuase there's an exception
+ expect(@handler.success?).to be_falsey # because there's an exception
expect(@handler.failed?).to be_truthy
end
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 1291571358..af8fa3f698 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -205,4 +205,18 @@ EXPECTED
end
end
+ describe "prerelease" do
+ it "isn't set in the config_content by default" do
+ expect(bootstrap_context.config_content).not_to include("prerelease")
+ end
+
+ describe "when configured via cli" do
+ let(:config) {{:prerelease => true}}
+
+ it "uses CLI value" do
+ expect(bootstrap_context.latest_current_chef_version_string).to eq("-p")
+ end
+ end
+ end
+
end
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index ea951e21dd..ceceef7178 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -66,9 +66,24 @@ describe Chef::Knife::NodeRunListRemove do
expect(@node.run_list).not_to include('role[monkey]')
expect(@node.run_list).not_to include('recipe[duck::type]')
end
+
+ it "should remove the items from the run list when name args contains whitespace" do
+ @node.run_list << 'role[monkey]'
+ @node.run_list << 'recipe[duck::type]'
+ @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]' ]
+ @knife.run
+ expect(@node.run_list).not_to include('role[monkey]')
+ expect(@node.run_list).not_to include('recipe[duck::type]')
+ end
+
+ it "should remove the items from the run list when name args contains multiple run lists" do
+ @node.run_list << 'role[blah]'
+ @node.run_list << 'recipe[duck::type]'
+ @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]', 'role[blah]' ]
+ @knife.run
+ expect(@node.run_list).not_to include('role[monkey]')
+ expect(@node.run_list).not_to include('recipe[duck::type]')
+ end
end
end
end
-
-
-
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index d35ba4fa5f..8f652e58c7 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -44,6 +44,10 @@ describe Chef::Knife do
@stderr = StringIO.new
end
+ after(:each) do
+ Chef::Knife.reset_config_loader!
+ end
+
describe "after loading a subcommand" do
before do
Chef::Knife.reset_subcommands!
@@ -64,7 +68,7 @@ describe Chef::Knife do
expect(KnifeSpecs::TestNameMapping.subcommand_category).to eq('test')
end
- it "has an explictly defined category if set" do
+ it "has an explicitly defined category if set" do
expect(KnifeSpecs::TestExplicitCategory.subcommand_category).to eq('cookbook site')
end
@@ -268,6 +272,7 @@ describe Chef::Knife do
@knife.config[:verbosity] = 1
@knife.config[:config_file] = fake_config
config_loader = double("Chef::WorkstationConfigLoader", :load => true, :no_config_found? => false, :chef_config_dir => "/etc/chef", :config_location => fake_config)
+ allow(config_loader).to receive(:explicit_config_file=).with(fake_config).and_return(fake_config)
allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
end
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb
index 0fb0ea7cab..35963dec64 100644
--- a/spec/unit/lwrp_spec.rb
+++ b/spec/unit/lwrp_spec.rb
@@ -247,7 +247,7 @@ describe "LWRP" do
end
end
- it "ammends actions when they are already defined" do
+ it "amends actions when they are already defined" do
raise_if_deprecated!
expect(child.actions).to eq([:eat, :sleep, :drink])
end
diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb
index 779445e04e..d107323f32 100644
--- a/spec/unit/mixin/deep_merge_spec.rb
+++ b/spec/unit/mixin/deep_merge_spec.rb
@@ -290,32 +290,6 @@ describe Chef::Mixin::DeepMerge do
end
- describe "role_merge" do
- it "errors out if knockout merge use is detected in an array" do
- hash_dst = {"property" => ["2","4"]}
- hash_src = {"property" => ["1","!merge:4"]}
- expect {@dm.role_merge(hash_dst, hash_src)}.to raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge)
- end
-
- it "errors out if knockout merge use is detected in an array (reversed merge order)" do
- hash_dst = {"property" => ["1","!merge:4"]}
- hash_src = {"property" => ["2","4"]}
- expect {@dm.role_merge(hash_dst, hash_src)}.to raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge)
- end
-
- it "errors out if knockout merge use is detected in a string" do
- hash_dst = {"property" => ["2","4"]}
- hash_src = {"property" => "!merge"}
- expect {@dm.role_merge(hash_dst, hash_src)}.to raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge)
- end
-
- it "errors out if knockout merge use is detected in a string (reversed merge order)" do
- hash_dst = {"property" => "!merge"}
- hash_src= {"property" => ["2","4"]}
- expect {@dm.role_merge(hash_dst, hash_src)}.to raise_error(Chef::Mixin::DeepMerge::InvalidSubtractiveMerge)
- end
- end
-
describe "hash-only merging" do
it "merges Hashes like normal deep merge" do
merge_ee_hash = {"top_level_a" => {"1_deep_a" => "1-a-merge-ee", "1_deep_b" => "1-deep-b-merge-ee"}, "top_level_b" => "top-level-b-merge-ee"}
diff --git a/spec/unit/monkey_patches/string_spec.rb b/spec/unit/monkey_patches/string_spec.rb
deleted file mode 100644
index 74e3753229..0000000000
--- a/spec/unit/monkey_patches/string_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Author:: Devin Ben-Hur <dbenhur@whitepages.com>
-# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'spec_helper'
-require 'chef/monkey_patches/string'
-
-describe String do
-
- describe "#ord" do
- it "converts each ASCII-8BIT character to corresponding positive Fixnum" do
- (0..0xff).each do |num|
- ch = num.chr
- ch.force_encoding('ASCII-8BIT') if ch.respond_to? :force_encoding
-
- expect(ch.ord).to be_a_kind_of(Fixnum)
- expect(ch.ord).to eq(num)
- end
- end
-
- end
-
-end
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 39e40a465f..c924ee2811 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -486,6 +486,34 @@ describe Chef::Node::Attribute do
expect(hash.class).to eq(Hash)
expect(hash["day"]).to eq("sunday")
end
+
+ it "should create a deep copy of the node attribute" do
+ @attributes.default['foo']['bar']['baz'] = 'fizz'
+ hash = @attributes['foo'].to_hash
+ expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
+ hash['bar']['baz'] = 'buzz'
+ expect(hash).to eql({"bar"=>{"baz"=>"buzz"}})
+ expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}})
+ end
+
+ it "should create a deep copy of arrays in the node attribute" do
+ @attributes.default['foo']['bar'] = ['fizz']
+ hash = @attributes['foo'].to_hash
+ expect(hash).to eql({"bar"=>[ 'fizz' ]})
+ hash['bar'].push('buzz')
+ expect(hash).to eql({"bar"=>[ 'fizz', 'buzz' ]})
+ expect(@attributes.default['foo']).to eql({"bar"=>[ 'fizz' ]})
+ end
+
+ it "mutating strings should not mutate the attributes" do
+ pending "this is a bug that should be fixed"
+ @attributes.default['foo']['bar']['baz'] = 'fizz'
+ hash = @attributes['foo'].to_hash
+ expect(hash).to eql({"bar"=>{"baz"=>"fizz"}})
+ hash['bar']['baz'] << 'buzz'
+ expect(hash).to eql({"bar"=>{"baz"=>"fizzbuzz"}})
+ expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}})
+ end
end
describe "dup" do
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index b1e7b9169b..d0ec81c7f7 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Node::ImmutableMash do
expect(@immutable_mash[:top][:second_level]).to eq("some value")
end
- it "elelment references like a regular Mash" do
+ it "element references like a regular Mash" do
expect(@immutable_mash[:top_level_2]).to eq(%w[array of values])
end
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index a3a4772229..b4960b2af3 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -536,6 +536,14 @@ describe Chef::Provider::Package::Rubygems do
expect(@provider.action_install).to be_truthy
end
+ it "installs the gem by shelling out when options are provided but no version is given" do
+ @new_resource.options('-i /alt/install/location')
+ @new_resource.version('')
+ expected ="gem install \"rspec-core\" -q --no-rdoc --no-ri -i /alt/install/location"
+ expect(@provider).to receive(:shell_out!).with(expected, :env => nil)
+ expect(@provider.action_install).to be_truthy
+ end
+
it "installs the gem via the gems api when options are given as a Hash" do
@new_resource.options(:install_dir => '/alt/install/location')
expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location')
diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb
index 01e28bf091..1371a8b9a6 100644
--- a/spec/unit/resource_definition_spec.rb
+++ b/spec/unit/resource_definition_spec.rb
@@ -85,7 +85,7 @@ describe Chef::ResourceDefinition do
expect(defn.recipe.call).to eql("I am what I am")
end
- it "should set paramaters based on method_missing" do
+ it "should set parameters based on method_missing" do
defn.mind "to fly"
expect(defn.params[:mind]).to eql("to fly")
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index bb02d91b23..335956009f 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -324,7 +324,7 @@ describe Chef::Resource do
expect(zm.is("one", "two", "three")).to eq(%w|one two three|)
end
- it "should allow arguments preceeded by is to methods" do
+ it "should allow arguments preceded by is to methods" do
@resource.noop(@resource.is(true))
expect(@resource.noop).to eql(true)
end
diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb
index 927257875e..859219d346 100644
--- a/spec/unit/run_list/run_list_expansion_spec.rb
+++ b/spec/unit/run_list/run_list_expansion_spec.rb
@@ -97,7 +97,7 @@ describe Chef::RunList::RunListExpansion do
expect(@expansion.recipes).to eq(['lobster', 'crabrevenge', 'fist'])
end
- it "has the merged attributes from the roles with outer roles overridding inner" do
+ it "has the merged attributes from the roles with outer roles overriding inner" do
expect(@expansion.default_attrs).to eq({'foo' => 'bar'})
expect(@expansion.override_attrs).to eq({'baz' => 'qux'})
end
@@ -109,7 +109,7 @@ describe Chef::RunList::RunListExpansion do
end
- describe "after expanding a run list with a non existant role" do
+ describe "after expanding a run list with a non existent role" do
before do
allow(@expansion).to receive(:fetch_role) { @expansion.role_not_found('crabrevenge', "role[base]") }
@expansion.expand
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index 58dea4c988..0e028f4359 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -47,7 +47,7 @@ describe Shell do
describe "reporting its status" do
- it "alway says it is running" do
+ it "always says it is running" do
expect(Shell).to be_running
end
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index c39c949991..e75e285d43 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -137,7 +137,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
describe "#find_configuration_document" do
it "should find the mof file" do
- # These tests seem way too implementation specific. Unfortunatly, File and Dir
+ # These tests seem way too implementation specific. Unfortunately, File and Dir
# need to be mocked because they are OS specific
allow(File).to receive(:join) do |a, b|
[a,b].join("++")
diff --git a/spec/unit/workstation_config_loader_spec.rb b/spec/unit/workstation_config_loader_spec.rb
index 0f60e3ec38..a865103188 100644
--- a/spec/unit/workstation_config_loader_spec.rb
+++ b/spec/unit/workstation_config_loader_spec.rb
@@ -219,7 +219,7 @@ describe Chef::WorkstationConfigLoader do
end
- context "when an explict config is given but it doesn't exist" do
+ context "when an explicit config is given but it doesn't exist" do
let(:explicit_config_location) { "/nope/nope/nope/frab/jab/nab" }