summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Preston <stuart@chef.io>2018-06-19 11:42:33 +0100
committerStuart Preston <stuart@chef.io>2018-06-19 11:42:33 +0100
commit3c3e56ed54266c2c084b3c623924c7aa8f980274 (patch)
tree14ac11f3b8efdab4945e3dec220cc038d3ab69cc
parent7b0577496c540c85772fd9284ede3f963337666f (diff)
parent20126dfb05fd75643b082bc5d6b601afad28197e (diff)
downloadchef-3c3e56ed54266c2c084b3c623924c7aa8f980274.tar.gz
Merge branch 'master' into sp/ffi-powershell
Signed-off-by: <>
-rw-r--r--.travis.yml57
-rw-r--r--CHANGELOG.md15
-rw-r--r--Gemfile.lock16
-rw-r--r--MAINTAINERS.md1
-rw-r--r--MAINTAINERS.toml1
-rw-r--r--RELEASE_NOTES.md49
-rw-r--r--VERSION2
-rw-r--r--acceptance/data-collector/.acceptance/data-collector-test/.gitignore2
-rw-r--r--chef-config/lib/chef-config/config.rb5
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef-universal-mingw32.gemspec2
-rw-r--r--kitchen-tests/Berksfile6
-rw-r--r--kitchen-tests/Gemfile3
-rw-r--r--kitchen-tests/README.md98
-rw-r--r--kitchen-tests/cookbooks/audit_test/.kitchen.yml16
-rw-r--r--kitchen-tests/cookbooks/audit_test/Berksfile3
-rw-r--r--kitchen-tests/cookbooks/audit_test/Berksfile.lock7
-rw-r--r--kitchen-tests/cookbooks/audit_test/README.md12
-rw-r--r--kitchen-tests/cookbooks/audit_test/metadata.rb7
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/default.rb26
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/error_duplicate_control_groups.rb17
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/error_no_block.rb7
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/error_orphan_control.rb13
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/failed_specs.rb14
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/serverspec_collision.rb31
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/serverspec_support.rb37
-rw-r--r--kitchen-tests/cookbooks/audit_test/recipes/with_include_recipe.rb16
-rw-r--r--kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/metadata.rb9
-rw-r--r--kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/recipes/default.rb8
-rw-r--r--kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/metadata.rb9
-rw-r--r--kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/recipes/default.rb8
-rw-r--r--kitchen-tests/data_bags/passwords/mysql.json5
-rw-r--r--kitchen-tests/kitchen.travis.yml (renamed from kitchen-tests/.kitchen.travis.yml)8
-rw-r--r--kitchen-tests/kitchen.yml (renamed from kitchen-tests/.kitchen.yml)9
-rw-r--r--lib/chef/chef_class.rb24
-rw-r--r--lib/chef/deprecated.rb282
-rw-r--r--lib/chef/formatters/base.rb15
-rw-r--r--lib/chef/formatters/doc.rb16
-rw-r--r--lib/chef/log.rb18
-rw-r--r--lib/chef/node_map.rb19
-rw-r--r--lib/chef/provider/windows_task.rb12
-rw-r--r--lib/chef/resource/homebrew_package.rb3
-rw-r--r--lib/chef/resource/http_request.rb7
-rw-r--r--lib/chef/resource/ifconfig.rb74
-rw-r--r--lib/chef/resource/ips_package.rb4
-rw-r--r--lib/chef/resource/launchd.rb303
-rw-r--r--lib/chef/resource/log.rb9
-rw-r--r--lib/chef/resource/mdadm.rb37
-rw-r--r--lib/chef/resource/windows_feature_dism.rb2
-rw-r--r--lib/chef/version.rb2
-rw-r--r--omnibus/.gitignore2
-rw-r--r--omnibus/Gemfile2
-rw-r--r--omnibus/Gemfile.lock21
-rw-r--r--omnibus/README.md81
-rw-r--r--omnibus/kitchen.vmware.yml (renamed from omnibus/.kitchen.vmware.yml)0
-rw-r--r--omnibus/kitchen.yml (renamed from omnibus/.kitchen.yml)26
-rw-r--r--spec/functional/resource/windows_task_spec.rb54
-rw-r--r--spec/integration/knife/common_options_spec.rb2
-rw-r--r--spec/unit/chef_class_spec.rb120
-rw-r--r--spec/unit/deprecated_spec.rb30
-rw-r--r--spec/unit/node_map_spec.rb14
61 files changed, 856 insertions, 844 deletions
diff --git a/.travis.yml b/.travis.yml
index 36fd343809..84d8c71543 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -132,7 +132,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- AMAZON=2
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -149,7 +149,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- AMAZON=201X
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -166,7 +166,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- UBUNTU=14.04
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -183,7 +183,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- UBUNTU=16.04
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -200,7 +200,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- UBUNTU=18.04
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -217,7 +217,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- DEBIAN=8
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -234,7 +234,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- DEBIAN=9
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -251,7 +251,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- CENTOS=6
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -268,7 +268,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- CENTOS=7
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -285,7 +285,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- FEDORA=latest
- - KITCHEN_YAML=.kitchen.travis.yml
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
@@ -302,42 +302,7 @@ matrix:
- cat .kitchen/logs/kitchen.log
env:
- OPENSUSELEAP=42
- - KITCHEN_YAML=.kitchen.travis.yml
-# - rvm: 2.4.4
-# services: docker
-# sudo: required
-# gemfile: kitchen-tests/Gemfile
-# before_install:
-# - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
-# - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2)
-# before_script:
-# - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
-# - cd kitchen-tests
-# script:
-# - bundle exec kitchen test awesome-customers-ubuntu-ubuntu-1404
-# after_failure:
-# - cat .kitchen/logs/kitchen.log
-# env:
-# - AWESOME_CUSTOMERS_UBUNTU=1
-# - KITCHEN_YAML=.kitchen.travis.yml
-# - rvm: 2.4.4
-# services: docker
-# sudo: required
-# gemfile: kitchen-tests/Gemfile
-# before_install:
-# - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
-# - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2)
-# before_script:
-# - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
-# - cd kitchen-tests
-# script:
-# - bundle exec kitchen test awesome-customers-rhel-centos-7
-# after_failure:
-# - cat .kitchen/logs/kitchen.log
-# env:
-# - AWESOME_CUSTOMERS_RHEL=1
-# - KITCHEN_YAML=.kitchen.travis.yml
-# ### END TEST KITCHEN ONLY ###
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.5.1
sudo: required
before_install:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19cadd50b0..1043b0ce04 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,24 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
-<!-- latest_release 14.3.10 -->
-## [v14.3.10](https://github.com/chef/chef/tree/v14.3.10) (2018-06-13)
+<!-- latest_release unreleased -->
+## Unreleased
#### Merged Pull Requests
-- package: Make sure to use the package_name name properties [#7365](https://github.com/chef/chef/pull/7365) ([tas50](https://github.com/tas50))
+- Remove the unused audit test cookbook [#7378](https://github.com/chef/chef/pull/7378) ([tas50](https://github.com/tas50))
<!-- latest_release -->
<!-- release_rollup since=14.2.0 -->
### Changes since 14.2.0 release
#### Merged Pull Requests
+- Remove the unused audit test cookbook [#7378](https://github.com/chef/chef/pull/7378) ([tas50](https://github.com/tas50)) <!-- 14.3.17 -->
+- Silence deprecation warnings [#7375](https://github.com/chef/chef/pull/7375) ([coderanger](https://github.com/coderanger)) <!-- 14.3.17 -->
+- Remove awesome customers testing and update kitchen configs [#7377](https://github.com/chef/chef/pull/7377) ([tas50](https://github.com/tas50)) <!-- 14.3.16 -->
+- windows_task: Fix for task is not idempotent when task name includes parent folder [#7293](https://github.com/chef/chef/pull/7293) ([Vasu1105](https://github.com/Vasu1105)) <!-- 14.3.16 -->
+- windows_task: Don&#39;t allow bad username/password to be provided to a task which will fail later [#7288](https://github.com/chef/chef/pull/7288) ([Vasu1105](https://github.com/Vasu1105)) <!-- 14.3.15 -->
+- Pull in win32-taskscheduler 1.0.2 [#7371](https://github.com/chef/chef/pull/7371) ([tas50](https://github.com/tas50)) <!-- 14.3.14 -->
+- removing mwrock from client maintainers [#7369](https://github.com/chef/chef/pull/7369) ([mwrock](https://github.com/mwrock)) <!-- 14.3.13 -->
+- Add more property descriptions to resources [#7358](https://github.com/chef/chef/pull/7358) ([tas50](https://github.com/tas50)) <!-- 14.3.12 -->
+- windows_feature_dism: Fix errors when specifying the source [#7370](https://github.com/chef/chef/pull/7370) ([tas50](https://github.com/tas50)) <!-- 14.3.11 -->
- package: Make sure to use the package_name name properties [#7365](https://github.com/chef/chef/pull/7365) ([tas50](https://github.com/tas50)) <!-- 14.3.10 -->
- Add missing chef/resource requires in resource [#7364](https://github.com/chef/chef/pull/7364) ([tas50](https://github.com/tas50)) <!-- 14.3.9 -->
- Update to the latest inspec and liblzma [#7355](https://github.com/chef/chef/pull/7355) ([tas50](https://github.com/tas50)) <!-- 14.3.8 -->
diff --git a/Gemfile.lock b/Gemfile.lock
index 1a19afb6c7..fa10f12837 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -9,10 +9,10 @@ GIT
PATH
remote: .
specs:
- chef (14.3.10)
+ chef (14.3.17)
addressable
bundler (>= 1.10)
- chef-config (= 14.3.10)
+ chef-config (= 14.3.17)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -40,10 +40,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (14.3.10-universal-mingw32)
+ chef (14.3.17-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 14.3.10)
+ chef-config (= 14.3.17)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -79,14 +79,14 @@ PATH
win32-mutex (~> 0.4.2)
win32-process (~> 0.8.2)
win32-service (~> 0.8.7)
- win32-taskscheduler (~> 0.4.0)
+ win32-taskscheduler (~> 1.0.0)
windows-api (~> 0.4.4)
wmi-lite (~> 1.0)
PATH
remote: chef-config
specs:
- chef-config (14.3.10)
+ chef-config (14.3.17)
addressable
fuzzyurl
mixlib-config (~> 2.0)
@@ -179,7 +179,7 @@ GEM
mixlib-log
mixlib-authentication (2.1.1)
mixlib-cli (1.7.0)
- mixlib-config (2.2.6)
+ mixlib-config (2.2.8)
tomlrb
mixlib-log (2.0.4)
mixlib-shellout (2.3.2)
@@ -339,7 +339,7 @@ GEM
win32-service (0.8.10)
ffi
ffi-win32-extensions
- win32-taskscheduler (0.4.1)
+ win32-taskscheduler (1.0.2)
ffi
structured_warnings
windows-api (0.4.4)
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index 536d9b6629..d0acb37daf 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -40,7 +40,6 @@ To mention the team, use @chef/client-core
* [Joshua Timberman](https://github.com/jtimberman)
* [Lamont Granquist](https://github.com/lamont-granquist)
* [Claire McQuin](https://github.com/mcquin)
-* [Matt Wrock](https://github.com/mwrock)
* [Ranjib Dey](https://github.com/ranjib)
* [Steven Murawski](https://github.com/smurawski)
* [Steven Danna](https://github.com/stevendanna)
diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml
index ce4f514d89..1d0888eb6e 100644
--- a/MAINTAINERS.toml
+++ b/MAINTAINERS.toml
@@ -46,7 +46,6 @@ Maintainers for the Chef client, Ohai, mixlibs, ChefDK, ChefSpec, Foodcritic, ch
"jtimberman",
"lamont-granquist",
"mcquin",
- "mwrock",
"ranjib",
"smurawski",
"stevendanna",
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index d9747c80df..85181821c6 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,5 +1,54 @@
This file holds "in progress" release notes for the current release under development and is intended for consumption by the Chef Documentation team. Please see <https://docs.chef.io/release_notes.html> for the official Chef release notes.
+## Silencing deprecation warnings
+
+While deprecation warnings have been great for the Chef community to ensure
+cookbooks are kept up-to-date and to prepare for major version upgrades, sometimes
+you just can't fix a deprecation right now. This is often compounded by the
+recommendation to enable `treat_deprecation_warnings_as_errors` mode in your
+Test Kitchen integration tests, which doesn't understand the difference between
+deprecations from community cookbooks and those from your own code.
+
+Two new options are provided for silencing deprecation warnings: `silence_deprecation_warnings`
+and inline `chef:silence_deprecation` comments.
+
+The `silence_deprecation_warnings` configuration value can be set in your
+`client.rb` or `solo.rb` config file, either to `true` to silence all deprecation
+warnings or to an array of deprecations to silence. You can specify which to
+silence either by the deprecation key name (e.g. `"internal_api"`), the numeric
+deprecation ID (e.g. `25` or `"CHEF-25"`), or by specifying the filename and
+line number where the deprecation is being raised from (e.g. `"default.rb:67"`).
+
+An example of setting the `silence_deprecation_warnings` option in your `client.rb`
+or `solo.rb`:
+
+```ruby
+silence_deprecation_warnings %w{deploy_resource chef-23 recipes/install.rb:22}
+```
+
+or in your `kitchen.yml`:
+
+```yaml
+provisioner:
+ name: chef_solo
+ solo_rb:
+ treat_deprecation_warnings_as_errors: true
+ silence_deprecation_warnings:
+ - deploy_resource
+ - chef-23
+ - recipes/install.rb:22
+```
+
+You can also silence deprecations using a comment on the line that is raising
+the warning:
+
+```ruby
+erl_call 'something' do # chef:silence_deprecation
+```
+
+We advise caution in the use of this feature, as excessive or prolonged silencing
+can lead to difficulty upgrading when the next major release of Chef comes out.
+
# Chef Client Release Notes 14.2:
## `ssh-agent` support for user keys
diff --git a/VERSION b/VERSION
index 3049607924..51aa22115e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.3.10 \ No newline at end of file
+14.3.17 \ No newline at end of file
diff --git a/acceptance/data-collector/.acceptance/data-collector-test/.gitignore b/acceptance/data-collector/.acceptance/data-collector-test/.gitignore
index ec2a890bd3..f0c21602ee 100644
--- a/acceptance/data-collector/.acceptance/data-collector-test/.gitignore
+++ b/acceptance/data-collector/.acceptance/data-collector-test/.gitignore
@@ -13,4 +13,4 @@ bin/*
.bundle/*
.kitchen/
-.kitchen.local.yml
+kitchen.local.yml
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 82f25f4139..ed8fab9ee4 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -715,6 +715,11 @@ module ChefConfig
ENV.key?("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
end
+ # Which deprecations warnings to silence. Can be set to `true` to silence
+ # all warnings, or an array of strings like either `"deprecation_type"` or
+ # `"filename.rb:lineno"`.
+ default :silence_deprecation_warnings, []
+
# Whether the resource count should be updated for log resource
# on running chef-client
default :count_log_resource_updates, true
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 5abec24b0d..311c80b218 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "14.3.10"
+ VERSION = "14.3.17"
end
#
diff --git a/chef-universal-mingw32.gemspec b/chef-universal-mingw32.gemspec
index a4949db712..05877d19b3 100644
--- a/chef-universal-mingw32.gemspec
+++ b/chef-universal-mingw32.gemspec
@@ -14,7 +14,7 @@ gemspec.add_dependency "win32-process", "~> 0.8.2"
gemspec.add_dependency "win32-service", "~> 0.8.7"
gemspec.add_dependency "windows-api", "~> 0.4.4"
gemspec.add_dependency "wmi-lite", "~> 1.0"
-gemspec.add_dependency "win32-taskscheduler", "~> 0.4.0"
+gemspec.add_dependency "win32-taskscheduler", "~> 1.0.0"
gemspec.extensions << "ext/win32-eventlog/Rakefile"
gemspec.files += %w{ext/win32-eventlog/Rakefile ext/win32-eventlog/chef-log.man}
diff --git a/kitchen-tests/Berksfile b/kitchen-tests/Berksfile
index 22f838d83e..ea45042a2e 100644
--- a/kitchen-tests/Berksfile
+++ b/kitchen-tests/Berksfile
@@ -1,9 +1,3 @@
source "https://supermarket.chef.io"
cookbook "base", path: "cookbooks/base"
-
-# Disabled pending updating these test cases for Chef 13.
-# cookbook "awesome_customers_ubuntu_wrapper", path: "cookbooks/awesome_customers_ubuntu_wrapper"
-# cookbook "awesome_customers_ubuntu", github: "lamont-granquist/awesome_customers_ubuntu", branch: "lcg/bump-mysql-version"
-# cookbook "awesome_customers_rhel_wrapper", path: "cookbooks/awesome_customers_rhel_wrapper"
-# cookbook "awesome_customers_rhel", github: "lamont-granquist/awesome_customers_rhel", branch: "lcg/bump-mysql-version"
diff --git a/kitchen-tests/Gemfile b/kitchen-tests/Gemfile
index 9cc63fb7d6..3505c5f32e 100644
--- a/kitchen-tests/Gemfile
+++ b/kitchen-tests/Gemfile
@@ -2,8 +2,7 @@ source "https://rubygems.org"
gem "rake" # required to build some native extensions
gem "chef", path: ".."
-# remove this ohai pin once we ship the 14 gem
-gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master"
+gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master" # avoids failures when we bump chef major
gem "berkshelf", git: "https://github.com/berkshelf/berkshelf.git", branch: "master"
gem "kitchen-appbundle-updater", git: "https://github.com/chef/kitchen-appbundle-updater", branch: "master"
gem "kitchen-dokken", "< 2.0" # 2.x fails atm: https://travis-ci.org/chef/chef/jobs/199125787
diff --git a/kitchen-tests/README.md b/kitchen-tests/README.md
index 2d03b19b62..8dcf9702a5 100644
--- a/kitchen-tests/README.md
+++ b/kitchen-tests/README.md
@@ -1,18 +1,16 @@
# End-To-End Testing for Chef Client
-Here we seek to provide end-to-end testing of Chef Client through cookbooks which
-exercise many of the available resources, providers, and common patterns. The cookbooks
-here are designed to ensure certain capabilities remain functional with updates
-to the client code base.
+
+Here we seek to provide end-to-end testing of Chef Client through cookbooks which exercise many of the available resources, providers, and common patterns. The cookbooks here are designed to ensure certain capabilities remain functional with updates to the client code base.
## Getting started
+
All the gems needed to run these tests can be installed with Bundler.
```shell
chef/kitchen-tests$ bundle install
```
-To ensure everything is working properly, and to see which platforms can have tests
-executed on them, run
+To ensure everything is working properly, and to see which platforms can have tests executed on them, run
```shell
chef/kitchen-tests$ bundle exec kitchen list
@@ -21,69 +19,55 @@ chef/kitchen-tests$ bundle exec kitchen list
You should see output similar to
```shell
-Instance Driver Provisioner Last Action
-webapp-ubuntu-1204 Vagrant ChefSolo <Not Created>
+Instance Driver Provisioner Verifier Transport Last Action Last Error
+base-amazonlinux Vagrant ChefGithub Inspec Ssh <Not Created> <None>
```
## Testing
-We use Test Kitchen to build instances, test client code, and destroy instances. If
-you are unfamiliar with Test Kitchen we recommend checking out the [tutorial](http://kitchen.ci/)
-along with the `kitchen-vagrant` [driver documentation](https://github.com/test-kitchen/kitchen-vagrant).
-Test Kitchen is configured to manipulate instances using [Vagrant](http://www.vagrantup.com/)
-when testing locally, and [Amazon EC2](http://aws.amazon.com/ec2/) when testing
-pull requests on [Travis CI](https://travis-ci.com).
+
+We use Test Kitchen to build instances, test client code, and destroy instances. If you are unfamiliar with Test Kitchen we recommend checking out the [tutorial](http://kitchen.ci/) along with the `kitchen-vagrant` [driver documentation](https://github.com/test-kitchen/kitchen-vagrant). Test Kitchen is configured to manipulate instances using [Vagrant](https://www.vagrantup.com/) when testing locally, and Docker via [kitchen-dokken](https://github.com/someara/kitchen-dokken/) when testing pull requests on [Travis CI](https://travis-ci.com/).
### Commands
-Kitchen instances are led through a series of states. The instance states, and the actions
-taken to transition into each state, are in order:
-* `destroy`: Delete all information for and terminate one or more instances.
- * This is equivalent to running `vagrant destroy` to stop and delete a Vagrant machine.
-* `create`: Start one or more instances.
- * This is equivalent to running `vagrant up --no-provision` to start a Vagrant instance.
-* `converge`: Use a provisioner to configure one or more instances.
- * By default, Test Kitchen is configured to use the `ChefSolo` provisioner which:
- * Prepares local files for transfer,
- * Installs the latest release of Chef Omnibus,
- * Downloads Chef Client source code from the prescribed GitHub repository and reference,
- * Builds and installs a `chef` gem from the downloaded source,
- * Runs `chef-client`.
-* `setup`: Prepare to run automated tests. Installs `busser` and related gems on one or more instances.
-* `verify`: Run automated tests on one or more instances.
-
-When transitioning between states, actions for any and all intermediate states will performed.
-Executing the `create` then the `verify` commands is equivalent to executing `create`, `converge`,
-`setup`, and `verify` one-by-one and in order. The only exception is `destroy`, which will
-immediately transfer that machine's state to destroyed.
-
-The `test` command takes one or more instances through all the states, in order: `destroy`, `create`,
-`converge`, `setup`, `verify`, `destroy`.
-
-To see a list of available commands, type `bundle exec kitchen help`. To see more information
-about a particular command, type `bundle exec kitchen help <command>`.
+
+Kitchen instances are led through a series of states. The instance states, and the actions taken to transition into each state, are in order:
+
+- `destroy`: Delete all information for and terminate one or more instances.
+ - This is equivalent to running `vagrant destroy` to stop and delete a Vagrant machine.
+- `create`: Start one or more instances.
+ - This is equivalent to running `vagrant up --no-provision` to start a Vagrant instance.
+- `converge`: Use a provisioner to configure one or more instances.
+ - By default, Test Kitchen is configured to use the `ChefSolo` provisioner which:
+ - Prepares local files for transfer,
+ - Installs the latest release of Chef Omnibus,
+ - Downloads Chef Client source code from the prescribed GitHub repository and reference,
+ - Builds and installs a `chef` gem from the downloaded source,
+ - Runs `chef-client`.
+- `setup`: Prepare the instance to run automated tests.
+- `verify`: Run automated tests on one or more instances.
+
+When transitioning between states, actions for any and all intermediate states will performed. Executing the `create` then the `verify` commands is equivalent to executing `create`, `converge`, `setup`, and `verify` one-by-one and in order. The only exception is `destroy`, which will immediately transfer that machine's state to destroyed.
+
+The `test` command takes one or more instances through all the states, in order: `destroy`, `create`, `converge`, `setup`, `verify`, `destroy`.
+
+To see a list of available commands, type `bundle exec kitchen help`. To see more information about a particular command, type `bundle exec kitchen help <command>`.
### Configuring your tests
-Test Kitchen is configured for local testing in the `.kitchen.yml` file which resides in this directory.
-You will need to configure the provisioner before running the tests.
-The provisioner can be configured to pull client source code from a GitHub repository using any
-valid Git reference. You are encouraged to modify any of these settings, but please return them
-to their original values before submitting a pull request for review (unless, of course, your
-changes are enhancements to the default provisioner settings).
+Test Kitchen is configured for local testing in the `kitchen.yml` file which resides in this directory. You will need to configure the provisioner before running the tests.
+
+The provisioner can be configured to pull client source code from a GitHub repository using any valid Git reference. You are encouraged to modify any of these settings, but please return them to their original values before submitting a pull request for review (unless, of course, your changes are enhancements to the default provisioner settings).
-By default, the provisioner is configured to pull your most recent commit to `opscode/chef`. You
-can change this by modifying the `github` and `branch` provisioner options:
-* `github`: Set this to `"<your_username>/<your_chef_repo>"`. The default is `"opscode/chef"`.
-* `branch`: This can be any valid git reference (e.g., branch name, tag, or commit SHA). If omitted, it defaults to `master`.
+By default, the provisioner is configured to pull your most recent commit to `chef/chef`. You can change this by modifying the `github` and `branch` provisioner options:
+
+- `github`: Set this to `"<your_username>/<your_chef_repo>"`. The default is `"chef/chef"`.
+- `branch`: This can be any valid git reference (e.g., branch name, tag, or commit SHA). If omitted, it defaults to `master`.
The branch you choose must be accessible on GitHub. You cannot use a local commit at this time.
### Testing pull requests
-These end-to-end tests are also configured to run with Travis on EC2 instances when you submit a pull request
-to `opscode/chef`. Kitchen is configured to pull chef client source code from the branch it is testing. There
-is no need to modify `.kitchen.travis.yml` unless you are contributing tests.
+
+These end-to-end tests are also configured to run on Travis-CI with docker containers when you submit a pull request to `chef/chef`. Kitchen is configured to pull chef client source code from the branch it is testing. There is no need to modify `kitchen.travis.yml` unless you are contributing tests.
## Contributing
-We would love to fill out our end-to-end testing coverage! If you have cookbooks and tests that you would
-like to see become a part of client testing, we encourage you to submit a pull request with your additions.
-We request that you do not add platforms to `.kitchen.travis.yml`. Please file a request to add a
-platform under [Issues](https://github.com/opscode/chef/issues).
+
+We would love to fill out our end-to-end testing coverage! If you have cookbooks and tests that you would like to see become a part of client testing, we encourage you to submit a pull request with your additions. We request that you do not add platforms to `kitchen.travis.yml`. Please file a request to add a platform under [Issues](https://github.com/chef/chef/issues).
diff --git a/kitchen-tests/cookbooks/audit_test/.kitchen.yml b/kitchen-tests/cookbooks/audit_test/.kitchen.yml
deleted file mode 100644
index be11e33081..0000000000
--- a/kitchen-tests/cookbooks/audit_test/.kitchen.yml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-driver:
- name: vagrant
-
-provisioner:
- name: chef_zero
-
-platforms:
- - name: ubuntu-12.04
- - name: centos-6.5
-
-suites:
- - name: default
- run_list:
- - recipe[audit_test::default]
- attributes:
diff --git a/kitchen-tests/cookbooks/audit_test/Berksfile b/kitchen-tests/cookbooks/audit_test/Berksfile
deleted file mode 100644
index 967b9a78b6..0000000000
--- a/kitchen-tests/cookbooks/audit_test/Berksfile
+++ /dev/null
@@ -1,3 +0,0 @@
-source "https://supermarket.chef.io"
-
-metadata
diff --git a/kitchen-tests/cookbooks/audit_test/Berksfile.lock b/kitchen-tests/cookbooks/audit_test/Berksfile.lock
deleted file mode 100644
index ef9f28a3be..0000000000
--- a/kitchen-tests/cookbooks/audit_test/Berksfile.lock
+++ /dev/null
@@ -1,7 +0,0 @@
-DEPENDENCIES
- audit_test
- path: .
- metadata: true
-
-GRAPH
- audit_test (0.1.0)
diff --git a/kitchen-tests/cookbooks/audit_test/README.md b/kitchen-tests/cookbooks/audit_test/README.md
deleted file mode 100644
index 75e2f44808..0000000000
--- a/kitchen-tests/cookbooks/audit_test/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# audit_test
-
-This cookbook has some basic recipes to test audit mode.
-
-In order to run these tests on your dev box:
-
-```
-$ bundle install
-$ bundle exec chef-client -c kitchen-tests/.chef/client.rb -z -o audit_test::default -l debug
-```
-
-Expected JSON output for the tests will be printed to `debug` log.
diff --git a/kitchen-tests/cookbooks/audit_test/metadata.rb b/kitchen-tests/cookbooks/audit_test/metadata.rb
deleted file mode 100644
index 2b34ce28d0..0000000000
--- a/kitchen-tests/cookbooks/audit_test/metadata.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-name "audit_test"
-maintainer "The Authors"
-maintainer_email "you@example.com"
-license "Apache-2.0"
-description "Installs/Configures audit_test"
-long_description "Installs/Configures audit_test"
-version "0.1.0"
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/default.rb b/kitchen-tests/cookbooks/audit_test/recipes/default.rb
deleted file mode 100644
index 886c2cd0ac..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/default.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: default
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-control_group "basic control group" do
- control "basic math" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
- end
-end
-
-control_group "control group without top level control" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
-end
-
-control_group "control group with empty control" do
- control "empty"
-end
-
-control_group "empty control group with block" do
-end
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/error_duplicate_control_groups.rb b/kitchen-tests/cookbooks/audit_test/recipes/error_duplicate_control_groups.rb
deleted file mode 100644
index 2b5b8b5d22..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/error_duplicate_control_groups.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: error_duplicate_control_groups
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-control_group "basic control group" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
-end
-
-control_group "basic control group" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
-end
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/error_no_block.rb b/kitchen-tests/cookbooks/audit_test/recipes/error_no_block.rb
deleted file mode 100644
index e4c444e8bc..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/error_no_block.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: error_no_block
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-control_group "empty control group without block"
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/error_orphan_control.rb b/kitchen-tests/cookbooks/audit_test/recipes/error_orphan_control.rb
deleted file mode 100644
index 61d809a7c0..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/error_orphan_control.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: error_orphan_control
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-control_group "basic control group" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
-end
-
-control "orphan control"
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/failed_specs.rb b/kitchen-tests/cookbooks/audit_test/recipes/failed_specs.rb
deleted file mode 100644
index 9e6adfe2e9..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/failed_specs.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: failed_specs
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-control_group "basic control group" do
- control "basic math" do
- # Can not write a good control :(
- it "should pass" do
- expect(2 - 0).to eq(0)
- end
- end
-end
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/serverspec_collision.rb b/kitchen-tests/cookbooks/audit_test/recipes/serverspec_collision.rb
deleted file mode 100644
index 36dd714cef..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/serverspec_collision.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: serverspec_collision
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-file "/tmp/audit_test_file" do
- action :create
- content "Welcome to audit mode."
-end
-
-control_group "file auditing" do
- describe "test file" do
- it "says welcome" do
- expect(file("/tmp/audit_test_file")).to contain("Welcome")
- end
- end
-end
-
-file "/tmp/audit_test_file_2" do
- action :create
- content "Bye to audit mode."
-end
-
-control_group "end file auditing" do
- describe "end file" do
- it "says bye" do
- expect(file("/tmp/audit_test_file_2")).to contain("Bye")
- end
- end
-end
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/serverspec_support.rb b/kitchen-tests/cookbooks/audit_test/recipes/serverspec_support.rb
deleted file mode 100644
index fc44fb334e..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/serverspec_support.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: serverspec_support
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-file "/tmp/audit_test_file" do
- action :create
- content "Welcome to audit mode."
-end
-
-# package "curl" do
-# action :install
-# end
-
-control_group "serverspec helpers with types" do
- control "file helper" do
- it "says welcome" do
- expect(file("/tmp/audit_test_file")).to contain("Welcome")
- end
- end
-
- control service("com.apple.CoreRAID") do
- it { is_expected.to be_enabled }
- it { is_expected.not_to be_running }
- end
-
- # describe "package helper" do
- # it "works" do
- # expect(package("curl")).to be_installed
- # end
- # end
-
- control package("postgresql") do
- it { is_expected.to_not be_installed }
- end
-end
diff --git a/kitchen-tests/cookbooks/audit_test/recipes/with_include_recipe.rb b/kitchen-tests/cookbooks/audit_test/recipes/with_include_recipe.rb
deleted file mode 100644
index 7727c573c7..0000000000
--- a/kitchen-tests/cookbooks/audit_test/recipes/with_include_recipe.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Cookbook Name:: audit_test
-# Recipe:: with_include_recipe
-#
-# Copyright 2014-2016, The Authors, All Rights Reserved.
-
-include_recipe "audit_test::serverspec_collision"
-
-control_group "basic example" do
- it "should pass" do
- expect(2 - 2).to eq(0)
- end
-end
-
-include_recipe "audit_test::serverspec_collision"
-include_recipe "audit_test::default"
diff --git a/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/metadata.rb b/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/metadata.rb
deleted file mode 100644
index 49dbb50869..0000000000
--- a/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/metadata.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-name "awesome_customers_rhel_wrapper"
-maintainer "The Authors"
-maintainer_email "you@example.com"
-license "Apache-2.0"
-description "Installs/Configures awesome_customers_rhel"
-long_description "Installs/Configures awesome_customers_rhel"
-version "0.1.0"
-
-depends "awesome_customers_rhel"
diff --git a/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/recipes/default.rb b/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/recipes/default.rb
deleted file mode 100644
index c58db5fe29..0000000000
--- a/kitchen-tests/cookbooks/awesome_customers_rhel_wrapper/recipes/default.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Cookbook:: awesome_customers_rhel
-# Recipe:: default
-#
-# Copyright:: 2014-2017, Chef Software, Inc.
-#
-
-include_recipe "awesome_customers_rhel::default"
diff --git a/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/metadata.rb b/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/metadata.rb
deleted file mode 100644
index d07a2c2c13..0000000000
--- a/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/metadata.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-name "awesome_customers_ubuntu_wrapper"
-maintainer "The Authors"
-maintainer_email "you@example.com"
-license "Apache-2.0"
-description "Installs/Configures awesome_customers_ubuntu"
-long_description "Installs/Configures awesome_customers_ubuntu"
-version "0.1.0"
-
-depends "awesome_customers_ubuntu"
diff --git a/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/recipes/default.rb b/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/recipes/default.rb
deleted file mode 100644
index f6fd388f16..0000000000
--- a/kitchen-tests/cookbooks/awesome_customers_ubuntu_wrapper/recipes/default.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Cookbook:: awesome_customers_ubuntu
-# Recipe:: default
-#
-# Copyright:: 2016-2017, Chef Software, Inc.
-#
-
-include_recipe "awesome_customers_ubuntu::default"
diff --git a/kitchen-tests/data_bags/passwords/mysql.json b/kitchen-tests/data_bags/passwords/mysql.json
deleted file mode 100644
index af02a6a858..0000000000
--- a/kitchen-tests/data_bags/passwords/mysql.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "id": "mysql",
- "server_root_password": "ilikerandompasswordstoo",
- "server_repl_password": "itoolikerandompasswords"
-}
diff --git a/kitchen-tests/.kitchen.travis.yml b/kitchen-tests/kitchen.travis.yml
index 7f1cc94667..7daf95195f 100644
--- a/kitchen-tests/.kitchen.travis.yml
+++ b/kitchen-tests/kitchen.travis.yml
@@ -121,11 +121,3 @@ suites:
- name: base
run_list:
- recipe[base::default]
- - name: awesome_customers_ubuntu
- includes: [ubuntu-14.04, ubuntu-16.04, ubuntu-18.04]
- run_list:
- - recipe[awesome_customers_ubuntu_wrapper::default]
- - name: awesome_customers_rhel
- includes: [centos-6, centos-7]
- run_list:
- - recipe[awesome_customers_rhel_wrapper::default]
diff --git a/kitchen-tests/.kitchen.yml b/kitchen-tests/kitchen.yml
index b449265ce7..9133401c7c 100644
--- a/kitchen-tests/.kitchen.yml
+++ b/kitchen-tests/kitchen.yml
@@ -31,16 +31,9 @@ platforms:
- name: opensuse-leap-42
- name: ubuntu-14.04
- name: ubuntu-16.04
+ - name: ubuntu-18.04
suites:
- name: base
run_list:
- recipe[base::default]
- - name: awesome_customers_ubuntu
- includes: [ubuntu-14.04, ubuntu-16.04]
- run_list:
- - recipe[awesome_customers_ubuntu_wrapper::default]
- - name: awesome_customers_rhel
- includes: [centos-6, centos-7]
- run_list:
- - recipe[awesome_customers_rhel_wrapper::default]
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index bfea51609a..95b03f1c5c 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -200,13 +200,14 @@ class Chef
#
# Emit a deprecation message.
#
- # @param [Symbol] type The message to send. This should refer to a class
+ # @param type [Symbol] The message to send. This should refer to a class
# defined in Chef::Deprecated
- # @param message An explicit message to display, rather than the generic one
- # associated with the deprecation.
- # @param location The location. Defaults to the caller who called you (since
- # generally the person who triggered the check is the one that needs to be
- # fixed).
+ # @param message [String, nil] An explicit message to display, rather than
+ # the generic one associated with the deprecation.
+ # @param location [String, nil] The location. Defaults to the caller who
+ # called you (since generally the person who triggered the check is the one
+ # that needs to be fixed).
+ # @return [void]
#
# @example
# Chef.deprecated(:my_deprecation, message: "This is deprecated!")
@@ -220,11 +221,18 @@ class Chef
# run. If we are not yet in a run, print to `Chef::Log`.
if run_context && run_context.events
run_context.events.deprecation(deprecation, location)
- else
- Chef::Log.deprecation(deprecation, location)
+ elsif !deprecation.silenced?
+ Chef::Log.deprecation(deprecation.to_s)
end
end
+ # Log a generic deprecation warning that doesn't have a specific class in
+ # Chef::Deprecated.
+ #
+ # This should generally not be used, as the user will not be given a link
+ # to get more infomration on fixing the deprecation warning.
+ #
+ # @see #deprecated
def log_deprecation(message, location = nil)
location ||= Chef::Log.caller_location
Chef.deprecated(:generic, message, location)
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 904578ff0b..d9a8df7b83 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -24,276 +24,196 @@ class Chef
class << self
include Chef::Mixin::ConvertToClassName
- def create(type, message = nil, location = nil)
- Chef::Deprecated.const_get(convert_to_class_name(type.to_s)).send(:new, message, location)
+ def create(type, message, location)
+ Chef::Deprecated.const_get(convert_to_class_name(type.to_s)).new(message, location)
end
end
class Base
BASE_URL = "https://docs.chef.io/deprecations_"
- attr_accessor :message, :location
+ attr_reader :message, :location
def initialize(msg = nil, location = nil)
- @message = msg if msg
- @location = location if location
+ @message = msg
+ @location = location
end
def link
"Please see #{url} for further details and information on how to correct this problem."
end
+ # Render the URL for the deprecation documentation page.
+ #
+ # @return [String]
def url
- "#{BASE_URL}#{target}"
- end
-
- # We know that the only time this gets called is by Chef::Log.deprecation,
- # so special case
- def <<(location)
- @location = location
- end
-
- def inspect
- "#{message} (CHEF-#{id})#{location}.\n#{link}"
- end
-
- def id
- raise NotImplementedError, "subclasses of Chef::Deprecated::Base should define #id with a unique number"
- end
-
- def target
- raise NotImplementedError, "subclasses of Chef::Deprecated::Base should define #target"
+ "#{BASE_URL}#{self.class.doc_page}"
+ end
+
+ # Render the user-visible message for this deprecation.
+ #
+ # @return [String]
+ def to_s
+ "Deprecation CHEF-#{self.class.deprecation_id} from #{location}\n\n #{message}\n\n#{link}"
+ end
+
+ # Check if this deprecation has been silenced.
+ #
+ # @return [Boolean]
+ def silenced?
+ # Check if all warnings have been silenced.
+ return true if Chef::Config[:silence_deprecation_warnings] == true
+ # Check if this warning has been silenced by the config.
+ return true if Chef::Config[:silence_deprecation_warnings].any? do |silence_spec|
+ # Just in case someone uses a symbol in the config by mistake.
+ silence_spec = silence_spec.to_s
+ # Check for a silence by deprecation name, or by location.
+ self.class.deprecation_key == silence_spec || self.class.deprecation_id.to_s == silence_spec || "chef-#{self.class.deprecation_id}" == silence_spec.downcase || location.include?(silence_spec)
+ end
+ # check if this warning has been silenced by inline comment.
+ return true if location =~ /^(.*?):(\d+):in/ && begin
+ # Don't buffer the whole file in memory, so read it one line at a time.
+ line_no = $2.to_i
+ location_file = ::File.open($1)
+ (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
+ relevant_line = location_file.readline
+ relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
+ end
+ false
+ end
+
+ class << self
+ attr_reader :deprecation_id, :doc_page
+
+ # Return the deprecation key as would be used with {Chef::Deprecated.create}.
+ #
+ # @return [String]
+ def deprecation_key
+ Chef::Mixin::ConvertToClassName.convert_to_snake_case(name, "Chef::Deprecated")
+ end
+
+ # Set the ID and documentation page path for this deprecation.
+ #
+ # Used in subclasses to set the data for each type of deprecation.
+ #
+ # @example
+ # class MyDeprecation < Base
+ # target 123, "my_deprecation.html"
+ # end
+ # @param id [Integer] Deprecation ID number. This must be unique among
+ # all deprecations.
+ # @param page [String, nil] Optional documentation page path. If not
+ # specified, the deprecation key is used.
+ # @return [void]
+ def target(id, page = nil)
+ @deprecation_id = id
+ @doc_page = page || "#{deprecation_key}.html"
+ end
end
end
class InternalApi < Base
- def id
- 0
- end
-
- def target
- "internal_api.html"
- end
+ target 0
end
class JsonAutoInflate < Base
- def id
- 1
- end
-
- def target
- "json_auto_inflate.html"
- end
+ target 1
end
class ExitCode < Base
- def id
- 2
- end
-
- def target
- "exit_code.html"
- end
+ target 2
end
# id 3 has been deleted
class Attributes < Base
- def id
- 4
- end
-
- def target
- "attributes.html"
- end
+ target 4
end
class CustomResource < Base
- def id
- 5
- end
-
- def target
- "custom_resource_cleanups.html"
- end
+ target 5, "custom_resource_cleanups.html"
end
class EasyInstall < Base
- def id
- 6
- end
-
- def target
- "easy_install.html"
- end
+ target 6
end
class VerifyFile < Base
- def id
- 7
- end
-
- def target
- "verify_file.html"
- end
+ target 7
end
class SupportsProperty < Base
- def id
- 8
- end
-
- def target
- "supports_property.html"
- end
+ target 8
end
class ChefRest < Base
- def id
- 9
- end
-
- def target
- "chef_rest.html"
- end
+ target 9
end
class DnfPackageAllowDowngrade < Base
- def id
- 10
- end
-
- def target
- "dnf_package_allow_downgrade.html"
- end
+ target 10
end
class PropertyNameCollision < Base
- def id
- 11
- end
-
- def target
- "property_name_collision.html"
- end
+ target 11
end
class LaunchdHashProperty < Base
- def id
- 12
- end
-
- def target
- "launchd_hash_property.html"
- end
+ target 12
end
class ChefPlatformMethods < Base
- def id
- 13
- end
-
- def target
- "chef_platform_methods.html"
- end
+ target 13
end
class RunCommand < Base
- def id
- 14
- end
-
- def target
- "run_command.html"
- end
+ target 14
end
class PackageMisc < Base
- def id
- 15
- end
-
- def target
- "package_misc.html"
- end
+ target 15
end
class MultiresourceMatch < Base
- def id
- 16
- end
-
- def target
- "multiresource_match.html"
- end
+ target 16
end
class UseInlineResources < Base
- def id
- 17
- end
-
- def target
- "use_inline_resources.html"
- end
+ target 17
end
class LocalListen < Base
- def id
- 18
- end
-
- def target
- "local_listen.html"
- end
+ target 18
end
class NamespaceCollisions < Base
- def id
- 19
- end
-
- def target
- "namespace_collisions.html"
- end
+ target 19
end
class DeployResource < Base
- def id
- 21
- end
-
- def target
- "deploy_resource.html"
- end
+ target 21
end
class ErlResource < Base
- def id
- 22
- end
-
- def target
- "erl_resource.html"
- end
+ target 22
end
class FreebsdPkgProvider < Base
- def id
- 23
- end
+ target 23
+ end
- def target
- "freebsd_pkg_provider.html"
- end
+ class MapCollision < Base
+ target 25
end
# id 3694 was deleted
# Returned when using the deprecated option on a property
class Property < Base
- def inspect
- "#{message}\n#{location}"
+ target 24
+
+ def to_s
+ "Deprecated resource property used from #{location}\n\n #{message}\n\nPlease consult the resource documentation for more information."
end
end
@@ -302,8 +222,8 @@ class Chef
"https://docs.chef.io/chef_deprecations_client.html"
end
- def inspect
- "#{message}\nThis is a generic error message and should be updated to have a proper deprecation class. #{location}\nPlease see #{url} for an overview of Chef deprecations."
+ def to_s
+ "Deprecation from #{location}\n\n #{message}\n\n#{link}"
end
end
diff --git a/lib/chef/formatters/base.rb b/lib/chef/formatters/base.rb
index 0b27b55048..997577aa7b 100644
--- a/lib/chef/formatters/base.rb
+++ b/lib/chef/formatters/base.rb
@@ -212,14 +212,13 @@ class Chef
file_load_failed(path, exception)
end
- def deprecation(message, location = caller(2..2)[0])
- out = if is_structured_deprecation?(message)
- message.inspect
- else
- "#{message} at #{location}"
- end
-
- Chef::Log.deprecation(out)
+ # Log a deprecation warning object.
+ #
+ # @param deprecation [Chef::Deprecated::Base] Deprecation object to log.
+ # In previous versions, this could be a string. Don't do that anymore.
+ # @param location [Object] Unused, present only for compatbility.
+ def deprecation(deprecation, _location = nil)
+ Chef::Log.deprecation(deprecation.to_s) unless deprecation.silenced?
end
def is_structured_deprecation?(deprecation)
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb
index 0c51cc2cfb..d47ab73a30 100644
--- a/lib/chef/formatters/doc.rb
+++ b/lib/chef/formatters/doc.rb
@@ -414,19 +414,15 @@ class Chef
end
end
- def deprecation(message, location = caller(2..2)[0])
+ # (see Base#deprecation)
+ def deprecation(deprecation, _location = nil)
if Chef::Config[:treat_deprecation_warnings_as_errors]
super
+ elsif !deprecation.silenced?
+ # Save non-silenced deprecations to the screen until the end.
+ deprecations[deprecation.message] ||= { url: deprecation.url, locations: Set.new }
+ deprecations[deprecation.message][:locations] << deprecation.location
end
-
- # Save deprecations to the screen until the end
- if is_structured_deprecation?(message)
- url = message.url
- message = message.message
- end
-
- deprecations[message] ||= { url: url, locations: Set.new }
- deprecations[message][:locations] << location
end
def indent
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 10c9f0f20d..3f77158579 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -46,19 +46,21 @@ class Chef
#
def self.caller_location
# Pick the first caller that is *not* part of the Chef gem, that's the
- # thing the user wrote.
+ # thing the user wrote. Or failing that, the most recent caller.
chef_gem_path = File.expand_path("../..", __FILE__)
- caller(0..20).find { |c| !c.start_with?(chef_gem_path) }
+ caller(0..20).find { |c| !c.start_with?(chef_gem_path) } || caller(0..1)[0]
end
- def self.deprecation(msg = nil, location = caller(2..2)[0], &block)
- if msg
- msg << " at #{Array(location).join("\n")}"
- msg = msg.join("") if msg.respond_to?(:join)
- end
+ # Log a deprecation warning.
+ #
+ # If the treat_deprecation_warnings_as_errors config option is set, this
+ # will raise an exception instead.
+ #
+ # @param msg [String] Deprecation message to display.
+ def self.deprecation(msg, &block)
if Chef::Config[:treat_deprecation_warnings_as_errors]
error(msg, &block)
- raise Chef::Exceptions::DeprecatedFeatureError.new(msg.inspect)
+ raise Chef::Exceptions::DeprecatedFeatureError.new(msg)
else
warn(msg, &block)
end
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index 634786af93..c0066bfce5 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -37,6 +37,21 @@
#
class Chef
class NodeMap
+ COLLISION_WARNING_14 = <<-EOH.gsub(/\s+/, " ").strip
+%{type_caps} %{key} has been loaded from a cookbook. The %{type} %{key} is now
+included in Chef and will take precedence over the existing cookbook %{type} in the
+next major release of Chef (15.0, April 2019). You may be able to remove this cookbook dependency from
+your runlist if you do not use other recipes/resources/libraries from the cookbook.
+Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
+EOH
+
+ COLLISION_WARNING_15 = <<-EOH.gsub(/\s+/, " ").strip
+%{type_caps} %{key} attempted to load from a cookbook. The %{type} %{key} is now
+included in Chef and takes precedence over the existing cookbook %{type}
+which will be ignored. You may be able to remove this cookbook dependency from
+your runlist if you do not use other recipes/resources/libraries from the cookbook.
+Alternatively there may be a newer version of this cookbook without the %{key} %{type}.
+EOH
#
# Set a key/value pair on the map with a filter. The filter must be true
@@ -85,9 +100,9 @@ class Chef
klass.superclass.to_s
end
# For now, only log the warning.
- Chef.log_deprecation("Trying to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
+ Chef.deprecated(:map_collision, COLLISION_WARNING_14 % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize })
# In 15.0, uncomment this and remove the log above.
- # Chef.log_deprecation("Rejecting attempt to register #{type_of_thing} #{key} on top of existing Chef core #{type_of_thing}. Check if a new version of the cookbook is available.")
+ # Chef.deprecated(:map_collision, COLLISION_WARNING_15 % {type: type_of_thing, key: key, type_caps: type_of_thing.capitalize}))
# return
end
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 0bb28c66c6..1676ec3f6b 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -100,15 +100,13 @@ class Chef
def load_current_resource
@current_resource = Chef::Resource::WindowsTask.new(new_resource.name)
- task = TaskScheduler.new
- if task.exists?(new_resource.task_name)
- @current_resource.exists = true
+ task = TaskScheduler.new(new_resource.task_name, nil, "\\", false)
+ @current_resource.exists = task.exists?(new_resource.task_name)
+ if @current_resource.exists
task.get_task(new_resource.task_name)
@current_resource.task = task
pathed_task_name = new_resource.task_name.start_with?('\\') ? new_resource.task_name : "\\#{new_resource.task_name}"
@current_resource.task_name(pathed_task_name)
- else
- @current_resource.exists = false
end
@current_resource
end
@@ -133,10 +131,10 @@ class Chef
converge_by("#{new_resource} task created") do
task = TaskScheduler.new
if new_resource.frequency == :none
- task.new_work_item(new_resource.task_name, {})
+ task.new_work_item(new_resource.task_name, {}, { user: new_resource.user, password: new_resource.password })
task.activate(new_resource.task_name)
else
- task.new_work_item(new_resource.task_name, trigger)
+ task.new_work_item(new_resource.task_name, trigger, { user: new_resource.user, password: new_resource.password })
end
task.application_name = new_resource.command
task.parameters = new_resource.command_arguments if new_resource.command_arguments
diff --git a/lib/chef/resource/homebrew_package.rb b/lib/chef/resource/homebrew_package.rb
index dee132a1b4..9d8c7b2596 100644
--- a/lib/chef/resource/homebrew_package.rb
+++ b/lib/chef/resource/homebrew_package.rb
@@ -30,7 +30,8 @@ class Chef
description "Use the homebrew_package resource to manage packages for the macOS platform."
introduced "12.0"
- property :homebrew_user, [ String, Integer ]
+ property :homebrew_user, [ String, Integer ],
+ description: "The name of the Homebrew owner to be used by the chef-client when executing a command."
end
end
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
index f209e419dd..3493cec9db 100644
--- a/lib/chef/resource/http_request.rb
+++ b/lib/chef/resource/http_request.rb
@@ -32,8 +32,11 @@ class Chef
default_action :get
allowed_actions :get, :patch, :put, :post, :delete, :head, :options
- property :url, String, identity: true
- property :headers, Hash, default: lazy { Hash.new }
+ property :url, String, identity: true,
+ description: "The URL to which an HTTP request is sent."
+
+ property :headers, Hash, default: lazy { Hash.new },
+ description: "A Hash of custom headers."
def initialize(name, run_context = nil)
super
diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb
index 579a4eeedb..84ee249ec4 100644
--- a/lib/chef/resource/ifconfig.rb
+++ b/lib/chef/resource/ifconfig.rb
@@ -35,23 +35,63 @@ class Chef
default_action :add
allowed_actions :add, :delete, :enable, :disable
- property :target, String, name_property: true
- property :hwaddr, String
- property :mask, String
- property :family, String, default: "inet"
- property :inet_addr, String
- property :bcast, String
- property :mtu, String
- property :metric, String
- property :device, String, identity: true
- property :onboot, String
- property :network, String
- property :bootproto, String
- property :onparent, String
- property :ethtool_opts, String
- property :bonding_opts, String
- property :master, String
- property :slave, String
+ property :target, String,
+ name_property: true,
+ description: "The IP address that is to be assigned to the network interface. If not specified we'll use the resource's name."
+
+ property :hwaddr, String,
+ description: "The hardware address for the network interface."
+
+ property :mask, String,
+ description: "The decimal representation of the network mask. For example: 255.255.255.0."
+
+ property :family, String,
+ default: "inet", introduced: "14.0",
+ description: "Networking family option for Debian-based systems. For example: inet or inet6."
+
+ property :inet_addr, String,
+ description: "The Internet host address for the network interface."
+
+ property :bcast, String,
+ description: "The broadcast address for a network interface. On some platforms this property is not set using ifconfig, but instead is added to the startup configuration file for the network interface."
+
+ property :mtu, String,
+ description: "The maximum transmission unit (MTU) for the network interface."
+
+ property :metric, String,
+ description: "The routing metric for the interface."
+
+ property :device, String,
+ identity: true,
+ description: "The network interface to be configured."
+
+ property :onboot, String,
+ description: "Bring up the network interface on boot."
+
+ property :network, String,
+ description: "The address for the network interface."
+
+ property :bootproto, String,
+ description: "The boot protocol used by a network interface."
+
+ property :onparent, String,
+ description: "Bring up the network interface when its parent interface is brought up."
+
+ property :ethtool_opts, String,
+ introduced: "13.4",
+ description: "Options to be passed to ethtool(8). For example: -A eth0 autoneg off rx off tx off"
+
+ property :bonding_opts, String,
+ introduced: "13.4",
+ description: "Bonding options to pass via BONDING_OPTS on RHEL and CentOS. For example: mode=active-backup miimon=100"
+
+ property :master, String,
+ introduced: "13.4",
+ description: "Specifies the channel bonding interface to which the Ethernet interface is linked."
+
+ property :slave, String,
+ introduced: "13.4",
+ description: "When set to yes, this device is controlled by the channel bonding interface that is specified via the master property."
end
end
end
diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb
index 70e3bfee81..ff154e8bd8 100644
--- a/lib/chef/resource/ips_package.rb
+++ b/lib/chef/resource/ips_package.rb
@@ -30,7 +30,9 @@ class Chef
allowed_actions :install, :remove, :upgrade
- property :accept_license, [TrueClass, FalseClass], default: false, desired_state: false
+ property :accept_license, [TrueClass, FalseClass],
+ default: false, desired_state: false,
+ description: "Accept an end-user license agreement, automatically."
end
end
end
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 9161efa6ea..df01675de1 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -30,16 +30,39 @@ class Chef
default_action :create
allowed_actions :create, :create_if_missing, :delete, :enable, :disable, :restart
- property :label, String, identity: true, name_property: true
- property :backup, [Integer, FalseClass], desired_state: false
- property :cookbook, String, desired_state: false
- property :group, [String, Integer]
- property :plist_hash, Hash
- property :mode, [String, Integer]
- property :owner, [String, Integer]
- property :path, String
- property :source, String
- property :session_type, String
+ property :label, String,
+ identity: true, name_property: true,
+ description: "The unique identifier for the job."
+
+ property :backup, [Integer, FalseClass],
+ desired_state: false,
+ description: "The number of backups to be kept in /var/chef/backup. Set to false to prevent backups from being kept."
+
+ property :cookbook, String,
+ desired_state: false,
+ description: "The name of the cookbook in which the source files are located."
+
+ property :group, [String, Integer],
+ description: "When launchd is run as the root user, the group to run the job as. If the username property is specified and this property is not, this value is set to the default group for the user."
+
+ property :plist_hash, Hash,
+ introduced: "12.19",
+ description: "A Hash of key value pairs used to create the launchd property list."
+
+ property :mode, [String, Integer],
+ description: "A quoted 3-5 character string that defines the octal mode. For example: '755', '0755', or 00755."
+
+ property :owner, [String, Integer],
+ description: "A string or ID that identifies the group owner by user name, including fully qualified user names such as domain_user or user@domain. If this value is not specified, existing owners remain unchanged and new owner assignments use the current user (when necessary)."
+
+ property :path, String,
+ description: "The path to the directory. Using a fully qualified path is recommended, but is not always required."
+
+ property :source, String,
+ description: "The path to the launchd property list."
+
+ property :session_type, String,
+ description: "The type of launchd plist to be created. Possible values: system (default) or user."
# StartCalendarInterval has some gotchas so we coerce it to help sanity
# check. According to `man 5 launchd.plist`:
@@ -50,96 +73,180 @@ class Chef
# this means that an entry like:
# { "Hour"=>0, "Weekday"=>"6-7"}
# will not just run on midnight of Sat and Sun, rather it will run _every_ midnight.
- property :start_calendar_interval, [Hash, Array], coerce: proc { |type|
- # Coerce into an array of hashes to make validation easier
- array = if type.is_a?(Array)
- type
- else
- [type]
- end
-
- # Check to make sure that our array only has hashes
- unless array.all? { |obj| obj.is_a?(Hash) }
- error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
-
- # Make sure the hashes don't have any incorrect keys/values
- array.each do |entry|
- allowed_keys = %w{Minute Hour Day Weekday Month}
- unless entry.keys.all? { |key| allowed_keys.include?(key) }
- failed_keys = entry.keys.reject { |k| allowed_keys.include?(k) }.join(", ")
- error_msg = "The following key(s): #{failed_keys} are invalid for start_calendar_interval, must be one of: #{allowed_keys.join(", ")}"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
-
- unless entry.values.all? { |val| val.is_a?(Integer) }
- failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
- error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- end
-
- # Don't return array if we only have one entry
- if array.size == 1
- array.first
- else
- array
- end
- }
-
- property :type, String, default: "daemon", coerce: proc { |type|
- type = type ? type.downcase : "daemon"
- types = %w{daemon agent}
-
- unless types.include?(type)
- error_msg = "type must be daemon or agent"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- type
- }
+ property :start_calendar_interval, [Hash, Array],
+ description: "A Hash (similar to crontab) that defines the calendar frequency at which a job is started or an Array.",
+ coerce: proc { |type|
+ # Coerce into an array of hashes to make validation easier
+ array = if type.is_a?(Array)
+ type
+ else
+ [type]
+ end
+
+ # Check to make sure that our array only has hashes
+ unless array.all? { |obj| obj.is_a?(Hash) }
+ error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+
+ # Make sure the hashes don't have any incorrect keys/values
+ array.each do |entry|
+ allowed_keys = %w{Minute Hour Day Weekday Month}
+ unless entry.keys.all? { |key| allowed_keys.include?(key) }
+ failed_keys = entry.keys.reject { |k| allowed_keys.include?(k) }.join(", ")
+ error_msg = "The following key(s): #{failed_keys} are invalid for start_calendar_interval, must be one of: #{allowed_keys.join(", ")}"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+
+ unless entry.values.all? { |val| val.is_a?(Integer) }
+ failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
+ error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ end
+
+ # Don't return array if we only have one entry
+ if array.size == 1
+ array.first
+ else
+ array
+ end
+ }
+
+ property :type, String,
+ description: "The type of resource. Possible values: daemon (default), agent.",
+ default: "daemon", coerce: proc { |type|
+ type = type ? type.downcase : "daemon"
+ types = %w{daemon agent}
+
+ unless types.include?(type)
+ error_msg = "type must be daemon or agent"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ type
+ }
# Apple LaunchD Keys
- property :abandon_process_group, [ TrueClass, FalseClass ]
- property :debug, [ TrueClass, FalseClass ]
- property :disabled, [ TrueClass, FalseClass ], default: false
- property :enable_globbing, [ TrueClass, FalseClass ]
- property :enable_transactions, [ TrueClass, FalseClass ]
- property :environment_variables, Hash
- property :exit_timeout, Integer
- property :hard_resource_limits, Hash
- property :inetd_compatibility, Hash
- property :init_groups, [ TrueClass, FalseClass ]
- property :keep_alive, [ TrueClass, FalseClass, Hash ]
- property :launch_only_once, [ TrueClass, FalseClass ]
- property :ld_group, String
- property :limit_load_from_hosts, Array
- property :limit_load_to_hosts, Array
- property :limit_load_to_session_type, [ Array, String ]
- property :low_priority_io, [ TrueClass, FalseClass ]
- property :mach_services, Hash
- property :nice, Integer
- property :on_demand, [ TrueClass, FalseClass ]
- property :process_type, String
- property :program, String
- property :program_arguments, Array
- property :queue_directories, Array
- property :root_directory, String
- property :run_at_load, [ TrueClass, FalseClass ]
- property :sockets, Hash
- property :soft_resource_limits, Array
- property :standard_error_path, String
- property :standard_in_path, String
- property :standard_out_path, String
- property :start_interval, Integer
- property :start_on_mount, [ TrueClass, FalseClass ]
- property :throttle_interval, Integer
- property :time_out, Integer
- property :umask, Integer
- property :username, String
- property :wait_for_debugger, [ TrueClass, FalseClass ]
- property :watch_paths, Array
- property :working_directory, String
+ property :abandon_process_group, [ TrueClass, FalseClass ],
+ description: "If a job dies, all remaining processes with the same process ID may be kept running. Set to true to kill all remaining processes."
+
+ property :debug, [ TrueClass, FalseClass ],
+ description: "Sets the log mask to LOG_DEBUG for this job."
+
+ property :disabled, [ TrueClass, FalseClass ], default: false,
+ description: "Hints to launchctl to not submit this job to launchd."
+
+ property :enable_globbing, [ TrueClass, FalseClass ],
+ description: "Update program arguments before invocation."
+
+ property :enable_transactions, [ TrueClass, FalseClass ],
+ description: "Track in-progress transactions; if none, then send the SIGKILL signal."
+
+ property :environment_variables, Hash,
+ description: "Additional environment variables to set before running a job."
+
+ property :exit_timeout, Integer,
+ description: "The amount of time (in seconds) launchd waits before sending a SIGKILL signal."
+
+ property :hard_resource_limits, Hash,
+ description: "A Hash of resource limits to be imposed on a job."
+
+ property :inetd_compatibility, Hash,
+ description: "Specifies if a daemon expects to be run as if it were launched from inetd. Set to wait => true to pass standard input, output, and error file descriptors. Set to wait => false to call the accept system call on behalf of the job, and then pass standard input, output, and error file descriptors."
+
+ property :init_groups, [ TrueClass, FalseClass ],
+ description: "Specify if initgroups is called before running a job."
+
+ property :keep_alive, [ TrueClass, FalseClass, Hash ],
+ introduced: "12.14",
+ description: "Keep a job running continuously (true) or allow demand and conditions on the node to determine if the job keeps running (false)."
+
+ property :launch_only_once, [ TrueClass, FalseClass ],
+ description: "Specify if a job can be run only one time. Set this value to true if a job cannot be restarted without a full machine reboot."
+
+ property :ld_group, String,
+ description: "The group name."
+
+ property :limit_load_from_hosts, Array,
+ description: "An array of hosts to which this configuration file does not apply, i.e. 'apply this configuration file to all hosts not specified in this array'."
+
+ property :limit_load_to_hosts, Array,
+ description: "An array of hosts to which this configuration file applies."
+
+ property :limit_load_to_session_type, [ Array, String ],
+ description: "The session type(s) to which this configuration file applies."
+
+ property :low_priority_io, [ TrueClass, FalseClass ],
+ description: "Specify if the kernel on the node should consider this daemon to be low priority during file system I/O."
+
+ property :mach_services, Hash,
+ description: "Specify services to be registered with the bootstrap subsystem."
+
+ property :nice, Integer,
+ description: "The program scheduling priority value in the range -20 to 20."
+
+ property :on_demand, [ TrueClass, FalseClass ],
+ description: "Keep a job alive. Only applies to macOS version 10.4 (and earlier); use keep_alive instead for newer versions."
+
+ property :process_type, String,
+ description: "The intended purpose of the job: Adaptive, Background, Interactive, or Standard."
+
+ property :program, String,
+ description: "The first argument of execvp, typically the file name associated with the file to be executed. This value must be specified if program_arguments is not specified, and vice-versa."
+
+ property :program_arguments, Array,
+ description: "The second argument of execvp. If program is not specified, this property must be specified and will be handled as if it were the first argument."
+
+ property :queue_directories, Array,
+ description: "An array of non-empty directories which, if any are modified, will cause a job to be started."
+
+ property :root_directory, String,
+ description: "chroot to this directory, and then run the job."
+
+ property :run_at_load, [ TrueClass, FalseClass ],
+ description: "Launch a job once (at the time it is loaded)."
+
+ property :sockets, Hash,
+ description: "A Hash of on-demand sockets that notify launchd when a job should be run."
+
+ property :soft_resource_limits, Array,
+ description: "A Hash of resource limits to be imposed on a job."
+
+ property :standard_error_path, String,
+ description: "The file to which standard error (stderr) is sent."
+
+ property :standard_in_path, String,
+ description: "The file to which standard input (stdin) is sent."
+
+ property :standard_out_path, String,
+ description: "The file to which standard output (stdout) is sent."
+
+ property :start_interval, Integer,
+ description: "The frequency (in seconds) at which a job is started."
+
+ property :start_on_mount, [ TrueClass, FalseClass ],
+ description: "Start a job every time a file system is mounted."
+
+ property :throttle_interval, Integer,
+ description: "The frequency (in seconds) at which jobs are allowed to spawn."
+
+ property :time_out, Integer,
+ description: "The amount of time (in seconds) a job may be idle before it times out. If no value is specified, the default timeout value for launchd will be used."
+
+ property :umask, Integer,
+ description: "A decimal value to pass to umask before running a job."
+
+ property :username, String,
+ description: "When launchd is run as the root user, the user to run the job as."
+
+ property :wait_for_debugger, [ TrueClass, FalseClass ],
+ description: "Specify if launchd has a job wait for a debugger to attach before executing code."
+
+ property :watch_paths, Array,
+ description: "An array of paths which, if any are modified, will cause a job to be started."
+
+ property :working_directory, String,
+ description: "Chdir to this directory, and then run the job."
end
end
end
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
index a9dea6b104..b97b5c9e66 100644
--- a/lib/chef/resource/log.rb
+++ b/lib/chef/resource/log.rb
@@ -37,8 +37,13 @@ class Chef
" entry that is not built into the resource collection, use Chef::Log instead"\
" of the log resource.)"
- property :message, String, name_property: true, identity: true
- property :level, Symbol, equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info
+ property :message, String,
+ name_property: true, identity: true,
+ description: "The message to be added to a log file. If not specified we'll use the resource's name instead."
+
+ property :level, Symbol,
+ equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info,
+ description: "The logging level to display this message at."
allowed_actions :write
default_action :write
diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb
index 3b54a53e98..3fc5b7c338 100644
--- a/lib/chef/resource/mdadm.rb
+++ b/lib/chef/resource/mdadm.rb
@@ -32,14 +32,35 @@ class Chef
default_action :create
allowed_actions :create, :assemble, :stop
- property :chunk, Integer, default: 16
- property :devices, Array, default: lazy { [] }
- property :exists, [ TrueClass, FalseClass ], default: false
- property :level, Integer, default: 1
- property :metadata, String, default: "0.90"
- property :bitmap, String
- property :raid_device, String, identity: true, name_property: true
- property :layout, String
+ property :chunk, Integer,
+ default: 16,
+ description: "The chunk size. This property should not be used for a RAID 1 mirrored pair (i.e. when the level property is set to 1)."
+
+ property :devices, Array,
+ default: lazy { [] },
+ description: "The devices to be part of a RAID array."
+
+ property :exists, [ TrueClass, FalseClass ],
+ default: false,
+ description: "Indicates whether the RAID array exists."
+
+ property :level, Integer,
+ default: 1,
+ description: "The RAID level."
+
+ property :metadata, String,
+ default: "0.90",
+ description: "The superblock type for RAID metadata."
+
+ property :bitmap, String,
+ description: "The path to a file in which a write-intent bitmap is stored."
+
+ property :raid_device, String,
+ identity: true, name_property: true,
+ description: "The name of the RAID device. We'll use the resource's name if this isn't specified."
+
+ property :layout, String,
+ description: "The RAID5 parity algorithm. Possible values: left-asymmetric (or la), left-symmetric (or ls), right-asymmetric (or ra), or right-symmetric (or rs)."
end
end
end
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb
index fc6f25fb3f..fd076ffad3 100644
--- a/lib/chef/resource/windows_feature_dism.rb
+++ b/lib/chef/resource/windows_feature_dism.rb
@@ -117,7 +117,7 @@ class Chef
def features_to_install
@install ||= begin
# disabled features are always available to install
- available_for_install = node["dism_features_cache"]["disabled"]
+ available_for_install = node["dism_features_cache"]["disabled"].dup
# if the user passes a source then removed features are also available for installation
available_for_install.concat(node["dism_features_cache"]["removed"]) if new_resource.source
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 98911491b7..7b30763bc7 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require "chef/version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("14.3.10")
+ VERSION = Chef::VersionString.new("14.3.17")
end
#
diff --git a/omnibus/.gitignore b/omnibus/.gitignore
index 1a2c556f8d..a959250f6e 100644
--- a/omnibus/.gitignore
+++ b/omnibus/.gitignore
@@ -1,6 +1,6 @@
vendor/bundle
pkg/*
-.kitchen.local.yml
+kitchen.local.yml
bin/*
files/chef-server-cookbooks/cache/
files/msi/ChefClient-Config.wxi
diff --git a/omnibus/Gemfile b/omnibus/Gemfile
index 5457f0f40b..1876755d84 100644
--- a/omnibus/Gemfile
+++ b/omnibus/Gemfile
@@ -17,7 +17,7 @@ group :development do
gem "ohai", "~> 13.0"
# Use Test Kitchen with Vagrant for converging the build environment
- gem "test-kitchen", "~> 1.13"
+ gem "test-kitchen", "~> 1.21"
gem "kitchen-vagrant", "~> 1.3.1"
gem "winrm-fs", "~> 1.0"
gem "pry"
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index 1bcf7ab0ae..fd190ca04a 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -31,13 +31,13 @@ GEM
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
awesome_print (1.8.0)
- aws-sdk (2.11.66)
- aws-sdk-resources (= 2.11.66)
- aws-sdk-core (2.11.66)
+ aws-sdk (2.11.70)
+ aws-sdk-resources (= 2.11.70)
+ aws-sdk-core (2.11.70)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.11.66)
- aws-sdk-core (= 2.11.66)
+ aws-sdk-resources (2.11.70)
+ aws-sdk-core (= 2.11.70)
aws-sigv4 (1.0.2)
berkshelf (4.3.5)
addressable (~> 2.3, >= 2.3.4)
@@ -103,8 +103,9 @@ GEM
gyoku (1.3.1)
builder (>= 2.1.2)
hashie (3.5.7)
- hitimes (1.2.6)
- hitimes (1.2.6-x86-mingw32)
+ hitimes (1.3.0)
+ hitimes (1.3.0-x64-mingw32)
+ hitimes (1.3.0-x86-mingw32)
httpclient (2.7.2)
iostruct (0.0.4)
ipaddress (0.8.3)
@@ -127,7 +128,7 @@ GEM
mixlib-log
mixlib-authentication (2.1.1)
mixlib-cli (1.7.0)
- mixlib-config (2.2.6)
+ mixlib-config (2.2.8)
tomlrb
mixlib-install (3.10.0)
mixlib-shellout
@@ -226,7 +227,7 @@ GEM
hitimes
toml-rb (1.1.1)
citrus (~> 3.0, > 3.0)
- tomlrb (1.2.6)
+ tomlrb (1.2.7)
varia_model (0.4.1)
buff-extensions (~> 1.0)
hashie (>= 2.0.2, < 4.0.0)
@@ -267,7 +268,7 @@ DEPENDENCIES
pry
pry-byebug
pry-stack_explorer
- test-kitchen (~> 1.13)
+ test-kitchen (~> 1.21)
winrm-fs (~> 1.0)
BUNDLED WITH
diff --git a/omnibus/README.md b/omnibus/README.md
index 5f325aa164..50c28779be 100644
--- a/omnibus/README.md
+++ b/omnibus/README.md
@@ -1,22 +1,21 @@
-Client Tools Omnibus project
-============================
+# Client Tools Omnibus project
+
This project creates full-stack platform-specific packages for the following projects:
-* AngryChef
-* Chef
-* Chef with FIPS enabled
+- AngryChef
+- Chef
+- Chef with FIPS enabled
+
+## Installation
-Installation
-------------
-You must have a sane Ruby 1.9+ environment with Bundler installed. Ensure all
-the required gems are installed:
+You must have a sane Ruby environment with Bundler installed. Ensure all the required gems are installed:
```shell
$ bundle install --without development
```
-Usage
------
+## Usage
+
### Build
You create a platform-specific package using the `build project` command:
@@ -25,23 +24,17 @@ You create a platform-specific package using the `build project` command:
$ bundle exec omnibus build <PROJECT>
```
-The platform/architecture type of the package created will match the platform
-where the `build project` command is invoked. For example, running this command
-on a MacBook Pro will generate a Mac OS X package. After the build completes
-packages will be available in the `pkg/` folder.
+The platform/architecture type of the package created will match the platform where the `build project` command is invoked. For example, running this command on a MacBook Pro will generate a Mac OS X package. After the build completes packages will be available in the `pkg/` folder.
### Clean
-You can clean up all temporary files generated during the build process with
-the `clean` command:
+You can clean up all temporary files generated during the build process with the `clean` command:
```shell
$ bundle exec omnibus clean <PROJECT>
```
-Adding the `--purge` purge option removes __ALL__ files generated during the
-build including the project install directory (`/opt/chef`) and
-the package cache directory (`/var/cache/omnibus/pkg`):
+Adding the `--purge` purge option removes **ALL** files generated during the build including the project install directory (`/opt/chef`) and the package cache directory (`/var/cache/omnibus/pkg`):
```shell
$ bundle exec omnibus clean <PROJECT> --purge
@@ -49,9 +42,7 @@ $ bundle exec omnibus clean <PROJECT> --purge
### Publish
-Omnibus has a built-in mechanism for releasing to a variety of "backends", such
-as Amazon S3 and Artifactory. You must set the proper credentials in your `omnibus.rb`
-config file or specify them via the command line.
+Omnibus has a built-in mechanism for releasing to a variety of "backends", such as Amazon S3 and Artifactory. You must set the proper credentials in your `omnibus.rb` config file or specify them via the command line.
```shell
$ bundle exec omnibus publish path/to/*.deb --backend s3
@@ -59,40 +50,27 @@ $ bundle exec omnibus publish path/to/*.deb --backend s3
### Help
-Full help for the Omnibus command line interface can be accessed with the
-`help` command:
+Full help for the Omnibus command line interface can be accessed with the `help` command:
```shell
$ bundle exec omnibus help
```
-Kitchen-based Build Environment
--------------------------------
-Every Omnibus project ships will a project-specific
-[Berksfile](http://berkshelf.com/) that will allow you to build your omnibus projects on all of the projects listed
-in the `.kitchen.yml`. You can add/remove additional platforms as needed by
-changing the list found in the `.kitchen.yml` `platforms` YAML stanza.
+## Kitchen-based Build Environment
-This build environment is designed to get you up-and-running quickly. However,
-there is nothing that restricts you to building on other platforms. Simply use
-the [omnibus cookbook](https://github.com/chef-cookbooks/omnibus) to setup
-your desired platform and execute the build steps listed above.
+Every Omnibus project ships will a project-specific [Berksfile](https://docs.chef.io/berkshelf.html/) that will allow you to build your omnibus projects on all of the projects listed in the `kitchen.yml`. You can add/remove additional platforms as needed by changing the list found in the `kitchen.yml` `platforms` YAML stanza.
-The default build environment requires Test Kitchen and VirtualBox for local
-development. Test Kitchen also exposes the ability to provision instances using
-various cloud providers like AWS, DigitalOcean, or OpenStack. For more
-information, please see the [Test Kitchen documentation](http://kitchen.ci).
+This build environment is designed to get you up-and-running quickly. However, there is nothing that restricts you to building on other platforms. Simply use the [omnibus cookbook](https://github.com/chef-cookbooks/omnibus) to setup your desired platform and execute the build steps listed above.
-Once you have tweaked your `.kitchen.yml` (or `.kitchen.local.yml`) to your
-liking, you can bring up an individual build environment using the `kitchen`
-command.
+The default build environment requires Test Kitchen and VirtualBox for local development. Test Kitchen also exposes the ability to provision instances using various cloud providers like AWS, DigitalOcean, or OpenStack. For more information, please see the [Test Kitchen documentation](http://kitchen.ci).
+
+Once you have tweaked your `kitchen.yml` (or `kitchen.local.yml`) to your liking, you can bring up an individual build environment using the `kitchen` command.
```shell
$ bundle exec kitchen converge chef-ubuntu-1404
```
-Then login to the instance and build the project as described in the Usage
-section:
+Then login to the instance and build the project as described in the Usage section:
```shell
$ bundle exec kitchen login <PROJECT>-ubuntu-1204
@@ -101,6 +79,7 @@ $ bundle exec kitchen login <PROJECT>-ubuntu-1204
[vagrant@ubuntu...] $ ...
[vagrant@ubuntu...] $ bundle exec omnibus build <PROJECT> -l internal
```
+
```shell
$ kitchen login chef-ubuntu-1404
[vagrant@ubuntu...] $ source load-omnibus-toolchain.sh
@@ -110,10 +89,7 @@ $ kitchen login chef-ubuntu-1404
[vagrant@ubuntu...] $ bundle exec omnibus build chef -l internal
```
-You can also login to Windows instances but will have to manually call the
-`load-omnibus-toolchain.bat` script which initializes the build environment.
-Please note the mounted code directory is also at `C:\home\vagrant\chef\omnibus`
-as opposed to `C:\Users\vagrant\chef\omnibus`.
+You can also login to Windows instances but will have to manually call the `load-omnibus-toolchain.bat` script which initializes the build environment. Please note the mounted code directory is also at `C:\home\vagrant\chef\omnibus` as opposed to `C:\Users\vagrant\chef\omnibus`.
```shell
$ bundle exec kitchen login <PROJECT>-windows-81-professional
@@ -130,13 +106,12 @@ C:\vagrant\code\chef\omnibus>bundle install --without development
C:\vagrant\code\chef\omnibus>bundle exec omnibus build chef -l internal
```
-For a complete list of all commands and platforms, run `kitchen list` or
-`kitchen help`.
+For a complete list of all commands and platforms, run `kitchen list` or `kitchen help`.
+
+## License
-License
--------
```text
-Copyright 2012-2016, Chef Software, Inc.
+Copyright 2012-2018, Chef Software, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/omnibus/.kitchen.vmware.yml b/omnibus/kitchen.vmware.yml
index 69f001ef97..69f001ef97 100644
--- a/omnibus/.kitchen.vmware.yml
+++ b/omnibus/kitchen.vmware.yml
diff --git a/omnibus/.kitchen.yml b/omnibus/kitchen.yml
index 56b11de3c3..2e889a789a 100644
--- a/omnibus/.kitchen.yml
+++ b/omnibus/kitchen.yml
@@ -33,25 +33,21 @@ provisioner:
chef_omnibus_root: /opt/angrychef
platforms:
- - name: centos-5.11
+ - name: centos-6
run_list: yum-epel::default
- - name: centos-6.7
+ - name: centos-7
run_list: yum-epel::default
- - name: centos-7.2
- run_list: yum-epel::default
- - name: debian-8.2
+ - name: debian-8
run_list: apt::default
- - name: freebsd-9.3
- run_list:
- - freebsd::portsnap
- - freebsd::pkgng
- - name: freebsd-10.2
+ - name: freebsd-10
+ run_list: freebsd::portsnap
+ - name: freebsd-11
run_list: freebsd::portsnap
- - name: ubuntu-10.04
+ - name: ubuntu-14.04
run_list: apt::default
- - name: ubuntu-12.04
+ - name: ubuntu-16.04
run_list: apt::default
- - name: ubuntu-14.04
+ - name: ubuntu-18.04
run_list: apt::default
# The following (private) boxes are shared via Atlas and are only
# available to users working for Chef. Sorry, it's about software licensing.
@@ -64,10 +60,10 @@ platforms:
# the private boxes.
#
# The Mac OS X boxes are VMware only also. You can enable VMware Fusion
- # by activating the `.kitchen.vmware.yml` file with the `KITCHEN_LOCAL_YAML`
+ # by activating the `kitchen.vmware.yml` file with the `KITCHEN_LOCAL_YAML`
# environment variable:
#
- # KITCHEN_LOCAL_YAML=.kitchen.vmware.yml kitchen converge chefdk-macosx-109
+ # KITCHEN_LOCAL_YAML=kitchen.vmware.yml kitchen converge chefdk-macosx-109
#
# OSX
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 65a396cf56..46fbfe2e82 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -1109,6 +1109,60 @@ describe Chef::Resource::WindowsTask, :windows_only do
end
end
+ context "task_name with parent folder" do
+ describe "task_name with path '\\foo\\chef-client-functional-test' " do
+ let(:task_name) { "\\foo\\chef-client-functional-test" }
+ after { delete_task }
+ subject do
+ new_resource = Chef::Resource::WindowsTask.new(task_name, run_context)
+ new_resource.command task_name
+ new_resource.run_level :highest
+ new_resource.frequency :once
+ new_resource.execution_time_limit = 259200 / 60 # converting "PT72H" into minutes and passing here since win32-taskscheduler accespts this
+ new_resource
+ end
+
+ it "creates the scheduled task with task name 'chef-client-functional-test' inside path '\\foo'" do
+ call_for_create_action
+ current_resource = call_for_load_current_resource
+ expect(current_resource.exists).to eq(true)
+ expect(current_resource.task.application_name).to eq(task_name)
+ end
+
+ it "does not converge the resource if it is already converged" do
+ subject.run_action(:create)
+ subject.run_action(:create)
+ expect(subject).not_to be_updated_by_last_action
+ end
+ end
+
+ describe "task_name with path '\\foo\\bar\\chef-client-functional-test' " do
+ let(:task_name) { "\\foo\\bar\\chef-client-functional-test" }
+ after { delete_task }
+ subject do
+ new_resource = Chef::Resource::WindowsTask.new(task_name, run_context)
+ new_resource.command task_name
+ new_resource.run_level :highest
+ new_resource.frequency :once
+ new_resource.execution_time_limit = 259200 / 60 # converting "PT72H" into minutes and passing here since win32-taskscheduler accespts this
+ new_resource
+ end
+
+ it "creates the scheduled task with task with name 'chef-client-functional-test' inside path '\\foo\\bar' " do
+ call_for_create_action
+ current_resource = call_for_load_current_resource
+ expect(current_resource.exists).to eq(true)
+ expect(current_resource.task.application_name).to eq(task_name)
+ end
+
+ it "does not converge the resource if it is already converged" do
+ subject.run_action(:create)
+ subject.run_action(:create)
+ expect(subject).not_to be_updated_by_last_action
+ end
+ end
+ end
+
describe "Examples of idempotent checks for each frequency" do
after { delete_task }
context "For frequency :once" do
diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb
index 6b6b83aafe..da1409456b 100644
--- a/spec/integration/knife/common_options_spec.rb
+++ b/spec/integration/knife/common_options_spec.rb
@@ -28,7 +28,7 @@ describe "knife common options", :workstation do
Chef::Config.treat_deprecation_warnings_as_errors(false)
end
- let(:local_listen_warning) { /\Awarn:.*local.*listen.*$/i }
+ let(:local_listen_warning) { /\Awarn:.*local.*listen.*$/im }
when_the_repository "has a node" do
before { file "nodes/x.json", {} }
diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb
index 21987c01ab..2f370388fa 100644
--- a/spec/unit/chef_class_spec.rb
+++ b/spec/unit/chef_class_spec.rb
@@ -107,4 +107,124 @@ describe "Chef class" do
end.to raise_error(Chef::Exceptions::InvalidEventType)
end
end
+
+ describe "Deprecation system" do
+ context "with treat_deprecation_warnings_as_errors false" do
+ before { Chef::Config[:treat_deprecation_warnings_as_errors] = false }
+
+ it "displays a simple deprecation warning" do
+ expect(Chef::Log).to receive(:warn).with(%r{spec/unit/chef_class_spec\.rb.*?I'm a little teapot.*?Please see}m)
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ end
+
+ it "allows silencing all warnings" do
+ Chef::Config[:silence_deprecation_warnings] = true
+ expect(Chef::Log).to_not receive(:warn)
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
+ it "allows silencing specific types" do
+ Chef::Config[:silence_deprecation_warnings] = [:internal_api]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
+ it "allows silencing specific IDs" do
+ Chef::Config[:silence_deprecation_warnings] = [0]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
+ it "allows silencing specific IDs using the CHEF- syntax" do
+ Chef::Config[:silence_deprecation_warnings] = ["CHEF-0"]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
+ it "allows silencing specific IDs using the chef- syntax" do
+ Chef::Config[:silence_deprecation_warnings] = ["chef-0"]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
+ it "allows silencing specific lines" do
+ Chef::Config[:silence_deprecation_warnings] = ["chef_class_spec.rb:#{__LINE__ + 4}"]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:generic, "Short and stout.")
+ Chef.deprecated(:internal_api, "This is my handle.")
+ end
+
+ it "allows silencing all via inline comments" do
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:generic, "Short and stout.") # chef:silence_deprecation
+ Chef.deprecated(:internal_api, "This is my handle.")
+ end
+
+ it "allows silencing specific types via inline comments" do
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:generic, "Short and stout.") # chef:silence_deprecation:generic
+ Chef.deprecated(:internal_api, "This is my handle.")
+ end
+
+ it "does not silence via inline comments when the types don't match" do
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/Short and stout/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.") # chef:silence_deprecation:generic
+ Chef.deprecated(:internal_api, "This is my handle.")
+ end
+
+ it "allows silencing all via inline comments with other stuff in the comment" do
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:generic, "Short and stout.") # rubocop:something chef:silence_deprecation other stuff
+ Chef.deprecated(:internal_api, "This is my handle.")
+ end
+
+ it "handles multiple silence configurations at the same time" do
+ Chef::Config[:silence_deprecation_warnings] = ["exit_code", "chef_class_spec.rb:#{__LINE__ + 6}"]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my spout/).once
+ expect(Chef::Log).to receive(:warn).with(/Hear me shout/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:generic, "Short and stout.") # chef:silence_deprecation
+ Chef.deprecated(:internal_api, "This is my handle.")
+ Chef.deprecated(:internal_api, "This is my spout.")
+ Chef.deprecated(:exit_code, "When I get all steamed up.")
+ Chef.deprecated(:generic, "Hear me shout.")
+ end
+ end
+
+ context "with treat_deprecation_warnings_as_errors true" do
+ # This is already turned on globally for Chef's unit tests, but just for clarity do it here too.
+ before { Chef::Config[:treat_deprecation_warnings_as_errors] = true }
+
+ it "displays a simple deprecation error" do
+ expect(Chef::Log).to receive(:error).with(%r{spec/unit/chef_class_spec\.rb.*?I'm a little teapot.*?Please see}m)
+ expect { Chef.deprecated(:generic, "I'm a little teapot.") }.to raise_error(/I'm a little teapot./)
+ end
+ end
+ end
end
diff --git a/spec/unit/deprecated_spec.rb b/spec/unit/deprecated_spec.rb
index 4eba764b63..9c60080cef 100644
--- a/spec/unit/deprecated_spec.rb
+++ b/spec/unit/deprecated_spec.rb
@@ -20,40 +20,46 @@ require "chef/deprecated"
describe Chef::Deprecated do
class TestDeprecation < Chef::Deprecated::Base
- def id; 999; end
-
- def target; "test.html"; end
-
- def link; "#{Chef::Deprecated::Base::BASE_URL}test.html"; end
+ target 999, "test.html"
end
context "loading a deprecation class" do
it "loads the correct class" do
- expect(Chef::Deprecated.create(:test_deprecation)).to be_an_instance_of(TestDeprecation)
+ expect(Chef::Deprecated.create(:test_deprecation, nil, nil)).to be_an_instance_of(TestDeprecation)
end
- it "optionally sets a message" do
- deprecation = Chef::Deprecated.create(:test_deprecation, "A test message")
+ it "sets a message" do
+ deprecation = Chef::Deprecated.create(:test_deprecation, "A test message", nil)
expect(deprecation.message).to eql("A test message")
end
- it "optionally sets the location" do
+ it "sets the location" do
deprecation = Chef::Deprecated.create(:test_deprecation, nil, "A test location")
expect(deprecation.location).to eql("A test location")
end
end
context "formatting deprecation warnings" do
- let(:base_url) { Chef::Deprecated::Base::BASE_URL }
let(:message) { "A test message" }
let(:location) { "the location" }
it "displays the full URL" do
- expect(TestDeprecation.new().url).to eql("#{base_url}test.html")
+ expect(TestDeprecation.new().url).to eql("https://docs.chef.io/deprecations_test.html")
end
it "formats a complete deprecation message" do
- expect(TestDeprecation.new(message, location).inspect).to eql("#{message} (CHEF-999)#{location}.\nhttps://docs.chef.io/deprecations_test.html")
+ expect(TestDeprecation.new(message, location).to_s).to eql("Deprecation CHEF-999 from the location\n\n A test message\n\nPlease see https://docs.chef.io/deprecations_test.html for further details and information on how to correct this problem.")
+ end
+ end
+
+ it "has no overlapping deprecation IDs" do
+ id_map = {}
+ ObjectSpace.each_object(Class).select { |cls| cls < Chef::Deprecated::Base }.each do |cls|
+ (id_map[cls.deprecation_id] ||= []) << cls
+ end
+ collisions = id_map.select { |k, v| v.size != 1 }
+ unless collisions.empty?
+ raise "Found deprecation ID collisions:\n#{collisions.map { |k, v| "* #{k} #{v.map(&:name).join(', ')}" }.join("\n")}"
end
end
end
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 7e4980219a..253486438b 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -213,7 +213,7 @@ describe Chef::NodeMap do
describe "locked mode" do
context "while unlocked" do
it "allows setting the same key twice" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource)
node_map.set(:foo, BarResource)
expect(node_map.get(node, :foo)).to eql(BarResource)
@@ -223,7 +223,7 @@ describe Chef::NodeMap do
context "while locked" do
# Uncomment the commented `expect`s in 15.0.
it "rejects setting the same key twice" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register resource foo on top of existing Chef core resource. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /resource foo/)
node_map.set(:foo, FooResource)
node_map.lock!
node_map.set(:foo, BarResource)
@@ -231,7 +231,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the first has allow_cookbook_override" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource, allow_cookbook_override: true)
node_map.lock!
node_map.set(:foo, BarResource)
@@ -239,7 +239,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the first has allow_cookbook_override with a future version" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource, allow_cookbook_override: "< 100")
node_map.lock!
node_map.set(:foo, BarResource)
@@ -247,7 +247,7 @@ describe Chef::NodeMap do
end
it "rejects setting the same key twice when the first has allow_cookbook_override with a past version" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register resource foo on top of existing Chef core resource. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /resource foo/)
node_map.set(:foo, FooResource, allow_cookbook_override: "< 1")
node_map.lock!
node_map.set(:foo, BarResource)
@@ -255,7 +255,7 @@ describe Chef::NodeMap do
end
it "allows setting the same key twice when the second has __core_override__" do
- expect(Chef).to_not receive(:log_deprecation)
+ expect(Chef).to_not receive(:deprecated)
node_map.set(:foo, FooResource)
node_map.lock!
node_map.set(:foo, BarResource, __core_override__: true)
@@ -263,7 +263,7 @@ describe Chef::NodeMap do
end
it "rejects setting the same key twice for a provider" do
- expect(Chef).to receive(:log_deprecation).with("Trying to register provider foo on top of existing Chef core provider. Check if a new version of the cookbook is available.")
+ expect(Chef).to receive(:deprecated).with(:map_collision, /provider foo/)
node_map.set(:foo, FooProvider)
node_map.lock!
node_map.set(:foo, BarProvider)