diff options
180 files changed, 1289 insertions, 2793 deletions
diff --git a/.travis.yml b/.travis.yml index 279dcd0929..336e1a20a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_install: - bundle --version - rm -f .bundle/config -bundler_args: --without changelog development docgen guard maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen +bundler_args: --without ci development docgen guard maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: # force all .rspec tests into progress display to reduce line count @@ -38,37 +38,33 @@ matrix: sudo: true script: sudo -E $(which bundle) exec rake spec; # also remove integration / external tests - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen - rvm: 2.3.3 sudo: true script: sudo -E $(which bundle) exec rake spec; # also remove integration / external tests - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen - rvm: 2.4.0 sudo: true script: sudo -E $(which bundle) exec rake spec; # also remove integration / external tests - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen - env: CHEFSTYLE: 1 rvm: 2.3.3 script: bundle exec rake style # also remove integration / external tests - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen - env: AUDIT_CHECK: 1 rvm: 2.3.3 script: bundle exec bundle-audit check --update # also remove integration / external tests - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen # # External tests # - env: - TEST_GEM: chef-provisioning - script: tasks/bin/run_external_test $TEST_GEM rake spec - rvm: 2.3.3 - - env: TEST_GEM: chef-sugar script: tasks/bin/run_external_test $TEST_GEM rake rvm: 2.3.3 @@ -99,10 +95,13 @@ matrix: TEST_GEM: halite script: tasks/bin/run_external_test $TEST_GEM rake spec rvm: 2.3.3 - - env: - TEST_GEM: knife-windows - script: tasks/bin/run_external_test $TEST_GEM rake unit_spec - rvm: 2.3.3 + # this has been broken for some time and running incorrectly, see: + # + # see https://github.com/chef/knife-windows/pull/421 + #- env: + # TEST_GEM: knife-windows + #script: tasks/bin/run_external_test $TEST_GEM rake unit_spec + #rvm: 2.3.3 - env: TEST_GEM: poise script: tasks/bin/run_external_test $TEST_GEM rake spec @@ -116,7 +115,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -134,7 +133,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -152,7 +151,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -170,7 +169,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -188,13 +187,13 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests script: - bundle exec kitchen test webapp-debian-8 - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen after_failure: - cat .kitchen/logs/kitchen.log env: @@ -207,7 +206,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -225,7 +224,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -243,7 +242,7 @@ matrix: # 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) -# bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen +# bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen # before_script: # - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) # - cd kitchen-tests @@ -262,7 +261,7 @@ matrix: # 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) -# bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen +# bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen # before_script: # - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) # - cd kitchen-tests @@ -280,7 +279,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -298,7 +297,7 @@ matrix: 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) - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) - cd kitchen-tests @@ -318,7 +317,7 @@ matrix: - gem install bundler -v $(grep bundler omnibus_overrides.rb | cut -d'"' -f2) - sudo apt-get update - sudo apt-get -y install squid3 git curl - bundler_args: --without changelog development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen + bundler_args: --without ci development docgen guard integration maintenance omnibus_package tools aix bsd mac_os_x solaris windows --frozen env: - PROXY_TESTS_DIR=proxy_tests/files/default/scripts - PROXY_TESTS_REPO=$PROXY_TESTS_DIR/repo diff --git a/CHANGELOG.md b/CHANGELOG.md index e2d50e9ce8..470b5d30ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,53 @@ This changelog reflects the current state of chef's master branch on github and may not reflect the current released version of chef, which is [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef). +## [v13.0.34](https://github.com/chef/chef/tree/v13.0.34) (2017-03-13) +[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.34) + +**Closed issues:** + +- apt\_repository can't identify key fingerprints when gnupg 2.1.x is used [\#5831](https://github.com/chef/chef/issues/5831) +- We should update the default data bag encryption version for Chef 13 [\#5819](https://github.com/chef/chef/issues/5819) + +**Merged pull requests:** + +- Changed EOP to 'EOP' to avoid content expansion [\#5888](https://github.com/chef/chef/pull/5888) ([afiune](https://github.com/afiune)) +- Compress debs and rpms with xz [\#5884](https://github.com/chef/chef/pull/5884) ([thommay](https://github.com/thommay)) +- Fix apt\_repository for latest os version 16.10 [\#5874](https://github.com/chef/chef/pull/5874) ([afiune](https://github.com/afiune)) +- convert additional resource methods to properties [\#5871](https://github.com/chef/chef/pull/5871) ([lamont-granquist](https://github.com/lamont-granquist)) +- Add the ability to blacklist attributes from being saved to the chef server [\#5868](https://github.com/chef/chef/pull/5868) ([robmul](https://github.com/robmul)) + +## [v12.19.33](https://github.com/chef/chef/tree/v12.19.33) (2017-02-16) +[Full Changelog](https://github.com/chef/chef/compare/v12.18.31...v12.19.33) + +**Closed issues:** + +- Package resource fails chefspec on RHEL starting with Chef 12.18. [\#5769](https://github.com/chef/chef/issues/5769) + +**Merged pull requests:** + +- coerce immutable arrays to normal arrays in the yum\_package resource [\#5816](https://github.com/chef/chef/pull/5816) ([lamont-granquist](https://github.com/lamont-granquist)) +- Suppress sensitive properties from resource log and reporting output [\#5803](https://github.com/chef/chef/pull/5803) ([tduffield](https://github.com/tduffield)) +- Sanitize UTF-8 data sent to Data Collector [\#5793](https://github.com/chef/chef/pull/5793) ([lamont-granquist](https://github.com/lamont-granquist)) +- Add multipackage\_api support to yum\_package provider [\#5791](https://github.com/chef/chef/pull/5791) ([tduffield](https://github.com/tduffield)) +- rhel7 / dnf 2.0 fixes / improved errors [\#5782](https://github.com/chef/chef/pull/5782) ([lamont-granquist](https://github.com/lamont-granquist)) +- Grant Administrators group permissions to nodes directory under chef-solo [\#5781](https://github.com/chef/chef/pull/5781) ([tduffield](https://github.com/tduffield)) +- Fix --no-fips on chef-client [\#5778](https://github.com/chef/chef/pull/5778) ([btm](https://github.com/btm)) +- Raise error if ips\_package install returns non-zero [\#5773](https://github.com/chef/chef/pull/5773) ([tduffield](https://github.com/tduffield)) +- Use CIDR notation rather than netmask in route-eth0 file [\#5772](https://github.com/chef/chef/pull/5772) ([tduffield](https://github.com/tduffield)) +- Verify systemd\_unit file with custom verifier [\#5765](https://github.com/chef/chef/pull/5765) ([mal](https://github.com/mal)) +- Windows alternate user support for execute resources [\#5764](https://github.com/chef/chef/pull/5764) ([NimishaS](https://github.com/NimishaS)) +- favor metadata.json over metadata.rb [\#5750](https://github.com/chef/chef/pull/5750) ([lamont-granquist](https://github.com/lamont-granquist)) +- Ensure ssh search paginates correctly [\#5744](https://github.com/chef/chef/pull/5744) ([thommay](https://github.com/thommay)) +- Do not modify File's new\_resource during why-run [\#5742](https://github.com/chef/chef/pull/5742) ([scottopherson](https://github.com/scottopherson)) +- Add gems for ECC algorithm support to omnibus. [\#5736](https://github.com/chef/chef/pull/5736) ([rhass](https://github.com/rhass)) +- dh/url support cab [\#5732](https://github.com/chef/chef/pull/5732) ([dheerajd-msys](https://github.com/dheerajd-msys)) +- use git archive to speed up putting source in place [\#5730](https://github.com/chef/chef/pull/5730) ([robbkidd](https://github.com/robbkidd)) +- use pkg.path variable to reference path to self [\#5729](https://github.com/chef/chef/pull/5729) ([robbkidd](https://github.com/robbkidd)) +- Raise NamedSecurityInfo related exception using HR result. [\#5727](https://github.com/chef/chef/pull/5727) ([Aliasgar16](https://github.com/Aliasgar16)) +- Core: Ensure paths are correctly escaped when syntax checking [\#5704](https://github.com/chef/chef/pull/5704) ([ceneo](https://github.com/ceneo)) +- Added module\_version attribute for dsc\_resource for SxS support [\#5701](https://github.com/chef/chef/pull/5701) ([Aliasgar16](https://github.com/Aliasgar16)) +- Bump net-ssh to v4, add dependencies for ed25519 support [\#5687](https://github.com/chef/chef/pull/5687) ([onlyhavecans](https://github.com/onlyhavecans)) + ## [v12.18.31](https://github.com/chef/chef/tree/v12.18.31) (2017-01-11) [Full Changelog](https://github.com/chef/chef/compare/v12.17.44...v12.18.31) @@ -1330,6 +1378,5 @@ of partial templates. would not share the same actions/default_action as their parent * Raise error if a guard_interpreter is specified and a block is passed to a guard (conditional) * Allow specifying a guard_interpreter after a conditional on a resource (Fixes #1943) -* Windows package type should be a symbol (Fixes #1997) \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file @@ -11,6 +11,9 @@ source "https://rubygems.org" # of bundler versions prior to 1.12.0 (https://github.com/bundler/bundler/commit/193a14fe5e0d56294c7b370a0e59f93b2c216eed) gem "chef", path: "." +# tracking master of ohai for chef-13.0 development, this should be able to be deleted after release +gem "ohai", git: "https://github.com/chef/ohai.git" + gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__)) gem "rake" gem "bundler" @@ -31,12 +34,11 @@ end # These are used for external tests group(:integration) do - gem "chef-provisioning" gem "chef-sugar" gem "chefspec" - gem "halite" - gem "poise" - gem "poise-boiler" + gem "halite", git: "https://github.com/poise/halite.git" + gem "poise", git: "https://github.com/poise/poise.git" + gem "poise-boiler", git: "https://github.com/poise/poise-boiler.git" gem "knife-windows" gem "foodcritic" @@ -50,7 +52,7 @@ group(:docgen) do gem "yard" end -group(:maintenance) do +group(:maintenance, :ci) do gem "tomlrb" # To sync maintainers with github @@ -77,7 +79,7 @@ group(:development, :test) do gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master" end -group(:changelog) do +group(:ci) do gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator" gem "mixlib-install" end diff --git a/Gemfile.lock b/Gemfile.lock index e712ef3f51..f941e3acce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/chef/chef-server - revision: 53b28425d56005a92b0e3bb153f95b505168354a + revision: 847eaefa52e105a8e3c94a530f63b74bcbab6931 specs: oc-chef-pedant (2.2.0) activesupport (>= 4.2.7.1, < 6.0) @@ -16,7 +16,7 @@ GIT GIT remote: https://github.com/chef/chefstyle.git - revision: 7e47afd6141d3c44a11322916e3fc85c89aa9b59 + revision: b2bf89dd11270e169fd2315495c98095d4a19090 branch: master specs: chefstyle (0.5.0) @@ -36,6 +36,73 @@ GIT retriable (>= 1.4) GIT + remote: https://github.com/chef/ohai.git + revision: cab56af9f8e096f8ce0053e24d8f488c79708824 + specs: + ohai (13.0.0) + chef-config (>= 12.5.0.alpha.1, < 14) + ffi (~> 1.9) + ffi-yajl (~> 2.2) + ipaddress + mixlib-cli + mixlib-config (~> 2.0) + mixlib-log (>= 1.7.1, < 2.0) + mixlib-shellout (~> 2.0) + plist (~> 3.1) + systemu (~> 2.6.4) + wmi-lite (~> 1.0) + +GIT + remote: https://github.com/poise/halite.git + revision: b0f1372ea7710e47b52c8c843597d21aaed5ebf6 + specs: + halite (1.4.1.pre) + bundler + chef (>= 12.0, < 14.0) + stove (~> 4.0) + thor + +GIT + remote: https://github.com/poise/poise-boiler.git + revision: 409326e84519cf1a212073aed2f5cd3a6963d347 + specs: + poise-boiler (1.13.3.pre) + bundler + chefspec (~> 5.0) + codeclimate-test-reporter (~> 0.4) + codecov (~> 0.0, >= 0.0.2) + foodcritic (>= 7, < 9) + fuubar (~> 2.0) + git (~> 1.2) + halite (~> 1.2) + kitchen-docker (>= 2.6.0.rc.0) + kitchen-ec2 (~> 1.0) + kitchen-sync (~> 2.1) + kitchen-vagrant + mixlib-shellout (>= 1.4, < 3.0) + poise-profiler (~> 1.0) + pry + pry-byebug + rake (>= 10.4, < 12.0) + rspec (~> 3.2) + rspec-its (~> 1.2) + simplecov (~> 0.9) + test-kitchen (~> 1.7, >= 1.7.1) + travis (~> 1.8, >= 1.8.1) + vagrant-wrapper + winrm (>= 1.6, < 3) + winrm-fs (>= 0.4, < 2) + yard (~> 0.8) + yard-classmethods (~> 1.0) + +GIT + remote: https://github.com/poise/poise.git + revision: 1aa3a6b7c5b3fe0c357e2f3fcc50080790772ccb + specs: + poise (2.7.3.pre) + halite (~> 1.0) + +GIT remote: https://github.com/rubysec/bundler-audit.git revision: 6eb5a81e9b184fbb8db03f3e57dc758c65dd7383 specs: @@ -46,10 +113,10 @@ GIT PATH remote: . specs: - chef (12.19.39) + chef (13.0.35) addressable bundler (>= 1.10) - chef-config (= 12.19.39) + chef-config (= 13.0.35) chef-zero (>= 4.8) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -64,7 +131,7 @@ PATH net-sftp (~> 2.1, >= 2.1.2) net-ssh (>= 2.9, < 5.0) net-ssh-multi (~> 1.2, >= 1.2.1) - ohai (>= 8.6.0.alpha.1, < 13) + ohai (~> 13.0) plist (~> 3.2) proxifier (~> 1.0) rspec-core (~> 3.5) @@ -75,10 +142,10 @@ PATH specinfra (~> 2.10) syslog-logger (~> 1.6) uuidtools (~> 2.1.5) - chef (12.19.39-universal-mingw32) + chef (13.0.35-universal-mingw32) addressable bundler (>= 1.10) - chef-config (= 12.19.39) + chef-config (= 13.0.35) chef-zero (>= 4.8) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -94,7 +161,7 @@ PATH net-sftp (~> 2.1, >= 2.1.2) net-ssh (>= 2.9, < 5.0) net-ssh-multi (~> 1.2, >= 1.2.1) - ohai (>= 8.6.0.alpha.1, < 13) + ohai (~> 13.0) plist (~> 3.2) proxifier (~> 1.0) rspec-core (~> 3.5) @@ -119,7 +186,7 @@ PATH PATH remote: chef-config specs: - chef-config (12.19.39) + chef-config (13.0.35) addressable fuzzyurl mixlib-config (~> 2.0) @@ -128,7 +195,7 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (5.0.1) + activesupport (5.0.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) @@ -136,15 +203,15 @@ GEM addressable (2.4.0) appbundler (0.10.0) mixlib-cli (~> 1.4) - artifactory (2.6.0) + artifactory (2.7.0) ast (2.3.0) - aws-sdk (2.7.7) - aws-sdk-resources (= 2.7.7) - aws-sdk-core (2.7.7) + aws-sdk (2.8.5) + aws-sdk-resources (= 2.8.5) + aws-sdk-core (2.8.5) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.7.7) - aws-sdk-core (= 2.7.7) + aws-sdk-resources (2.8.5) + aws-sdk-core (= 2.8.5) aws-sigv4 (1.0.0) backports (3.6.8) binding_of_caller (0.7.2) @@ -154,22 +221,14 @@ GEM chef-api (0.7.0) logify (~> 0.1) mime-types - chef-provisioning (2.1.0) - cheffish (~> 4.0) - inifile (>= 2.0.2) - mixlib-install (>= 1.0, < 3.0) - net-scp (~> 1.0) - net-ssh (>= 2.9, < 5.0) - net-ssh-gateway (~> 1.2) - winrm-fs (~> 1.0) chef-sugar (3.4.0) - chef-zero (5.3.0) + chef-zero (5.3.1) ffi-yajl (~> 2.2) hashie (>= 2.0, < 4.0) mixlib-log (~> 1.3) rack (~> 2.0) uuidtools (~> 2.1) - cheffish (4.1.1) + cheffish (5.0.1) chef-zero (~> 5.0) net-ssh chefspec (5.4.0) @@ -178,12 +237,12 @@ GEM rspec (~> 3.0) codeclimate-test-reporter (0.6.0) simplecov (>= 0.7.1, < 1.0.0) - codecov (0.1.9) + codecov (0.1.10) json simplecov url coderay (1.1.1) - concurrent-ruby (1.0.4) + concurrent-ruby (1.0.5) cucumber (2.4.0) builder (>= 2.1.2) cucumber-core (~> 1.5.0) @@ -198,7 +257,7 @@ GEM debug_inspector (0.0.2) diff-lcs (1.3) docile (1.1.5) - domain_name (0.5.20161129) + domain_name (0.5.20170223) unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) ethon (0.10.1) @@ -212,8 +271,8 @@ GEM faraday (>= 0.7.4, < 1.0) fauxhai (3.10.0) net-ssh - ffi (1.9.17) - ffi (1.9.17-x86-mingw32) + ffi (1.9.18) + ffi (1.9.18-x86-mingw32) ffi-win32-extensions (1.0.3) ffi ffi-yajl (2.3.0) @@ -243,25 +302,19 @@ GEM ffi (>= 1.0.1) gyoku (1.3.1) builder (>= 2.1.2) - halite (1.4.0) - bundler - chef (~> 12.0) - stove (~> 4.0) - thor - hashie (3.5.3) + hashie (3.5.5) highline (1.7.8) http-cookie (1.0.3) domain_name (~> 0.5) httpclient (2.8.3) - i18n (0.8.0) - inifile (3.0.0) + i18n (0.8.1) iniparse (1.4.2) ipaddress (0.8.3) jmespath (1.3.1) json (2.0.3) kitchen-docker (2.6.0) test-kitchen (>= 1.0.0) - kitchen-ec2 (1.3.0) + kitchen-ec2 (1.3.2) aws-sdk (~> 2) excon multi_json @@ -270,7 +323,7 @@ GEM kitchen-sync (2.1.2) net-sftp test-kitchen (>= 1.0.0) - kitchen-vagrant (1.0.1) + kitchen-vagrant (1.0.2) test-kitchen (~> 1.4) knife-windows (1.9.0) winrm (~> 2.1) @@ -279,7 +332,7 @@ GEM addressable (~> 2.3) libyajl2 (1.2.0) little-plugger (1.1.4) - logging (2.1.0) + logging (2.2.0) little-plugger (~> 1.1) multi_json (~> 1.10) logify (0.2.0) @@ -316,7 +369,7 @@ GEM net-ssh (>= 2.6.5) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (4.0.1) + net-ssh (4.1.0) net-ssh-gateway (1.3.0) net-ssh (>= 2.6.5) net-ssh-multi (1.2.1) @@ -331,51 +384,9 @@ GEM nori (2.6.0) octokit (4.6.2) sawyer (~> 0.8.0, >= 0.5.3) - ohai (8.23.0) - chef-config (>= 12.5.0.alpha.1, < 13) - ffi (~> 1.9) - ffi-yajl (~> 2.2) - ipaddress - mixlib-cli - mixlib-config (~> 2.0) - mixlib-log (>= 1.7.1, < 2.0) - mixlib-shellout (~> 2.0) - plist (~> 3.1) - systemu (~> 2.6.4) - wmi-lite (~> 1.0) parser (2.4.0.0) ast (~> 2.2) plist (3.2.0) - poise (2.7.2) - halite (~> 1.0) - poise-boiler (1.13.2) - bundler - chefspec (~> 5.0) - codeclimate-test-reporter (~> 0.4) - codecov (~> 0.0, >= 0.0.2) - foodcritic (>= 7, < 9) - fuubar (~> 2.0) - git (~> 1.2) - halite (~> 1.2) - kitchen-docker (>= 2.6.0.rc.0) - kitchen-ec2 (~> 1.0) - kitchen-sync (~> 2.1) - kitchen-vagrant - mixlib-shellout (>= 1.4, < 3.0) - poise-profiler (~> 1.0) - pry - pry-byebug - rake (>= 10.4, < 12.0) - rspec (~> 3.2) - rspec-its (~> 1.2) - simplecov (~> 0.9) - test-kitchen (~> 1.7, >= 1.7.1) - travis (~> 1.8, >= 1.8.1) - vagrant-wrapper - winrm (>= 1.6, < 3) - winrm-fs (>= 0.4, < 2) - yard (~> 0.8) - yard-classmethods (~> 1.0) poise-profiler (1.0.1) halite (~> 1.0) polyglot (0.3.5) @@ -401,16 +412,16 @@ GEM rainbow (2.2.1) rake (11.3.0) rb-readline (0.5.4) - rest-client (2.0.0) + rest-client (2.0.1) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rest-client (2.0.0-x86-mingw32) + rest-client (2.0.1-x86-mingw32) ffi (~> 1.9) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - retriable (3.0.0) + retriable (3.0.1) retryable (2.0.4) rspec (3.5.0) rspec-core (~> 3.5.0) @@ -461,7 +472,7 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.0) slop (3.6.0) - specinfra (2.66.9) + specinfra (2.67.2) net-scp net-ssh (>= 2.7, < 5.0) net-telnet @@ -471,18 +482,18 @@ GEM logify (~> 0.2) syslog-logger (1.6.8) systemu (2.6.5) - test-kitchen (1.15.0) + test-kitchen (1.16.0) mixlib-install (>= 1.2, < 3.0) mixlib-shellout (>= 1.2, < 3.0) net-scp (~> 1.1) net-ssh (>= 2.9, < 5.0) net-ssh-gateway (~> 1.2) safe_yaml (~> 1.0) - thor (~> 0.18) - thor (0.19.4) - thread_safe (0.3.5) + thor (~> 0.19, < 0.19.2) + thor (0.19.1) + thread_safe (0.3.6) tomlrb (1.2.3) - travis (1.8.6) + travis (1.8.8) backports faraday (~> 0.9) faraday_middleware (~> 0.9, >= 0.9.1) @@ -526,7 +537,7 @@ GEM ffi-win32-extensions windows-api (0.4.4) win32-api (>= 1.4.5) - winrm (2.1.2) + winrm (2.1.3) builder (>= 2.1.2) erubis (~> 2.7) gssapi (~> 1.2) @@ -559,7 +570,6 @@ DEPENDENCIES bundler-audit! chef! chef-config! - chef-provisioning chef-sugar cheffish chefspec @@ -567,15 +577,16 @@ DEPENDENCIES cucumber (>= 2.4.0) foodcritic github_changelog_generator! - halite + halite! knife-windows mixlib-install netrc nokogiri oc-chef-pedant! octokit - poise - poise-boiler + ohai! + poise! + poise-boiler! pry pry-byebug pry-remote @@ -590,4 +601,4 @@ DEPENDENCIES yard BUNDLED WITH - 1.12.5 + 1.14.6 diff --git a/HISTORY.md b/HISTORY.md index acce953a47..9c3fdb8771 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,35 @@ +## [v12.19.33](https://github.com/chef/chef/tree/v12.19.33) (2017-02-16) +[Full Changelog](https://github.com/chef/chef/compare/v12.18.31...v12.19.33) + +**Closed issues:** + +- Package resource fails chefspec on RHEL starting with Chef 12.18. [\#5769](https://github.com/chef/chef/issues/5769) + +**Merged pull requests:** + +- coerce immutable arrays to normal arrays in the yum\_package resource [\#5816](https://github.com/chef/chef/pull/5816) ([lamont-granquist](https://github.com/lamont-granquist)) +- Suppress sensitive properties from resource log and reporting output [\#5803](https://github.com/chef/chef/pull/5803) ([tduffield](https://github.com/tduffield)) +- Sanitize UTF-8 data sent to Data Collector [\#5793](https://github.com/chef/chef/pull/5793) ([lamont-granquist](https://github.com/lamont-granquist)) +- Add multipackage\_api support to yum\_package provider [\#5791](https://github.com/chef/chef/pull/5791) ([tduffield](https://github.com/tduffield)) +- rhel7 / dnf 2.0 fixes / improved errors [\#5782](https://github.com/chef/chef/pull/5782) ([lamont-granquist](https://github.com/lamont-granquist)) +- Grant Administrators group permissions to nodes directory under chef-solo [\#5781](https://github.com/chef/chef/pull/5781) ([tduffield](https://github.com/tduffield)) +- Fix --no-fips on chef-client [\#5778](https://github.com/chef/chef/pull/5778) ([btm](https://github.com/btm)) +- Raise error if ips\_package install returns non-zero [\#5773](https://github.com/chef/chef/pull/5773) ([tduffield](https://github.com/tduffield)) +- Use CIDR notation rather than netmask in route-eth0 file [\#5772](https://github.com/chef/chef/pull/5772) ([tduffield](https://github.com/tduffield)) +- Verify systemd\_unit file with custom verifier [\#5765](https://github.com/chef/chef/pull/5765) ([mal](https://github.com/mal)) +- Windows alternate user support for execute resources [\#5764](https://github.com/chef/chef/pull/5764) ([NimishaS](https://github.com/NimishaS)) +- favor metadata.json over metadata.rb [\#5750](https://github.com/chef/chef/pull/5750) ([lamont-granquist](https://github.com/lamont-granquist)) +- Ensure ssh search paginates correctly [\#5744](https://github.com/chef/chef/pull/5744) ([thommay](https://github.com/thommay)) +- Do not modify File's new\_resource during why-run [\#5742](https://github.com/chef/chef/pull/5742) ([scottopherson](https://github.com/scottopherson)) +- Add gems for ECC algorithm support to omnibus. [\#5736](https://github.com/chef/chef/pull/5736) ([rhass](https://github.com/rhass)) +- dh/url support cab [\#5732](https://github.com/chef/chef/pull/5732) ([dheerajd-msys](https://github.com/dheerajd-msys)) +- use git archive to speed up putting source in place [\#5730](https://github.com/chef/chef/pull/5730) ([robbkidd](https://github.com/robbkidd)) +- use pkg.path variable to reference path to self [\#5729](https://github.com/chef/chef/pull/5729) ([robbkidd](https://github.com/robbkidd)) +- Raise NamedSecurityInfo related exception using HR result. [\#5727](https://github.com/chef/chef/pull/5727) ([Aliasgar16](https://github.com/Aliasgar16)) +- Core: Ensure paths are correctly escaped when syntax checking [\#5704](https://github.com/chef/chef/pull/5704) ([ceneo](https://github.com/ceneo)) +- Added module\_version attribute for dsc\_resource for SxS support [\#5701](https://github.com/chef/chef/pull/5701) ([Aliasgar16](https://github.com/Aliasgar16)) +- Bump net-ssh to v4, add dependencies for ed25519 support [\#5687](https://github.com/chef/chef/pull/5687) ([onlyhavecans](https://github.com/onlyhavecans)) + ## [v12.18.31](https://github.com/chef/chef/tree/v12.18.31) (2017-01-11) [Full Changelog](https://github.com/chef/chef/compare/v12.17.44...v12.18.31) @@ -1327,5 +1359,4 @@ of partial templates. * Fixed a bug where nested resources that inherited from Resource::LWRPBase would not share the same actions/default_action as their parent * Raise error if a guard_interpreter is specified and a block is passed to a guard (conditional) -* Allow specifying a guard_interpreter after a conditional on a resource (Fixes #1943) -* Windows package type should be a symbol (Fixes #1997)
\ No newline at end of file +* Allow specifying a guard_interpreter after a conditional on a resource (Fixes #1943)
\ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7d990d9fe7..4a5c0b8f8c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,150 +1,61 @@ _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._ -# Chef Client Release Notes 12.19: +# Chef Client Release Notes 13.0: -## Highlighted enhancements for this release: +## Back Compat Breaks -- Systemd unit files are now verified before being installed. -- Added support for windows alternate user identity in execute resources. -- Added ed25519 key support for for ssh connections. +### The path property of the execute resource has been removed -### Windows alternate user identity execute support +It was never implemented in the provider, so it was always a no-op to use it, the remediation is +to simply delete it. -The `execute` resource and similar resources such as `script`, `batch`, and `powershell_script` now support the specification of credentials on Windows so that the resulting process is created with the security identity that corresponds to those credentials. +### Using the command property on any script resource (including bash, etc) is now a hard error -**Note**: When Chef is running as a service, this feature requires that the user that Chef runs as has 'SeAssignPrimaryTokenPrivilege' (aka 'SE_ASSIGNPRIMARYTOKEN_NAME') user right. By default only LocalSystem and NetworkService have this right when running as a service. This is necessary even if the user is an Administrator. +This was always a usage mistake. The command property was used internally by the script resource and was not intended to be exposed +to users. Users should use the code property instead (or use the command property on an execute resource to execute a single command). -This right bacn be added and checked in a recipe using this example: +### Omitting the code property on any script resource (including bash, etc) is now a hard error -```ruby -# Add 'SeAssignPrimaryTokenPrivilege' for the user -Chef::ReservedNames::Win32::Security.add_account_right('<user>', 'SeAssignPrimaryTokenPrivilege') +It is possible that this was being used as a no-op resource, but the log resource is a better choice for that until we get a null +resource added. Omitting the code property or mixing up the code property with the command property are also common usage mistakes +that we need to catch and error on. -# Check if the user has 'SeAssignPrimaryTokenPrivilege' rights -Chef::ReservedNames::Win32::Security.get_account_right('<user>').include?('SeAssignPrimaryTokenPrivilege') -``` +### The chef_gem resource defaults to not run at compile time -#### Properties +The `compile_time true` flag may still be used to force compile time. -The following properties are new or updated for the `execute`, `script`, `batch`, and `powershell_script` resources and any resources derived from them: +### The Chef::Config[:chef_gem_compile_time] config option has been removed -- `user`<br> - **Ruby types:** String<br> - The user name of the user identity with which to launch the new process. Default value: `nil`. The user name may optionally be specified with a domain, i.e. `domain\user` or `user@my.dns.domain.com` via Universal Principal Name (UPN) format. It can also be specified without a domain simply as `user` if the domain is instead specified using the `domain` attribute. On Windows only, if this property is specified, the `password` property **must** be specified. +In order to for community cookbooks to behave consistently across all users this optional flag has been removed. -- `password`<br> - **Ruby types** String<br> - _Windows only:_ The password of the user specified by the `user` property. Default value: `nil`. This property is mandatory if `user` is specified on Windows and may only be specified if `user` is specified. The `sensitive` property for this resource will automatically be set to `true` if `password` is specified. +### The `supports[:manage_home]` and `supports[:non_unique]` API has been removed from all user providers -- `domain`<br> - **Ruby types** String<br> - _Windows only:_ The domain of the user user specified by the `user` property. Default value: `nil`. If not specified, the user name and password specified by the `user` and `password` properties will be used to resolve that user against the domain in which the system running Chef client is joined, or if that system is not joined to a domain it will resolve the user as a local account on that system. An alternative way to specify the domain is to leave this property unspecified and specify the domain as part of the `user` property. +The remediation is to set the manage_home and non_unique properties directly. -#### Usage +### Using relative paths in the `creates` property of an execute resource with specifying a `cwd` is now a hard error -The following examples explain how alternate user identity properties can be used in the execute resources: +Without a declared cwd the relative path was (most likely?) relative to wherever chef-client happened to be invoked which is +not deterministic or easy to intuit behavior. -```ruby -powershell_script 'create powershell-test file' do - code <<-EOH - $stream = [System.IO.StreamWriter] "#{Chef::Config[:file_cache_path]}/powershell-test.txt" - $stream.WriteLine("In #{Chef::Config[:file_cache_path]}...word.") - $stream.close() - EOH - user 'username' - password 'password' -end +### Chef::PolicyBuilder::ExpandNodeObject#load_node has been removed -execute 'mkdir test_dir' do - cwd Chef::Config[:file_cache_path] - domain "domain-name" - user "user" - password "password" -end +This change is most likely to only affect internals of tooling like chefspec if it affects anything at all. -script 'create test_dir' do - interpreter "bash" - code "mkdir test_dir" - cwd Chef::Config[:file_cache_path] - user "domain-name\\username" - password "password" -end +### PolicyFile failback to create non-policyfile nodes on Chef Server < 12.3 has been removed -batch 'create test_dir' do - code "mkdir test_dir" - cwd Chef::Config[:file_cache_path] - user "username@domain-name" - password "password" -end -``` +PolicyFile users on Chef-13 should be using Chef Server 12.3 or higher. -## Highlighted bug fixes for this release: +### Cookbooks with self dependencies are no longer allowed -- Ensure that the Windows Administrator group can access the chef-solo nodes directory -- When loading a cookbook in Chef Solo, use `metadata.json` in preference to `metadata.rb` +The remediation is removing the self-dependency `depends` line in the metadata. -## Deprecation Notice +### Removed `supports` API from Chef::Resource -- As of version 12.19, chef client will no longer be build or tested on the Cisco NX-OS and IOS XR platforms. +Retained only for the service resource (where it makes some sense) and for the mount resource. -# Ohai Release Notes 8.23: +### Removed deprecated `method_missing` access from the Chef::Node object -## Cumulus Linux Platform +Previously, the syntax `node.foo.bar` could be used to mean `node["foo"]["bar"]`, but this API had sharp edges where methods collided +with the core ruby Object class (e.g. `node.class`) and where it collided with our own ability to extend the `Chef::Node` API. This +method access has been deprecated for some time, and has been removed in Chef-13. -Cumulus Linux will now be detected as platform `cumulus` instead of `debian` and the `platform_version` will be properly set to the Cumulus Linux release. - -## Virtualization Detection - -Windows / Linux / BSD guests running on the Veertu hypervisors will now be detected - -Windows guests running on Xen and Hyper-V hypervisors will now be detected - -## New Sysconf Plugin - -A new plugin parses the output of the sysconf command to provide information on the underlying system. - -## AWS Account ID - -The EC2 plugin now fetches the AWS Account ID in addition to previous instance metadata - -## GCC Detection - -GCC detection has been improved to collect additional information, and to not prompt for the installation of Xcode on macOS systems - -## New deprecations introduced in this release: - -### Ohai::Config removed - -- **Deprecation ID**: OHAI-1 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_legacy_config.html> -- **Expected Removal**: Ohai 13 (April 2017) - -### sigar gem based plugins removed - -- **Deprecation ID**: OHAI-2 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_sigar_plugins.html> -- **Expected Removal**: Ohai 13 (April 2017) - -### run_command and popen4 helper methods removed - -- **Deprecation ID**: OHAI-3 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_run_command_helpers.html> -- **Expected Removal**: Ohai 13 (April 2017) - -### libvirt plugin attributes moved - -- **Deprecation ID**: OHAI-4 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_libvirt_plugin.html> -- **Expected Removal**: Ohai 13 (April 2017) - -### Windows CPU plugin attribute changes - -- **Deprecation ID**: OHAI-5 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_windows_cpu.html> -- **Expected Removal**: Ohai 13 (April 2017) - -### DigitalOcean plugin attribute changes - -- **Deprecation ID**: OHAI-6 -- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_digitalocean.html> -- **Expected Removal**: Ohai 13 (April 2017) @@ -29,30 +29,12 @@ require_relative "tasks/cbgb" require_relative "tasks/dependencies" require_relative "tasks/changelog" require_relative "tasks/announce" +require_relative "tasks/version" ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package| package.component_paths = ["chef-config"] package.generate_version_class = true end -# Add conservative dependency update to version:bump (which was created by PackageTask) -task "version:bump" => %w{version:bump_patch version:update} -task "version:bump" => %w{version:bump_patch version:update} - -task "version:bump_minor" do - Rake::Task["changelog:archive"].invoke - maj, min, _build = Chef::VERSION.split(".") - File.open("VERSION", "w+") { |f| f.write("#{maj}.#{min.to_i + 1}.0") } - Rake::Task["version"].invoke - Rake::Task["bundle:install"].invoke -end - -task "version:bump_major" do - Rake::Task["changelog:archive"].invoke - maj, _min, _build = Chef::VERSION.split(".") - File.open("VERSION", "w+") { |f| f.write("#{maj.to_i + 1}.0.0") } - Rake::Task["version"].invoke - Rake::Task["bundle:install"].invoke -end task :pedant, :chef_zero_spec @@ -1 +1 @@ -12.19.39
\ No newline at end of file +13.0.35
\ No newline at end of file diff --git a/acceptance/Gemfile b/acceptance/Gemfile index 41a18c9914..b466cd0f07 100644 --- a/acceptance/Gemfile +++ b/acceptance/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" gem "rake" # required to build some native extensions -gem "chef-acceptance", github: "chef/chef-acceptance" +gem "chef-acceptance", git: "https://github.com/chef/chef-acceptance.git" gem "kitchen-ec2" gem "inspec" gem "kitchen-vagrant" @@ -14,3 +14,6 @@ gem "berkshelf" # Pin to 1.2.3 because current mixlib-install has a problem where unstable # packages are not always immediately available via the omnitruck API. gem "mixlib-install", "1.2.3" + +# for chef-13 development - pin to the released rubygems version +gem "chef-config", "< 13.0" diff --git a/acceptance/Gemfile.lock b/acceptance/Gemfile.lock index 8dfb2ec217..40fcb3db61 100644 --- a/acceptance/Gemfile.lock +++ b/acceptance/Gemfile.lock @@ -1,5 +1,5 @@ GIT - remote: git://github.com/chef/chef-acceptance.git + remote: https://github.com/chef/chef-acceptance.git revision: e92ddae46d2126864698b9c8e4fc4ec2dcc46c55 specs: chef-acceptance (0.2.0) @@ -11,16 +11,16 @@ GEM specs: addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) - artifactory (2.6.0) - aws-sdk (2.7.5) - aws-sdk-resources (= 2.7.5) - aws-sdk-core (2.7.5) + artifactory (2.7.0) + aws-sdk (2.8.5) + aws-sdk-resources (= 2.8.5) + aws-sdk-core (2.8.5) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.7.5) - aws-sdk-core (= 2.7.5) + aws-sdk-resources (2.8.5) + aws-sdk-core (= 2.8.5) aws-sigv4 (1.0.0) - berkshelf (5.6.2) + berkshelf (5.6.3) addressable (~> 2.3, >= 2.3.4) berkshelf-api-client (>= 2.0.2, < 4.0) buff-config (~> 2.0) @@ -40,6 +40,7 @@ GEM faraday (~> 0.9) httpclient (~> 2.7) ridley (>= 4.5, < 6.0) + blankslate (2.1.2.4) buff-config (2.0.0) buff-extensions (~> 2.0) varia_model (~> 0.6) @@ -54,7 +55,7 @@ GEM celluloid-io (0.16.2) celluloid (>= 0.16.0) nio4r (>= 1.1.0) - chef-config (12.18.31) + chef-config (12.19.36) addressable fuzzyurl mixlib-config (~> 2.0) @@ -69,16 +70,16 @@ GEM excon (0.55.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - ffi (1.9.17) + ffi (1.9.18) fuzzyurl (0.9.0) gssapi (1.2.0) ffi (>= 1.0.1) gyoku (1.3.1) builder (>= 2.1.2) - hashie (3.5.1) + hashie (3.5.5) hitimes (1.2.4) httpclient (2.8.3) - inspec (1.14.1) + inspec (1.16.1) faraday (>= 0.9.0) hashie (~> 3.4) json (>= 1.8, < 3.0) @@ -93,10 +94,11 @@ GEM rubyzip (~> 1.1) sslshake (~> 1) thor (~> 0.19) + toml (~> 0.1) train (>= 0.22.0, < 1.0) jmespath (1.3.1) json (2.0.3) - kitchen-ec2 (1.2.0) + kitchen-ec2 (1.3.2) aws-sdk (~> 2) excon multi_json @@ -106,10 +108,10 @@ GEM hashie (~> 3.4) inspec (>= 0.34.0, < 2.0.0) test-kitchen (~> 1.6) - kitchen-vagrant (1.0.0) + kitchen-vagrant (1.0.2) test-kitchen (~> 1.4) little-plugger (1.1.4) - logging (2.1.0) + logging (2.2.0) little-plugger (~> 1.1) multi_json (~> 1.10) method_source (0.8.2) @@ -126,19 +128,21 @@ GEM mixlib-log (1.7.1) mixlib-shellout (2.2.7) mixlib-versioning (1.1.0) - molinillo (0.5.6) + molinillo (0.5.7) multi_json (1.12.1) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.0.1) + net-ssh (4.1.0) net-ssh-gateway (1.3.0) net-ssh (>= 2.6.5) nio4r (2.0.0) nori (2.6.0) octokit (4.6.2) sawyer (~> 0.8.0, >= 0.5.3) - parallel (1.10.0) + parallel (1.11.0) + parslet (1.5.0) + blankslate (~> 2.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -196,17 +200,19 @@ GEM molinillo (>= 0.5) semverse (>= 1.1, < 3.0) sslshake (1.0.13) - test-kitchen (1.15.0) + test-kitchen (1.16.0) mixlib-install (>= 1.2, < 3.0) mixlib-shellout (>= 1.2, < 3.0) net-scp (~> 1.1) net-ssh (>= 2.9, < 5.0) net-ssh-gateway (~> 1.2) safe_yaml (~> 1.0) - thor (~> 0.18) + thor (~> 0.19, < 0.19.2) thor (0.19.1) timers (4.0.4) hitimes + toml (0.1.2) + parslet (~> 1.5.0) train (0.22.1) docker-api (~> 1.26) json (>= 1.8, < 3.0) @@ -220,7 +226,7 @@ GEM hashie (>= 2.0.2, < 4.0.0) windows_chef_zero (2.0.0) test-kitchen (>= 1.2.1) - winrm (2.1.2) + winrm (2.1.3) builder (>= 2.1.2) erubis (~> 2.7) gssapi (~> 1.2) @@ -244,6 +250,7 @@ PLATFORMS DEPENDENCIES berkshelf chef-acceptance! + chef-config (< 13.0) inspec kitchen-ec2 kitchen-inspec @@ -255,4 +262,4 @@ DEPENDENCIES winrm-elevated BUNDLED WITH - 1.12.5 + 1.14.6 diff --git a/appveyor.yml b/appveyor.yml index 7b3780896c..2ea59184a6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,7 +31,7 @@ install: - bundler --version - SET BUNDLE_IGNORE_CONFIG=true - SET BUNDLE_FROZEN=1 - - SET BUNDLE_WITHOUT=development:guard:maintenance:tools:integration:changelog:docgen:travis:style:omnibus_package:aix:bsd:linux:mac_os_x:solaris + - SET BUNDLE_WITHOUT=development:guard:maintenance:tools:integration:ci:docgen:travis:style:omnibus_package:aix:bsd:linux:mac_os_x:solaris - appveyor DownloadFile http://curl.haxx.se/ca/cacert.pem -FileName C:\cacert.pem - set SSL_CERT_FILE=C:\cacert.pem diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 4f2516331d..9166437101 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -4,7 +4,7 @@ # Author:: AJ Christensen (<aj@chef.io>) # Author:: Mark Mzyk (<mmzyk@chef.io>) # Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -606,13 +606,10 @@ module ChefConfig end end - # As of Chef 11.0, version "1" is the default encrypted data bag item - # format. Version "2" is available which adds encrypt-then-mac protection. - # To maintain compatibility, versions other than 1 must be opt-in. + # As of Chef 13.0, version "3" is the default encrypted data bag item + # format. # - # Set this to `2` if you have chef-client 11.6.0+ in your infrastructure. - # Set this to `3` if you have chef-client 11.?.0+, ruby 2 and OpenSSL >= 1.0.1 in your infrastructure. (TODO) - default :data_bag_encrypt_version, 1 + default :data_bag_encrypt_version, 3 # When reading data bag items, any supported version is accepted. However, # if all encrypted data bags have been generated with the version 2 format, @@ -714,6 +711,7 @@ module ChefConfig default :ssh_user, nil default :ssh_attribute, nil default :ssh_gateway, nil + default :ssh_gateway_identity, nil default :bootstrap_version, nil default :bootstrap_proxy, nil default :bootstrap_template, nil @@ -825,13 +823,6 @@ module ChefConfig # default :no_lazy_load, true - # Default for the chef_gem compile_time attribute. Nil is the same as true but will emit - # warnings on every use of chef_gem prompting the user to be explicit. If the user sets this to - # true then the user will get backcompat behavior but with a single nag warning that cookbooks - # may break with this setting in the future. The false setting is the recommended setting and - # will become the default. - default :chef_gem_compile_time, nil - # A whitelisted array of attributes you want sent over the wire when node # data is saved. # The default setting is nil, which collects all data. Setting to [] will not @@ -841,6 +832,15 @@ module ChefConfig default :normal_attribute_whitelist, nil default :override_attribute_whitelist, nil + # A blacklisted array of attributes you do not want to send over the + # wire when node data is saved + # The default setting is nil, which collects all data. Setting to [] will + # still collect all data for save + default :automatic_attribute_blacklist, nil + default :default_attribute_blacklist, nil + default :normal_attribute_blacklist, nil + default :override_attribute_blacklist, nil + # Pull down all the rubygems versions from rubygems and cache them the first time we do a gem_package or # chef_gem install. This is memory-expensive and will grow without bounds, but will reduce network # round trips. @@ -1053,12 +1053,6 @@ module ChefConfig default :rubygems_url, "https://rubygems.org" - # This controls the behavior of resource cloning (and CHEF-3694 warnings). For Chef < 12 the behavior - # has been that this is 'true', in Chef 13 this will change to false. Setting this to 'true' in Chef - # 13 is not a viable or supported migration strategy since Chef 13 community cookbooks will be expected - # to break with this setting set to 'true'. - default :resource_cloning, true - # If installed via an omnibus installer, this gives the path to the # "embedded" directory which contains all of the software packaged with # omnibus. This is used to locate the cacert.pem file on windows. diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index de830c09d3..6c4ca4f435 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -182,6 +182,20 @@ module ChefConfig IO.write(version_file_path, new_version) end + task :bump_minor do + current_version = version + new_version = current_version.sub(/^(\d+)\.(\d+)\.(\d+)/) { "#{$1}.#{$2.to_i + 1}.0" } + puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" + IO.write(version_file_path, new_version) + end + + task :bump_major do + current_version = version + new_version = current_version.sub(/^(\d+)\.(\d+\.\d+)/) { "#{$1.to_i + 1}.0.0" } + puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}" + IO.write(version_file_path, new_version) + end + def update_version_rb # rubocop:disable Lint/NestedMethodDefinition puts "Updating #{version_rb_path} to include version #{version} ..." contents = <<-VERSION_RB diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index c84ff4304e..a7e0f6e5ff 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 = "12.19.39" + VERSION = "13.0.35" end # diff --git a/chef.gemspec b/chef.gemspec index 2b80d817b8..36387f91b0 100644 --- a/chef.gemspec +++ b/chef.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_dependency "mixlib-authentication", "~> 1.4" s.add_dependency "mixlib-shellout", "~> 2.0" s.add_dependency "mixlib-archive", "~> 0.4" - s.add_dependency "ohai", ">= 8.6.0.alpha.1", "< 13" + s.add_dependency "ohai", "~> 13.0" s.add_dependency "ffi-yajl", "~> 2.2" s.add_dependency "net-ssh", ">= 2.9", "< 5.0" diff --git a/ci/bundle_install.sh b/ci/bundle_install.sh index 4eecec9f18..6914189479 100755 --- a/ci/bundle_install.sh +++ b/ci/bundle_install.sh @@ -5,6 +5,6 @@ set -evx gem environment bundler_version=$(grep bundler omnibus_overrides.rb | cut -d'"' -f2) gem install bundler -v $bundler_version --user-install --conservative -# WITH: changelog (for version bumping and changelog creation) -export BUNDLE_WITHOUT=omnibus_package:test:pry:integration:docgen:maintenance:travis:aix:bsd:linux:mac_os_x:solaris:windows:development:travis +# WITH: ci (for version bumping and changelog creation) +export BUNDLE_WITHOUT=omnibus_package:test:pry:integration:docgen:maintenance:travis:aix:bsd:linux:mac_os_x:solaris:windows:development bundle _${bundler_version}_ install diff --git a/ci/version_bump.sh b/ci/version_bump.sh index ed2229ecc3..4b5ba5236b 100755 --- a/ci/version_bump.sh +++ b/ci/version_bump.sh @@ -6,8 +6,6 @@ export LANG=en_US.UTF-8 . ci/bundle_install.sh -bundle exec rake version:bump -bundle exec rake changelog || true -bundle exec rake update_dockerfile +bundle exec rake ci_version_bump git checkout .bundle/config diff --git a/kitchen-tests/.kitchen.travis.yml b/kitchen-tests/.kitchen.travis.yml index aae5202457..6a66daffe6 100644 --- a/kitchen-tests/.kitchen.travis.yml +++ b/kitchen-tests/.kitchen.travis.yml @@ -14,6 +14,7 @@ provisioner: github_owner: "chef" github_repo: "chef" refname: <%= ENV['TRAVIS_COMMIT'] %> + ohai_refname: "master" github_access_token: <%= ENV['KITCHEN_GITHUB_TOKEN'] %> data_path: test/fixtures # disable file provider diffs so we don't overflow travis' line limit diff --git a/kitchen-tests/.kitchen.yml b/kitchen-tests/.kitchen.yml index d6df77932a..33841b0b94 100644 --- a/kitchen-tests/.kitchen.yml +++ b/kitchen-tests/.kitchen.yml @@ -15,6 +15,7 @@ provisioner: chef_omnibus_install_options: "-c current" github_owner: "chef" github_repo: "chef" + ohai_refname: "master" refname: <%= %x(git rev-parse HEAD) %> data_path: test/fixtures client_rb: diff --git a/kitchen-tests/Berksfile.lock b/kitchen-tests/Berksfile.lock index 6d8f40436a..bf0adfee6c 100644 --- a/kitchen-tests/Berksfile.lock +++ b/kitchen-tests/Berksfile.lock @@ -14,7 +14,7 @@ DEPENDENCIES php (~> 1.5.0) resolver git: https://github.com/chef-cookbooks/resolver.git - revision: 8bf9034dabc47d29a07870e4059c32114f2c820a + revision: f82d7595a3536a757e7a9ed799ec06643c69ce25 GRAPH apt (4.0.2) @@ -52,37 +52,33 @@ GRAPH sudo (>= 0.0.0) ubuntu (>= 0.0.0) users (>= 0.0.0) - build-essential (7.0.3) - compat_resource (>= 12.16.3) + build-essential (8.0.0) mingw (>= 1.1) seven_zip (>= 0.0.0) - chef-client (7.1.0) + chef-client (7.2.0) cron (>= 1.7.0) logrotate (>= 1.9.0) windows (>= 1.42.0) chef-sugar (3.4.0) - chef_hostname (0.4.2) - compat_resource (>= 0.0.0) + chef_hostname (0.5.0) compat_resource (12.16.3) - cron (3.0.0) + cron (4.0.0) database (6.1.1) postgresql (>= 1.0.0) - firewall (2.5.3) + firewall (2.5.4) chef-sugar (>= 0.0.0) - httpd (0.4.4) - compat_resource (>= 12.14.6) - iis (5.0.5) + httpd (0.4.5) + compat_resource (>= 12.16.3) + iis (5.0.7) windows (>= 1.34.6) - iptables (3.1.0) - compat_resource (>= 12.14.3) + iptables (4.0.0) logrotate (2.1.0) compat_resource (>= 0.0.0) mariadb (1.0.1) apt (>= 0.0.0) yum (>= 0.0.0) yum-epel (>= 0.0.0) - mingw (1.2.5) - compat_resource (>= 12.16.3) + mingw (2.0.0) seven_zip (>= 0.0.0) multipackage (4.0.0) compat_resource (>= 0.0.0) @@ -93,14 +89,12 @@ GRAPH build-essential (>= 0.0.0) mariadb (>= 0.0.0) mysql (>= 6.0) - nscd (4.1.0) - compat_resource (>= 0.0.0) + nscd (5.0.0) ntp (3.3.1) - ohai (4.2.3) - compat_resource (>= 12.14.7) + ohai (5.0.0) openssh (2.1.1) iptables (>= 1.0) - openssl (6.1.1) + openssl (7.0.0) php (1.5.0) build-essential (>= 0.0.0) iis (>= 0.0.0) @@ -108,26 +102,26 @@ GRAPH windows (>= 0.0.0) xml (>= 0.0.0) yum-epel (>= 0.0.0) - postgresql (6.0.1) + postgresql (6.1.1) build-essential (>= 2.0.0) compat_resource (>= 12.16.3) openssl (>= 4.0) rbac (1.0.3) - resolver (1.3.1) + resolver (2.0.1) selinux (0.9.0) seven_zip (2.0.2) windows (>= 1.2.2) smf (2.2.8) rbac (>= 1.0.1) sudo (3.3.1) - ubuntu (2.0.0) + ubuntu (2.0.1) apt (>= 0.0.0) users (4.0.3) windows (2.1.1) ohai (>= 4.0.0) xml (3.1.1) build-essential (>= 0.0.0) - yum (4.1.0) + yum (5.0.0) yum-epel (2.1.1) compat_resource (>= 12.16.3) yum-mysql-community (2.0.3) diff --git a/kitchen-tests/Gemfile b/kitchen-tests/Gemfile index 707a38a7f6..e41d2ff808 100644 --- a/kitchen-tests/Gemfile +++ b/kitchen-tests/Gemfile @@ -1,5 +1,6 @@ source "https://rubygems.org" +gem "chef-config", "< 13" gem "rake" # required to build some native extensions gem "berkshelf" gem "kitchen-appbundle-updater" diff --git a/kitchen-tests/Gemfile.lock b/kitchen-tests/Gemfile.lock index b9d14397f1..ad1674fd6a 100644 --- a/kitchen-tests/Gemfile.lock +++ b/kitchen-tests/Gemfile.lock @@ -3,16 +3,16 @@ GEM specs: addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) - artifactory (2.6.0) - aws-sdk (2.7.5) - aws-sdk-resources (= 2.7.5) - aws-sdk-core (2.7.5) + artifactory (2.7.0) + aws-sdk (2.8.5) + aws-sdk-resources (= 2.8.5) + aws-sdk-core (2.8.5) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.7.5) - aws-sdk-core (= 2.7.5) + aws-sdk-resources (2.8.5) + aws-sdk-core (= 2.8.5) aws-sigv4 (1.0.0) - berkshelf (5.6.2) + berkshelf (5.6.3) addressable (~> 2.3, >= 2.3.4) berkshelf-api-client (>= 2.0.2, < 4.0) buff-config (~> 2.0) @@ -32,6 +32,7 @@ GEM faraday (~> 0.9) httpclient (~> 2.7) ridley (>= 4.5, < 6.0) + blankslate (2.1.2.4) buff-config (2.0.0) buff-extensions (~> 2.0) varia_model (~> 0.6) @@ -46,7 +47,7 @@ GEM celluloid-io (0.16.2) celluloid (>= 0.16.0) nio4r (>= 1.1.0) - chef-config (12.18.31) + chef-config (12.19.36) addressable fuzzyurl mixlib-config (~> 2.0) @@ -61,18 +62,18 @@ GEM excon (0.55.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - ffi (1.9.17) - ffi (1.9.17-x86-mingw32) + ffi (1.9.18) + ffi (1.9.18-x86-mingw32) fuzzyurl (0.9.0) gssapi (1.2.0) ffi (>= 1.0.1) gyoku (1.3.1) builder (>= 2.1.2) - hashie (3.5.1) + hashie (3.5.5) hitimes (1.2.4) hitimes (1.2.4-x86-mingw32) httpclient (2.8.3) - inspec (1.14.1) + inspec (1.16.1) faraday (>= 0.9.0) hashie (~> 3.4) json (>= 1.8, < 3.0) @@ -87,14 +88,15 @@ GEM rubyzip (~> 1.1) sslshake (~> 1) thor (~> 0.19) + toml (~> 0.1) train (>= 0.22.0, < 1.0) jmespath (1.3.1) json (2.0.3) - kitchen-appbundle-updater (0.1.2) + kitchen-appbundle-updater (0.2.0) kitchen-dokken (1.1.0) docker-api (~> 1.33) test-kitchen (~> 1.13) - kitchen-ec2 (1.2.0) + kitchen-ec2 (1.3.2) aws-sdk (~> 2) excon multi_json @@ -104,10 +106,10 @@ GEM hashie (~> 3.4) inspec (>= 0.34.0, < 2.0.0) test-kitchen (~> 1.6) - kitchen-vagrant (1.0.0) + kitchen-vagrant (1.0.2) test-kitchen (~> 1.4) little-plugger (1.1.4) - logging (2.1.0) + logging (2.2.0) little-plugger (~> 1.1) multi_json (~> 1.10) method_source (0.8.2) @@ -128,19 +130,21 @@ GEM win32-process (~> 0.8.2) wmi-lite (~> 1.0) mixlib-versioning (1.1.0) - molinillo (0.5.6) + molinillo (0.5.7) multi_json (1.12.1) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.0.1) + net-ssh (4.1.0) net-ssh-gateway (1.3.0) net-ssh (>= 2.6.5) nio4r (2.0.0) nori (2.6.0) octokit (4.6.2) sawyer (~> 0.8.0, >= 0.5.3) - parallel (1.10.0) + parallel (1.11.0) + parslet (1.5.0) + blankslate (~> 2.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -198,17 +202,19 @@ GEM molinillo (>= 0.5) semverse (>= 1.1, < 3.0) sslshake (1.0.13) - test-kitchen (1.15.0) + test-kitchen (1.16.0) mixlib-install (>= 1.2, < 3.0) mixlib-shellout (>= 1.2, < 3.0) net-scp (~> 1.1) net-ssh (>= 2.9, < 5.0) net-ssh-gateway (~> 1.2) safe_yaml (~> 1.0) - thor (~> 0.18) + thor (~> 0.19, < 0.19.2) thor (0.19.1) timers (4.0.4) hitimes + toml (0.1.2) + parslet (~> 1.5.0) train (0.22.1) docker-api (~> 1.26) json (>= 1.8, < 3.0) @@ -223,7 +229,7 @@ GEM hashie (>= 2.0.2, < 4.0.0) win32-process (0.8.3) ffi (>= 1.0.0) - winrm (2.1.2) + winrm (2.1.3) builder (>= 2.1.2) erubis (~> 2.7) gssapi (~> 1.2) @@ -245,6 +251,7 @@ PLATFORMS DEPENDENCIES berkshelf + chef-config (< 13) kitchen-appbundle-updater kitchen-dokken (< 2.0) kitchen-ec2 @@ -256,4 +263,4 @@ DEPENDENCIES vagrant-wrapper BUNDLED WITH - 1.12.5 + 1.14.6 diff --git a/lib-backcompat/chef/chef_fs/file_system/acl_entry.rb b/lib-backcompat/chef/chef_fs/file_system/acl_entry.rb deleted file mode 100644 index f28b9f86e3..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/acl_entry.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/chef_server/acl_entry" - -module Chef::ChefFS::FileSystem - AclEntry = ChefServer::AclEntry -end diff --git a/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb b/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb b/lib-backcompat/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb deleted file mode 100644 index 123fb9ee9a..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir" - -module Chef::ChefFS::FileSystem - ChefRepositoryFileSystemRootDir = Repository::ChefRepositoryFileSystemRootDir -end diff --git a/lib-backcompat/chef/chef_fs/file_system/chef_server_root_dir.rb b/lib-backcompat/chef/chef_fs/file_system/chef_server_root_dir.rb deleted file mode 100644 index acb81dd08a..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/chef_server_root_dir.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/chef_server/chef_server_root_dir" - -module Chef::ChefFS::FileSystem - ChefServerRootDir = ChefServer::ChefServerRootDir -end diff --git a/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb b/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb b/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb b/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb b/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb b/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb b/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb b/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb deleted file mode 100644 index 75cebe5497..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/exceptions" -Chef.deprecated :internal_api, "Individual ChefFS error files are deprecated. Please require 'chef/chef_fs/file_system/exceptions' rather than 'chef/chef_fs/file_system/#{File.basename(__FILE__, ".rb")}'." diff --git a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb b/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb deleted file mode 100644 index d9bdbc104c..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/repository/acls_dir" - -module Chef::ChefFS::FileSystem::Repository - ChefRepositoryFileSystemAclsDir = AclsDir -end diff --git a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb b/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb deleted file mode 100644 index 4ebcb5f010..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/repository/client_keys_dir" - -module Chef::ChefFS::FileSystem::Repository - ChefRepositoryFileSystemClientKeysDir = ClientKeysDir -end diff --git a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb b/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb deleted file mode 100644 index 7668c6b174..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "chef/chef_fs/file_system/repository/file_system_entry" - -module Chef::ChefFS::FileSystem::Repository - Chef.deprecated :internal_api, "Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemEntry is deprecated. Please use FileSystemEntry directly" - ChefRepositoryFileSystemEntry = FileSystemEntry -end diff --git a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb b/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb deleted file mode 100644 index 393e4aa85d..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "chef/chef_fs/file_system/repository/policies_dir" - -module Chef::ChefFS::FileSystem::Repository - ChefRepositoryFileSystemPoliciesDir = PoliciesDir -end diff --git a/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb b/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb deleted file mode 100644 index 1c8bb87d72..0000000000 --- a/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/chef_fs/file_system/repository/file_system_entry" - -class Chef - module ChefFS - module FileSystem - module Repository - class FileSystemRootDir < FileSystemEntry - def initialize(file_path) - Chef.deprecated :internal_api, "Chef::ChefFS::FileSystem::Repository::FileSystemRootDir is deprecated." - super("", nil, file_path) - end - end - end - end - end -end diff --git a/lib/chef/application.rb b/lib/chef/application.rb index ab19e6571e..86078300c2 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@chef.io>) # Author:: Mark Mzyk (mmzyk@chef.io) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,7 +48,6 @@ class Chef configure_chef configure_logging configure_encoding - emit_warnings end # Get this party started @@ -332,12 +331,6 @@ class Chef ENV end - def emit_warnings - if Chef::Config[:chef_gem_compile_time] - Chef.deprecated :chef_gem_compile_time, "setting chef_gem_compile_time to true is deprecated" - end - end - class << self def debug_stacktrace(e) message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}" diff --git a/lib/chef/blacklist.rb b/lib/chef/blacklist.rb new file mode 100644 index 0000000000..a49c318295 --- /dev/null +++ b/lib/chef/blacklist.rb @@ -0,0 +1,81 @@ + +require "chef/exceptions" + +class Chef + class Blacklist + + # filter takes two arguments - the data you want to filter, and a blacklisted array + # of keys you want discluded. You can capture a subtree of the data to filter by + # providing a "/"-delimited string of keys. If some key includes "/"-characters, + # you must provide an array of keys instead. + # + # Blacklist.filter( + # { "filesystem" => { + # "/dev/disk" => { + # "size" => "10mb" + # }, + # "map - autohome" => { + # "size" => "10mb" + # } + # }, + # "network" => { + # "interfaces" => { + # "eth0" => {...}, + # "eth1" => {...} + # } + # } + # }, + # ["network/interfaces/eth0", ["filesystem", "/dev/disk"]]) + # will exclude the eth0 and /dev/disk subtrees. + def self.filter(data, blacklist = nil) + return data if blacklist.nil? + + blacklist.each do |item| + Chef::Log.warn("Removing item #{item}") + remove_data(data, item) + end + data + end + + # Walk the data according to the keys provided by the blacklisted item + # to get a reference to the item that will be removed. + def self.remove_data(data, item) + parts = to_array(item) + + item_ref = data + parts[0..-2].each do |part| + unless item_ref[part] + Chef::Log.warn("Could not find blacklist attribute #{item}.") + return nil + end + + item_ref = item_ref[part] + end + + unless item_ref.key?(parts[-1]) + Chef::Log.warn("Could not find blacklist attribute #{item}.") + return nil + end + + item_ref.delete(parts[-1]) + data + end + + private_class_method :remove_data + + # Accepts a String or an Array, and returns an Array of String keys that + # are used to traverse the data hash. Strings are split on "/", Arrays are + # assumed to contain exact keys (that is, Array elements will not be split + # by "/"). + def self.to_array(item) + return item if item.kind_of? Array + + parts = item.split("/") + parts.shift if !parts.empty? && parts[0].empty? + parts + end + + private_class_method :to_array + + end +end diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index 3f23bc2056..a8ec901e97 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) # Author:: Seth Falcon (<seth@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -306,7 +306,7 @@ class Chef # versions<Array>:: Returns the list of versions for the platform def depends(cookbook, *version_args) if cookbook == name - Chef::Log.warn "Ignoring self-dependency in cookbook #{name}, please remove it (in the future this will be fatal)." + raise "Cookbook depends on itself in cookbook #{name}, please remove the this unnecessary self-dependency" else version = new_args_format(:depends, cookbook, version_args) constraint = validate_version_constraint(:depends, cookbook, version) diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb index e5026d2317..461f65225b 100644 --- a/lib/chef/deprecated.rb +++ b/lib/chef/deprecated.rb @@ -1,5 +1,5 @@ #-- -# Copyright:: Copyright 2016 Chef Software, Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,36 +66,38 @@ class Chef end end - class JsonAutoInflate < Base + class InternalApi < Base def id - 1 + 0 end def target - "json_auto_inflate.html" + "internal_api.html" end end - class ExitCode < Base + class JsonAutoInflate < Base def id - 2 + 1 end def target - "exit_code.html" + "json_auto_inflate.html" end end - class ChefGemCompileTime < Base + class ExitCode < Base def id - 3 + 2 end def target - "chef_gem_compile_time.html" + "exit_code.html" end end + # id 3 has been deleted + class Attributes < Base def id 4 @@ -156,6 +158,16 @@ class Chef end end + class DnfPackageAllowDowngrade < Base + def id + 10 + end + + def target + "dnf_package_allow_downgrade.html" + end + end + class PropertyNameCollision < Base def id 11 @@ -206,35 +218,7 @@ class Chef end end - class ResourceCloning < Base - def id - 3694 - end - - def target - "resource_cloning.html" - end - end - - class InternalApi < Base - def id - 0 - end - - def target - "internal_api.html" - end - end - - class DnfPackageAllowDowngrade < Base - def id - 10 - end - - def target - "dnf_package_allow_downgrade.html" - end - end + # id 3694 was deleted class Generic < Base def url diff --git a/lib/chef/deprecation/mixin/template.rb b/lib/chef/deprecation/mixin/template.rb deleted file mode 100644 index 0c902123cf..0000000000 --- a/lib/chef/deprecation/mixin/template.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "tempfile" -require "erubis" - -class Chef - module Deprecation - module Mixin - # == Deprecation::Provider::Mixin::Template - # This module contains the deprecated functions of - # Chef::Mixin::Template. These functions are refactored to different - # components. They are frozen and will be removed in Chef 13. - # - - module Template - def render_template(template, context) - begin - eruby = Erubis::Eruby.new(template) - output = eruby.evaluate(context) - rescue Object => e - raise TemplateError.new(e, template, context) - end - Tempfile.open("chef-rendered-template") do |tempfile| - tempfile.print(output) - tempfile.close - yield tempfile - end - end - end - end - end -end diff --git a/lib/chef/deprecation/provider/cookbook_file.rb b/lib/chef/deprecation/provider/cookbook_file.rb deleted file mode 100644 index d6e8a7566e..0000000000 --- a/lib/chef/deprecation/provider/cookbook_file.rb +++ /dev/null @@ -1,54 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module Deprecation - module Provider - - # == Deprecation::Provider::CookbookFile - # This module contains the deprecated functions of - # Chef::Provider::CookbookFile. These functions are refactored to - # different components. They are frozen and will be removed in Chef 13. - # - module CookbookFile - - def file_cache_location - @file_cache_location ||= begin - cookbook = run_context.cookbook_collection[resource_cookbook] - cookbook.preferred_filename_on_disk_location(node, :files, @new_resource.source, @new_resource.path) - end - end - - def resource_cookbook - @new_resource.cookbook || @new_resource.cookbook_name - end - - def content_stale? - ( ! ::File.exist?(@new_resource.path)) || ( ! compare_content) - end - - def backup_new_resource - if ::File.exists?(@new_resource.path) - backup @new_resource.path - end - end - - end - end - end -end diff --git a/lib/chef/deprecation/provider/file.rb b/lib/chef/deprecation/provider/file.rb deleted file mode 100644 index edb0052fdf..0000000000 --- a/lib/chef/deprecation/provider/file.rb +++ /dev/null @@ -1,198 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/util/path_helper" - -class Chef - module Deprecation - module Provider - - # == Deprecation::Provider::File - # This module contains the deprecated functions of - # Chef::Provider::File. These functions are refactored to different - # components. They are frozen and will be removed in Chef 13. - # - module File - - def diff_current_from_content(new_content) - result = nil - Tempfile.open("chef-diff") do |file| - file.write new_content - file.close - result = diff_current file.path - end - result - end - - def is_binary?(path) - ::File.open(path) do |file| - - buff = file.read(Chef::Config[:diff_filesize_threshold]) - buff = "" if buff.nil? - return buff !~ /^[\r[:print:]]*$/ - end - end - - def diff_current(temp_path) - suppress_resource_reporting = false - - return [ "(diff output suppressed by config)" ] if Chef::Config[:diff_disabled] - return [ "(no temp file with new content, diff output suppressed)" ] unless ::File.exists?(temp_path) # should never happen? - - # solaris does not support diff -N, so create tempfile to diff against if we are creating a new file - target_path = if ::File.exists?(@current_resource.path) - @current_resource.path - else - suppress_resource_reporting = true # suppress big diffs going to resource reporting service - tempfile = Tempfile.new("chef-tempfile") - tempfile.path - end - - diff_filesize_threshold = Chef::Config[:diff_filesize_threshold] - diff_output_threshold = Chef::Config[:diff_output_threshold] - - if ::File.size(target_path) > diff_filesize_threshold || ::File.size(temp_path) > diff_filesize_threshold - return [ "(file sizes exceed #{diff_filesize_threshold} bytes, diff output suppressed)" ] - end - - # MacOSX(BSD?) diff will *sometimes* happily spit out nasty binary diffs - return [ "(current file is binary, diff output suppressed)"] if is_binary?(target_path) - return [ "(new content is binary, diff output suppressed)"] if is_binary?(temp_path) - - begin - # -u: Unified diff format - result = shell_out("diff -u #{target_path} #{temp_path}" ) - rescue Exception => e - # Should *not* receive this, but in some circumstances it seems that - # an exception can be thrown even using shell_out instead of shell_out! - return [ "Could not determine diff. Error: #{e.message}" ] - end - - # diff will set a non-zero return code even when there's - # valid stdout results, if it encounters something unexpected - # So as long as we have output, we'll show it. - if not result.stdout.empty? - if result.stdout.length > diff_output_threshold - [ "(long diff of over #{diff_output_threshold} characters, diff output suppressed)" ] - else - val = result.stdout.split("\n") - val.delete("\\ No newline at end of file") - @new_resource.diff(val.join("\\n")) unless suppress_resource_reporting - val - end - elsif not result.stderr.empty? - [ "Could not determine diff. Error: #{result.stderr}" ] - else - [ "(no diff)" ] - end - end - - def setup_acl - return if Chef::Platform.windows? - acl_scanner = ScanAccessControl.new(@new_resource, @current_resource) - acl_scanner.set_all! - end - - def compare_content - checksum(@current_resource.path) == new_resource_content_checksum - end - - def set_content - unless compare_content - description = [] - description << "update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(new_resource_content_checksum)}" - description << diff_current_from_content(@new_resource.content) - converge_by(description) do - backup @new_resource.path if ::File.exists?(@new_resource.path) - ::File.open(@new_resource.path, "w") { |f| f.write @new_resource.content } - Chef::Log.info("#{@new_resource} contents updated") - end - end - end - - def update_new_file_state(path = @new_resource.path) - if !::File.directory?(path) - @new_resource.checksum(checksum(path)) - end - - if Chef::Platform.windows? - # TODO: To work around CHEF-3554, add support for Windows - # equivalent, or implicit resource reporting won't work for - # Windows. - return - end - - acl_scanner = ScanAccessControl.new(@new_resource, @new_resource) - acl_scanner.set_all! - end - - def set_all_access_controls - if access_controls.requires_changes? - converge_by(access_controls.describe_changes) do - access_controls.set_all - #Update file state with new access values - update_new_file_state - end - end - end - - def deploy_tempfile - Tempfile.open(::File.basename(@new_resource.name)) do |tempfile| - yield tempfile - - temp_res = Chef::Resource::CookbookFile.new(@new_resource.name) - temp_res.path(tempfile.path) - ac = Chef::FileAccessControl.new(temp_res, @new_resource, self) - ac.set_all! - FileUtils.mv(tempfile.path, @new_resource.path) - end - end - - def backup(file = nil) - file ||= @new_resource.path - if @new_resource.backup != false && @new_resource.backup > 0 && ::File.exist?(file) - time = Time.now - savetime = time.strftime("%Y%m%d%H%M%S") - backup_filename = "#{@new_resource.path}.chef-#{savetime}" - backup_filename = backup_filename.sub(/^([A-Za-z]:)/, "") #strip drive letter on Windows - # if :file_backup_path is nil, we fallback to the old behavior of - # keeping the backup in the same directory. We also need to to_s it - # so we don't get a type error around implicit to_str conversions. - prefix = Chef::Config[:file_backup_path].to_s - backup_path = ::File.join(prefix, backup_filename) - FileUtils.mkdir_p(::File.dirname(backup_path)) if Chef::Config[:file_backup_path] - FileUtils.cp(file, backup_path, :preserve => true) - Chef::Log.info("#{@new_resource} backed up to #{backup_path}") - - # Clean up after the number of backups - slice_number = @new_resource.backup - backup_files = Dir[Chef::Util::PathHelper.escape_glob_dir(prefix, ".#{@new_resource.path}") + ".chef-*"].sort { |a, b| b <=> a } - if backup_files.length >= @new_resource.backup - remainder = backup_files.slice(slice_number..-1) - remainder.each do |backup_to_delete| - FileUtils.rm(backup_to_delete) - Chef::Log.info("#{@new_resource} removed backup at #{backup_to_delete}") - end - end - end - end - - end - end - end -end diff --git a/lib/chef/deprecation/provider/remote_directory.rb b/lib/chef/deprecation/provider/remote_directory.rb deleted file mode 100644 index 9b442651d7..0000000000 --- a/lib/chef/deprecation/provider/remote_directory.rb +++ /dev/null @@ -1,52 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module Deprecation - module Provider - module RemoteDirectory - - def directory_root_in_cookbook_cache - Chef.deprecated :internal_api, "the Chef::Provider::RemoteDirectory#directory_root_in_cookbook_cache method is deprecated" - - @directory_root_in_cookbook_cache ||= - begin - cookbook = run_context.cookbook_collection[resource_cookbook] - cookbook.preferred_filename_on_disk_location(node, :files, source, path) - end - end - - # List all excluding . and .. - def ls(path) - files = Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob_dir(path), "**", "*"), - ::File::FNM_DOTMATCH) - - # Remove current directory and previous directory - files = files.reject do |name| - basename = Pathname.new(name).basename().to_s - [".", ".."].include?(basename) - end - - # Clean all the paths... this is required because of the join - files.map { |f| Chef::Util::PathHelper.cleanpath(f) } - end - - end - end - end -end diff --git a/lib/chef/deprecation/provider/remote_file.rb b/lib/chef/deprecation/provider/remote_file.rb deleted file mode 100644 index aefb04752e..0000000000 --- a/lib/chef/deprecation/provider/remote_file.rb +++ /dev/null @@ -1,85 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module Deprecation - module Provider - - # == Deprecation::Provider::RemoteFile - # This module contains the deprecated functions of - # Chef::Provider::RemoteFile. These functions are refactored to different - # components. They are frozen and will be removed in Chef 13. - # - module RemoteFile - - def current_resource_matches_target_checksum? - @new_resource.checksum && @current_resource.checksum && @current_resource.checksum =~ /^#{Regexp.escape(@new_resource.checksum)}/ - end - - def matches_current_checksum?(candidate_file) - Chef::Log.debug "#{@new_resource} checking for file existence of #{@new_resource.path}" - if ::File.exists?(@new_resource.path) - Chef::Log.debug "#{@new_resource} file exists at #{@new_resource.path}" - @new_resource.checksum(checksum(candidate_file.path)) - Chef::Log.debug "#{@new_resource} target checksum: #{@current_resource.checksum}" - Chef::Log.debug "#{@new_resource} source checksum: #{@new_resource.checksum}" - - @new_resource.checksum == @current_resource.checksum - else - Chef::Log.debug "#{@new_resource} creating #{@new_resource.path}" - false - end - end - - def backup_new_resource - if ::File.exists?(@new_resource.path) - Chef::Log.debug "#{@new_resource} checksum changed from #{@current_resource.checksum} to #{@new_resource.checksum}" - backup @new_resource.path - end - end - - def source_file(source, current_checksum, &block) - if absolute_uri?(source) - fetch_from_uri(source, &block) - elsif !Chef::Config[:solo_legacy_mode] - fetch_from_chef_server(source, current_checksum, &block) - else - fetch_from_local_cookbook(source, &block) - end - end - - def http_client_opts(source) - opts = {} - # CHEF-3140 - # 1. If it's already compressed, trying to compress it more will - # probably be counter-productive. - # 2. Some servers are misconfigured so that you GET $URL/file.tgz but - # they respond with content type of tar and content encoding of gzip, - # which tricks Chef::REST into decompressing the response body. In this - # case you'd end up with a tar archive (no gzip) named, e.g., foo.tgz, - # which is not what you wanted. - if @new_resource.path =~ /gz$/ || source =~ /gz$/ - opts[:disable_gzip] = true - end - opts - end - - end - end - end -end diff --git a/lib/chef/deprecation/provider/template.rb b/lib/chef/deprecation/provider/template.rb deleted file mode 100644 index ea5a880798..0000000000 --- a/lib/chef/deprecation/provider/template.rb +++ /dev/null @@ -1,63 +0,0 @@ -# -# Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/deprecation/mixin/template" - -class Chef - module Deprecation - module Provider - - # == Deprecation::Provider::Template - # This module contains the deprecated functions of - # Chef::Provider::Template. These functions are refactored to different - # components. They are frozen and will be removed in Chef 13. - # - module Template - - include Chef::Deprecation::Mixin::Template - - def template_finder - @template_finder ||= begin - Chef::Provider::TemplateFinder.new(run_context, cookbook_name, node) - end - end - - def template_location - @template_file_cache_location ||= begin - template_finder.find(@new_resource.source, :local => @new_resource.local, :cookbook => @new_resource.cookbook) - end - end - - def resource_cookbook - @new_resource.cookbook || @new_resource.cookbook_name - end - - def rendered(rendered_template) - @new_resource.checksum(checksum(rendered_template.path)) - Chef::Log.debug("Current content's checksum: #{@current_resource.checksum}") - Chef::Log.debug("Rendered content's checksum: #{@new_resource.checksum}") - end - - def content_matches? - @current_resource.checksum == @new_resource.checksum - end - - end - end - end -end diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index ae62f42b09..78bdf0cf4a 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@chef.io>) # Author:: Seth Falcon (<seth@chef.io>) # Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,6 +47,7 @@ class Chef class Cron < RuntimeError; end class Env < RuntimeError; end class Exec < RuntimeError; end + class Execute < RuntimeError; end class ErlCall < RuntimeError; end class FileNotFound < RuntimeError; end class Package < RuntimeError; end diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb index 6053c38a56..dc363cdc54 100644 --- a/lib/chef/http/json_output.rb +++ b/lib/chef/http/json_output.rb @@ -1,7 +1,7 @@ #-- # Author:: Daniel DeLeo (<dan@chef.io>) # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,6 +61,9 @@ class Chef [http_response, rest_request, return_value] else Chef::Log.debug("Expected JSON response, but got content-type '#{http_response['content-type']}'") + if http_response.body + Chef::Log.debug("Response body contains:\n#{http_response.body.length < 256 ? http_response.body : http_response.body[0..256] + " [...truncated...]"}") + end return [http_response, rest_request, http_response.body.to_s] end end diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index ee4d9ce7af..f9dca7896a 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -67,6 +67,11 @@ class Chef :description => "The ssh gateway", :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key } + option :ssh_gateway_identity, + :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", + :description => "The SSH identity file used for gateway authentication", + :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway_identity] = key } + option :forward_agent, :short => "-A", :long => "--forward-agent", @@ -438,6 +443,7 @@ class Chef ssh.config[:ssh_password] = config[:ssh_password] ssh.config[:ssh_port] = config[:ssh_port] ssh.config[:ssh_gateway] = config[:ssh_gateway] + ssh.config[:ssh_gateway_identity] = config[:ssh_gateway_identity] ssh.config[:forward_agent] = config[:forward_agent] ssh.config[:ssh_identity_file] = config[:ssh_identity_file] || config[:identity_file] ssh.config[:manual] = true diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb index 6007ff9859..145761a39e 100644 --- a/lib/chef/knife/bootstrap/templates/chef-full.erb +++ b/lib/chef/knife/bootstrap/templates/chef-full.erb @@ -182,21 +182,21 @@ fi mkdir -p /etc/chef <% if client_pem -%> -cat > /etc/chef/client.pem <<EOP +cat > /etc/chef/client.pem <<'EOP' <%= ::File.read(::File.expand_path(client_pem)) %> EOP chmod 0600 /etc/chef/client.pem <% end -%> <% if validation_key -%> -cat > /etc/chef/validation.pem <<EOP +cat > /etc/chef/validation.pem <<'EOP' <%= validation_key %> EOP chmod 0600 /etc/chef/validation.pem <% end -%> <% if encrypted_data_bag_secret -%> -cat > /etc/chef/encrypted_data_bag_secret <<EOP +cat > /etc/chef/encrypted_data_bag_secret <<'EOP' <%= encrypted_data_bag_secret %> EOP chmod 0600 /etc/chef/encrypted_data_bag_secret @@ -212,17 +212,17 @@ mkdir -p /etc/chef/trusted_certs mkdir -p /etc/chef/ohai/hints <% @chef_config[:knife][:hints].each do |name, hash| -%> -cat > /etc/chef/ohai/hints/<%= name %>.json <<EOP +cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP' <%= Chef::JSONCompat.to_json(hash) %> EOP <% end -%> <% end -%> -cat > /etc/chef/client.rb <<EOP +cat > /etc/chef/client.rb <<'EOP' <%= config_content %> EOP -cat > /etc/chef/first-boot.json <<EOP +cat > /etc/chef/first-boot.json <<'EOP' <%= Chef::JSONCompat.to_json(first_boot) %> EOP diff --git a/lib/chef/knife/data_bag_create.rb b/lib/chef/knife/data_bag_create.rb index 196278bb80..563e931dca 100644 --- a/lib/chef/knife/data_bag_create.rb +++ b/lib/chef/knife/data_bag_create.rb @@ -49,13 +49,15 @@ class Chef exit(1) end - # create the data bag + # Verify if the data bag exists begin + rest.get("data/#{@data_bag_name}") + ui.info("Data bag #{@data_bag_name} already exists") + rescue Net::HTTPServerException => e + raise unless e.to_s =~ /^404/ + # if it doesn't exists, try to create it rest.post("data", { "name" => @data_bag_name }) ui.info("Created data_bag[#{@data_bag_name}]") - rescue Net::HTTPServerException => e - raise unless e.to_s =~ /^409/ - ui.info("Data bag #{@data_bag_name} already exists") end # if an item is specified, create it, as well diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb index 8489e4e179..46903e7420 100644 --- a/lib/chef/knife/edit.rb +++ b/lib/chef/knife/edit.rb @@ -9,7 +9,7 @@ class Chef deps do require "chef/chef_fs/file_system" - require "chef/chef_fs/file_system/not_found_error" + require "chef/chef_fs/file_system/exceptions" end option :local, diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index e206f72630..d79565991f 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -92,6 +92,10 @@ class Chef :description => "The ssh gateway", :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip } + option :ssh_gateway_identity, + :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", + :description => "The SSH identity file used for gateway authentication" + option :forward_agent, :short => "-A", :long => "--forward-agent", @@ -250,7 +254,10 @@ class Chef {}.tap do |opts| # Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user] opts[:user] = user || config[:ssh_user] || ssh_config[:user] - if config[:ssh_identity_file] + if config[:ssh_gateway_identity] + opts[:keys] = File.expand_path(config[:ssh_gateway_identity]) + opts[:keys_only] = true + elsif config[:ssh_identity_file] opts[:keys] = File.expand_path(config[:ssh_identity_file]) opts[:keys_only] = true elsif config[:ssh_password] @@ -546,6 +553,10 @@ class Chef config[:ssh_identity_file] = get_stripped_unfrozen_value(config[:ssh_identity_file] || config[:identity_file] || Chef::Config[:knife][:ssh_identity_file]) end + def configure_ssh_gateway_identity + config[:ssh_gateway_identity] = get_stripped_unfrozen_value(config[:ssh_gateway_identity] || Chef::Config[:knife][:ssh_gateway_identity]) + end + def run @longest = 0 @@ -553,6 +564,7 @@ class Chef configure_password @password = config[:ssh_password] if config[:ssh_password] configure_ssh_identity_file + configure_ssh_gateway_identity configure_gateway configure_session diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb index 6559ca2e74..7f436d7936 100644 --- a/lib/chef/knife/xargs.rb +++ b/lib/chef/knife/xargs.rb @@ -9,7 +9,7 @@ class Chef deps do require "chef/chef_fs/file_system" - require "chef/chef_fs/file_system/not_found_error" + require "chef/chef_fs/file_system/exceptions" end # TODO modify to remote-only / local-only pattern (more like delete) diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 808fb1dc6e..1c2fbfee0f 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -2,7 +2,7 @@ # Author:: Christopher Brown (<cb@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ require "chef/mash" require "chef/json_compat" require "chef/search/query" require "chef/whitelist" +require "chef/blacklist" class Chef class Node @@ -599,11 +600,6 @@ class Chef rescue Net::HTTPServerException => e if e.response.code == "404" chef_server_rest.post("nodes", data_for_save) - # Chef Server before 12.3 rejects node JSON with 'policy_name' or - # 'policy_group' keys, but 'policy_name' will be detected first. - # Backcompat can be removed in 13.0 - elsif e.response.code == "400" && e.response.body.include?("Invalid key policy_name") - save_without_policyfile_attrs else raise end @@ -669,6 +665,13 @@ class Chef Chef::Log.info("Whitelisting #{level} node attributes for save.") data[level] = Chef::Whitelist.filter(data[level], whitelist) end + + blacklist_config_option = "#{level}_attribute_blacklist".to_sym + blacklist = Chef::Config[blacklist_config_option] + unless blacklist.nil? # nil => remove nothing + Chef::Log.info("Blacklisting #{level} node attributes for save") + data[level] = Chef::Blacklist.filter(data[level], blacklist) + end end data end diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 4febd47b44..761694e010 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -1,7 +1,7 @@ #-- # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -476,25 +476,6 @@ class Chef alias :each_attribute :each - def method_missing(symbol, *args) - if symbol == :to_ary - merged_attributes.send(symbol, *args) - elsif args.empty? - Chef.deprecated(:attributes, %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"])}) - if key?(symbol) - self[symbol] - else - raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'" - end - elsif symbol.to_s =~ /=$/ - Chef.deprecated(:attributes, %q{method setting of node attributes (node.foo="bar") is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]="bar")}) - key_to_set = symbol.to_s[/^(.+)=$/, 1] - self[key_to_set] = (args.length == 1 ? args[0] : args) - else - raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'" - end - end - def to_s merged_attributes.to_s end diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 694b5fbc3a..a31b2d2b9b 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -1,6 +1,6 @@ #-- # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software, Inc. +# Copyright:: Copyright 2012-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -180,24 +180,6 @@ class Chef alias :attribute? :has_key? - def method_missing(symbol, *args) - # Calling `puts arg` implicitly calls #to_ary on `arg`. If `arg` does - # not implement #to_ary, ruby recognizes it as a single argument, and - # if it returns an Array, then ruby prints each element. If we don't - # account for that here, we'll auto-vivify a VividMash for the key - # :to_ary which creates an unwanted key and raises a TypeError. - if symbol == :to_ary - super - elsif args.empty? - self[symbol] - elsif symbol.to_s =~ /=$/ - key_to_set = symbol.to_s[/^(.+)=$/, 1] - self[key_to_set] = (args.length == 1 ? args[0] : args) - else - raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'. To set an attribute, use `#{symbol}=value' instead." - end - end - def convert_key(key) super end diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index dad712e078..12ee2e5dd8 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -1,5 +1,5 @@ #-- -# Copyright:: Copyright 2012-2016, Chef Software, Inc. +# Copyright:: Copyright 2012-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -125,24 +125,6 @@ class Chef alias :attribute? :has_key? - def method_missing(symbol, *args) - if symbol == :to_ary - super - elsif args.empty? - if key?(symbol) - self[symbol] - else - raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'" - end - # This will raise a ImmutableAttributeModification error: - elsif symbol.to_s =~ /=$/ - key_to_set = symbol.to_s[/^(.+)=$/, 1] - self[key_to_set] = (args.length == 1 ? args[0] : args) - else - raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'" - end - end - # Mash uses #convert_value to mashify values on input. # Since we're handling this ourselves, override it to be a no-op def convert_value(value) diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index d8f4f752de..dbed44a002 100644 --- a/lib/chef/policy_builder/expand_node_object.rb +++ b/lib/chef/policy_builder/expand_node_object.rb @@ -3,7 +3,7 @@ # Author:: Tim Hinderliter (<tim@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2008-2016 Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -103,33 +103,6 @@ class Chef run_context end - # DEPRECATED: As of Chef 12.5, chef selects either policyfile mode or - # "expand node" mode dynamically, based on the content of the node - # object, first boot JSON, and config. This happens in - # PolicyBuilder::Dynamic, which selects the implementation during - # #load_node and then delegates to either ExpandNodeObject or Policyfile - # implementations as appropriate. Tools authors should update their code - # to create a PolicyBuilder::Dynamc policy builder and allow it to select - # the proper implementation. - def load_node - Chef.deprecated(:internal_api, "ExpandNodeObject#load_node is deprecated. Please use Chef::PolicyBuilder::Dynamic instead of using ExpandNodeObject directly") - - events.node_load_start(node_name, config) - Chef::Log.debug("Building node object for #{node_name}") - - @node = - if Chef::Config[:solo_legacy_mode] - Chef::Node.build(node_name) - else - Chef::Node.find_or_create(node_name) - end - finish_load_node(node) - node - rescue Exception => e - events.node_load_failed(node_name, e, config) - raise - end - def finish_load_node(node) @node = node end diff --git a/lib/chef/property.rb b/lib/chef/property.rb index 8fa290251a..ac226bc815 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -106,17 +106,8 @@ class Chef @options = options end - # Only pick the first of :default, :name_property and :name_attribute if - # more than one is specified. - if options.has_key?(:default) && options[:name_property] - if options[:default].nil? || options.keys.index(:name_property) < options.keys.index(:default) - options.delete(:default) - preferred_default = :name_property - else - options.delete(:name_property) - preferred_default = :default - end - Chef.deprecated(:custom_resource, "Cannot specify both default and name_property together on property #{self}. Only one (#{preferred_default}) will be obeyed. In Chef 13, this will become an error. Please remove one or the other from the property.") + if options.has_key?(:default) && options.has_key?(:name_property) + raise ArgumentError, "Cannot specify both default and name_property/name_attribute together on property #{self}" end # Validate the default early, so the user gets a good error message, and diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 40c31e4371..0ec441202c 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2008-2016, 2009-2016 Chef Software, Inc. +# Copyright:: Copyright 2008-2016, 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,7 +75,7 @@ class Chef end def whyrun_supported? - false + true end def node diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb index 9e91b12373..2c72849d1c 100644 --- a/lib/chef/provider/apt_repository.rb +++ b/lib/chef/provider/apt_repository.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef which("apt-get") end - def whyrun_supported? - true - end - def load_current_resource end @@ -115,7 +111,7 @@ class Chef so = shell_out(cmd) so.run_command so.stdout.split(/\n/).map do |t| - if z = t.match(/^ +Key fingerprint = ([0-9A-F ]+)/) + if z = t.match(/^fpr:+([0-9A-F]+):/) z[1].split.join end end.compact @@ -147,8 +143,10 @@ class Chef end def no_new_keys?(file) - installed_keys = extract_fingerprints_from_cmd("apt-key finger") - proposed_keys = extract_fingerprints_from_cmd("gpg --with-fingerprint #{file}") + # Now we are using the option --with-colons that works across old os versions + # as well as the latest (16.10). This for both `apt-key` and `gpg` commands + installed_keys = extract_fingerprints_from_cmd("apt-key adv --list-public-keys --with-fingerprint --with-colons") + proposed_keys = extract_fingerprints_from_cmd("gpg --with-fingerprint --with-colons #{file}") (installed_keys & proposed_keys).sort == proposed_keys.sort end diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb index baa763df9d..135bd64035 100644 --- a/lib/chef/provider/apt_update.rb +++ b/lib/chef/provider/apt_update.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,10 +34,6 @@ class Chef APT_CONF_DIR = "/etc/apt/apt.conf.d" STAMP_DIR = "/var/lib/apt/periodic" - def whyrun_supported? - true - end - def load_current_resource end diff --git a/lib/chef/provider/breakpoint.rb b/lib/chef/provider/breakpoint.rb index 0902634a64..9f8b8a6467 100644 --- a/lib/chef/provider/breakpoint.rb +++ b/lib/chef/provider/breakpoint.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/provider/cookbook_file.rb b/lib/chef/provider/cookbook_file.rb index dc900d871b..92383fd5fa 100644 --- a/lib/chef/provider/cookbook_file.rb +++ b/lib/chef/provider/cookbook_file.rb @@ -17,8 +17,6 @@ # require "chef/provider/file" -require "chef/deprecation/provider/cookbook_file" -require "chef/deprecation/warnings" class Chef class Provider @@ -26,10 +24,6 @@ class Chef provides :cookbook_file - extend Chef::Deprecation::Warnings - include Chef::Deprecation::Provider::CookbookFile - add_deprecation_warnings_for(Chef::Deprecation::Provider::CookbookFile.instance_methods) - def initialize(new_resource, run_context) @content_class = Chef::Provider::CookbookFile::Content super diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index f22367b461..a45e889bcc 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -42,10 +42,6 @@ class Chef end attr_accessor :cron_exists, :cron_empty - def whyrun_supported? - true - end - def load_current_resource crontab_lines = [] @current_resource = Chef::Resource::Cron.new(new_resource.name) diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb index 2cd6ad62c6..172705ac71 100644 --- a/lib/chef/provider/deploy.rb +++ b/lib/chef/provider/deploy.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,10 +46,6 @@ class Chef @configuration[:environment] = @configuration[:environment] && @configuration[:environment]["RAILS_ENV"] end - def whyrun_supported? - true - end - def load_current_resource @scm_provider.load_current_resource @release_path = new_resource.deploy_to + "/releases/#{release_slug}" diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb index 38ee1f241f..a176230bba 100644 --- a/lib/chef/provider/directory.rb +++ b/lib/chef/provider/directory.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +29,6 @@ class Chef provides :directory - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Directory.new(new_resource.name) current_resource.path(new_resource.path) diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index 0ad075484f..959227b408 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -1,7 +1,7 @@ # # Author:: Adam Edwards (<adamed@chef.io>) # -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, 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. @@ -45,10 +45,6 @@ class Chef def load_current_resource end - def whyrun_supported? - true - end - def define_resource_requirements requirements.assert(:run) do |a| a.assertion { supports_dsc_invoke_resource? } diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index 66783ceb0f..654f202ed9 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -1,7 +1,7 @@ # # Author:: Adam Edwards (<adamed@chef.io>) # -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, 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. @@ -58,10 +58,6 @@ class Chef end end - def whyrun_supported? - true - end - def define_resource_requirements requirements.assert(:run) do |a| err = [ diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb index 5e05fe4798..7777da183d 100644 --- a/lib/chef/provider/env.rb +++ b/lib/chef/provider/env.rb @@ -28,6 +28,10 @@ class Chef provides :env, os: "!windows" + def whyrun_supported? + false + end + def initialize(new_resource, run_context) super @key_exists = true diff --git a/lib/chef/provider/env/windows.rb b/lib/chef/provider/env/windows.rb index e25cab31d2..e813025c81 100644 --- a/lib/chef/provider/env/windows.rb +++ b/lib/chef/provider/env/windows.rb @@ -26,6 +26,10 @@ class Chef provides :env, os: "windows" + def whyrun_supported? + false + end + def create_env obj = env_obj(@new_resource.key_name) unless obj diff --git a/lib/chef/provider/erl_call.rb b/lib/chef/provider/erl_call.rb index 50571d5256..26ac19d03b 100644 --- a/lib/chef/provider/erl_call.rb +++ b/lib/chef/provider/erl_call.rb @@ -31,10 +31,6 @@ class Chef super(node, new_resource) end - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 28dce5d18c..101d7c4c06 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,14 +34,10 @@ class Chef current_resource end - def whyrun_supported? - true - end - def define_resource_requirements - # @todo: this should change to raise in some appropriate major version bump. if creates && creates_relative? && !cwd - Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)" + # FIXME? move this onto the resource? + raise Chef::Exceptions::Execute, "Please either specify a full path for the creates attribute, or specify a cwd propoerty to the #{new_resource} resource" end end diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index ecde068751..fea77dd7ea 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -30,8 +30,6 @@ require "chef/mixin/enforce_ownership_and_permissions" require "chef/util/backup" require "chef/util/diff" require "chef/util/selinux" -require "chef/deprecation/provider/file" -require "chef/deprecation/warnings" require "chef/file_content_management/deploy" # The Tao of File Providers: @@ -52,10 +50,6 @@ class Chef include Chef::Util::Selinux include Chef::Mixin::FileClass - extend Chef::Deprecation::Warnings - include Chef::Deprecation::Provider::File - add_deprecation_warnings_for(Chef::Deprecation::Provider::File.instance_methods) - provides :file attr_reader :deployment_strategy @@ -72,10 +66,6 @@ class Chef super end - def whyrun_supported? - true - end - def load_current_resource # true if there is a symlink and we need to manage what it points at @managing_symlink = file_class.symlink?(new_resource.path) && ( new_resource.manage_symlink_source || new_resource.manage_symlink_source.nil? ) diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 2907c20211..db83e0aea6 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,10 +30,6 @@ class Chef def_delegator :new_resource, :destination, :cwd - def whyrun_supported? - true - end - def load_current_resource @resolved_reference = nil @current_resource = Chef::Resource::Git.new(new_resource.name) diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb index 6751052ae4..82196c72f3 100644 --- a/lib/chef/provider/group.rb +++ b/lib/chef/provider/group.rb @@ -1,6 +1,6 @@ # # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +29,6 @@ class Chef attr_accessor :group_exists attr_accessor :change_desc - def whyrun_supported? - true - end - def initialize(new_resource, run_context) super @group_exists = true diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb index eaca17a972..8370c2375c 100644 --- a/lib/chef/provider/http_request.rb +++ b/lib/chef/provider/http_request.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,10 +27,6 @@ class Chef attr_accessor :http - def whyrun_supported? - true - end - def load_current_resource @http = Chef::HTTP::Simple.new(new_resource.url) end diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 4f32baaadb..003cc3b0e0 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -53,10 +53,6 @@ class Chef @config_path = nil end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Ifconfig.new(new_resource.name) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index aed60b7c47..94f9120582 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,10 +42,6 @@ class Chef private :negative_complement - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Link.new(new_resource.name) current_resource.target_file(new_resource.target_file) diff --git a/lib/chef/provider/log.rb b/lib/chef/provider/log.rb index a0219db753..fbbc053b5b 100644 --- a/lib/chef/provider/log.rb +++ b/lib/chef/provider/log.rb @@ -1,6 +1,6 @@ # # Author:: Cary Penniman (<cary@rightscale.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,10 +27,6 @@ class Chef provides :log - def whyrun_supported? - true - end - # No concept of a 'current' resource for logs, this is a no-op # # === Return diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index 88da7b5eff..5c972462bc 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -29,10 +29,6 @@ class Chef raise Exception, "deprecated" end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Mdadm.new(new_resource.name) current_resource.raid_device(new_resource.raid_device) diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb index 5168c93348..4d0d273ea9 100644 --- a/lib/chef/provider/mount.rb +++ b/lib/chef/provider/mount.rb @@ -1,7 +1,7 @@ # # Author:: Joshua Timberman (<joshua@chef.io>) # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software, Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,10 +28,6 @@ class Chef attr_accessor :unmount_retries - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/noop.rb b/lib/chef/provider/noop.rb index 207bf7dedb..ca8f7324f7 100644 --- a/lib/chef/provider/noop.rb +++ b/lib/chef/provider/noop.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/provider/ohai.rb b/lib/chef/provider/ohai.rb index c36655077b..0c2397cee5 100644 --- a/lib/chef/provider/ohai.rb +++ b/lib/chef/provider/ohai.rb @@ -25,10 +25,6 @@ class Chef provides :ohai - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb index 9ea68f4c9f..8ecde54ce0 100644 --- a/lib/chef/provider/osx_profile.rb +++ b/lib/chef/provider/osx_profile.rb @@ -29,10 +29,6 @@ class Chef provides :osx_profile, os: "darwin" provides :osx_config_profile, os: "darwin" - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::OsxProfile.new(new_resource.name) current_resource.profile_name(new_resource.profile_name) @@ -57,7 +53,7 @@ class Chef end current_profile = nil - if all_profiles && !all_profiles.empty? + if all_profiles && all_profiles.key?("_computerlevel") current_profile = all_profiles["_computerlevel"].find do |item| item["ProfileIdentifier"] == @new_profile_identifier end diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index 97aefbd559..36df048741 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -61,10 +61,6 @@ class Chef end end - def whyrun_supported? - true - end - def check_resource_semantics! # FIXME: this is not universally true and subclasses are needing to override this and no-ops it. It should be turned into # another "subclass_directive" and the apt and yum providers should declare that they need this behavior. diff --git a/lib/chef/provider/package/windows/registry_uninstall_entry.rb b/lib/chef/provider/package/windows/registry_uninstall_entry.rb index a693558883..03f6ff318e 100644 --- a/lib/chef/provider/package/windows/registry_uninstall_entry.rb +++ b/lib/chef/provider/package/windows/registry_uninstall_entry.rb @@ -41,7 +41,8 @@ class Chef entry = reg.open(key, desired) display_name = read_registry_property(entry, "DisplayName") if display_name == package_name - entries.push(RegistryUninstallEntry.new(hkey, key, entry)) + quiet_uninstall_string = RegistryUninstallEntry.read_registry_property(entry, "QuietUninstallString") + entries.push(quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry)) end rescue ::Win32::Registry::Error => ex Chef::Log.debug("Registry error opening key '#{key}' on node #{desired}: #{ex}") @@ -55,6 +56,11 @@ class Chef entries end + def self.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry) + return RegistryUninstallEntry.new(hkey, key, entry) if quiet_uninstall_string.nil? + RegistryUninstallEntry.new(hkey, key, entry, "QuietUninstallString") + end + def self.read_registry_property(data, property) data[property] rescue ::Win32::Registry::Error => ex @@ -62,14 +68,14 @@ class Chef nil end - def initialize(hive, key, registry_data) + def initialize(hive, key, registry_data, uninstall_key = "UninstallString") Chef::Log.debug("Creating uninstall entry for #{hive}::#{key}") @hive = hive @key = key @data = registry_data @display_name = RegistryUninstallEntry.read_registry_property(registry_data, "DisplayName") @display_version = RegistryUninstallEntry.read_registry_property(registry_data, "DisplayVersion") - @uninstall_string = RegistryUninstallEntry.read_registry_property(registry_data, "UninstallString") + @uninstall_string = RegistryUninstallEntry.read_registry_property(registry_data, uninstall_key) end attr_reader :hive diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb index ff85f7a99a..32dc38f788 100644 --- a/lib/chef/provider/reboot.rb +++ b/lib/chef/provider/reboot.rb @@ -24,10 +24,6 @@ class Chef class Reboot < Chef::Provider provides :reboot - def whyrun_supported? - true - end - def load_current_resource @current_resource ||= Chef::Resource::Reboot.new(new_resource.name) current_resource.reason(new_resource.reason) diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 2443a3d184..f196154986 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -35,10 +35,6 @@ class Chef include Chef::Mixin::Checksum - def whyrun_supported? - true - end - def running_on_windows! unless Chef::Platform.windows? raise Chef::Exceptions::Win32NotWindows, "Attempt to manipulate the windows registry on a non-windows node" diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb index d2f90d233b..6f4956de96 100644 --- a/lib/chef/provider/remote_directory.rb +++ b/lib/chef/provider/remote_directory.rb @@ -23,8 +23,6 @@ require "chef/resource/cookbook_file" require "chef/mixin/file_class" require "chef/platform/query_helpers" require "chef/util/path_helper" -require "chef/deprecation/warnings" -require "chef/deprecation/provider/remote_directory" require "forwardable" @@ -268,16 +266,6 @@ class Chef res end - # - # Add back deprecated methods and aliases that are internally unused and should be removed in Chef-13 - # - extend Chef::Deprecation::Warnings - include Chef::Deprecation::Provider::RemoteDirectory - add_deprecation_warnings_for(Chef::Deprecation::Provider::RemoteDirectory.instance_methods) - - alias_method :resource_for_directory, :directory_resource - add_deprecation_warnings_for([:resource_for_directory]) - end end end diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb index 05e213e842..c0a0f9433c 100644 --- a/lib/chef/provider/remote_file.rb +++ b/lib/chef/provider/remote_file.rb @@ -18,18 +18,12 @@ # require "chef/provider/file" -require "chef/deprecation/provider/remote_file" -require "chef/deprecation/warnings" class Chef class Provider class RemoteFile < Chef::Provider::File provides :remote_file - extend Chef::Deprecation::Warnings - include Chef::Deprecation::Provider::RemoteFile - add_deprecation_warnings_for(Chef::Deprecation::Provider::RemoteFile.instance_methods) - def initialize(new_resource, run_context) @content_class = Chef::Provider::RemoteFile::Content super diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index 5e20fdf11e..2e2a1266b4 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -84,10 +84,6 @@ class Chef end end - def whyrun_supported? - true - end - def load_current_resource self.is_running = false diff --git a/lib/chef/provider/ruby_block.rb b/lib/chef/provider/ruby_block.rb index c44b776661..878b7b52d3 100644 --- a/lib/chef/provider/ruby_block.rb +++ b/lib/chef/provider/ruby_block.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software, Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,6 @@ class Chef class RubyBlock < Chef::Provider provides :ruby_block - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb index 2f08697ed7..11d04eaca2 100644 --- a/lib/chef/provider/service.rb +++ b/lib/chef/provider/service.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Davide Cavalca (<dcavalca@fb.com>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef @enabled = nil end - def whyrun_supported? - true - end - def load_current_resource supports[:status] = false if supports[:status].nil? supports[:reload] = false if supports[:reload].nil? diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb index 201f9ff5f9..dd74caf6ae 100644 --- a/lib/chef/provider/service/aix.rb +++ b/lib/chef/provider/service/aix.rb @@ -1,6 +1,6 @@ # # Author:: kaustubh (<kaustubh@clogeny.com>) -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,10 +43,6 @@ class Chef @current_resource end - def whyrun_supported? - true - end - def start_service if @is_resource_group shell_out!("startsrc -g #{@new_resource.service_name}") diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index d75e85989f..84ced52071 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -41,10 +41,6 @@ class Chef @current_resource end - def whyrun_supported? - true - end - def shared_resource_requirements super requirements.assert(:all_actions) do |a| diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 9bfd9238cd..931e320695 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -2,7 +2,7 @@ # Author:: Nuo Yan <nuo@chef.io> # Author:: Bryan McLellan <btm@loftninjas.org> # Author:: Seth Chisamore <schisamo@chef.io> -# Copyright:: Copyright 2010-2016, Chef Software Inc. +# Copyright:: Copyright 2010-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,10 +49,6 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service SERVICE_RIGHT = "SeServiceLogonRight" - def whyrun_supported? - false - end - def load_current_resource @current_resource = Chef::Resource::WindowsService.new(@new_resource.name) @current_resource.service_name(@new_resource.service_name) diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index ee8ea7c495..d7e26f3968 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef include Chef::Mixin::Command include ChefConfig::Mixin::FuzzyHostnameMatcher - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Subversion.new(new_resource.name) diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb index 7cb0ba008d..05cdbdbf62 100644 --- a/lib/chef/provider/template.rb +++ b/lib/chef/provider/template.rb @@ -19,18 +19,12 @@ require "chef/provider/template_finder" require "chef/provider/file" -require "chef/deprecation/provider/template" -require "chef/deprecation/warnings" class Chef class Provider class Template < Chef::Provider::File provides :template - extend Chef::Deprecation::Warnings - include Chef::Deprecation::Provider::Template - add_deprecation_warnings_for(Chef::Deprecation::Provider::Template.instance_methods) - def initialize(new_resource, run_context) @content_class = Chef::Provider::Template::Content super diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index c44adbf818..dcfee22c31 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,10 +43,6 @@ class Chef @group_name_resolved = false end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::User.new(new_resource.name) current_resource.username(new_resource.username) @@ -205,16 +201,6 @@ class Chef def check_lock raise NotImplementedError end - - def non_unique? - # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.non_unique - new_resource.non_unique || new_resource.supports[:non_unique] - end - - def managing_home_dir? - # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.manage_home - new_resource.manage_home || new_resource.supports[:manage_home] - end end end end diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 2302a874e2..60167856d1 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -1,6 +1,6 @@ # # Author:: Dreamcat4 (<dreamcat4@gmail.com>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -297,7 +297,7 @@ user password using shadow hash.") return end - if managing_home_dir? + if new_resource.manage_home validate_home_dir_specification! if (current_resource.home == new_resource.home) && !new_home_exists? @@ -442,7 +442,7 @@ user password using shadow hash.") # and deleting home directory if needed. # def remove_user - if managing_home_dir? + if new_resource.manage_home # Remove home directory FileUtils.rm_rf(current_resource.home) end diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb index 445421ad38..cf75bdc38b 100644 --- a/lib/chef/provider/user/linux.rb +++ b/lib/chef/provider/user/linux.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,14 +52,14 @@ class Chef opts << "-s" << new_resource.shell if should_set?(:shell) opts << "-u" << new_resource.uid if should_set?(:uid) opts << "-d" << new_resource.home if updating_home? - opts << "-o" if non_unique? + opts << "-o" if new_resource.non_unique opts end def usermod_options opts = [] if updating_home? - if managing_home_dir? + if new_resource.manage_home opts << "-m" end end @@ -69,7 +69,7 @@ class Chef def useradd_options opts = [] opts << "-r" if new_resource.system - opts << if managing_home_dir? + opts << if new_resource.manage_home "-m" else "-M" @@ -79,7 +79,7 @@ class Chef def userdel_options opts = [] - opts << "-r" if managing_home_dir? + opts << "-r" if new_resource.manage_home opts << "-f" if new_resource.force opts end diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb index 42d862a983..cf47bb7fde 100644 --- a/lib/chef/provider/user/pw.rb +++ b/lib/chef/provider/user/pw.rb @@ -1,6 +1,6 @@ # # Author:: Stephen Haynes (<sh@nomitor.com>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ class Chef def remove_user command = [ "pw", "userdel", new_resource.username ] - command << "-r" if managing_home_dir? + command << "-r" if new_resource.manage_home shell_out_compact!(command) end @@ -83,7 +83,7 @@ class Chef opts << new_resource.send(field_symbol) end end - if managing_home_dir? + if new_resource.manage_home Chef::Log.debug("#{new_resource} is managing the users home directory") opts << "-m" end diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index 4e772312ae..25ec13fe5c 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -2,7 +2,7 @@ # Author:: Stephen Nelson-Smith (<sns@chef.io>) # Author:: Jon Ramsey (<jonathon.ramsey@gmail.com>) # Author:: Dave Eddy (<dave@daveeddy.com>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. +# Copyright:: Copyright 2012-2017, Chef Software Inc. # Copyright:: Copyright 2015-2016, Dave Eddy # License:: Apache License, Version 2.0 # @@ -77,7 +77,7 @@ class Chef # @return [Array<String>] def useradd_options opts = [] - opts << "-m" if managing_home_dir? + opts << "-m" if new_resource.manage_home opts end diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index cf6f4e727f..0a32126903 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,7 +46,7 @@ class Chef def remove_user command = [ "userdel" ] - command << "-r" if managing_home_dir? + command << "-r" if new_resource.manage_home command << "-f" if new_resource.force command << new_resource.username shell_out_compact!(command) @@ -117,14 +117,14 @@ class Chef end if updating_home? opts << "-d" << new_resource.home - if managing_home_dir? + if new_resource.manage_home Chef::Log.debug("#{new_resource} managing the users home directory") opts << "-m" else Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}") end end - opts << "-o" if non_unique? + opts << "-o" if new_resource.non_unique opts end end @@ -139,7 +139,7 @@ class Chef def useradd_options opts = [] opts << "-r" if new_resource.system - opts << "-M" unless managing_home_dir? + opts << "-M" unless new_resource.manage_home opts end diff --git a/lib/chef/provider/yum_repository.rb b/lib/chef/provider/yum_repository.rb index be4d43f7ad..bcba8e676d 100644 --- a/lib/chef/provider/yum_repository.rb +++ b/lib/chef/provider/yum_repository.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,9 +34,8 @@ class Chef which "yum" end - def whyrun_supported?; true; end - - def load_current_resource; end + def load_current_resource + end action :create do declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 40911cd2cc..23de50324c 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -130,7 +130,6 @@ class Chef def initialize(name, run_context = nil) name(name) unless name.nil? @run_context = run_context - @noop = nil @before = nil @params = Hash.new @provider = nil @@ -138,10 +137,6 @@ class Chef @action = self.class.default_action @updated = false @updated_by_last_action = false - @supports = {} - @ignore_failure = false - @retries = 0 - @retry_delay = 2 @not_if = [] @only_if = [] @source_line = nil @@ -153,7 +148,6 @@ class Chef @guard_interpreter = nil @default_guard_interpreter = :default @elapsed_time = 0 - @sensitive = false end # @@ -437,10 +431,7 @@ class Chef # @param arg [Integer] The number of retries. # @return [Integer] The number of retries. # - def retries(arg = nil) - set_or_return(:retries, arg, kind_of: Integer) - end - attr_writer :retries + property :retries, Integer, default: 0, desired_state: false # # The number of seconds to wait between retries. Default: 2. @@ -448,10 +439,7 @@ class Chef # @param arg [Integer] The number of seconds to wait between retries. # @return [Integer] The number of seconds to wait between retries. # - def retry_delay(arg = nil) - set_or_return(:retry_delay, arg, kind_of: Integer) - end - attr_writer :retry_delay + property :retry_delay, Integer, default: 2, desired_state: false # # Whether to treat this resource's data as sensitive. If set, no resource @@ -460,15 +448,7 @@ class Chef # @param arg [Boolean] Whether this resource is sensitive or not. # @return [Boolean] Whether this resource is sensitive or not. # - def sensitive(arg = nil) - set_or_return(:sensitive, arg, :kind_of => [ TrueClass, FalseClass ]) - end - attr_writer :sensitive - - # ??? TODO unreferenced. Delete? - attr_reader :not_if_args - # ??? TODO unreferenced. Delete? - attr_reader :only_if_args + property :sensitive, [ TrueClass, FalseClass ], default: false, desired_state: false # # The time it took (in seconds) to run the most recently-run action. Not @@ -561,10 +541,7 @@ class Chef # @param arg [Boolean] Whether to ignore failures. # @return Whether this resource will ignore failures. # - def ignore_failure(arg = nil) - set_or_return(:ignore_failure, arg, kind_of: [ TrueClass, FalseClass ]) - end - attr_writer :ignore_failure + property :ignore_failure, [ TrueClass, FalseClass ], default: false, desired_state: false # # Equivalent to #ignore_failure. @@ -955,29 +932,6 @@ class Chef end # - # Sets a list of capabilities of the real resource. For example, `:remount` - # (for filesystems) and `:restart` (for services). - # - # TODO Calling resource.supports({}) will not set this to empty; it will do - # a get instead. That's wrong. - # - # @param args Hash{Symbol=>Boolean} If non-empty, sets the capabilities of - # this resource. Default: {} - # @return Hash{Symbol=>Boolean} An array of things this resource supports. - # - def supports(args = {}) - if args.any? - @supports = args - else - @supports - end - end - - def supports=(args) - supports(args) - end - - # # A hook called after a resource is created. Meant to be overriden by # subclasses. # @@ -986,21 +940,6 @@ class Chef end # - # The DSL name of this resource (e.g. `package` or `yum_package`) - # - # @return [String] The DSL name of this resource. - # - # @deprecated Use resource_name instead. - # - def self.dsl_name - Chef.deprecated(:custom_resource, "Resource.dsl_name is deprecated and will be removed in Chef 13. Use resource_name instead.") - if name - name = self.name.split("::")[-1] - convert_to_snake_case(name) - end - end - - # # The display name of this resource type, for printing purposes. # # This also automatically calls "provides" to provide DSL with the given @@ -1054,29 +993,6 @@ class Chef end # - # The module where Chef should look for providers for this resource. - # The provider for `MyResource` will be looked up using - # `provider_base::MyResource`. Defaults to `Chef::Provider`. - # - # @param arg [Module] The module containing providers for this resource - # @return [Module] The module containing providers for this resource - # - # @example - # class MyResource < Chef::Resource - # provider_base Chef::Provider::Deploy - # # ...other stuff - # end - # - # @deprecated Use `provides` on the provider, or `provider` on the resource, instead. - # - def self.provider_base(arg = nil) - if arg - Chef.deprecated(:custom_resource, "Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.") - end - @provider_base ||= arg || Chef::Provider - end - - # # The list of allowed actions for the resource. # # @param actions [Array<Symbol>] The list of actions to add to allowed_actions. @@ -1485,24 +1401,6 @@ class Chef provider end - # ??? TODO Seems unused. Delete? - def noop(tf = nil) - if !tf.nil? - raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false - @noop = tf - end - @noop - end - - # TODO Seems unused. Delete? - def is(*args) - if args.size == 1 - args.first - else - args - end - end - # # Preface an exception message with generic Resource information. # @@ -1580,13 +1478,14 @@ class Chef # @api private def lookup_provider_constant(name, action = :nothing) - self.class.provider_base.const_get(convert_to_class_name(name.to_s)) - rescue NameError => e - if e.to_s =~ /#{Regexp.escape(self.class.provider_base.to_s)}/ - raise ArgumentError, "No provider found to match '#{name}'" - else - raise e - end + # XXX: "name" is probably a poor choice of name here, ideally this would be nil, but we need to + # fix resources so that nil or empty names work (also solving the apt_update "doesn't matter one bit" + # problem). WARNING: this string is not a public API and should not be referenced (e.g. in provides blocks) + # and may change at any time. If you've found this comment you're also probably very lost and should maybe + # consider using `declare_resource :whatever` instead of trying to set `provider :whatever` on a resource, or in some + # other way reconsider what you're trying to do, since you're likely trying to force a bad design that we + # can't/won't support. + self.class.resource_for_node(name, node).new("name", run_context).provider_for_action(action).class end module DeprecatedLWRPClass diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index 5f51c9e208..7025d74e58 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -1,6 +1,6 @@ # # Author:: Bryan McLellan <btm@loftninjas.org> -# Copyright:: Copyright 2012-2016, Chef Software Inc. +# Copyright:: Copyright 2012-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,17 +28,10 @@ class Chef callbacks: { "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" }, } - property :compile_time, [ true, false, nil ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false + property :compile_time, [ true, false ], default: false, desired_state: false def after_created - # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled - # Action could be an array of symbols, but probably won't (think install + enable for a package) - if compile_time.nil? - message = "#{self} chef_gem compile_time installation is deprecated. Please set `compile_time false` on the resource to use the new behavior, or set `compile_time true` on the resource if compile_time behavior is required." - Chef.deprecated :chef_gem_compile_time, message - end - - if compile_time || compile_time.nil? + if compile_time Array(action).each do |action| run_action(action) end diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 677c4608b3..659fa341b5 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -109,16 +109,6 @@ class Chef :kind_of => [ TrueClass, FalseClass ]) end - def path(arg = nil) - Chef::Log.warn "The 'path' attribute of 'execute' is not used by any provider in Chef 11 or Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13." - - set_or_return( - :path, - arg, - :kind_of => [ Array ] - ) - end - def returns(arg = nil) set_or_return( :returns, @@ -141,13 +131,7 @@ class Chef property :password, String, sensitive: true - def sensitive(args = nil) - if password - true - else - super - end - end + property :sensitive, [ TrueClass, FalseClass ], default: false, coerce: proc { |x| password ? true : x } def self.set_guard_inherited_attributes(*inherited_attributes) @class_inherited_attributes = inherited_attributes diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb index 3400684bc5..079e6dc201 100644 --- a/lib/chef/resource/file/verification.rb +++ b/lib/chef/resource/file/verification.rb @@ -106,15 +106,10 @@ class Chef # We reuse Chef::GuardInterpreter in order to support # the same set of options that the not_if/only_if blocks do def verify_command(path, opts) - # First implementation interpolated `file`; docs & RFC claim `path` - # is interpolated. Until `file` can be deprecated, interpolate both. if @command.include?("%{file}") - Chef.deprecated(:verify_file, - "%{file} is deprecated in verify command and will not be "\ - "supported in Chef 13. Please use %{path} instead." - ) + raise ArgumentError, "The %{file} expansion for verify commands has been removed. Please use %{path} instead." end - command = @command % { :file => path, :path => path } + command = @command % { :path => path } interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts) interpreter.evaluate end diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index 3e35325246..2aca8432dd 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -1,7 +1,7 @@ # # Author:: Joshua Timberman (<joshua@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,10 @@ class Chef default_action :mount allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable + # this is a poor API please do not re-use this pattern + property :supports, Hash, default: { remount: false }, + coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x } + def initialize(name, run_context = nil) super @mount_point = name @@ -42,7 +46,6 @@ class Chef @pass = 2 @mounted = false @enabled = false - @supports = { :remount => false } @username = nil @password = nil @domain = nil @@ -140,16 +143,6 @@ class Chef ) end - def supports(args = {}) - if args.is_a? Array - args.each { |arg| @supports[arg] = true } - elsif args.any? - @supports = args - else - @supports - end - end - def username(arg = nil) set_or_return( :username, diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index 5173a76542..5039e2d8fe 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,51 +23,25 @@ require "chef/provider/script" class Chef class Resource class Script < Chef::Resource::Execute - # Chef-13: go back to using :name as the identity attr - identity_attr :command + identity_attr :name def initialize(name, run_context = nil) super - # Chef-13: the command variable should be initialized to nil - @command = name - @code = nil - @interpreter = nil - @flags = nil + @command = nil @default_guard_interpreter = :default end + # FIXME: remove this and use an execute sub-resource instead of inheriting from Execute def command(arg = nil) unless arg.nil? - # Chef-13: change this to raise if the user is trying to set a value here - Chef::Log.warn "Specifying command attribute on a script resource is a coding error, use the 'code' attribute, or the execute resource" - Chef::Log.warn "This attribute is deprecated and must be fixed or this code will fail on Chef 13" + raise Chef::Exceptions::Script, "Do not use the command attribute on a #{resource_name} resource, use the 'code' attribute instead." end super end - def code(arg = nil) - set_or_return( - :code, - arg, - :kind_of => [ String ] - ) - end - - def interpreter(arg = nil) - set_or_return( - :interpreter, - arg, - :kind_of => [ String ] - ) - end - - def flags(arg = nil) - set_or_return( - :flags, - arg, - :kind_of => [ String ] - ) - end + property :code, String, required: true + property :interpreter, String + property :flags, String end end diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index 1ca4b84af0..d9f0969ecb 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,10 @@ class Chef allowed_actions :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask + # this is a poor API please do not re-use this pattern + property :supports, Hash, default: { restart: nil, reload: nil, status: nil }, + coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x } + def initialize(name, run_context = nil) super @service_name = name @@ -48,7 +52,6 @@ class Chef @timeout = nil @run_levels = nil @user = nil - @supports = { :restart => nil, :reload => nil, :status => nil } end def service_name(arg = nil) @@ -201,17 +204,6 @@ class Chef :kind_of => [ String ] ) end - - def supports(args = {}) - if args.is_a? Array - args.each { |arg| @supports[arg] = true } - elsif args.any? - @supports = args - else - @supports - end - end - end end end diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb index fc7720bc25..a1e315ef50 100644 --- a/lib/chef/resource/user.rb +++ b/lib/chef/resource/user.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,10 +42,6 @@ class Chef @manage_home = false @force = false @non_unique = false - @supports = { - manage_home: false, - non_unique: false, - } @iterations = 27855 @salt = nil end @@ -155,20 +151,6 @@ class Chef :kind_of => [ TrueClass, FalseClass ] ) end - - def supports(args = {}) - if args.key?(:manage_home) - Chef.deprecated(:supports_property, "supports { manage_home: #{args[:manage_home]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home #{args[:manage_home]} instead") - end - if args.key?(:non_unique) - Chef.deprecated(:supports_property, "supports { non_unique: #{args[:non_unique]} } on the user resource is deprecated and will be removed in Chef 13, set non_unique #{args[:non_unique]} instead") - end - super - end - - def supports=(args) - supports(args) - end end end end diff --git a/lib/chef/resource/user/aix_user.rb b/lib/chef/resource/user/aix_user.rb index 7c07db2e25..d5f1829b63 100644 --- a/lib/chef/resource/user/aix_user.rb +++ b/lib/chef/resource/user/aix_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource/user/dscl_user.rb b/lib/chef/resource/user/dscl_user.rb index 61517d8b44..6eb1c953f4 100644 --- a/lib/chef/resource/user/dscl_user.rb +++ b/lib/chef/resource/user/dscl_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource/user/linux_user.rb b/lib/chef/resource/user/linux_user.rb index ec60ac89bf..056a421197 100644 --- a/lib/chef/resource/user/linux_user.rb +++ b/lib/chef/resource/user/linux_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,15 +26,6 @@ class Chef provides :linux_user provides :user, os: "linux" - def initialize(name, run_context = nil) - super - @supports = { - manage_home: false, - non_unique: false, - } - @manage_home = false - end - end end end diff --git a/lib/chef/resource/user/pw_user.rb b/lib/chef/resource/user/pw_user.rb index 873be19d59..3672943f5c 100644 --- a/lib/chef/resource/user/pw_user.rb +++ b/lib/chef/resource/user/pw_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource/user/solaris_user.rb b/lib/chef/resource/user/solaris_user.rb index bb897228b9..cca90e6743 100644 --- a/lib/chef/resource/user/solaris_user.rb +++ b/lib/chef/resource/user/solaris_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource/user/windows_user.rb b/lib/chef/resource/user/windows_user.rb index d1a249fb50..baedc14f5e 100644 --- a/lib/chef/resource/user/windows_user.rb +++ b/lib/chef/resource/user/windows_user.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright 2016, Chef Software Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource_builder.rb b/lib/chef/resource_builder.rb index 1aee852f5d..275f795362 100644 --- a/lib/chef/resource_builder.rb +++ b/lib/chef/resource_builder.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2015-2016, Chef Software, Inc. +# Copyright:: Copyright 2015-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,14 +52,6 @@ class Chef resource.source_line = created_at resource.declared_type = type - # If we have a resource like this one, we want to steal its state - # This behavior is very counter-intuitive and should be removed. - # See CHEF-3694, https://tickets.opscode.com/browse/CHEF-3694 - # Moved to this location to resolve CHEF-5052, https://tickets.opscode.com/browse/CHEF-5052 - if prior_resource && Chef::Config[:resource_cloning] - resource.load_from(prior_resource) - end - resource.cookbook_name = cookbook_name resource.recipe_name = recipe_name # Determine whether this resource is being created in the context of an enclosing Provider @@ -79,15 +71,6 @@ class Chef end end - # emit a cloned resource warning if it is warranted - if prior_resource && Chef::Config[:resource_cloning] - if is_trivial_resource?(prior_resource) && identicalish_resources?(prior_resource, resource) - emit_harmless_cloning_debug - else - emit_cloned_resource_warning - end - end - # Run optional resource hook resource.after_created @@ -103,51 +86,6 @@ class Chef @resource_class ||= Chef::Resource.resource_for_node(type, run_context.node) end - def is_trivial_resource?(resource) - trivial_resource = resource_class.new(name, run_context) - # force un-lazy the name property on the created trivial resource - name_property = resource_class.properties.find { |sym, p| p.name_property? } - trivial_resource.send(name_property[0]) unless name_property.nil? - identicalish_resources?(trivial_resource, resource) - end - - # this is an equality test specific to checking for 3694 cloning warnings - def identicalish_resources?(first, second) - skipped_ivars = [ :@source_line, :@cookbook_name, :@recipe_name, :@params, :@elapsed_time, :@declared_type ] - checked_ivars = ( first.instance_variables | second.instance_variables ) - skipped_ivars - non_matching_ivars = checked_ivars.reject do |iv| - if iv == :@action && ( [first.instance_variable_get(iv)].flatten == [:nothing] || [second.instance_variable_get(iv)].flatten == [:nothing] ) - # :nothing action on either side of the comparison always matches - true - else - first.instance_variable_get(iv) == second.instance_variable_get(iv) - end - end - Chef::Log.debug("ivars which did not match with the prior resource: #{non_matching_ivars}") - non_matching_ivars.empty? - end - - def emit_cloned_resource_warning - message = "Cloning resource attributes for #{resource} from prior resource" - message << "\nPrevious #{prior_resource}: #{prior_resource.source_line}" if prior_resource.source_line - message << "\nCurrent #{resource}: #{resource.source_line}" if resource.source_line - Chef.deprecated(:resource_cloning, message) - end - - def emit_harmless_cloning_debug - Chef::Log.debug("Harmless resource cloning from #{prior_resource}:#{prior_resource.source_line} to #{resource}:#{resource.source_line}") - end - - def prior_resource - @prior_resource ||= - begin - key = "#{type}[#{name}]" - run_context.resource_collection.lookup_local(key) - rescue Chef::Exceptions::ResourceNotFound - nil - end - end - end end diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb index ccd7351eeb..ad769ee952 100644 --- a/lib/chef/run_list/versioned_recipe_list.rb +++ b/lib/chef/run_list/versioned_recipe_list.rb @@ -1,7 +1,7 @@ # # Author:: Stephen Delano (<stephen@chef.io>) # Author:: Seth Falcon (<seth@chef.io>) -# Copyright:: Copyright 2010-2016, Chef Software, Inc. +# Copyright:: Copyright 2010-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -83,17 +83,19 @@ class Chef end end - # Get an array of strings of both fully-qualified and unexpanded recipe names - # in response to chef/chef#3767 - # Chef-13 will revert to the behaviour of just including the fully-qualified name + # For "foo::default" also include "foo", for "foo" also include "foo::default", for + # "foo::bar" just return "foo::bar". This makes it easier for people to search on + # default recipe names. # # @return [Array] Array of strings with fully-qualified and unexpanded recipe names def with_duplicate_names map do |recipe_name| - if recipe_name.include?("::") + if recipe_name.end_with?("::default") + [ recipe_name.sub(/::default$/, ""), recipe_name ] + elsif recipe_name.include?("::") recipe_name else - [recipe_name, "#{recipe_name}::default"] + [ recipe_name, "#{recipe_name}::default" ] end end.flatten end diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index bea8205935..fb77238ced 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -39,28 +39,6 @@ class Chef @rest ||= Chef::ServerAPI.new(@url || @config[:chef_server_url]) end - # Backwards compatability for cookbooks. - # This can be removed in Chef > 12. - def partial_search(type, query = "*:*", *args, &block) - Chef::Log.warn(<<-WARNDEP) -DEPRECATED: The 'partial_search' API is deprecated and will be removed in -future releases. Please use 'search' with a :filter_result argument to get -partial search data. -WARNDEP - - if !args.empty? && args.first.is_a?(Hash) - # partial_search uses :keys instead of :filter_result for - # result filtering. - args_h = args.first.dup - args_h[:filter_result] = args_h[:keys] - args_h.delete(:keys) - - search(type, query, args_h, &block) - else - search(type, query, *args, &block) - end - end - # # New search input, designed to be backwards compatible with the old method signature # 'type' and 'query' are the same as before, args now will accept either a Hash of diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 82afd17006..3fe6b82b87 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -21,7 +21,7 @@ class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = "12.19.39" + VERSION = "13.0.35" end # diff --git a/omnibus/Gemfile b/omnibus/Gemfile index 735b371c62..652a6e69b8 100644 --- a/omnibus/Gemfile +++ b/omnibus/Gemfile @@ -1,8 +1,8 @@ source "https://rubygems.org" -gem "omnibus", github: "chef/omnibus", branch: "rhass/COOL-502_with_gcc_investigate" -gem "omnibus-software", github: "chef/omnibus-software", branch: "shain/ruby_windows_monster" -gem "license_scout", github: "chef/license_scout" +gem "omnibus", git: "https://github.com/chef/omnibus" +gem "omnibus-software", git: "https://github.com/chef/omnibus-software" +gem "license_scout", git: "https://github.com/chef/license_scout" gem "pedump" diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index ceb322bf20..20eb83adec 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -1,24 +1,14 @@ GIT - remote: git://github.com/chef/license_scout.git - revision: f90293a9753652fb64994a14de4108e503c06632 + remote: https://github.com/chef/license_scout + revision: 83f16f6bbf7f0f9ef94cf694aea2881e65ee034c specs: license_scout (0.1.2) ffi-yajl (~> 2.2) mixlib-shellout (~> 2.2) GIT - remote: git://github.com/chef/omnibus-software.git - revision: 086710002ec0054b3d240d14ca04d11163f528aa - branch: shain/ruby_windows_monster - specs: - omnibus-software (4.0.0) - chef-sugar (>= 3.4.0) - omnibus (>= 5.5.0) - -GIT - remote: git://github.com/chef/omnibus.git - revision: dce5283a85a44484a66a8a84991beba92e46fd12 - branch: rhass/COOL-502_with_gcc_investigate + remote: https://github.com/chef/omnibus + revision: 76d907f4fe92a28c5f7ab11779341e1d773c358d specs: omnibus (5.5.0) aws-sdk (~> 2) @@ -32,20 +22,28 @@ GIT ruby-progressbar (~> 1.7) thor (~> 0.18) +GIT + remote: https://github.com/chef/omnibus-software + revision: 703ecb80af7897a6a85a7340f9b280f757f3372f + specs: + omnibus-software (4.0.0) + chef-sugar (>= 3.4.0) + omnibus (>= 5.5.0) + GEM remote: https://rubygems.org/ specs: addressable (2.5.0) public_suffix (~> 2.0, >= 2.0.2) - artifactory (2.6.0) + artifactory (2.7.0) awesome_print (1.7.0) - aws-sdk (2.7.5) - aws-sdk-resources (= 2.7.5) - aws-sdk-core (2.7.5) + aws-sdk (2.8.5) + aws-sdk-resources (= 2.8.5) + aws-sdk-core (2.8.5) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.7.5) - aws-sdk-core (= 2.7.5) + aws-sdk-resources (2.8.5) + aws-sdk-core (= 2.8.5) aws-sigv4 (1.0.0) berkshelf (4.3.5) addressable (~> 2.3, >= 2.3.4) @@ -86,7 +84,7 @@ GEM celluloid-io (0.16.2) celluloid (>= 0.16.0) nio4r (>= 1.1.0) - chef-config (12.18.31) + chef-config (12.19.36) addressable fuzzyurl mixlib-config (~> 2.0) @@ -98,8 +96,8 @@ GEM erubis (2.7.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - ffi (1.9.17) - ffi (1.9.17-x86-mingw32) + ffi (1.9.18) + ffi (1.9.18-x86-mingw32) ffi-yajl (2.3.0) libyajl2 (~> 1.2) fuzzyurl (0.9.0) @@ -107,7 +105,7 @@ GEM ffi (>= 1.0.1) gyoku (1.3.1) builder (>= 2.1.2) - hashie (3.5.1) + hashie (3.5.5) hitimes (1.2.4) hitimes (1.2.4-x86-mingw32) httpclient (2.7.2) @@ -119,7 +117,7 @@ GEM test-kitchen (~> 1.4) libyajl2 (1.2.0) little-plugger (1.1.4) - logging (2.1.0) + logging (2.2.0) little-plugger (~> 1.1) multi_json (~> 1.10) method_source (0.8.2) @@ -146,7 +144,7 @@ GEM multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (4.0.1) + net-ssh (4.1.0) net-ssh-gateway (1.3.0) net-ssh (>= 2.6.5) nio4r (2.0.0) @@ -216,15 +214,15 @@ GEM molinillo (~> 0.4.2) semverse (~> 1.1) systemu (2.6.5) - test-kitchen (1.15.0) + test-kitchen (1.16.0) mixlib-install (>= 1.2, < 3.0) mixlib-shellout (>= 1.2, < 3.0) net-scp (~> 1.1) net-ssh (>= 2.9, < 5.0) net-ssh-gateway (~> 1.2) safe_yaml (~> 1.0) - thor (~> 0.18) - thor (0.19.4) + thor (~> 0.19, < 0.19.2) + thor (0.19.1) timers (4.0.4) hitimes varia_model (0.4.1) @@ -232,7 +230,7 @@ GEM hashie (>= 2.0.2, < 4.0.0) win32-process (0.8.3) ffi (>= 1.0.0) - winrm (2.1.2) + winrm (2.1.3) builder (>= 2.1.2) erubis (~> 2.7) gssapi (~> 1.2) @@ -267,4 +265,4 @@ DEPENDENCIES winrm-fs (~> 1.0) BUNDLED WITH - 1.12.5 + 1.14.6 diff --git a/omnibus/config/projects/chef.rb b/omnibus/config/projects/chef.rb index a0e490ceab..10c2cd21b3 100644 --- a/omnibus/config/projects/chef.rb +++ b/omnibus/config/projects/chef.rb @@ -53,6 +53,16 @@ dependency "chef-complete" package :rpm do signing_passphrase ENV["OMNIBUS_RPM_SIGNING_PASSPHRASE"] + + unless rhel? && platform_version.satisfies?("< 6") + compression_level 1 + compression_type :xz + end +end + +package :deb do + compression_level 1 + compression_type :xz end proj_to_work_around_cleanroom = self diff --git a/omnibus/config/software/chef-gem-ohai.rb b/omnibus/config/software/chef-gem-ohai.rb new file mode 100644 index 0000000000..7ee7ff4909 --- /dev/null +++ b/omnibus/config/software/chef-gem-ohai.rb @@ -0,0 +1,10 @@ +# gem installs this gem from the version specified in chef's Gemfile.lock +# so we can take advantage of omnibus's caching. Just duplicate this file and +# add the new software def to chef software def if you want to separate +# another gem's installation. +require_relative "../../files/chef-gem/build-chef-gem/gem-install-software-def" +BuildChefGem::GemInstallSoftwareDef.define(self, __FILE__) + +license "Apache-2.0" +license_file "https://github.com/chef/ohai/blob/master/LICENSE" +skip_transitive_dependency_licensing true diff --git a/omnibus/config/software/chef.rb b/omnibus/config/software/chef.rb index c53a2339ae..4f7319bda1 100644 --- a/omnibus/config/software/chef.rb +++ b/omnibus/config/software/chef.rb @@ -38,6 +38,7 @@ dependency "bundler" # Install all the native gems separately # Worst offenders first to take best advantage of cache: dependency "chef-gem-ffi-yajl" +dependency "chef-gem-ohai" dependency "chef-gem-nokogiri" dependency "chef-gem-libyajl2" dependency "chef-gem-ruby-prof" diff --git a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb index 3022bf448e..ea6c32e94a 100644 --- a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb +++ b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb @@ -21,8 +21,40 @@ module BuildChefGem attr_reader :software, :software_filename + # XXX: why are we programmatically defining config that is already expressed as code-as-configuration? + def define + # this has to come first because gem_metadata depends on it software.name "#{File.basename(software_filename)[0..-4]}" + if installing_from_git? + define_git + else + define_gem + end + end + + def define_git + software.default_version gem_metadata[:ref] + + # If the source directory for building stuff changes, tell omnibus to de-cache us + software.source git: gem_metadata[:git] + + # ruby and bundler and friends + software.dependency "ruby" + software.dependency "rubygems" + + software.relative_path gem_name + + gem_name = self.gem_name + + software.build do + extend BuildChefGem + gem "build #{gem_name}.gemspec", env: env + gem "install #{gem_name}*.gem --no-ri --no-rdoc", env: env + end + end + + def define_gem software.default_version gem_version # If the source directory for building stuff changes, tell omnibus to @@ -44,7 +76,8 @@ module BuildChefGem if gem_version == "<skip>" if gem_metadata block do - log.info(log_key) { "#{gem_name} has source #{gem_metadata} in #{lockfile_path}. We only cache rubygems.org installs in omnibus to keep things simple. The chef step will build #{gem_name} ..." } + raise "can we just remove this use case? what is it for?" + #log.info(log_key) { "#{gem_name} has source #{gem_metadata} in #{lockfile_path}. We only cache rubygems.org installs in omnibus to keep things simple. The chef step will build #{gem_name} ..." } end else block do @@ -105,6 +138,10 @@ module BuildChefGem end end + def installing_from_git? + gem_metadata && gem_metadata[:git] && gem_metadata[:ref] + end + def gem_version @gem_version ||= begin if gem_metadata && URI(gem_metadata[:source]) == URI("https://rubygems.org/") diff --git a/spec/data/lwrp/resources/buck_passer.rb b/spec/data/lwrp/resources/buck_passer.rb new file mode 100644 index 0000000000..7335c0aae2 --- /dev/null +++ b/spec/data/lwrp/resources/buck_passer.rb @@ -0,0 +1,5 @@ + +provides :buck_passer + +default_action :pass_buck +actions :pass_buck diff --git a/spec/data/lwrp/resources/buck_passer_2.rb b/spec/data/lwrp/resources/buck_passer_2.rb new file mode 100644 index 0000000000..c7a1a279f3 --- /dev/null +++ b/spec/data/lwrp/resources/buck_passer_2.rb @@ -0,0 +1,3 @@ + +default_action :pass_buck +actions :pass_buck diff --git a/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb b/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb new file mode 100644 index 0000000000..3a8ae2c19f --- /dev/null +++ b/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb @@ -0,0 +1,3 @@ + +default_action :twiddle_thumbs +actions :twiddle_thumbs diff --git a/spec/data/lwrp/resources/inline_compiler.rb b/spec/data/lwrp/resources/inline_compiler.rb new file mode 100644 index 0000000000..fe446ddf84 --- /dev/null +++ b/spec/data/lwrp/resources/inline_compiler.rb @@ -0,0 +1,3 @@ + +default_action :test +actions :test, :no_updates diff --git a/spec/data/lwrp/resources/monkey_name_printer.rb b/spec/data/lwrp/resources/monkey_name_printer.rb new file mode 100644 index 0000000000..d70e2f34e3 --- /dev/null +++ b/spec/data/lwrp/resources/monkey_name_printer.rb @@ -0,0 +1,5 @@ + +property :monkey + +default_action :twiddle_thumbs +actions :twiddle_thumbs diff --git a/spec/data/lwrp/resources/paint_drying_watcher.rb b/spec/data/lwrp/resources/paint_drying_watcher.rb new file mode 100644 index 0000000000..519b7f83fd --- /dev/null +++ b/spec/data/lwrp/resources/paint_drying_watcher.rb @@ -0,0 +1,3 @@ + +default_action :prepare_eyes +actions :prepare_eyes, :watch_paint_dry diff --git a/spec/data/lwrp/resources/thumb_twiddler.rb b/spec/data/lwrp/resources/thumb_twiddler.rb new file mode 100644 index 0000000000..2b5d2d803e --- /dev/null +++ b/spec/data/lwrp/resources/thumb_twiddler.rb @@ -0,0 +1,3 @@ + +default_action :prepare_thumbs +actions :prepare_thumbs, :twiddle_thumbs diff --git a/spec/data/shef-config.rb b/spec/data/shef-config.rb index 3c3ae9045a..02d3610e55 100644 --- a/spec/data/shef-config.rb +++ b/spec/data/shef-config.rb @@ -1,10 +1,9 @@ -Ohai::Config[:disabled_plugins] << 'darwin::system_profiler' << 'darwin::kernel' << 'darwin::ssh_host_key' << 'network_listeners' -Ohai::Config[:disabled_plugins] << "virtualization" << "darwin::virtualization" -Ohai::Config[:disabled_plugins] << 'darwin::uptime' << 'darwin::filesystem' << 'dmi' << 'lanuages' << 'perl' << 'python' << 'java' -Ohai::Config[:disabled_plugins] << "linux::block_device" << "linux::kernel" << "linux::ssh_host_key" << "linux::virtualization" -Ohai::Config[:disabled_plugins] << "linux::cpu" << "linux::memory" << "ec2" << "rackspace" << "eucalyptus" << "ip_scopes" -Ohai::Config[:disabled_plugins] << "solaris2::cpu" << "solaris2::dmi" << "solaris2::filesystem" << "solaris2::kernel" -Ohai::Config[:disabled_plugins] << "solaris2::virtualization" << "solaris2::zpools" -Ohai::Config[:disabled_plugins] << 'c' << 'php' << 'mono' << 'groovy' << 'lua' << 'erlang' -Ohai::Config[:disabled_plugins] << "kernel" << "linux::filesystem" << "ruby" - +ohai[:disabled_plugins] << "darwin::system_profiler" << "darwin::kernel" << "darwin::ssh_host_key" << "network_listeners" +ohai[:disabled_plugins] << "virtualization" << "darwin::virtualization" +ohai[:disabled_plugins] << "darwin::uptime" << "darwin::filesystem" << "dmi" << "lanuages" << "perl" << "python" << "java" +ohai[:disabled_plugins] << "linux::block_device" << "linux::kernel" << "linux::ssh_host_key" << "linux::virtualization" +ohai[:disabled_plugins] << "linux::cpu" << "linux::memory" << "ec2" << "rackspace" << "eucalyptus" << "ip_scopes" +ohai[:disabled_plugins] << "solaris2::cpu" << "solaris2::dmi" << "solaris2::filesystem" << "solaris2::kernel" +ohai[:disabled_plugins] << "solaris2::virtualization" << "solaris2::zpools" +ohai[:disabled_plugins] << "c" << "php" << "mono" << "groovy" << "lua" << "erlang" +ohai[:disabled_plugins] << "kernel" << "linux::filesystem" << "ruby" diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index aea7585bb2..dbd7b92c6c 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2010-2016, Chef Software Inc. +# Copyright:: Copyright 2010-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -246,6 +246,34 @@ describe Chef::Knife::Ssh do end end + context "when knife[:ssh_gateway_identity] is set" do + before do + setup_knife(["*:*", "uptime"]) + Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname" + Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/aws-gateway.rsa" + end + + it "uses the ssh_gateway_identity file" do + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true }) + @knife.run + expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") + end + end + + context "when -ssh-gateway-identity is provided and knife[:ssh_gateway] is set" do + before do + setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"]) + Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname" + Chef::Config[:knife][:ssh_gateway_identity] = nil + end + + it "uses the ssh_gateway_identity file" do + expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { :keys => File.expand_path("#{ENV['HOME']}/.ssh/aws-gateway.rsa").squeeze("/"), :keys_only => true }) + @knife.run + expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa") + end + end + context "when the gateway requires a password" do before do setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"]) diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb index a2e174d557..4a5fee64bc 100644 --- a/spec/functional/resource/bash_spec.rb +++ b/spec/functional/resource/bash_spec.rb @@ -1,6 +1,6 @@ # # Author:: Serdar Sutay (<serdar@chef.io>) -# Copyright:: Copyright 2014-2016, Chef Software Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,59 +23,25 @@ describe Chef::Resource::Bash, :unix_only do let(:code) { "echo hello" } let(:resource) do resource = Chef::Resource::Bash.new("foo_resource", run_context) - resource.code(code) + resource.code(code) unless code.nil? resource end describe "when setting the command attribute" do let (:command) { "wizard racket" } - # in Chef-12 the `command` attribute is largely useless, but does set the identity attribute - # so that notifications need to target the value of the command. it will not run the `command` - # and if it is given without a code block then it does nothing and always succeeds. - describe "in Chef-12", chef: "< 13" do - it "gets the commmand attribute from the name" do - expect(resource.command).to eql("foo_resource") - end - - it "sets the resource identity to the command name" do - resource.command command - expect(resource.identity).to eql(command) - end - - it "warns when the code is not present and a useless `command` is present" do - expect(Chef::Log).to receive(:warn).with(/coding error/) - expect(Chef::Log).to receive(:warn).with(/deprecated/) - resource.code nil - resource.command command - expect { resource.run_action(:run) }.not_to raise_error - end - - describe "when the code is not present" do - let(:code) { nil } - it "warns" do - expect(Chef::Log).to receive(:warn) - expect { resource.run_action(:run) }.not_to raise_error - end - end + it "should raise an exception when trying to set the command" do + expect { resource.command command }.to raise_error(Chef::Exceptions::Script) end - # in Chef-13 the `command` attribute needs to be for internal use only - describe "in Chef-13", chef: ">= 13" do - it "should raise an exception when trying to set the command" do - expect { resource.command command }.to raise_error # FIXME: add a real error in Chef-13 - end - - it "should initialize the command to nil" do - expect(resource.command).to be_nil - end + it "should initialize the command to nil" do + expect(resource.command).to be_nil + end - describe "when the code is not present" do - let(:code) { nil } - it "raises an exception" do - expect { resource.run_action(:run) }.to raise_error # FIXME: add a real error in Chef-13 - expect { resource.run_action(:run) }.not_to raise_error - end + describe "when the code is not present" do + let(:code) { nil } + it "raises an exception" do + expect { resource.run_action(:run) }.to raise_error(Chef::Exceptions::ValidationFailed) end end end diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index 292bce6002..40ec411780 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -211,20 +211,16 @@ depends "bar"' depends "baz"' file "cookbooks/baz/metadata.rb", 'name "baz" depends "foo"' - file "cookbooks/self/metadata.rb", 'name "self" -depends "self"' end it "knife deps prints each once" do - knife("deps /cookbooks/foo /cookbooks/self").should_succeed( - stdout: "/cookbooks/baz\n/cookbooks/bar\n/cookbooks/foo\n/cookbooks/self\n", - stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n" + knife("deps /cookbooks/foo").should_succeed( + stdout: "/cookbooks/baz\n/cookbooks/bar\n/cookbooks/foo\n" ) end it "knife deps --tree prints each once" do - knife("deps --tree /cookbooks/foo /cookbooks/self").should_succeed( - stdout: "/cookbooks/foo\n /cookbooks/bar\n /cookbooks/baz\n /cookbooks/foo\n/cookbooks/self\n", - stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n" + knife("deps --tree /cookbooks/foo").should_succeed( + stdout: "/cookbooks/foo\n /cookbooks/bar\n /cookbooks/baz\n /cookbooks/foo\n" ) end end diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index d372a83a35..dc713d02b3 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software, Inc. +# Copyright:: Copyright 2013-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -178,16 +178,8 @@ EOM file "cookbooks/x/metadata.rb", "name 'x'; version '1.0.0'; depends 'x'" end - it "should warn", chef: "< 13" do - knife("upload /cookbooks").should_succeed( - stdout: "Updated /cookbooks/x\n", - stderr: "WARN: Ignoring self-dependency in cookbook x, please remove it (in the future this will be fatal).\n" - ) - knife("diff --name-status /").should_succeed "" - end - it "should fail in Chef 13", chef: ">= 13" do - knife("upload /cookbooks").should_fail "" - # FIXME: include the error message here + it "should fail in Chef 13" do + expect { knife("upload /cookbooks") }.to raise_error RuntimeError, /Cookbook depends on itself/ end end diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index fb50ee2298..120e73740d 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -1,5 +1,6 @@ require "fcntl" require "chef/mixin/shell_out" +require "ohai/mixin/http_helper" require "ohai/mixin/gce_metadata" class ShellHelpers @@ -221,12 +222,12 @@ def fips? ENV["CHEF_FIPS"] == "1" end -class GCEDetector - extend Ohai::Mixin::GCEMetadata +class HttpHelper + extend Ohai::Mixin::HttpHelper end def gce? - GCEDetector.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80) + HttpHelper.can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80) rescue SocketError false end diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb index ab6ed2b86b..ae56a9697d 100644 --- a/spec/support/shared/unit/execute_resource.rb +++ b/spec/support/shared/unit/execute_resource.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -76,14 +76,8 @@ shared_examples_for "an execute resource" do expect(@resource.group).to eql(1) end - it "should accept an array for the execution path in Chef-12 and log deprecation message", chef: "< 13" do - expect(Chef::Log).to receive(:warn).at_least(:once) - @resource.path ["woot"] - expect(@resource.path).to eql(["woot"]) - end - - it "should raise an exception in chef-13", chef: ">= 13" do - expect(@resource.path [ "woot" ]).to raise_error + it "the old path property (that never worked) is not supported in chef >= 13" do + expect { @resource.path [ "woot" ] }.to raise_error end it "should accept an integer for the return code" do @@ -138,15 +132,12 @@ shared_examples_for "an execute resource" do end it "should be true if the password is non-nil" do - expect(@resource.sensitive).to eq(false) @resource.password("we.funk!") expect(@resource.sensitive).to eq(true) end it "should be true if the password is non-nil but the value is explicitly set to false" do - expect(@resource.sensitive).to eq(false) @resource.password("we.funk!") - expect(@resource.sensitive).to eq(true) @resource.sensitive false expect(@resource.sensitive).to eq(true) end diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb index 27864e1625..a04da4b63e 100644 --- a/spec/support/shared/unit/script_resource.rb +++ b/spec/support/shared/unit/script_resource.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,10 +34,6 @@ shared_examples_for "a script resource" do expect(script_resource.command).to be nil end - it "should set command to the name on the resource", chef: "< 13" do - expect(script_resource.command).to eql script_resource.name - end - it "should accept a string for the code" do script_resource.code "hey jude" expect(script_resource.code).to eql("hey jude") @@ -52,10 +48,6 @@ shared_examples_for "a script resource" do expect { script_resource.command("foo") }.to raise_error(Chef::Exceptions::Script) end - it "should not raise an exception if users set command on the resource", chef: "< 13" do - expect { script_resource.command("foo") }.not_to raise_error - end - describe "when executing guards" do let(:resource) do resource = script_resource diff --git a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb index 7f3eb6efe2..acdbe35c45 100644 --- a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +++ b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb @@ -17,7 +17,7 @@ # require "spec_helper" -require "chef/chef_fs/file_system/operation_failed_error" +require "chef/chef_fs/file_system/exceptions" describe Chef::ChefFS::FileSystem::OperationFailedError do context "message" do diff --git a/spec/unit/deprecation_spec.rb b/spec/unit/deprecation_spec.rb index 41c1724e5b..6e2bcc32fd 100644 --- a/spec/unit/deprecation_spec.rb +++ b/spec/unit/deprecation_spec.rb @@ -45,20 +45,6 @@ describe Chef::Deprecation do add_deprecation_warnings_for(DeprecatedMethods.instance_methods) end - method_snapshot_file = File.join(CHEF_SPEC_DATA, "file-providers-method-snapshot-chef-11-4.json") - method_snapshot = Chef::JSONCompat.parse(File.open(method_snapshot_file).read()) - - method_snapshot.each do |class_name, old_methods| - class_object = class_from_string(class_name) - current_methods = class_object.public_instance_methods.map(&:to_sym) - - it "defines all methods on #{class_object} that were available in 11.0" do - old_methods.each do |old_method| - expect(current_methods).to include(old_method.to_sym) - end - end - end - context "when Chef::Config[:treat_deprecation_warnings_as_errors] is off" do before do Chef::Config[:treat_deprecation_warnings_as_errors] = false diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index a8fb144bf7..14b5d9eb28 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -39,7 +39,7 @@ describe Chef::EncryptedDataBagItem::Encryptor do let(:key) { "passwd" } it "encrypts to format version 1 by default" do - expect(encryptor).to be_a_instance_of(Chef::EncryptedDataBagItem::Encryptor::Version1Encryptor) + expect(encryptor).to be_a_instance_of(Chef::EncryptedDataBagItem::Encryptor::Version3Encryptor) end describe "generating a random IV" do @@ -66,8 +66,8 @@ describe Chef::EncryptedDataBagItem::Encryptor do final_data = encryptor.for_encrypted_item expect(final_data["encrypted_data"]).to eq encryptor.encrypted_data expect(final_data["iv"]).to eq Base64.encode64(encryptor.iv) - expect(final_data["version"]).to eq 1 - expect(final_data["cipher"]).to eq "aes-256-cbc" + expect(final_data["version"]).to eq 3 + expect(final_data["cipher"]).to eq "aes-256-gcm" end end @@ -238,7 +238,7 @@ describe Chef::EncryptedDataBagItem::Decryptor do context "when decrypting a version 1 (JSON+aes-256-cbc+random iv) encrypted value" do let(:encrypted_value) do - Chef::EncryptedDataBagItem::Encryptor.new(plaintext_data, encryption_key).for_encrypted_item + Chef::EncryptedDataBagItem::Encryptor::Version1Encryptor.new(plaintext_data, encryption_key).for_encrypted_item end it "selects the correct strategy for version 1" do @@ -336,7 +336,7 @@ describe Chef::EncryptedDataBagItem do end it "encrypts non-collection objects" do - expect(encoded_data["greeting"]["version"]).to eq 1 + expect(encoded_data["greeting"]["version"]).to eq 3 expect(encoded_data["greeting"]).to have_key("iv") iv = encoded_data["greeting"]["iv"] @@ -346,7 +346,7 @@ describe Chef::EncryptedDataBagItem do end it "encrypts nested values" do - expect(encoded_data["nested"]["version"]).to eq 1 + expect(encoded_data["nested"]["version"]).to eq 3 expect(encoded_data["nested"]).to have_key("iv") iv = encoded_data["nested"]["iv"] diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 9f944b82d9..4201963b7d 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -48,6 +48,35 @@ describe Chef::Knife::Bootstrap do expect(File.basename(knife.bootstrap_template)).to eq("chef-full") end + context "when using the chef-full default template" do + let(:rendered_template) do + knife.merge_configs + knife.render_template + end + + it "should render client.rb" do + expect(rendered_template).to match("cat > /etc/chef/client.rb <<'EOP'") + expect(rendered_template).to match("chef_server_url \"https://localhost:443\"") + expect(rendered_template).to match("validation_client_name \"chef-validator\"") + expect(rendered_template).to match("log_location STDOUT") + end + + it "should render first-boot.json" do + expect(rendered_template).to match("cat > /etc/chef/first-boot.json <<'EOP'") + expect(rendered_template).to match('{"run_list":\[\]}') + end + + context "and encrypted_data_bag_secret was provided" do + it "should render encrypted_data_bag_secret file" do + expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true) + expect(knife).to receive(:read_secret).and_return("secrets") + expect(rendered_template).to match("cat > /etc/chef/encrypted_data_bag_secret <<'EOP'") + expect(rendered_template).to match('{"run_list":\[\]}') + expect(rendered_template).to match(%r{secrets}) + end + end + end + context "with --bootstrap-vault-item" do let(:bootstrap_cli_options) { [ "--bootstrap-vault-item", "vault1:item1", "--bootstrap-vault-item", "vault1:item2", "--bootstrap-vault-item", "vault2:item1" ] } it "sets the knife config cli option correctly" do @@ -649,6 +678,7 @@ describe Chef::Knife::Bootstrap do Chef::Config[:knife][:forward_agent] = true Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/you.rsa" Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl" + Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/gateway.rsa" Chef::Config[:knife][:host_key_verify] = true allow(knife).to receive(:render_template).and_return("") knife.config = {} @@ -676,6 +706,10 @@ describe Chef::Knife::Bootstrap do expect(knife_ssh.config[:ssh_gateway]).to eq("towel.blinkenlights.nl") end + it "configures the ssh gateway identity" do + expect(knife_ssh.config[:ssh_gateway_identity]).to eq("~/.ssh/gateway.rsa") + end + it "configures the host key verify mode" do expect(knife_ssh.config[:host_key_verify]).to eq(true) end diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb index b852c30401..b7d185a58c 100644 --- a/spec/unit/knife/data_bag_create_spec.rb +++ b/spec/unit/knife/data_bag_create_spec.rb @@ -46,64 +46,84 @@ describe Chef::Knife::DataBagCreate do allow(knife).to receive(:config).and_return(config) end - it "tries to create a data bag with an invalid name when given one argument" do - knife.name_args = ["invalid&char"] - expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName) - expect { knife.run }.to exit_with_code(1) - end - - context "when given one argument" do - before do - knife.name_args = [bag_name] - end - - it "creates a data bag" do - expect(rest).to receive(:post).with("data", { "name" => bag_name }) - expect(knife.ui).to receive(:info).with("Created data_bag[#{bag_name}]") + context "when data_bag already exist" do + it "doesn't creates a data bag" do + expect(knife).to receive(:create_object).and_yield(raw_hash) + expect(rest).to receive(:get).with("data/#{bag_name}") + expect(rest).to_not receive(:post).with("data", { "name" => bag_name }) + expect(knife.ui).to receive(:info).with("Data bag #{bag_name} already exists") knife.run end end - context "no secret is specified for encryption" do - let(:item) do - item = Chef::DataBagItem.from_hash(raw_hash) - item.data_bag(bag_name) - item + context "when data_bag doesn't exist" do + before do + # Data bag doesn't exist by default so we mock the GET request to return 404 + exception = double("404 error", :code => "404") + allow(rest).to receive(:get) + .with("data/#{bag_name}") + .and_raise(Net::HTTPServerException.new("404", exception)) end - it "creates a data bag item" do - expect(knife).to receive(:create_object).and_yield(raw_hash) - expect(knife).to receive(:encryption_secret_provided?).and_return(false) - expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered - expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered - - knife.run + it "tries to create a data bag with an invalid name when given one argument" do + knife.name_args = ["invalid&char"] + expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName) + expect { knife.run }.to exit_with_code(1) end - end - context "a secret is specified for encryption" do - let(:encoded_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(raw_hash, secret) } + context "when given one argument" do + before do + knife.name_args = [bag_name] + end + + it "creates a data bag" do + expect(rest).to receive(:post).with("data", { "name" => bag_name }) + expect(knife.ui).to receive(:info).with("Created data_bag[#{bag_name}]") - let(:item) do - item = Chef::DataBagItem.from_hash(encoded_data) - item.data_bag(bag_name) - item + knife.run + end end - it "creates an encrypted data bag item" do - expect(knife).to receive(:create_object).and_yield(raw_hash) - expect(knife).to receive(:encryption_secret_provided?).and_return(true) - expect(knife).to receive(:read_secret).and_return(secret) - expect(Chef::EncryptedDataBagItem) - .to receive(:encrypt_data_bag_item) - .with(raw_hash, secret) - .and_return(encoded_data) - expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered - expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered + context "no secret is specified for encryption" do + let(:item) do + item = Chef::DataBagItem.from_hash(raw_hash) + item.data_bag(bag_name) + item + end + + it "creates a data bag item" do + expect(knife).to receive(:create_object).and_yield(raw_hash) + expect(knife).to receive(:encryption_secret_provided?).and_return(false) + expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered + expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered + + knife.run + end + end - knife.run + context "a secret is specified for encryption" do + let(:encoded_data) { Chef::EncryptedDataBagItem.encrypt_data_bag_item(raw_hash, secret) } + + let(:item) do + item = Chef::DataBagItem.from_hash(encoded_data) + item.data_bag(bag_name) + item + end + + it "creates an encrypted data bag item" do + expect(knife).to receive(:create_object).and_yield(raw_hash) + expect(knife).to receive(:encryption_secret_provided?).and_return(true) + expect(knife).to receive(:read_secret).and_return(secret) + expect(Chef::EncryptedDataBagItem) + .to receive(:encrypt_data_bag_item) + .with(raw_hash, secret) + .and_return(encoded_data) + expect(rest).to receive(:post).with("data", { "name" => bag_name }).ordered + expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered + + knife.run + end end end - end diff --git a/spec/unit/lib_backcompat_spec.rb b/spec/unit/lib_backcompat_spec.rb deleted file mode 100644 index c7dfee5bcd..0000000000 --- a/spec/unit/lib_backcompat_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# -# Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "spec_helper" - -describe "lib-backcompat" do - it "require 'chef/chef_fs/file_system/chef_server_root_dir' yields the proper class" do - require "chef/chef_fs/file_system/chef_server_root_dir" - expect(Chef::ChefFS::FileSystem::ChefServerRootDir).to eq(Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir) - end - it "require 'chef/chef_fs/file_system/chef_repository_file_system_root_dir' yields the proper class" do - require "chef/chef_fs/file_system/chef_repository_file_system_root_dir" - expect(Chef::ChefFS::FileSystem::ChefRepositoryFileSystemRootDir).to eq(Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemRootDir) - end - it "require 'chef/chef_fs/file_system/acl_entry' yields the proper class" do - require "chef/chef_fs/file_system/acl_entry" - expect(Chef::ChefFS::FileSystem::AclEntry).to eq(Chef::ChefFS::FileSystem::ChefServer::AclEntry) - end -end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 9700b8ef2b..28773a3c30 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -1,6 +1,6 @@ # # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,14 +41,11 @@ describe "LWRP" do Chef::ResourceResolver.resolve(name) end - def get_lwrp_provider(name) - old_treat_deprecation_warnings_as_errors = Chef::Config[:treat_deprecation_warnings_as_errors] - Chef::Config[:treat_deprecation_warnings_as_errors] = false - begin - Chef::Provider.const_get(convert_to_class_name(name.to_s)) - ensure - Chef::Config[:treat_deprecation_warnings_as_errors] = old_treat_deprecation_warnings_as_errors - end + def get_dynamic_lwrp_provider(name) + # need a node to do dynamic lookup, so also need a run_context and a resource instance + node = Chef::Node.new + run_context = Chef::RunContext.new(node, {}, nil) + Chef::Resource.new("name", run_context).lookup_provider_constant(name) end describe "when overriding an existing class" do @@ -324,14 +321,7 @@ describe "LWRP" do end end - def raise_if_deprecated! - if Chef::VERSION.split(".").first.to_i > 12 - raise "This test should be removed and the associated code should be removed!" - end - end - it "amends actions when they are already defined" do - raise_if_deprecated! expect(child.actions).to eq([:nothing, :eat, :sleep, :drink]) end end @@ -393,7 +383,7 @@ describe "LWRP" do let(:runner) { Chef::Runner.new(run_context) } - let(:lwrp_cookbok_name) { "lwrp" } + let(:lwrp_cookbook_name) { "lwrp" } before do Chef::Provider::LWRPBase.class_eval { @loaded_lwrps = {} } @@ -401,18 +391,18 @@ describe "LWRP" do before(:each) do Dir[File.expand_path(File.expand_path("../../data/lwrp/resources/*", __FILE__))].each do |file| - Chef::Resource::LWRPBase.build_from_file(lwrp_cookbok_name, file, run_context) + Chef::Resource::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context) end Dir[File.expand_path(File.expand_path("../../data/lwrp/providers/*", __FILE__))].each do |file| - Chef::Provider::LWRPBase.build_from_file(lwrp_cookbok_name, file, run_context) + Chef::Provider::LWRPBase.build_from_file(lwrp_cookbook_name, file, run_context) end end it "should properly handle a new_resource reference" do resource = get_lwrp(:lwrp_foo).new("morpheus", run_context) resource.monkey("bob") - resource.provider(get_lwrp_provider(:lwrp_monkey_name_printer)) + resource.provider(get_dynamic_lwrp_provider(:lwrp_monkey_name_printer)) provider = resource.provider_for_action(:twiddle_thumbs) provider.action_twiddle_thumbs end @@ -433,8 +423,8 @@ describe "LWRP" do end it "should create a method for each action" do - expect(get_lwrp_provider(:lwrp_buck_passer).instance_methods).to include(:action_pass_buck) - expect(get_lwrp_provider(:lwrp_thumb_twiddler).instance_methods).to include(:action_twiddle_thumbs) + expect(get_dynamic_lwrp_provider(:lwrp_buck_passer).instance_methods).to include(:action_pass_buck) + expect(get_dynamic_lwrp_provider(:lwrp_thumb_twiddler).instance_methods).to include(:action_twiddle_thumbs) end it "sets itself as a provider for a resource of the same name" do @@ -442,30 +432,30 @@ describe "LWRP" do # we bypass the per-file loading to get the file to load each time, # which creates the LWRP class repeatedly. New things get prepended to # the list of providers. - expect(found_providers.first).to eq(get_lwrp_provider(:lwrp_buck_passer)) + expect(found_providers.first).to eq(get_dynamic_lwrp_provider(:lwrp_buck_passer)) end context "with a cookbook with an underscore in the name" do - let(:lwrp_cookbok_name) { "l_w_r_p" } + let(:lwrp_cookbook_name) { "l_w_r_p" } it "sets itself as a provider for a resource of the same name" do found_providers = Chef::Platform::ProviderHandlerMap.instance.list(node, :l_w_r_p_buck_passer) expect(found_providers.size).to eq(1) - expect(found_providers.last).to eq(get_lwrp_provider(:l_w_r_p_buck_passer)) + expect(found_providers.last).to eq(get_dynamic_lwrp_provider(:l_w_r_p_buck_passer)) end end context "with a cookbook with a hypen in the name" do - let(:lwrp_cookbok_name) { "l-w-r-p" } + let(:lwrp_cookbook_name) { "l-w-r-p" } it "sets itself as a provider for a resource of the same name" do incorrect_providers = Chef::Platform::ProviderHandlerMap.instance.list(node, :'l-w-r-p_buck_passer') expect(incorrect_providers).to eq([]) found_providers = Chef::Platform::ProviderHandlerMap.instance.list(node, :l_w_r_p_buck_passer) - expect(found_providers.first).to eq(get_lwrp_provider(:l_w_r_p_buck_passer)) + expect(found_providers.first).to eq(get_dynamic_lwrp_provider(:l_w_r_p_buck_passer)) end end end @@ -473,7 +463,7 @@ describe "LWRP" do it "should insert resources embedded in the provider into the middle of the resource collection" do injector = get_lwrp(:lwrp_foo).new("morpheus", run_context) injector.action(:pass_buck) - injector.provider(get_lwrp_provider(:lwrp_buck_passer)) + injector.provider(get_dynamic_lwrp_provider(:lwrp_buck_passer)) dummy = Chef::Resource::ZenMaster.new("keanu reeves", run_context) dummy.provider(Chef::Provider::Easy) run_context.resource_collection.insert(injector) @@ -490,11 +480,11 @@ describe "LWRP" do it "should insert embedded resources from multiple providers, including from the last position, properly into the resource collection" do injector = get_lwrp(:lwrp_foo).new("morpheus", run_context) injector.action(:pass_buck) - injector.provider(get_lwrp_provider(:lwrp_buck_passer)) + injector.provider(get_dynamic_lwrp_provider(:lwrp_buck_passer)) injector2 = get_lwrp(:lwrp_bar).new("tank", run_context) injector2.action(:pass_buck) - injector2.provider(get_lwrp_provider(:lwrp_buck_passer_2)) + injector2.provider(get_dynamic_lwrp_provider(:lwrp_buck_passer_2)) dummy = Chef::Resource::ZenMaster.new("keanu reeves", run_context) dummy.provider(Chef::Provider::Easy) @@ -517,7 +507,7 @@ describe "LWRP" do it "should properly handle a new_resource reference" do resource = get_lwrp(:lwrp_foo).new("morpheus", run_context) resource.monkey("bob") - resource.provider(get_lwrp_provider(:lwrp_monkey_name_printer)) + resource.provider(get_dynamic_lwrp_provider(:lwrp_monkey_name_printer)) provider = resource.provider_for_action(:twiddle_thumbs) provider.action_twiddle_thumbs @@ -528,7 +518,7 @@ describe "LWRP" do it "should properly handle an embedded Resource accessing the enclosing Provider's scope" do resource = get_lwrp(:lwrp_foo).new("morpheus", run_context) resource.monkey("bob") - resource.provider(get_lwrp_provider(:lwrp_embedded_resource_accesses_providers_scope)) + resource.provider(get_dynamic_lwrp_provider(:lwrp_embedded_resource_accesses_providers_scope)) provider = resource.provider_for_action(:twiddle_thumbs) #provider = @runner.build_provider(resource) @@ -548,7 +538,7 @@ describe "LWRP" do @resource = get_lwrp(:lwrp_foo).new("morpheus", run_context) @resource.allowed_actions << :test @resource.action(:test) - @resource.provider(get_lwrp_provider(:lwrp_inline_compiler)) + @resource.provider(get_dynamic_lwrp_provider(:lwrp_inline_compiler)) end it "does not add interior resources to the exterior resource collection" do diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index a3e62ff939..e9515ff3b4 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -490,11 +490,6 @@ describe Chef::Node::Attribute do expect(@attributes.has_key?("does_not_exist_at_all")).to eq(false) end - it "should return true if an attribute exists but is set to nil using dot notation" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(@attributes.music.deeper.has_key?("gates_of_ishtar")).to eq(true) - end - it "should return true if an attribute exists but is set to false" do @attributes.has_key?("music") expect(@attributes["music"].has_key?("apophis")).to eq(true) @@ -530,19 +525,6 @@ describe Chef::Node::Attribute do end - describe "method_missing" do - it "should behave like a [] lookup" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(@attributes.music.mastodon).to eq("rocks") - end - - it "should allow the last method to set a value if it has an = sign on the end" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @attributes.normal.music.mastodon = %w{dream still shining} - expect(@attributes.normal.music.mastodon).to eq(%w{dream still shining}) - end - end - describe "keys" do before(:each) do @attributes = Chef::Node::Attribute.new( @@ -1109,25 +1091,25 @@ describe Chef::Node::Attribute do describe "when setting a component attribute to a new value" do it "converts the input in to a VividMash tree (default)" do @attributes.default = {} - @attributes.default.foo = "bar" + @attributes.default["foo"] = "bar" expect(@attributes.merged_attributes[:foo]).to eq("bar") end it "converts the input in to a VividMash tree (normal)" do @attributes.normal = {} - @attributes.normal.foo = "bar" + @attributes.normal["foo"] = "bar" expect(@attributes.merged_attributes[:foo]).to eq("bar") end it "converts the input in to a VividMash tree (override)" do @attributes.override = {} - @attributes.override.foo = "bar" + @attributes.override["foo"] = "bar" expect(@attributes.merged_attributes[:foo]).to eq("bar") end it "converts the input in to a VividMash tree (automatic)" do @attributes.automatic = {} - @attributes.automatic.foo = "bar" + @attributes.automatic["foo"] = "bar" expect(@attributes.merged_attributes[:foo]).to eq("bar") end end @@ -1170,11 +1152,6 @@ describe Chef::Node::Attribute do it "raises an error when using []=" do expect { @attributes[:new_key] = "new value" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end - - it "raises an error when using `attr=value`" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect { @attributes.new_key = "new value" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) - end end describe "deeply converting values" do diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index ac227c5479..40780e523b 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -238,43 +238,25 @@ describe Chef::Node do expect(node["battles"]["people"].attribute?("snozzberry")).to eq(false) end - it "does not allow you to set an attribute via method_missing" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect { node.sunshine = "is bright" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) - end - it "does not allow modification of node attributes via hash methods" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["h4sh"] = { foo: "bar" } expect { node["h4sh"].delete("foo") }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) - expect { node.h4sh.delete("foo") }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end it "does not allow modification of node attributes via array methods" do Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["array"] = [] expect { node["array"] << "boom" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) - expect { node.array << "boom" }.to raise_error(Chef::Exceptions::ImmutableAttributeModification) end it "returns merged immutable attributes for arrays" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["array"] = [] expect( node["array"].class ).to eql(Chef::Node::ImmutableArray) - expect( node.array.class ).to eql(Chef::Node::ImmutableArray) end it "returns merged immutable attributes for hashes" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["h4sh"] = {} expect( node["h4sh"].class ).to eql(Chef::Node::ImmutableMash) - expect( node.h4sh.class ).to eql(Chef::Node::ImmutableMash) - end - - it "should allow you get get an attribute via method_missing" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - node.default.sunshine = "is bright" - expect(node.sunshine).to eql("is bright") end describe "normal attributes" do @@ -321,12 +303,6 @@ describe Chef::Node do expect(node[:snoopy][:is_a_puppy]).to eq(true) end - it "auto-vivifies attributes created via method syntax" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - node.normal.fuu.bahrr.baz = "qux" - expect(node.fuu.bahrr.baz).to eq("qux") - end - it "should let you use tag as a convience method for the tags attribute" do node.normal["tags"] = %w{one two} node.tag("three", "four") @@ -407,12 +383,6 @@ describe Chef::Node do expect(node["a"]["r1"]["g"]["u"]).to eql("u1") end - it "auto-vivifies attributes created via method syntax" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - node.default.fuu.bahrr.baz = "qux" - expect(node.fuu.bahrr.baz).to eq("qux") - end - it "default_unless correctly resets the deep merge cache" do node.normal["tags"] = [] # this sets our top-level breadcrumb node.default_unless["foo"]["bar"] = "NK-19V" @@ -469,12 +439,6 @@ describe Chef::Node do node.override[:snoopy][:is_a_puppy] = true expect(node[:snoopy][:is_a_puppy]).to eq(true) end - - it "auto-vivifies attributes created via method syntax" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - node.override.fuu.bahrr.baz = "qux" - expect(node.fuu.bahrr.baz).to eq("qux") - end end describe "globally deleting attributes" do @@ -811,10 +775,9 @@ describe Chef::Node do # describe "deep merge attribute cache edge conditions" do it "does not error with complicated attribute substitution" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["chef_attribute_hell"]["attr1"] = "attribute1" - node.default["chef_attribute_hell"]["attr2"] = "#{node.chef_attribute_hell.attr1}/attr2" - expect { node.default["chef_attribute_hell"]["attr3"] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error + node.default["chef_attribute_hell"]["attr2"] = "#{node[:chef_attribute_hell][:attr1]}/attr2" + expect { node.default["chef_attribute_hell"]["attr3"] = "#{node[:chef_attribute_hell][:attr2]}/attr3" }.not_to raise_error end it "caches both strings and symbols correctly" do @@ -829,7 +792,7 @@ describe Chef::Node do Chef::Config[:treat_deprecation_warnings_as_errors] = false node.default["passenger"]["version"] = "4.0.57" node.default["passenger"]["root_path"] = "passenger-#{node['passenger']['version']}" - node.default["passenger"]["root_path_2"] = "passenger-#{node.passenger['version']}" + node.default["passenger"]["root_path_2"] = "passenger-#{node[:passenger]['version']}" expect(node["passenger"]["root_path_2"]).to eql("passenger-4.0.57") expect(node[:passenger]["root_path_2"]).to eql("passenger-4.0.57") end @@ -841,8 +804,8 @@ describe Chef::Node do end it "should allow you to iterate over attributes with each_attribute" do - node.default.sunshine = "is bright" - node.default.canada = "is a nice place" + node.default["sunshine"] = "is bright" + node.default["canada"] = "is a nice place" seen_attributes = Hash.new node.each_attribute do |a, v| seen_attributes[a] = v @@ -1609,6 +1572,78 @@ describe Chef::Node do end end + context "with blacklisted attributes configured" do + it "should only save non-blacklisted attributes (and subattributes)" do + Chef::Config[:automatic_attribute_blacklist] = [ + ["filesystem", "/dev/disk0s2"], + "network/interfaces/eth0", + ] + + data = { + "automatic" => { + "filesystem" => { + "/dev/disk0s2" => { "size" => "10mb" }, + "map - autohome" => { "size" => "10mb" }, + }, + "network" => { + "interfaces" => { + "eth0" => {}, + "eth1" => {}, + }, + }, + }, + "default" => {}, "normal" => {}, "override" => {} + } + + selected_data = { + "automatic" => { + "filesystem" => { + "map - autohome" => { "size" => "10mb" }, + }, + "network" => { + "interfaces" => { + "eth1" => {}, + }, + }, + }, + "default" => {}, "normal" => {}, "override" => {} + } + node.name("picky-monkey") + allow(node).to receive(:for_json).and_return(data) + expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo") + node.save + end + + it "should save all attributes if the blacklist is empty" do + Chef::Config[:automatic_attribute_blacklist] = [] + + data = { + "automatic" => { + "filesystem" => { + "/dev/disk0s2" => { "size" => "10mb" }, + "map - autohome" => { "size" => "10mb" }, + }, + }, + "default" => {}, "normal" => {}, "override" => {} + } + + selected_data = { + "automatic" => { + "filesystem" => { + "/dev/disk0s2" => { "size" => "10mb" }, + "map - autohome" => { "size" => "10mb" }, + }, + }, + "default" => {}, "normal" => {}, "override" => {} + } + + node.name("picky-monkey") + allow(node).to receive(:for_json).and_return(data) + expect(@rest).to receive(:put).with("nodes/picky-monkey", selected_data).and_return("foo") + node.save + end + end + context "when policyfile attributes are present" do before do @@ -1657,55 +1692,9 @@ describe Chef::Node do end - context "on Chef Client 13 and later" do - - # Though we normally attempt to provide compatibility with chef - # server one major version back, policyfiles were beta when we - # added the policyfile attributes to the node JSON, therefore - # policyfile users need to be on 12.3 minimum when upgrading Chef - # Client to 13+ - it "lets the 400 pass through", chef: ">= 13" do - expect { node.save }.to raise_error(http_exception) - end - - end - - context "when the node exists" do - - it "falls back to saving without policyfile attributes" do - expect(@rest).to receive(:put).with("nodes/example-node", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:put).with("nodes/example-node", trimmed_node).and_return(@node) - expect { node.save }.to_not raise_error - end - - end - - context "when the node doesn't exist" do - - let(:response_404) do - Net::HTTPResponse.send(:response_class, "404").new("1.0", "404", "Not Found") - end - - let(:http_exception_404) do - begin - response_404.error! - rescue => e - e - end - end - - it "falls back to saving without policyfile attributes" do - expect(@rest).to receive(:put).with("nodes/example-node", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:put).with("nodes/example-node", trimmed_node).and_raise(http_exception_404) - expect(@rest).to receive(:post).with("nodes", trimmed_node).and_return(@node) - node.save - end - - it "creates the node without policyfile attributes" do - expect(@rest).to receive(:post).with("nodes", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:post).with("nodes", trimmed_node).and_return(@node) - node.create - end + it "lets the 400 pass through" do + expect(@rest).to receive(:put).and_raise(http_exception) + expect { node.save }.to raise_error(http_exception) end end diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index 420db2e855..a7f4f1fa43 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,11 +34,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(policy_builder).to respond_to(:node) end - it "implements a load_node method for backwards compatibility until Chef 13" do - expect(policy_builder).to respond_to(:load_node) - end - - it "has removed the deprecated #load_node method", chef: ">= 13" do + it "has removed the deprecated #load_node method" do expect(policy_builder).to_not respond_to(:load_node) end @@ -106,27 +102,6 @@ describe Chef::PolicyBuilder::ExpandNodeObject do end - context "deprecated #load_node method" do - - let(:node) do - node = Chef::Node.new - node.name(node_name) - node.run_list(["recipe[a::default]", "recipe[b::server]"]) - node - end - - before do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef::Node).to receive(:find_or_create).with(node_name).and_return(node) - policy_builder.load_node - end - - it "loads the node" do - expect(policy_builder.node).to eq(node) - end - - end - context "once the node has been loaded" do let(:node) do node = Chef::Node.new diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 50ff3434f6..0e7bf53ec5 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -1019,74 +1019,23 @@ describe "Chef::Resource.property" do end context "default ordering deprecation warnings" do - it "emits a deprecation warning for property :x, default: 10, #{name}: true" do - expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error Chef::Exceptions::DeprecatedFeatureError, - /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(default\) will be obeyed./ + it "emits an error for property :x, default: 10, #{name}: true" do + expect { resource_class.property :x, :default => 10, name.to_sym => true }.to raise_error Chef::Exceptions::ArgumentError, + /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/ end - it "emits a deprecation warning for property :x, default: nil, #{name}: true" do - expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error Chef::Exceptions::DeprecatedFeatureError, - /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) will be obeyed./ + it "emits an error for property :x, default: nil, #{name}: true" do + expect { resource_class.property :x, :default => nil, name.to_sym => true }.to raise_error Chef::Exceptions::ArgumentError, + /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/ end - it "emits a deprecation warning for property :x, #{name}: true, default: 10" do - expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error Chef::Exceptions::DeprecatedFeatureError, - /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) will be obeyed./ + it "emits an error for property :x, #{name}: true, default: 10" do + expect { resource_class.property :x, name.to_sym => true, :default => 10 }.to raise_error Chef::Exceptions::ArgumentError, + /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/ end - it "emits a deprecation warning for property :x, #{name}: true, default: nil" do - expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError, - /Cannot specify both default and name_property together on property x of resource chef_resource_property_spec_(\d+). Only one \(name_property\) will be obeyed./ + it "emits an error for property :x, #{name}: true, default: nil" do + expect { resource_class.property :x, name.to_sym => true, :default => nil }.to raise_error Chef::Exceptions::ArgumentError, + /Cannot specify both default and name_property\/name_attribute together on property x of resource chef_resource_property_spec_(\d+)/ end end - - context "default ordering" do - before { Chef::Config[:treat_deprecation_warnings_as_errors] = false } - with_property ":x, default: 10, #{name}: true" do - it "chooses default over #{name}" do - expect(resource.x).to eq 10 - end - end - with_property ":x, default: nil, #{name}: true" do - it "chooses #{name} over default" do - expect(resource.x).to eq "blah" - end - end - with_property ":x, #{name}: true, default: 10" do - it "chooses #{name} over default" do - expect(resource.x).to eq "blah" - end - end - with_property ":x, #{name}: true, default: nil" do - it "chooses #{name} over default" do - expect(resource.x).to eq "blah" - end - end - end - - context "default ordering when #{name} is nil" do - with_property ":x, #{name}: nil, default: 10" do - it "chooses default" do - expect(resource.x).to eq 10 - end - end - with_property ":x, default: 10, #{name}: nil" do - it "chooses default" do - expect(resource.x).to eq 10 - end - end - end - - context "default ordering when #{name} is false" do - with_property ":x, #{name}: false, default: 10" do - it "chooses default" do - expect(resource.x).to eq 10 - end - end - with_property ":x, default: 10, #{name}: nil" do - it "chooses default" do - expect(resource.x).to eq 10 - end - end - end - end end diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb index d8f2c85cb7..6180582d69 100644 --- a/spec/unit/provider/apt_repository_spec.rb +++ b/spec/unit/provider/apt_repository_spec.rb @@ -18,32 +18,30 @@ require "spec_helper" +# Now we are using the option --with-colons that works across old os versions +# as well as the latest (16.10). This for both `apt-key` and `gpg` commands +# +# Output of the command: +# => apt-key adv --list-public-keys --with-fingerprint --with-colons APT_KEY_FINGER = <<-EOF -/etc/apt/trusted.gpg --------------------- -pub 1024D/437D05B5 2004-09-12 - Key fingerprint = 6302 39CC 130E 1A7F D81A 27B1 4097 6EAF 437D 05B5 -uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> -sub 2048g/79164387 2004-09-12 - -pub 1024D/FBB75451 2004-12-30 - Key fingerprint = C598 6B4F 1257 FFA8 6632 CBA7 4618 1433 FBB7 5451 -uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com> - -pub 4096R/C0B21F32 2012-05-11 - Key fingerprint = 790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32 -uid Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com> - -pub 4096R/EFE21092 2012-05-11 - Key fingerprint = 8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092 -uid Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com> - +tru:t:1:1488924856:0:3:1:5 +pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC: +fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: +sub:-:2048:16:251BEFF479164387:2004-09-12::::::e: +pub:-:1024:17:46181433FBB75451:2004-12-30:::-:Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>::scSC: +fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: +pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11:::-:Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>::scSC: +fpr:::::::::790BC7277767219C42C86F933B4FE6ACC0B21F32: +pub:-:4096:1:D94AA3F0EFE21092:2012-05-11:::-:Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>::scSC: +fpr:::::::::843938DF228D22F7B3742BC0D94AA3F0EFE21092: EOF +# Output of the command: +# => gpg --with-fingerprint --with-colons [FILE] GPG_FINGER = <<-EOF -pub 1024D/02A818DD 2009-04-22 Cloudera Apt Repository - Key fingerprint = F36A 89E3 3CC1 BD0F 7107 9007 3275 74EE 02A8 18DD -sub 2048g/D1CA74A1 2009-04-22 +pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository: +fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD: +sub:-:2048:16:84080586D1CA74A1:2009-04-22:::: EOF describe Chef::Provider::AptRepository do @@ -57,6 +55,10 @@ describe Chef::Provider::AptRepository do Chef::Provider::AptRepository.new(new_resource, run_context) end + let(:apt_key_finger_cmd) do + "apt-key adv --list-public-keys --with-fingerprint --with-colons" + end + let(:apt_key_finger) do r = double("Mixlib::ShellOut", stdout: APT_KEY_FINGER, exitstatus: 0, live_stream: true) allow(r).to receive(:run_command) @@ -102,28 +104,32 @@ C5986B4F1257FFA86632CBA746181433FBB75451 it "should run the desired command" do expect(apt_key_finger).to receive(:run_command) - provider.extract_fingerprints_from_cmd("apt-key finger") + provider.extract_fingerprints_from_cmd(apt_key_finger_cmd) end it "should return a list of key fingerprints" do - expect(provider.extract_fingerprints_from_cmd("apt-key finger")).to eql(apt_fingerprints) + expect(provider.extract_fingerprints_from_cmd(apt_key_finger_cmd)).to eql(apt_fingerprints) end end describe "#no_new_keys?" do before do - allow(provider).to receive(:extract_fingerprints_from_cmd).with("apt-key finger").and_return(apt_fingerprints) + allow(provider).to receive(:extract_fingerprints_from_cmd).with(apt_key_finger_cmd).and_return(apt_fingerprints) end let(:file) { "/tmp/remote-gpg-keyfile" } it "should match a set of keys" do - allow(provider).to receive(:extract_fingerprints_from_cmd).with("gpg --with-fingerprint #{file}").and_return(Array(apt_fingerprints.first)) + allow(provider).to receive(:extract_fingerprints_from_cmd) + .with("gpg --with-fingerprint --with-colons #{file}") + .and_return(Array(apt_fingerprints.first)) expect(provider.no_new_keys?(file)).to be_truthy end it "should notice missing keys" do - allow(provider).to receive(:extract_fingerprints_from_cmd).with("gpg --with-fingerprint #{file}").and_return(%w{ F36A89E33CC1BD0F71079007327574EE02A818DD }) + allow(provider).to receive(:extract_fingerprints_from_cmd) + .with("gpg --with-fingerprint --with-colons #{file}") + .and_return(%w{ F36A89E33CC1BD0F71079007327574EE02A818DD }) expect(provider.no_new_keys?(file)).to be_falsey end end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 1901e2ea03..904a2841c5 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -1,6 +1,6 @@ # # Author:: Prajakta Purohit (<prajakta@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -118,19 +118,9 @@ describe Chef::Provider::Execute do new_resource.creates "foo_resource" end - it "should warn in Chef-12", chef: "< 13" do - expect(Chef::Log).to receive(:warn).with(/relative path/) - expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true) + it "should raise if user specified relative path without cwd for Chef-13" do expect(provider).not_to receive(:shell_out!) - provider.run_action(:run) - expect(new_resource).not_to be_updated - end - - it "should raise if user specified relative path without cwd for Chef-13", chef: ">= 13" do - expect(Chef::Log).to receive(:warn).with(/relative path/) - expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true) - expect(provider).not_to receive(:shell_out!) - expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13 + expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::Execute) end end diff --git a/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb b/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb new file mode 100644 index 0000000000..d9339861a4 --- /dev/null +++ b/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" +require "chef/provider/package/windows/registry_uninstall_entry" + +describe Chef::Provider::Package::Windows::RegistryUninstallEntry do + let(:hkey) { :hkey } # mock all the methods + let(:key) { :key } + let(:entry) { { "UninstallString" => "UninstallStringPath", "QuietUninstallString" => "QuietUninstallStringPath" } } + + describe "when QuietUninstallString key not present" do + let(:quiet_uninstall_string) { nil } + let (:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string } + it "should return UninstallString key value" do + expect(quiet_uninstall_string_key).to eql "UninstallStringPath" + end + end + + describe "when QuietUninstallString key present" do + let(:quiet_uninstall_string) { "QuietUninstallString" } + let (:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string } + + it "should return QuietUninstallString key value" do + expect(quiet_uninstall_string_key).to eql "QuietUninstallStringPath" + end + end +end diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index 4fd3f3534d..d7a1620530 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Edwards (<adamed@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,10 +30,20 @@ describe Chef::Provider::PowershellScript, "action_run" do node end - let(:provider) do - empty_events = Chef::EventDispatch::Dispatcher.new - run_context = Chef::RunContext.new(node, {}, empty_events) + # code block is mandatory for the powershell provider + let(:code) { "" } + + let(:events) { Chef::EventDispatch::Dispatcher.new } + + let(:run_context) { run_context = Chef::RunContext.new(node, {}, events) } + + let(:new_resource) do new_resource = Chef::Resource::PowershellScript.new("run some powershell code", run_context) + new_resource.code code + new_resource + end + + let(:provider) do Chef::Provider::PowershellScript.new(new_resource, run_context) end diff --git a/spec/unit/provider/user/linux_spec.rb b/spec/unit/provider/user/linux_spec.rb index b04ada2511..5092c8f4b9 100644 --- a/spec/unit/provider/user/linux_spec.rb +++ b/spec/unit/provider/user/linux_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # # License:: Apache License, Version 2.0 # @@ -45,56 +45,18 @@ describe Chef::Provider::User::Linux do @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context) end - it "supports manage_home does not exist", chef: ">= 13" do - expect( @new_resource.supports.key?(:manage_home) ).to be false + it "throws an error when trying to set supports manage_home: true" do + expect { @new_resource.supports( manage_home: true ) }.to raise_error(NoMethodError) end - it "supports non_unique does not exist", chef: ">= 13" do - expect( @new_resource.supports.key?(:non_unique) ).to be false - end - - # supports is a method on the superclass so can't totally be removed, but we should aggressively NOP it to decisively break it - it "disables the supports API", chef: ">= 13" do - @new_resource.supports( manage_home: true ) - expect( @new_resource.supports.key?(:manage_home) ).to be false - end - - it "sets supports manage_home to false" do - expect( @new_resource.supports[:manage_home] ).to be false - end - - it "sets supports non-unique to false" do - expect( @new_resource.supports[:non_unique] ).to be false - end - - it "throws a deprecation warning on setting supports[:non_unique]" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef).to receive(:deprecated).with(:supports_property, "supports { non_unique: true } on the user resource is deprecated and will be removed in Chef 13, set non_unique true instead") - @new_resource.supports( non_unique: true ) - end - - it "throws a deprecation warning on setting supports[:manage_home]" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect(Chef).to receive(:deprecated).with(:supports_property, "supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home true instead") - @new_resource.supports( manage_home: true ) + it "throws an error when trying to set supports non_unique: true" do + expect { @new_resource.supports( non_unique: true ) }.to raise_error(NoMethodError) end it "defaults manage_home to false" do expect( @new_resource.manage_home ).to be false end - it "supports[:manage_home] (incorectly) acts like manage_home" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports(manage_home: true) - expect( provider.useradd_options ).to eql(["-m"]) - end - - it "supports[:manage_home] does not change behavior of manage_home: false", chef: ">= 13" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports(manage_home: true) - expect( provider.useradd_options ).to eql(["-M"]) - end - it "by default manage_home is false and we use -M" do expect( provider.useradd_options ).to eql(["-M"]) end diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index 2f44d6f3e3..3637ce0b95 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -1,6 +1,6 @@ # # Author:: Stephen Haynes (<sh@nomitor.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,9 +32,7 @@ describe Chef::Provider::User::Pw do @new_resource.shell "/usr/bin/zsh" @new_resource.password "abracadabra" - # XXX: rip out in Chef-13 - Chef::Config[:treat_deprecation_warnings_as_errors] = false - @new_resource.supports manage_home: true + @new_resource.manage_home true @current_resource = Chef::Resource::User::PwUser.new("adam") @current_resource.comment "Adam Jacob" @@ -67,12 +65,6 @@ describe Chef::Provider::User::Pw do allow(@new_resource).to receive(attribute).and_return("hola") expect(@provider.set_options).to eql([ @new_resource.username, option, @new_resource.send(attribute), "-m"]) end - - it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do - allow(@new_resource).to receive(:supports).and_return(manage_home: false) - allow(@new_resource).to receive(attribute).and_return("hola") - expect(@provider.set_options).to eql([@new_resource.username, option, @new_resource.send(attribute)]) - end end it "should combine all the possible options" do @@ -123,7 +115,7 @@ describe Chef::Provider::User::Pw do describe "remove_user" do it "should run pw userdel with the new resources user name" do - @new_resource.supports manage_home: false + @new_resource.manage_home false expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username).and_return(true) @provider.remove_user end diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb index 2bc2ae7c88..f252d3177d 100644 --- a/spec/unit/provider_spec.rb +++ b/spec/unit/provider_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -91,8 +91,8 @@ describe Chef::Provider do expect(@provider.current_resource).to eql(nil) end - it "should not support whyrun by default" do - expect(@provider.send(:whyrun_supported?)).to eql(false) + it "should support whyrun by default" do + expect(@provider.send(:whyrun_supported?)).to eql(true) end it "should do nothing for check_resource_semantics! by default" do diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index e1e3e0ad72..abba1ceb4d 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -3,7 +3,7 @@ # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) # Author:: Seth Chisamore (<schisamo@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -225,109 +225,6 @@ describe Chef::Recipe do end end - describe "when cloning resources" do - def expect_warning - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - end - - it "should emit a 3694 warning when attributes change" do - recipe.zen_master "klopp" do - something "bvb" - end - expect_warning - recipe.zen_master "klopp" do - something "vbv" - end - end - - it "should emit a 3694 warning when attributes change" do - recipe.zen_master "klopp" do - something "bvb" - end - expect_warning - recipe.zen_master "klopp" do - something "bvb" - peace true - end - end - - it "should emit a 3694 warning when attributes change" do - recipe.zen_master "klopp" do - something "bvb" - peace true - end - expect_warning - recipe.zen_master "klopp" do - something "bvb" - end - end - - it "should emit a 3694 warning for non-trivial attributes (unfortunately)" do - recipe.zen_master "klopp" do - something "bvb" - end - expect_warning - recipe.zen_master "klopp" do - something "bvb" - end - end - - it "should not emit a 3694 warning for completely trivial resource cloning" do - recipe.zen_master "klopp" - expect(Chef).to_not receive(:deprecated) - recipe.zen_master "klopp" - end - - it "should not emit a 3694 warning when attributes do not change and the first action is :nothing" do - recipe.zen_master "klopp" do - action :nothing - end - expect(Chef).to_not receive(:deprecated) - recipe.zen_master "klopp" do - action :score - end - end - - it "should not emit a 3694 warning when attributes do not change and the second action is :nothing" do - recipe.zen_master "klopp" do - action :score - end - expect(Chef).to_not receive(:deprecated) - recipe.zen_master "klopp" do - action :nothing - end - end - - class Coerced < Chef::Resource - resource_name :coerced - provides :coerced - default_action :whatever - property :package_name, [String, Array], coerce: proc { |x| [x].flatten }, name_property: true - def after_created - Array(action).each do |action| - run_action(action) - end - end - action :whatever do - package_name # unlazy the package_name - end - end - - it "does not emit 3694 when the name_property is unlazied by running it at compile_time" do - recipe.coerced "string" - expect(Chef).to_not receive(:deprecated) - recipe.coerced "string" - end - - it "validating resources via build_resource" do - expect do - recipe.build_resource(:remote_file, "klopp") do - source Chef::DelayedEvaluator.new { "http://chef.io" } - end end.to_not raise_error - end - - end - describe "creating resources via declare_resource" do let(:zm_resource) do recipe.declare_resource(:zen_master, "klopp") do @@ -351,7 +248,6 @@ describe Chef::Recipe do end it "will insert another resource if create_if_missing is not set (cloned resource as of Chef-12)" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) zm_resource recipe.declare_resource(:zen_master, "klopp") expect(run_context.resource_collection.count).to eql(2) @@ -453,58 +349,6 @@ describe Chef::Recipe do end - describe "resource cloning" do - - let(:second_recipe) do - Chef::Recipe.new("second_cb", "second_recipe", run_context) - end - - let(:original_resource) do - recipe.zen_master("klopp") do - something "bvb09" - action :score - end - end - - let(:duplicated_resource) do - original_resource - second_recipe.zen_master("klopp") do - # attrs should be cloned - end - end - - it "copies attributes from the first resource" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - expect(duplicated_resource.something).to eq("bvb09") - end - - it "does not copy the action from the first resource" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - expect(original_resource.action).to eq([:score]) - expect(duplicated_resource.action).to eq([:nothing]) - end - - it "does not copy the source location of the first resource" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - # sanity check source location: - expect(original_resource.source_line).to include(__FILE__) - expect(duplicated_resource.source_line).to include(__FILE__) - # actual test: - expect(original_resource.source_line).not_to eq(duplicated_resource.source_line) - end - - it "sets the cookbook name on the cloned resource to that resource's cookbook" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - expect(duplicated_resource.cookbook_name).to eq("second_cb") - end - - it "sets the recipe name on the cloned resource to that resoure's recipe" do - expect(Chef).to receive(:deprecated).with(:resource_cloning, /^Cloning resource attributes for zen_master\[klopp\]/) - expect(duplicated_resource.recipe_name).to eq("second_recipe") - end - - end - describe "resource definitions" do it "should execute defined resources" do crow_define = Chef::ResourceDefinition.new diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb index c98b447582..2b09fb388f 100644 --- a/spec/unit/resource/chef_gem_spec.rb +++ b/spec/unit/resource/chef_gem_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Bryan McLellan <btm@loftninjas.org> -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,8 +42,8 @@ describe Chef::Resource::ChefGem, "gem_binary" do expect(resource.gem_binary).to eql("#{RbConfig::CONFIG['bindir']}/gem") end - it "should set the gem_binary based on computing it from RbConfig" do - expect(resource.compile_time).to be nil + it "should set compile_time to false by default" do + expect(resource.compile_time).to be false end context "when building the resource" do @@ -70,22 +70,13 @@ describe Chef::Resource::ChefGem, "gem_binary" do expect(Chef::Resource::ChefGem).to receive(:new).and_return(resource) end - it "runs the install at compile-time by default", chef: "< 13" do - expect(resource).to receive(:run_action).with(:install) - expect(Chef::Log).to receive(:deprecation).at_least(:once) - recipe.chef_gem "foo" - end - - # the default behavior will change in Chef-13 - it "does not runs the install at compile-time by default", chef: ">= 13" do + it "does not runs the install at compile-time by default" do expect(resource).not_to receive(:run_action).with(:install) - expect(Chef::Log).not_to receive(:deprecation) recipe.chef_gem "foo" end it "compile_time true installs at compile-time" do expect(resource).to receive(:run_action).with(:install) - expect(Chef::Log).not_to receive(:deprecation) recipe.chef_gem "foo" do compile_time true end @@ -93,64 +84,27 @@ describe Chef::Resource::ChefGem, "gem_binary" do it "compile_time false does not install at compile-time" do expect(resource).not_to receive(:run_action).with(:install) - expect(Chef::Log).not_to receive(:deprecation) recipe.chef_gem "foo" do compile_time false end end - describe "when Chef::Config[:chef_gem_compile_time] is explicitly true" do - let(:chef_gem_compile_time) { true } - - before do - expect(Chef::Log).not_to receive(:deprecation) - end - - it "by default installs at compile-time" do - expect(resource).to receive(:run_action).with(:install) - recipe.chef_gem "foo" - end - - it "compile_time true installs at compile-time" do - expect(resource).to receive(:run_action).with(:install) - recipe.chef_gem "foo" do - compile_time true - end - end - - it "compile_time false does not install at compile-time" do - expect(resource).not_to receive(:run_action).with(:install) - recipe.chef_gem "foo" do - compile_time false - end - end + it "by default does not install at compile-time" do + expect(resource).not_to receive(:run_action).with(:install) + recipe.chef_gem "foo" end - describe "when Chef::Config[:chef_gem_compile_time] is explicitly false" do - - let(:chef_gem_compile_time) { false } - - before do - expect(Chef::Log).not_to receive(:deprecation) - end - - it "by default does not install at compile-time" do - expect(resource).not_to receive(:run_action).with(:install) - recipe.chef_gem "foo" - end - - it "compile_time true installs at compile-time" do - expect(resource).to receive(:run_action).with(:install) - recipe.chef_gem "foo" do - compile_time true - end + it "compile_time true installs at compile-time" do + expect(resource).to receive(:run_action).with(:install) + recipe.chef_gem "foo" do + compile_time true end + end - it "compile_time false does not install at compile-time" do - expect(resource).not_to receive(:run_action).with(:install) - recipe.chef_gem "foo" do - compile_time false - end + it "compile_time false does not install at compile-time" do + expect(resource).not_to receive(:run_action).with(:install) + recipe.chef_gem "foo" do + compile_time false end end end diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb index 33f16b4a89..a758638244 100644 --- a/spec/unit/resource/deploy_spec.rb +++ b/spec/unit/resource/deploy_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -216,12 +216,12 @@ describe Chef::Resource::Deploy do end it "allows deploy providers to be set via symbol" do - @resource.provider :revision + @resource.provider :deploy_revision expect(@resource.provider).to eq(Chef::Provider::Deploy::Revision) end it "allows deploy providers to be set via string" do - @resource.provider "revision" + @resource.provider "deploy_revision" expect(@resource.provider).to eq(Chef::Provider::Deploy::Revision) end diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb index 4c0ee694c3..69e4e91f2a 100644 --- a/spec/unit/resource/execute_spec.rb +++ b/spec/unit/resource/execute_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index 6416bb3ad8..feacd715a4 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -81,24 +81,18 @@ describe Chef::Resource::File::Verification do end end - it "substitutes \%{file} with the path" do + it "raises an error when \%{file} is used" do test_command = platform_specific_verify_command("file") - v = Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - expect(v.verify(temp_path)).to eq(true) - end - - it "warns about deprecation when \%{file} is used" do - expect(Chef).to receive(:deprecated).with(:verify_file, /%{file} is deprecated/) - test_command = platform_specific_verify_command("file") - Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - .verify(temp_path) + expect do + Chef::Resource::File::Verification.new(parent_resource, test_command, {}).verify(temp_path) + end.to raise_error(ArgumentError) end - it "does not warn about deprecation when \%{file} is not used" do - expect(Chef::Log).to_not receive(:deprecation) + it "does not raise an error when \%{file} is not used" do test_command = platform_specific_verify_command("path") - Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - .verify(temp_path) + expect do + Chef::Resource::File::Verification.new(parent_resource, test_command, {}).verify(temp_path) + end.to_not raise_error end it "substitutes \%{path} with the path" do diff --git a/spec/unit/resource/script_spec.rb b/spec/unit/resource/script_spec.rb index fca9fb0d7b..16f7650712 100644 --- a/spec/unit/resource/script_spec.rb +++ b/spec/unit/resource/script_spec.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 7aadc55532..8d661e2a7a 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -146,13 +146,13 @@ describe Chef::Resource::Service do it "should allow you to set what features this resource supports as a array" do support_array = [ :status, :restart ] - support_hash = { :status => true, :restart => true, :reload => nil } + support_hash = { :status => true, :restart => true } @resource.supports(support_array) expect(@resource.supports).to eq(support_hash) end it "should allow you to set what features this resource supports as a hash" do - support_hash = { :status => true, :restart => true, :reload => false } + support_hash = { :status => true, :restart => true } @resource.supports(support_hash) expect(@resource.supports).to eq(support_hash) end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 138ffb1bfe..afd3969164 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,12 +46,12 @@ describe Chef::Resource::User, "initialize" do expect(@resource.action).to eql([:create]) end - it "should set supports[:manage_home] to false" do - expect(@resource.supports[:manage_home]).to eql(false) + it "should set manage_home to false" do + expect(@resource.manage_home).to eql(false) end - it "should set supports[:non_unique] to false" do - expect(@resource.supports[:non_unique]).to eql(false) + it "should set non_unique to false" do + expect(@resource.non_unique).to eql(false) end it "should set force to false" do diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 2f75ba0241..df8ae3100a 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -3,7 +3,7 @@ # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) # Author:: Seth Chisamore (<schisamo@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -192,7 +192,6 @@ describe Chef::Resource do describe "load_from" do let(:prior_resource) do prior_resource = Chef::Resource.new("funk") - prior_resource.supports(:funky => true) prior_resource.source_line prior_resource.allowed_actions << :funkytown prior_resource.action(:funkytown) @@ -205,7 +204,6 @@ describe Chef::Resource do it "should load the attributes of a prior resource" do resource.load_from(prior_resource) - expect(resource.supports).to eq({ :funky => true }) end it "should not inherit the action from the prior resource" do @@ -233,14 +231,6 @@ describe Chef::Resource do end end - describe "noop" do - it "should accept true or false for noop" do - expect { resource.noop true }.not_to raise_error - expect { resource.noop false }.not_to raise_error - expect { resource.noop "eat it" }.to raise_error(ArgumentError) - end - end - describe "notifies" do it "should make notified resources appear in the actions hash" do run_context.resource_collection << Chef::Resource::ZenMaster.new("coffee") @@ -452,18 +442,6 @@ describe Chef::Resource do end end - describe "is" do - it "should return the arguments passed with 'is'" do - zm = Chef::Resource::ZenMaster.new("coffee") - expect(zm.is("one", "two", "three")).to eq(%w{one two three}) - end - - it "should allow arguments preceded by is to methods" do - resource.noop(resource.is(true)) - expect(resource.noop).to eql(true) - end - end - describe "to_json" do it "should serialize to json" do json = resource.to_json @@ -481,10 +459,10 @@ describe Chef::Resource do let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } } it "should include the default in the hash" do expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, :supports, - :noop, :ignore_failure, :name, :source_line, - :action, :retries, :retry_delay, :elapsed_time, - :default_guard_interpreter, :guard_interpreter, :sensitive].sort) + :updated_by_last_action, :before, + :name, :source_line, + :action, :elapsed_time, + :default_guard_interpreter, :guard_interpreter].sort) expect(resource.to_hash[:name]).to eq "funk" expect(resource.to_hash[:a]).to eq 1 end @@ -493,10 +471,10 @@ describe Chef::Resource do it "should convert to a hash" do hash = resource.to_hash expected_keys = [ :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, :supports, - :noop, :ignore_failure, :name, :source_line, - :action, :retries, :retry_delay, :elapsed_time, - :default_guard_interpreter, :guard_interpreter, :sensitive ] + :updated_by_last_action, :before, + :name, :source_line, + :action, :elapsed_time, + :default_guard_interpreter, :guard_interpreter ] expect(hash.keys - expected_keys).to eq([]) expect(expected_keys - hash.keys).to eq([]) expect(hash[:name]).to eql("funk") @@ -512,18 +490,6 @@ describe Chef::Resource do end end - describe "supports" do - it "should allow you to set what features this resource supports" do - support_hash = { :one => :two } - resource.supports(support_hash) - expect(resource.supports).to eql(support_hash) - end - - it "should return the current value of supports" do - expect(resource.supports).to eq({}) - end - end - describe "ignore_failure" do it "should default to throwing an error if a provider fails for a resource" do expect(resource.ignore_failure).to eq(false) @@ -585,31 +551,6 @@ describe Chef::Resource do end end - describe "setting the base provider class for the resource" do - - it "defaults to Chef::Provider for the base class" do - expect(Chef::Resource.provider_base).to eq(Chef::Provider) - end - - it "allows the base provider to be overridden" do - Chef::Config.treat_deprecation_warnings_as_errors(false) - class OverrideProviderBaseTest < Chef::Resource - provider_base Chef::Provider::Package - end - - expect(OverrideProviderBaseTest.provider_base).to eq(Chef::Provider::Package) - end - - it "warns when setting provider_base" do - expect do - class OverrideProviderBaseTest2 < Chef::Resource - provider_base Chef::Provider::Package - end - end.to raise_error(Chef::Exceptions::DeprecatedFeatureError) - end - - end - it "runs an action by finding its provider, loading the current resource and then running the action" do skip end diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb index 91c601b294..859fee75ec 100644 --- a/spec/unit/run_list/versioned_recipe_list_spec.rb +++ b/spec/unit/run_list/versioned_recipe_list_spec.rb @@ -1,6 +1,6 @@ # # Author:: Stephen Delano (<stephen@chef.io>) -# Copyright:: Copyright 2010-2016, Chef Software Inc. +# Copyright:: Copyright 2010-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -186,9 +186,12 @@ describe Chef::RunList::VersionedRecipeList do end end - context "with duplicated names", chef: ">= 13" do - it "should fail in Chef 13" do - expect(list).to_not respond_to(:with_duplicate_names) + context "with duplicate names" do + let(:fq_names) { list.with_duplicate_names } + let(:recipes) { %w{ foo bar::default } } + + it "expands default recipes" do + expect(fq_names).to eq(%w{foo foo::default bar bar::default}) end end end diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index 51667784fb..6df8587717 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -269,22 +269,4 @@ describe Chef::Search::Query do end end - describe "#partial_search" do - include_context "filtered search" do - let(:filter_key) { :keys } - - it "emits a deprecation warning" do - # partial_search calls search, so we'll stub search to return empty - allow(query).to receive(:search).and_return( [ [], 0, 0 ] ) - expect(Chef::Log).to receive(:warn).with(/DEPRECATED: The 'partial_search' API is deprecated/) - query.partial_search(:node, "platform:rhel", args) - end - - it "returns an array of filtered hashes" do - expect(rest).to receive(:post).with(query_string, args[filter_key]).and_return(response) - results = query.partial_search(:node, "platform:rhel", args) - expect(results[0]).to match_array(response_rows) - end - end - end end diff --git a/tasks/dependencies.rb b/tasks/dependencies.rb index b37c351d12..6b836b747e 100644 --- a/tasks/dependencies.rb +++ b/tasks/dependencies.rb @@ -1,5 +1,5 @@ # -# Copyright:: Copyright (c) 2016 Chef Software Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,66 +44,53 @@ namespace :dependencies do dependencies:update_acceptance_gemfile_lock dependencies:update_kitchen_tests_gemfile_lock dependencies:update_kitchen_tests_berksfile_lock + dependencies:update_audit_tests_berksfile_lock } - desc "Update Gemfile.lock and all Gemfile.<platform>.locks." - task :update_gemfile_lock do |t, rake_args| - Rake::Task["bundle:update"].invoke + def bundle_update_locked_multiplatform_task(task_name, dir) + desc "Update #{dir}/Gemfile.lock." + task task_name do + Dir.chdir(dir) do + Bundler.with_clean_env do + sh "bundle config --local frozen '0'" + sh "bundle lock --update --add-platform ruby" + sh "bundle lock --update --add-platform x86-mingw32" + sh "bundle config --local frozen '1'" + end + end + end end - def gemfile_lock_task(task_name, dirs: [], other_platforms: true, leave_frozen: true) - dirs.each do |dir| - desc "Update #{dir}/Gemfile.lock." - task task_name do |t, rake_args| - extend BundleUtil - puts "" - puts "-------------------------------------------------------------------" - puts "Updating #{dir}/Gemfile.lock ..." - puts "-------------------------------------------------------------------" - with_bundle_unfrozen(cwd: dir, leave_frozen: leave_frozen) do - bundle "install", cwd: dir, delete_gemfile_lock: true - if other_platforms - # Include all other supported platforms into the lockfile as well - platforms.each do |platform| - bundle "lock", cwd: dir, platform: platform - end - end + def bundle_update_task(task_name, dir) + desc "Update #{dir}/Gemfile.lock." + task task_name do + Dir.chdir(dir) do + Bundler.with_clean_env do + sh "bundle update" end end end end - def berksfile_lock_task(task_name, dirs: []) - dirs.each do |dir| - desc "Update #{dir}/Berksfile.lock." - task task_name do |t, rake_args| - extend BundleUtil - puts "" - puts "-------------------------------------------------------------------" - puts "Updating #{dir}/Berksfile.lock ..." - puts "-------------------------------------------------------------------" - if File.exist?("#{project_root}/#{dir}/Berksfile.lock") - File.delete("#{project_root}/#{dir}/Berksfile.lock") - end - Dir.chdir("#{project_root}/#{dir}") do - Bundler.with_clean_env do - sh "bundle exec berks install" - end + def berks_update_task(task_name, dir) + desc "Update #{dir}/Berksfile.lock." + task task_name do + FileUtils.rm_f("#{dir}/Berksfile.lock") + Dir.chdir(dir) do + Bundler.with_clean_env do + sh "bundle exec berks install" end end end end - gemfile_lock_task :update_omnibus_gemfile_lock, dirs: %w{omnibus} - gemfile_lock_task :update_acceptance_gemfile_lock, dirs: %w{acceptance}, - other_platforms: false, leave_frozen: false - gemfile_lock_task :update_kitchen_tests_gemfile_lock, dirs: %w{ - kitchen-tests - } - berksfile_lock_task :update_kitchen_tests_berksfile_lock, dirs: %w{ - kitchen-tests - kitchen-tests/cookbooks/audit_test - } + bundle_update_locked_multiplatform_task :update_gemfile_lock, "." + bundle_update_locked_multiplatform_task :update_omnibus_gemfile_lock, "omnibus" + bundle_update_task :update_acceptance_gemfile_lock, "acceptance" + bundle_update_locked_multiplatform_task :update_kitchen_tests_gemfile_lock, "kitchen-tests" + + berks_update_task :update_kitchen_tests_berksfile_lock, "kitchen-tests" + berks_update_task :update_audit_tests_berksfile_lock, "kitchen-tests/cookbooks/audit_test" desc "Update omnibus overrides, including versions in version_policy.rb and latest version of gems: #{OMNIBUS_RUBYGEMS_AT_LATEST_VERSION.keys}." task :update_omnibus_overrides do |t, rake_args| diff --git a/tasks/version.rb b/tasks/version.rb new file mode 100644 index 0000000000..e1fd538f68 --- /dev/null +++ b/tasks/version.rb @@ -0,0 +1,41 @@ +# +# Copyright:: Copyright 2017 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +task :ci_version_bump do + begin + require "rake" + + Rake::Task["version:bump_patch"].invoke + Rake::Task["version:update"].invoke + + # We want to log errors that occur in the following tasks, but we don't + # want them to stop an otherwise valid version bump from progressing. + begin + Rake::Task["changelog:update"].invoke + rescue Exception => e + puts "There was an error updating the CHANGELOG" + puts e + end + + begin + Rake::Task["update_dockerfile"].invoke + rescue Exception => e + puts "There was an error updating the Dockerfile" + puts e + end + end +end diff --git a/version_policy.rb b/version_policy.rb index 85c29a760b..41206f2dfc 100644 --- a/version_policy.rb +++ b/version_policy.rb @@ -108,7 +108,7 @@ GEMS_ALLOWED_TO_FLOAT = [ # our test phase a lot easier. # INSTALL_WITHOUT_GROUPS = %w{ - changelog + ci development docgen guard |