summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dodge <mikedodge04@gmail.com>2017-03-27 12:06:28 -0700
committerMike Dodge <mikedodge04@gmail.com>2017-03-27 12:09:37 -0700
commitc5af95ac434b1b177239483a2def064bfa989daf (patch)
tree3fbbdb169683f5c012262dfaa2a4d8c61d900d51
parent0b66a3a5cbecec2921d296cc2a45c3993888c3bb (diff)
parentd3d8d0d4bf99f7a8e76bd0cfd583f583ad3de830 (diff)
downloadchef-c5af95ac434b1b177239483a2def064bfa989daf.tar.gz
Merge remote-tracking branch 'chef/master' into ld_restart
Signed-off-by: Mike Dodge <mikedodge04@gmail.com>
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml128
-rw-r--r--CHANGELOG.md87
-rw-r--r--Gemfile17
-rw-r--r--Gemfile.lock217
-rw-r--r--HISTORY.md35
-rw-r--r--MAINTAINERS.md1
-rw-r--r--MAINTAINERS.toml9
-rw-r--r--README.md2
-rw-r--r--RELEASE_NOTES.md209
-rw-r--r--Rakefile20
-rw-r--r--VERSION2
-rw-r--r--acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb2
-rw-r--r--acceptance/Gemfile5
-rw-r--r--acceptance/Gemfile.lock51
-rw-r--r--acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb2
-rw-r--r--acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb17
-rw-r--r--appveyor.yml2
-rw-r--r--chef-config/lib/chef-config/config.rb34
-rw-r--r--chef-config/lib/chef-config/package_task.rb14
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--chef.gemspec2
-rwxr-xr-xci/bundle_install.sh4
-rwxr-xr-xci/version_bump.sh4
-rw-r--r--kitchen-tests/.kitchen.travis.yml1
-rw-r--r--kitchen-tests/.kitchen.yml1
-rw-r--r--kitchen-tests/Berksfile4
-rw-r--r--kitchen-tests/Berksfile.lock76
-rw-r--r--kitchen-tests/Gemfile1
-rw-r--r--kitchen-tests/Gemfile.lock53
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/acl_entry.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/chef_server_root_dir.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/file_system_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/not_found_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb20
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb6
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb5
-rw-r--r--lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb34
-rw-r--r--lib/chef.rb3
-rw-r--r--lib/chef/api_client.rb5
-rw-r--r--lib/chef/application.rb9
-rw-r--r--lib/chef/application/solo.rb1
-rw-r--r--lib/chef/blacklist.rb81
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb15
-rw-r--r--lib/chef/client.rb11
-rw-r--r--lib/chef/constants.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb4
-rw-r--r--lib/chef/cookbook_version.rb5
-rw-r--r--lib/chef/data_bag.rb6
-rw-r--r--lib/chef/data_bag_item.rb6
-rw-r--r--lib/chef/data_collector/resource_report.rb36
-rw-r--r--lib/chef/deprecated.rb62
-rw-r--r--lib/chef/deprecation/mixin/template.rb48
-rw-r--r--lib/chef/deprecation/provider/cookbook_file.rb54
-rw-r--r--lib/chef/deprecation/provider/file.rb198
-rw-r--r--lib/chef/deprecation/provider/remote_directory.rb52
-rw-r--r--lib/chef/deprecation/provider/remote_file.rb85
-rw-r--r--lib/chef/deprecation/provider/template.rb63
-rw-r--r--lib/chef/dsl/declare_resource.rb24
-rw-r--r--lib/chef/dsl/method_missing.rb75
-rw-r--r--lib/chef/dsl/recipe.rb5
-rw-r--r--lib/chef/dsl/resources.rb10
-rw-r--r--lib/chef/environment.rb5
-rw-r--r--lib/chef/exceptions.rb3
-rw-r--r--lib/chef/http/json_output.rb5
-rw-r--r--lib/chef/json_compat.rb94
-rw-r--r--lib/chef/key.rb5
-rw-r--r--lib/chef/knife/bootstrap.rb6
-rw-r--r--lib/chef/knife/bootstrap/templates/chef-full.erb12
-rw-r--r--lib/chef/knife/core/ui.rb3
-rw-r--r--lib/chef/knife/data_bag_create.rb10
-rw-r--r--lib/chef/knife/edit.rb2
-rw-r--r--lib/chef/knife/search.rb7
-rw-r--r--lib/chef/knife/ssh.rb14
-rw-r--r--lib/chef/knife/xargs.rb2
-rw-r--r--lib/chef/mixin/params_validate.rb11
-rw-r--r--lib/chef/node.rb21
-rw-r--r--lib/chef/node/attribute.rb33
-rw-r--r--lib/chef/node/attribute_collections.rb20
-rw-r--r--lib/chef/node/immutable_collections.rb80
-rw-r--r--lib/chef/node/mixin/immutablize_array.rb2
-rw-r--r--lib/chef/node/mixin/immutablize_hash.rb2
-rw-r--r--lib/chef/node_map.rb7
-rw-r--r--lib/chef/org.rb5
-rw-r--r--lib/chef/platform/provider_mapping.rb169
-rw-r--r--lib/chef/policy_builder/expand_node_object.rb29
-rw-r--r--lib/chef/property.rb133
-rw-r--r--lib/chef/provider.rb19
-rw-r--r--lib/chef/provider/apt_repository.rb14
-rw-r--r--lib/chef/provider/apt_update.rb6
-rw-r--r--lib/chef/provider/breakpoint.rb2
-rw-r--r--lib/chef/provider/cookbook_file.rb6
-rw-r--r--lib/chef/provider/cron.rb4
-rw-r--r--lib/chef/provider/deploy.rb6
-rw-r--r--lib/chef/provider/directory.rb6
-rw-r--r--lib/chef/provider/dsc_resource.rb6
-rw-r--r--lib/chef/provider/dsc_script.rb6
-rw-r--r--lib/chef/provider/env.rb4
-rw-r--r--lib/chef/provider/env/windows.rb4
-rw-r--r--lib/chef/provider/erl_call.rb4
-rw-r--r--lib/chef/provider/execute.rb10
-rw-r--r--lib/chef/provider/file.rb10
-rw-r--r--lib/chef/provider/git.rb6
-rw-r--r--lib/chef/provider/group.rb6
-rw-r--r--lib/chef/provider/http_request.rb6
-rw-r--r--lib/chef/provider/ifconfig.rb4
-rw-r--r--lib/chef/provider/link.rb6
-rw-r--r--lib/chef/provider/log.rb6
-rw-r--r--lib/chef/provider/mdadm.rb4
-rw-r--r--lib/chef/provider/mount.rb6
-rw-r--r--lib/chef/provider/noop.rb2
-rw-r--r--lib/chef/provider/ohai.rb4
-rw-r--r--lib/chef/provider/osx_profile.rb6
-rw-r--r--lib/chef/provider/package.rb4
-rw-r--r--lib/chef/provider/package/easy_install.rb135
-rw-r--r--lib/chef/provider/package/windows/registry_uninstall_entry.rb12
-rw-r--r--lib/chef/provider/reboot.rb4
-rw-r--r--lib/chef/provider/registry_key.rb4
-rw-r--r--lib/chef/provider/remote_directory.rb12
-rw-r--r--lib/chef/provider/remote_file.rb6
-rw-r--r--lib/chef/provider/route.rb4
-rw-r--r--lib/chef/provider/ruby_block.rb6
-rw-r--r--lib/chef/provider/service.rb6
-rw-r--r--lib/chef/provider/service/aix.rb6
-rw-r--r--lib/chef/provider/service/simple.rb4
-rw-r--r--lib/chef/provider/service/solaris.rb6
-rw-r--r--lib/chef/provider/service/windows.rb6
-rw-r--r--lib/chef/provider/subversion.rb6
-rw-r--r--lib/chef/provider/template.rb6
-rw-r--r--lib/chef/provider/user.rb16
-rw-r--r--lib/chef/provider/user/dscl.rb6
-rw-r--r--lib/chef/provider/user/linux.rb10
-rw-r--r--lib/chef/provider/user/pw.rb6
-rw-r--r--lib/chef/provider/user/solaris.rb4
-rw-r--r--lib/chef/provider/user/useradd.rb10
-rw-r--r--lib/chef/provider/yum_repository.rb7
-rw-r--r--lib/chef/provider_resolver.rb7
-rw-r--r--lib/chef/providers.rb1
-rw-r--r--lib/chef/recipe.rb10
-rw-r--r--lib/chef/resource.rb147
-rw-r--r--lib/chef/resource/chef_gem.rb13
-rw-r--r--lib/chef/resource/easy_install_package.rb32
-rw-r--r--lib/chef/resource/execute.rb20
-rw-r--r--lib/chef/resource/file/verification.rb9
-rw-r--r--lib/chef/resource/mount.rb17
-rw-r--r--lib/chef/resource/script.rb42
-rw-r--r--lib/chef/resource/service.rb28
-rw-r--r--lib/chef/resource/user.rb20
-rw-r--r--lib/chef/resource/user/aix_user.rb2
-rw-r--r--lib/chef/resource/user/dscl_user.rb2
-rw-r--r--lib/chef/resource/user/linux_user.rb11
-rw-r--r--lib/chef/resource/user/pw_user.rb2
-rw-r--r--lib/chef/resource/user/solaris_user.rb2
-rw-r--r--lib/chef/resource/user/windows_user.rb2
-rw-r--r--lib/chef/resource_builder.rb64
-rw-r--r--lib/chef/resource_collection.rb10
-rw-r--r--lib/chef/resource_collection/resource_collection_serialization.rb9
-rw-r--r--lib/chef/resource_collection/resource_list.rb6
-rw-r--r--lib/chef/resource_collection/resource_set.rb8
-rw-r--r--lib/chef/resources.rb1
-rw-r--r--lib/chef/rest.rb210
-rw-r--r--lib/chef/role.rb6
-rw-r--r--lib/chef/run_context.rb23
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb14
-rw-r--r--lib/chef/search/query.rb39
-rw-r--r--lib/chef/shell.rb37
-rw-r--r--lib/chef/shell/shell_session.rb16
-rw-r--r--lib/chef/shell_out.rb13
-rw-r--r--lib/chef/tasks/chef_repo.rake200
-rw-r--r--lib/chef/user.rb5
-rw-r--r--lib/chef/user_v1.rb5
-rw-r--r--lib/chef/util/windows/net_user.rb2
-rw-r--r--lib/chef/version.rb2
-rw-r--r--lib/chef/win32/security/sid.rb5
-rw-r--r--omnibus/Gemfile6
-rw-r--r--omnibus/Gemfile.lock61
-rw-r--r--omnibus/config/projects/chef.rb10
-rw-r--r--omnibus/config/software/chef-gem-ohai.rb10
-rw-r--r--omnibus/config/software/chef.rb1
-rw-r--r--omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb39
-rw-r--r--omnibus_overrides.rb2
-rw-r--r--spec/data/lwrp/resources/buck_passer.rb5
-rw-r--r--spec/data/lwrp/resources/buck_passer_2.rb3
-rw-r--r--spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb3
-rw-r--r--spec/data/lwrp/resources/inline_compiler.rb3
-rw-r--r--spec/data/lwrp/resources/monkey_name_printer.rb5
-rw-r--r--spec/data/lwrp/resources/paint_drying_watcher.rb3
-rw-r--r--spec/data/lwrp/resources/thumb_twiddler.rb3
-rw-r--r--spec/data/shef-config.rb21
-rw-r--r--spec/functional/knife/ssh_spec.rb32
-rw-r--r--spec/functional/resource/bash_spec.rb56
-rw-r--r--spec/functional/rest_spec.rb95
-rw-r--r--spec/functional/shell_spec.rb18
-rw-r--r--spec/integration/client/client_spec.rb16
-rw-r--r--spec/integration/knife/deps_spec.rb14
-rw-r--r--spec/integration/knife/upload_spec.rb14
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb118
-rw-r--r--spec/integration/recipes/resource_action_spec.rb6
-rw-r--r--spec/support/platform_helpers.rb7
-rw-r--r--spec/support/shared/unit/execute_resource.rb15
-rw-r--r--spec/support/shared/unit/script_resource.rb10
-rw-r--r--spec/unit/chef_fs/file_system/operation_failed_error_spec.rb2
-rw-r--r--spec/unit/data_collector/resource_report_spec.rb145
-rw-r--r--spec/unit/deprecation_spec.rb14
-rw-r--r--spec/unit/encrypted_data_bag_item_spec.rb12
-rw-r--r--spec/unit/json_compat_spec.rb32
-rw-r--r--spec/unit/knife/bootstrap_spec.rb34
-rw-r--r--spec/unit/knife/core/ui_spec.rb29
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb110
-rw-r--r--spec/unit/lib_backcompat_spec.rb34
-rw-r--r--spec/unit/lwrp_spec.rb56
-rw-r--r--spec/unit/node/attribute_spec.rb98
-rw-r--r--spec/unit/node/immutable_collections_spec.rb105
-rw-r--r--spec/unit/node_map_spec.rb24
-rw-r--r--spec/unit/node_spec.rb173
-rw-r--r--spec/unit/platform_spec.rb269
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb29
-rw-r--r--spec/unit/property/validation_spec.rb120
-rw-r--r--spec/unit/property_spec.rb150
-rw-r--r--spec/unit/provider/apt_repository_spec.rb60
-rw-r--r--spec/unit/provider/execute_spec.rb16
-rw-r--r--spec/unit/provider/package/easy_install_spec.rb114
-rw-r--r--spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb25
-rw-r--r--spec/unit/provider/powershell_script_spec.rb18
-rw-r--r--spec/unit/provider/service/solaris_smf_service_spec.rb38
-rw-r--r--spec/unit/provider/user/linux_spec.rb48
-rw-r--r--spec/unit/provider/user/pw_spec.rb14
-rw-r--r--spec/unit/provider_resolver_spec.rb1
-rw-r--r--spec/unit/provider_spec.rb6
-rw-r--r--spec/unit/recipe_spec.rb169
-rw-r--r--spec/unit/resource/chef_gem_spec.rb78
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb4
-rw-r--r--spec/unit/resource/cron_spec.rb2
-rw-r--r--spec/unit/resource/deploy_spec.rb8
-rw-r--r--spec/unit/resource/directory_spec.rb4
-rw-r--r--spec/unit/resource/easy_install_package_spec.rb39
-rw-r--r--spec/unit/resource/env_spec.rb2
-rw-r--r--spec/unit/resource/execute_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb22
-rw-r--r--spec/unit/resource/file_spec.rb6
-rw-r--r--spec/unit/resource/group_spec.rb4
-rw-r--r--spec/unit/resource/ifconfig_spec.rb2
-rw-r--r--spec/unit/resource/link_spec.rb4
-rw-r--r--spec/unit/resource/mdadm_spec.rb2
-rw-r--r--spec/unit/resource/mount_spec.rb6
-rw-r--r--spec/unit/resource/ohai_spec.rb2
-rw-r--r--spec/unit/resource/package_spec.rb4
-rw-r--r--spec/unit/resource/registry_key_spec.rb4
-rw-r--r--spec/unit/resource/remote_directory_spec.rb4
-rw-r--r--spec/unit/resource/remote_file_spec.rb4
-rw-r--r--spec/unit/resource/route_spec.rb2
-rw-r--r--spec/unit/resource/scm_spec.rb4
-rw-r--r--spec/unit/resource/script_spec.rb2
-rw-r--r--spec/unit/resource/service_spec.rb30
-rw-r--r--spec/unit/resource/systemd_unit_spec.rb2
-rw-r--r--spec/unit/resource/template_spec.rb4
-rw-r--r--spec/unit/resource/user_spec.rb12
-rw-r--r--spec/unit/resource_collection_spec.rb4
-rw-r--r--spec/unit/resource_reporter_spec.rb10
-rw-r--r--spec/unit/resource_spec.rb91
-rw-r--r--spec/unit/rest/auth_credentials_spec.rb292
-rw-r--r--spec/unit/rest_spec.rb753
-rw-r--r--spec/unit/run_list/versioned_recipe_list_spec.rb11
-rw-r--r--spec/unit/runner_spec.rb38
-rw-r--r--spec/unit/search/query_spec.rb43
-rw-r--r--spec/unit/shell/shell_session_spec.rb35
-rw-r--r--spec/unit/shell_out_spec.rb18
-rw-r--r--tasks/dependencies.rb81
-rw-r--r--tasks/version.rb41
-rw-r--r--version_policy.rb6
278 files changed, 2393 insertions, 6074 deletions
diff --git a/.gitignore b/.gitignore
index 03d53ceb10..aaf9fa045e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@ kitchen-tests/nodes/*
# Temporary files present during spec runs
spec/data/test-dir
+spec/data/nodes
/config/
# acceptance binstubs
diff --git a/.travis.yml b/.travis.yml
index 279dcd0929..3afe4670c2 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
@@ -254,25 +253,6 @@ matrix:
# env:
# - FEDORA=latest
# - KITCHEN_YAML=.kitchen.travis.yml
-# can re-enable amazonlinux when we get a build in current that contains the crypto libs added in #5687
-# - rvm: 2.3.3
-# services: docker
-# sudo: required
-# gemfile: kitchen-tests/Gemfile
-# before_install:
-# - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
-# - gem install bundler -v $(grep bundler omnibus_overrides.rb | cut -d'"' -f2)
-# bundler_args: --without changelog 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:
-# - travis_wait bundle exec kitchen test webapp-amazonlinux
-# after_failure:
-# - cat .kitchen/logs/kitchen.log
-# env:
-# - AMAZONLINUX=LATEST
-# - KITCHEN_YAML=.kitchen.travis.yml
- rvm: 2.3.3
services: docker
sudo: required
@@ -280,36 +260,54 @@ 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 awesome-customers-ubuntu-ubuntu-1404
+ - travis_wait bundle exec kitchen test webapp-amazonlinux
after_failure:
- cat .kitchen/logs/kitchen.log
env:
- - AWESOME_CUSTOMERS_UBUNTU=1
+ - AMAZONLINUX=LATEST
- KITCHEN_YAML=.kitchen.travis.yml
- - rvm: 2.3.3
- services: docker
- sudo: required
- gemfile: kitchen-tests/Gemfile
- before_install:
- - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
- - gem install bundler -v $(grep bundler omnibus_overrides.rb | cut -d'"' -f2)
- bundler_args: --without changelog 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 awesome-customers-rhel-centos-7
- after_failure:
- - cat .kitchen/logs/kitchen.log
- env:
- - AWESOME_CUSTOMERS_RHEL=1
- - KITCHEN_YAML=.kitchen.travis.yml
- ### END TEST KITCHEN ONLY ###
+# - rvm: 2.3.3
+# services: docker
+# sudo: required
+# gemfile: kitchen-tests/Gemfile
+# before_install:
+# - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
+# - gem install bundler -v $(grep bundler omnibus_overrides.rb | cut -d'"' -f2)
+# 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 awesome-customers-ubuntu-ubuntu-1404
+# after_failure:
+# - cat .kitchen/logs/kitchen.log
+# env:
+# - AWESOME_CUSTOMERS_UBUNTU=1
+# - KITCHEN_YAML=.kitchen.travis.yml
+# - rvm: 2.3.3
+# services: docker
+# sudo: required
+# gemfile: kitchen-tests/Gemfile
+# before_install:
+# - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
+# - gem install bundler -v $(grep bundler omnibus_overrides.rb | cut -d'"' -f2)
+# 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 awesome-customers-rhel-centos-7
+# after_failure:
+# - cat .kitchen/logs/kitchen.log
+# env:
+# - AWESOME_CUSTOMERS_RHEL=1
+# - KITCHEN_YAML=.kitchen.travis.yml
+# ### END TEST KITCHEN ONLY ###
- rvm: 2.3.3
sudo: required
dist: trusty
@@ -318,7 +316,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..dc6d9735c0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,91 @@
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.66](https://github.com/chef/chef/tree/v13.0.66) (2017-03-27)
+[Full Changelog](https://github.com/chef/chef/compare/v13.0.66...v13.0.66)
+
+**Closed issues:**
+
+- powershell\_out stdout contains '\r\n' at the end of the output [\#5947](https://github.com/chef/chef/issues/5947)
+
+**Merged pull requests:**
+
+- Make ResourceReporter smarter to get resource identity and state [\#5941](https://github.com/chef/chef/pull/5941) ([afiune](https://github.com/afiune))
+
+## [v13.0.66](https://github.com/chef/chef/tree/v13.0.66) (2017-03-27)
+[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.66)
+
+**Closed issues:**
+
+- `group` resource not idempotent on Windows \(12.19.36\) [\#5857](https://github.com/chef/chef/issues/5857)
+- Chef doesn't have access to a file created by itself, under the ownership of SYSTEM? [\#5844](https://github.com/chef/chef/issues/5844)
+- apt\_repository can't identify key fingerprints when gnupg 2.1.x is used [\#5831](https://github.com/chef/chef/issues/5831)
+- FATAL: NoMethodError: undefined method `password' for Chef::Resource::Execute [\#5824](https://github.com/chef/chef/issues/5824)
+- We should update the default data bag encryption version for Chef 13 [\#5819](https://github.com/chef/chef/issues/5819)
+
+**Merged pull requests:**
+
+- Chef-13: Simplify DSL creation [\#5934](https://github.com/chef/chef/pull/5934) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: Remove deprecated Chef::Client attrs [\#5932](https://github.com/chef/chef/pull/5932) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove method\_missing from the DSL [\#5930](https://github.com/chef/chef/pull/5930) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove node\_map back-compat [\#5926](https://github.com/chef/chef/pull/5926) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove deprecated run\_context methods [\#5925](https://github.com/chef/chef/pull/5925) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove Chef::ShellOut [\#5923](https://github.com/chef/chef/pull/5923) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove old platform mapping code [\#5914](https://github.com/chef/chef/pull/5914) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove the old rake tasks [\#5913](https://github.com/chef/chef/pull/5913) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: raise on properties redefining inherited methods [\#5912](https://github.com/chef/chef/pull/5912) ([lamont-granquist](https://github.com/lamont-granquist))
+- fix node\#debug\_value access through arrays [\#5911](https://github.com/chef/chef/pull/5911) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: Nillable properties [\#5907](https://github.com/chef/chef/pull/5907) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: freeze merged node attribute [\#5905](https://github.com/chef/chef/pull/5905) ([lamont-granquist](https://github.com/lamont-granquist))
+- bump ruby to 2.3.3 [\#5902](https://github.com/chef/chef/pull/5902) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: Remove declare\_resource create\_if\_missing API [\#5900](https://github.com/chef/chef/pull/5900) ([lamont-granquist](https://github.com/lamont-granquist))
+- Properly use chef-shell in SoloSession by deprecating old behavior into SoloLegacySession [\#5898](https://github.com/chef/chef/pull/5898) ([afiune](https://github.com/afiune))
+- Chef-13: properly deep dup Node\#to\_hash [\#5896](https://github.com/chef/chef/pull/5896) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: remove method\_missing access to node object. [\#5895](https://github.com/chef/chef/pull/5895) ([lamont-granquist](https://github.com/lamont-granquist))
+- Jeremymv2/cheffs optimizations [\#5890](https://github.com/chef/chef/pull/5890) ([jeremymv2](https://github.com/jeremymv2))
+- 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))
+- Chef-13: Chef::Resource cleanup [\#5882](https://github.com/chef/chef/pull/5882) ([lamont-granquist](https://github.com/lamont-granquist))
+- Fix apt\_repository for latest os version 16.10 [\#5874](https://github.com/chef/chef/pull/5874) ([afiune](https://github.com/afiune))
+- Chef-13: 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))
+- Chef-13: remove supports API from Chef::Resource [\#5863](https://github.com/chef/chef/pull/5863) ([lamont-granquist](https://github.com/lamont-granquist))
+- HTTP: add debug long for non-JSON response [\#5858](https://github.com/chef/chef/pull/5858) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13 remove resource cloning and 3694 warnings [\#5856](https://github.com/chef/chef/pull/5856) ([lamont-granquist](https://github.com/lamont-granquist))
+- Chef-13: support why-run by default [\#5853](https://github.com/chef/chef/pull/5853) ([lamont-granquist](https://github.com/lamont-granquist))
+- bump major to chef-13 [\#5833](https://github.com/chef/chef/pull/5833) ([lamont-granquist](https://github.com/lamont-granquist))
+
+## [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 +1416,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
diff --git a/Gemfile b/Gemfile
index b3fa6b01a3..416927bf3a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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"
@@ -19,7 +22,8 @@ gem "cheffish" # required for rspec tests
group(:omnibus_package) do
gem "appbundler"
gem "rb-readline"
- gem "nokogiri"
+ # CVE-2016-4658 https://github.com/sparklemotion/nokogiri/issues/1615
+ gem "nokogiri", ">= 1.7.1"
end
group(:omnibus_package, :pry) do
@@ -31,12 +35,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 +53,7 @@ group(:docgen) do
gem "yard"
end
-group(:maintenance) do
+group(:maintenance, :ci) do
gem "tomlrb"
# To sync maintainers with github
@@ -77,7 +80,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..293dd61eb6 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.67)
addressable
bundler (>= 1.10)
- chef-config (= 12.19.39)
+ chef-config (= 13.0.67)
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.67-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 12.19.39)
+ chef-config (= 13.0.67)
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.67)
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)
@@ -324,58 +377,16 @@ GEM
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
netrc (0.11.0)
- nokogiri (1.7.0.1)
+ nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
- nokogiri (1.7.0.1-x86-mingw32)
+ nokogiri (1.7.1-x86-mingw32)
mini_portile2 (~> 2.1.0)
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
+ nokogiri (>= 1.7.1)
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/MAINTAINERS.md b/MAINTAINERS.md
index e9cfec0f94..c87879ac16 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -143,6 +143,7 @@ To mention the team, use @chef/client-os-x
### Maintainers
* [Tyler Ball](https://github.com/tyler-ball)
+* [mikedodge04](https://github.com/mikedodge04)
## Debian
diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml
index 5eb83988c0..10e7655cd8 100644
--- a/MAINTAINERS.toml
+++ b/MAINTAINERS.toml
@@ -136,7 +136,8 @@ The specific components of Chef related to a given platform - including (but not
lieutenant = "jtimberman"
maintainers = [
- "tyler-ball"
+ "tyler-ball",
+ "mikedodge04"
]
[Org.Components.Subsystems.Debian]
@@ -359,3 +360,9 @@ The specific components of Chef related to a given platform - including (but not
[people.tduffield]
Name = "Tom Duffield"
GitHub = "tduffield"
+
+ [people.mikedodge04]
+ Name = "mikedodge04"
+ GitHub = "mikedodge04"
+ Twitter = "mikedodge04"
+ IRC = "mikedodge04"
diff --git a/README.md b/README.md
index 3152007551..69c3f1d768 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
[![Build Status Master](https://travis-ci.org/chef/chef.svg?branch=master)](https://travis-ci.org/chef/chef)
[![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/chef?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/chef/branch/master)
[![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
+[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef-rfc/blob/master/rfc086-chef-oss-project-policies.md#cadence-release)
Want to try Chef? Get started with [learnchef](https://learn.chef.io)
@@ -307,4 +308,3 @@ 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.
```
-
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 7d990d9fe7..5118ce9031 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,150 +1,139 @@
_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 following properties are new or updated for the `execute`, `script`, `batch`, and `powershell_script` resources and any resources derived from them:
-
-- `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.
-
-- `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.
-
-- `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.
-
-#### Usage
-
-The following examples explain how alternate user identity properties can be used in the execute resources:
-
-```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
-
-execute 'mkdir test_dir' do
- cwd Chef::Config[:file_cache_path]
- domain "domain-name"
- user "user"
- password "password"
-end
-
-script 'create test_dir' do
- interpreter "bash"
- code "mkdir test_dir"
- cwd Chef::Config[:file_cache_path]
- user "domain-name\\username"
- password "password"
-end
-
-batch 'create test_dir' do
- code "mkdir test_dir"
- cwd Chef::Config[:file_cache_path]
- user "username@domain-name"
- password "password"
-end
-```
+The `compile_time true` flag may still be used to force compile time.
+
+### The Chef::Config[:chef_gem_compile_time] config option has been removed
+
+In order to for community cookbooks to behave consistently across all users this optional flag has been removed.
+
+### The `supports[:manage_home]` and `supports[:non_unique]` API has been removed from all user providers
+
+The remediation is to set the manage_home and non_unique properties directly.
+
+### Using relative paths in the `creates` property of an execute resource with specifying a `cwd` is now a hard error
+
+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.
+
+### Chef::PolicyBuilder::ExpandNodeObject#load_node has been removed
+
+This change is most likely to only affect internals of tooling like chefspec if it affects anything at all.
-## Highlighted bug fixes for this release:
+### PolicyFile failback to create non-policyfile nodes on Chef Server < 12.3 has been removed
-- 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`
+PolicyFile users on Chef-13 should be using Chef Server 12.3 or higher.
-## Deprecation Notice
+### Cookbooks with self dependencies are no longer allowed
-- As of version 12.19, chef client will no longer be build or tested on the Cisco NX-OS and IOS XR platforms.
+The remediation is removing the self-dependency `depends` line in the metadata.
-# Ohai Release Notes 8.23:
+### Removed `supports` API from Chef::Resource
-## Cumulus Linux Platform
+Retained only for the service resource (where it makes some sense) and for the mount resource.
-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.
+### Removed retrying of non-StandardError exceptions for Chef::Resource
-## Virtualization Detection
+Exceptions not decending from StandardError (e.g. LoadError, SecurityError, SystemExit) will no longer trigger a retry if they are raised during the executiong of a resources with a non-zero retries setting.
+
+### Removed deprecated `method_missing` access from the Chef::Node object
+
+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.
+
+### Changed `declare_resource` API
+
+Dropped the `create_if_missing` parameter that was immediately supplanted by the `edit_resource` API (most likely nobody ever used
+this) and converted the `created_at` parameter from an optional positional parameter to a named parameter. These changes are unlikely
+to affect any cookbook code.
+
+### Node deep-duping fixes
+
+The `node.to_hash`/`node.to_h` and `node.dup` APIs have been fixed so that they correctly deep-dup the node data structure including every
+string value. This results in a mutable copy of the immutable merged node structure. This is correct behavior, but is now more expensive
+and may break some poor code (which would have been buggy and difficult to follow code with odd side effects before).
+
+For example:
+
+```
+node.default["foo"] = "fizz"
+n = node.to_hash # or node.dup
+n["foo"] << "buzz"
+```
-Windows / Linux / BSD guests running on the Veertu hypervisors will now be detected
+before this would have mutated the original string in-place so that `node["foo"]` and `node.default["foo"]` would have changed to "fizzbuzz"
+while now they remain "fizz" and only the mutable `n["foo"]` copy is changed to "fizzbuzz".
-Windows guests running on Xen and Hyper-V hypervisors will now be detected
+### Freezing immutable merged attributes
-## New Sysconf Plugin
+Since Chef 11 merged node attributes have been intended to be immutable but the merged strings have not been frozen. In Chef 13, in the
+process of merging the node attributes strings and other simple objects are dup'd and frozen. In order to get a mutable copy, you can
+now correctly use the `node.dup` or `node.to_hash` methods, or you should mutate the object correctly through its precedence level like
+`node.default["some_string"] << "appending_this"`.
-A new plugin parses the output of the sysconf command to provide information on the underlying system.
+### The Chef::REST API has been removed
-## AWS Account ID
+It has been fully replaced with `Chef::ServerAPI` in chef-client code.
-The EC2 plugin now fetches the AWS Account ID in addition to previous instance metadata
+### Properties overriding methods now raise an error
-## GCC Detection
+Defining a property that overrides methods defined on the base ruby `Object` or on `Chef::Resource` itself can cause large amounts of
+confusion. A simple example is `property :hash` which overrides the Object#hash method which will confuse ruby when the Custom Resource
+is placed into the Chef::ResourceCollection which uses a Hash internally which expects to call Object#hash to get a unique id for the
+object. Attempting to create `property :action` would also override the Chef::Resource#action method which is unlikely to end well for
+the user. Overriding inherited properties is still supported.
-GCC detection has been improved to collect additional information, and to not prompt for the installation of Xcode on macOS systems
+### `chef-shell` now supports solo and legacy solo modes
-## New deprecations introduced in this release:
+Running `chef-shell -s` or `chef-shell --solo` will give you an experience consistent with `chef-solo`. `chef-shell --solo-legacy-mode`
+will give you an experience consistent with `chef-solo --legacy-mode`.
-### Ohai::Config removed
+### Chef::Platform.set and related methods have been removed
-- **Deprecation ID**: OHAI-1
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_legacy_config.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+The deprecated code has been removed. All providers and resources should now be using Chef >= 12.0 `provides` syntax.
-### sigar gem based plugins removed
+### Remove `sort` option for the Search API
-- **Deprecation ID**: OHAI-2
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_sigar_plugins.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+This option has been unimplemented on the server side for years, so any use of it has been pointless.
-### run_command and popen4 helper methods removed
+### Remove Chef::ShellOut
-- **Deprecation ID**: OHAI-3
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_run_command_helpers.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+This was deprecated and replaced a long time ago with mixlib-shellout and the shell_out mixin.
-### libvirt plugin attributes moved
+### Remove `method_missing` from the Recipe DSL
-- **Deprecation ID**: OHAI-4
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_libvirt_plugin.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+The core of chef hasn't used this to implement the Recipe DSL since 12.5.1 and its unlikely that any external code depended upon it.
-### Windows CPU plugin attribute changes
+### Simplify Recipe DSL wiring
-- **Deprecation ID**: OHAI-5
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_windows_cpu.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+Support for actions with spaces and hyphens in the action name has been dropped. Resources and property names with spaces and hyphens
+most likely never worked in Chef-12. UTF-8 characters have always been supported and still are.
-### DigitalOcean plugin attribute changes
+### `easy_install` resource has been removed
-- **Deprecation ID**: OHAI-6
-- **Remediation Docs**: <https://docs.chef.io/deprecations_ohai_digitalocean.html>
-- **Expected Removal**: Ohai 13 (April 2017)
+The Python `easy_install` package installer has been deprecated for many years,
+so we have removed support for it. No specific replacement for `pip` is being
+included with Chef at this time, but a `pip`-based `python_package` resource is
+available in the [`poise-python`](https://github.com/poise/poise-python) cookbooks.
diff --git a/Rakefile b/Rakefile
index 311639230b..34d62788ea 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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
diff --git a/VERSION b/VERSION
index 2c35ae5b76..91097adae2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-12.19.39 \ No newline at end of file
+13.0.67 \ No newline at end of file
diff --git a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
index d5d2e1380b..cf0b4eda5d 100644
--- a/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
+++ b/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb
@@ -32,7 +32,7 @@ module KitchenAcceptance
property :artifactory_username, String, default: lazy { ENV["ARTIFACTORY_USERNAME"] ? ENV["ARTIFACTORY_USERNAME"] : "" }
property :artifactory_password, String, default: lazy { ENV["ARTIFACTORY_PASSWORD"] ? ENV["ARTIFACTORY_PASSWORD"] : "" }
property :env, Hash, default: {}
- property :kitchen_options, String, default: lazy { ENV["PROJECT_NAME"] ? "-c -l debug" : "-c" }
+ property :kitchen_options, String, default: "-c"
action :run do
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/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb b/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb
index dd0e0e4e34..7bdb4e4ed3 100644
--- a/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb
+++ b/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
gem_path = "/opt/chef/embedded/bin/gem"
-white_list = %w{chef-config json rake}
+white_list = %w{addressable chef-config json rake}
describe "gem list" do
it "should not have non-whitelisted duplicate gems" do
diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb
index 73f5151bca..5716b97737 100644
--- a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb
+++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb
@@ -12,15 +12,16 @@ class TopCookbooks < Chef::Resource
cookbook_kitchen "#{command} git" do
end
- cookbook_kitchen "#{command} learn-the-basics-ubuntu" do
- repository "learn-chef/learn-chef-acceptance"
- cookbook_relative_dir "cookbooks/learn-the-basics-ubuntu"
- end
+ # FIXME: waiting for https://github.com/learn-chef/learn-chef-acceptance/pull/23
+ # cookbook_kitchen "#{command} learn-the-basics-ubuntu" do
+ # repository "learn-chef/learn-chef-acceptance"
+ # cookbook_relative_dir "cookbooks/learn-the-basics-ubuntu"
+ # end
- cookbook_kitchen "#{command} learn-the-basics-windows" do
- repository "learn-chef/learn-chef-acceptance"
- cookbook_relative_dir "cookbooks/learn-the-basics-windows"
- end
+ # cookbook_kitchen "#{command} learn-the-basics-windows" do
+ # repository "learn-chef/learn-chef-acceptance"
+ # cookbook_relative_dir "cookbooks/learn-the-basics-windows"
+ # end
cookbook_kitchen "#{command} powershell" do
end
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..657a9a1226 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.67"
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 b/kitchen-tests/Berksfile
index 5319e45a19..09e4cea33a 100644
--- a/kitchen-tests/Berksfile
+++ b/kitchen-tests/Berksfile
@@ -8,6 +8,6 @@ cookbook "php", "~> 1.5.0"
cookbook "resolver", github: "chef-cookbooks/resolver"
cookbook "awesome_customers_ubuntu_wrapper", path: "cookbooks/awesome_customers_ubuntu_wrapper"
-cookbook "awesome_customers_ubuntu", github: "learn-chef/awesome_customers_ubuntu"
+cookbook "awesome_customers_ubuntu", github: "lamont-granquist/awesome_customers_ubuntu", branch: "lcg/bump-mysql-version"
cookbook "awesome_customers_rhel_wrapper", path: "cookbooks/awesome_customers_rhel_wrapper"
-cookbook "awesome_customers_rhel", github: "learn-chef/awesome_customers_rhel"
+cookbook "awesome_customers_rhel", github: "lamont-granquist/awesome_customers_rhel", branch: "lcg/bump-mysql-version"
diff --git a/kitchen-tests/Berksfile.lock b/kitchen-tests/Berksfile.lock
index 6d8f40436a..51217e0602 100644
--- a/kitchen-tests/Berksfile.lock
+++ b/kitchen-tests/Berksfile.lock
@@ -1,12 +1,14 @@
DEPENDENCIES
awesome_customers_rhel
- git: https://github.com/learn-chef/awesome_customers_rhel.git
- revision: b576fcf2988e2cdf156e7ba6ff59a94d556e16f1
+ git: https://github.com/lamont-granquist/awesome_customers_rhel.git
+ revision: ed730957b1b75c8701c708e2deb0740ca8325322
+ branch: lcg/bump-mysql-version
awesome_customers_rhel_wrapper
path: cookbooks/awesome_customers_rhel_wrapper
awesome_customers_ubuntu
- git: https://github.com/learn-chef/awesome_customers_ubuntu.git
- revision: fea174c5855266f28218f76f00f6eff69e850244
+ git: https://github.com/lamont-granquist/awesome_customers_ubuntu.git
+ revision: 9d40958413d0ed1ef1e68c74d41895158c724964
+ branch: lcg/bump-mysql-version
awesome_customers_ubuntu_wrapper
path: cookbooks/awesome_customers_ubuntu_wrapper
base
@@ -14,7 +16,7 @@ DEPENDENCIES
php (~> 1.5.0)
resolver
git: https://github.com/chef-cookbooks/resolver.git
- revision: 8bf9034dabc47d29a07870e4059c32114f2c820a
+ revision: f82d7595a3536a757e7a9ed799ec06643c69ce25
GRAPH
apt (4.0.2)
@@ -23,7 +25,7 @@ GRAPH
database (~> 6.0)
firewall (~> 2.5)
httpd (~> 0.4)
- mysql (~> 7.0)
+ mysql (~> 8.0)
mysql2_chef_gem (~> 1.1)
selinux (~> 0.9)
awesome_customers_rhel_wrapper (0.1.0)
@@ -33,7 +35,7 @@ GRAPH
database (~> 6.0)
firewall (~> 2.5)
httpd (~> 0.4)
- mysql (~> 7.0)
+ mysql (~> 8.0)
mysql2_chef_gem (~> 1.1)
awesome_customers_ubuntu_wrapper (0.1.0)
awesome_customers_ubuntu (>= 0.0.0)
@@ -52,55 +54,51 @@ 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.1.0)
+ compat_resource (>= 0.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.8)
windows (>= 1.34.6)
- iptables (3.1.0)
- compat_resource (>= 12.14.3)
+ inifile_chef_gem (0.1.0)
+ build-essential (>= 0.0.0)
+ iptables (4.0.0)
logrotate (2.1.0)
compat_resource (>= 0.0.0)
- mariadb (1.0.1)
+ mariadb (1.2.0)
apt (>= 0.0.0)
yum (>= 0.0.0)
yum-epel (>= 0.0.0)
- mingw (1.2.5)
- compat_resource (>= 12.16.3)
+ yum-scl (>= 0.0.0)
+ mingw (2.0.0)
seven_zip (>= 0.0.0)
multipackage (4.0.0)
compat_resource (>= 0.0.0)
- mysql (7.2.0)
- smf (>= 0.0.0)
- yum-mysql-community (>= 0.0.0)
+ mysql (8.2.0)
mysql2_chef_gem (1.1.0)
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,27 +106,25 @@ 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)
+ windows (3.0.0)
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)
- compat_resource (>= 12.16.3)
+ yum-scl (0.2.0)
+ inifile_chef_gem (>= 0.0.0)
+ yum (>= 0.0.0)
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.rb b/lib/chef.rb
index 3e161dc365..3d6b783253 100644
--- a/lib/chef.rb
+++ b/lib/chef.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");
@@ -24,7 +24,6 @@ require "chef/log"
require "chef/config"
require "chef/providers"
require "chef/resources"
-require "chef/shell_out"
require "chef/daemon"
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb
index 6999a4f52d..087de3fdf9 100644
--- a/lib/chef/api_client.rb
+++ b/lib/chef/api_client.rb
@@ -140,11 +140,6 @@ class Chef
client
end
- def self.json_create(data)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::ApiClient#from_hash")
- from_hash(data)
- end
-
def self.from_json(j)
from_hash(Chef::JSONCompat.parse(j))
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/application/solo.rb b/lib/chef/application/solo.rb
index 1481338a9c..2705a930ae 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -23,7 +23,6 @@ require "chef/client"
require "chef/config"
require "chef/daemon"
require "chef/log"
-require "chef/rest"
require "chef/config_fetcher"
require "fileutils"
require "chef/mixin/shell_out"
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/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
index 8f9e554526..c16c5ad4d7 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
@@ -30,6 +30,7 @@ class Chef
def initialize(name, parent, exists = nil)
super(name, parent)
@exists = exists
+ @this_object_cache = nil
end
def data_handler
@@ -69,7 +70,7 @@ class Chef
def exists?
if @exists.nil?
begin
- rest.get(api_path)
+ @this_object_cache = rest.get(api_path)
@exists = true
rescue Net::HTTPServerException => e
if e.response.code == "404"
@@ -85,6 +86,8 @@ class Chef
end
def delete(recurse)
+ # free up cache - it will be hydrated on next check for exists?
+ @this_object_cache = nil
rest.delete(api_path)
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e, "Timeout deleting: #{e}")
@@ -97,12 +100,12 @@ class Chef
end
def read
+ # Minimize the value (get rid of defaults) so the results don't look terrible
Chef::JSONCompat.to_json_pretty(minimize_value(_read_json))
end
def _read_json
- # Minimize the value (get rid of defaults) so the results don't look terrible
- root.get_json(api_path)
+ @this_object_cache ? JSON.parse(@this_object_cache) : root.get_json(api_path)
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading: #{e}")
rescue Net::HTTPServerException => e
@@ -151,6 +154,9 @@ class Chef
other_value = minimize_value(other_value)
other_value_json = Chef::JSONCompat.to_json_pretty(other_value)
+ # free up cache - it will be hydrated on next check for exists?
+ @this_object_cache = nil
+
[ value == other_value, value_json, other_value_json ]
end
@@ -159,6 +165,9 @@ class Chef
end
def write(file_contents)
+ # free up cache - it will be hydrated on next check for exists?
+ @this_object_cache = nil
+
begin
object = Chef::JSONCompat.parse(file_contents)
rescue Chef::Exceptions::JSON::ParseError => e
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index c064d33209..b219fdfdd6 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -3,7 +3,7 @@
# Author:: Christopher Walters (<cw@chef.io>)
# Author:: Christopher Brown (<cb@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");
@@ -894,15 +894,6 @@ class Chef
#
STDERR_FD = STDERR
- #
- # Deprecated writers
- #
-
- include Chef::Mixin::Deprecation
- deprecated_attr_writer :ohai, "There is no alternative. Leave ohai alone!"
- deprecated_attr_writer :rest, "There is no alternative. Leave rest alone!"
- deprecated_attr :runner, "There is no alternative. Leave runner alone!"
-
private
attr_reader :override_runlist
diff --git a/lib/chef/constants.rb b/lib/chef/constants.rb
index f32c3e6654..d75b632173 100644
--- a/lib/chef/constants.rb
+++ b/lib/chef/constants.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser <jkeiser@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");
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/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 2037b5f972..7353941bb1 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -484,11 +484,6 @@ class Chef
cookbook_version
end
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::CookbookVersion#from_hash")
- from_hash(o)
- end
-
def self.from_cb_artifact_data(o)
from_hash(o)
end
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index 4bb656a2c8..15531d7304 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -78,12 +78,6 @@ class Chef
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
end
- # Create a Chef::Role from JSON
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::DataBag#from_hash")
- from_hash(o)
- end
-
def self.from_hash(o)
bag = new
bag.name(o["name"])
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 2bd27e3eef..ddb520dc0b 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -139,12 +139,6 @@ class Chef
item
end
- # Create a Chef::DataBagItem from JSON
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::DataBagItem#from_hash")
- from_hash(o)
- end
-
# Load a Data Bag Item by name via either the RESTful API or local data_bag_path if run in solo mode
def self.load(data_bag, name)
if Chef::Config[:solo_legacy_mode]
diff --git a/lib/chef/data_collector/resource_report.rb b/lib/chef/data_collector/resource_report.rb
index dcaf9c8e44..01651d5460 100644
--- a/lib/chef/data_collector/resource_report.rb
+++ b/lib/chef/data_collector/resource_report.rb
@@ -18,6 +18,8 @@
# limitations under the License.
#
+require "chef/exceptions"
+
class Chef
class DataCollector
class ResourceReport
@@ -67,9 +69,9 @@ class Chef
hash = {
"type" => new_resource.resource_name.to_sym,
"name" => new_resource.name.to_s,
- "id" => new_resource.identity.to_s,
- "after" => new_resource.state_for_resource_reporter,
- "before" => current_resource ? current_resource.state_for_resource_reporter : {},
+ "id" => resource_identity,
+ "after" => new_resource_state_reporter,
+ "before" => current_resource_state_reporter,
"duration" => elapsed_time_in_milliseconds.to_s,
"delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "",
"ignore_failure" => new_resource.ignore_failure,
@@ -83,13 +85,39 @@ class Chef
hash["recipe_name"] = new_resource.recipe_name
end
- hash["conditional"] = conditional.to_text if status == "skipped"
+ hash["conditional"] = conditional.to_text if status == "skipped"
hash["error_message"] = exception.message unless exception.nil?
hash
end
alias :to_h :to_hash
alias :for_json :to_hash
+
+ # We should be able to call the identity of a resource safely, but there
+ # is an edge case where resources that have a lazy property that is both
+ # the name_property and the identity property, it will thow a validation
+ # exception causing the chef-client run to fail. We are not fixing this
+ # case since Chef is actually doing the right thing but we are making the
+ # ResourceReporter smarter so that it detects the failure and sends a
+ # message to the data collector containing a static resource identity
+ # since we were unable to generate a proper one.
+ def resource_identity
+ new_resource.identity.to_s
+ rescue => e
+ "unknown identity (due to #{e.class})"
+ end
+
+ def new_resource_state_reporter
+ new_resource.state_for_resource_reporter
+ rescue
+ {}
+ end
+
+ def current_resource_state_reporter
+ current_resource ? current_resource.state_for_resource_reporter : {}
+ rescue
+ {}
+ end
end
end
end
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/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index e48d741c60..ac3776c92f 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters
-# 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");
@@ -117,7 +117,7 @@ class Chef
# cookbook_name: cookbook_name
# end
#
- def edit_resource!(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
+ def edit_resource!(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
resource = find_resource!(type, name, run_context: run_context)
if resource_attrs_block
if defined?(new_resource)
@@ -152,10 +152,10 @@ class Chef
# end
# resource.variables.merge!({ home: "/home/klowns" })
#
- def edit_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
- edit_resource!(type, name, created_at, run_context: run_context, &resource_attrs_block)
+ def edit_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
+ edit_resource!(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
rescue Chef::Exceptions::ResourceNotFound
- declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
+ declare_resource(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
end
# Lookup a resource in the resource collection by name. If the resource is not
@@ -207,7 +207,7 @@ class Chef
find_resource!(type, name, run_context: run_context)
rescue Chef::Exceptions::ResourceNotFound
if resource_attrs_block
- declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
+ declare_resource(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block)
end # returns nil otherwise
end
@@ -236,16 +236,10 @@ class Chef
# action :delete
# end
#
- def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
+ def declare_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
created_at ||= caller[0]
- if create_if_missing
- Chef::Log.deprecation "build_resource with a create_if_missing flag is deprecated, use edit_resource instead"
- # midly goofy since we call edit_resource only to re-call ourselves, but that's why its deprecated...
- return edit_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
- end
-
- resource = build_resource(type, name, created_at, &resource_attrs_block)
+ resource = build_resource(type, name, created_at: created_at, &resource_attrs_block)
run_context.resource_collection.insert(resource, resource_type: type, instance_name: name)
resource
@@ -272,7 +266,7 @@ class Chef
# action :delete
# end
#
- def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
+ def build_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
created_at ||= caller[0]
# this needs to be lazy in order to avoid circular dependencies since ResourceBuilder
diff --git a/lib/chef/dsl/method_missing.rb b/lib/chef/dsl/method_missing.rb
deleted file mode 100644
index 2917a54ee8..0000000000
--- a/lib/chef/dsl/method_missing.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-#--
-# 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.
-#
-
-class Chef
- module DSL
- # @deprecated scheduled to die in a Chef 13 fire
- module MethodMissing
- def describe_self_for_error
- if respond_to?(:name)
- %Q{`#{self.class} "#{name}"'}
- elsif respond_to?(:recipe_name)
- %Q{`#{self.class} "#{recipe_name}"'}
- else
- to_s
- end
- end
-
- # DEPRECATED:
- # method_missing must live for backcompat purposes until Chef 13.
- def method_missing(method_symbol, *args, &block)
- #
- # If there is already DSL for this, someone must have called
- # method_missing manually. Not a fan. Not. A. Fan.
- #
- if respond_to?(method_symbol)
- Chef.deprecated(:internal_api, "Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13. Use public_send() or send() instead.")
- return send(method_symbol, *args, &block)
- end
-
- #
- # If a definition exists, then Chef::DSL::Definitions.add_definition was
- # never called. DEPRECATED.
- #
- if run_context.definitions.has_key?(method_symbol.to_sym)
- Chef.deprecated(:internal_api, "Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.")
- Chef::DSL::Definitions.add_definition(method_symbol)
- return send(method_symbol, *args, &block)
- end
-
- #
- # See if the resource exists anyway. If the user had set
- # Chef::Resource::Blah = <resource>, a deprecation warning will be
- # emitted and the DSL method 'blah' will be added to the DSL.
- #
- resource_class = Chef::ResourceResolver.resolve(method_symbol, node: run_context ? run_context.node : nil)
- if resource_class
- Chef::DSL::Resources.add_resource_dsl(method_symbol)
- return send(method_symbol, *args, &block)
- end
-
- begin
- super
- rescue NoMethodError
- raise NoMethodError, "No resource or method named `#{method_symbol}' for #{describe_self_for_error}"
- rescue NameError
- raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_for_error}"
- end
- end
- end
- end
-end
diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb
index e2bd070179..dedf291857 100644
--- a/lib/chef/dsl/recipe.rb
+++ b/lib/chef/dsl/recipe.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@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,7 +27,6 @@ require "chef/dsl/reboot_pending"
require "chef/dsl/audit"
require "chef/dsl/powershell"
require "chef/dsl/core"
-require "chef/dsl/method_missing"
require "chef/mixin/lazy_module_include"
class Chef
@@ -60,8 +59,6 @@ class Chef
include Chef::DSL::Powershell
include Chef::DSL::Resources
include Chef::DSL::Definitions
- # method_missing will disappear in Chef 13
- include Chef::DSL::MethodMissing
extend Chef::Mixin::LazyModuleInclude
def resource_class_for(snake_case_name)
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb
index 1401e3ed53..36ec018500 100644
--- a/lib/chef/dsl/resources.rb
+++ b/lib/chef/dsl/resources.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser <jkeiser@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");
@@ -36,15 +36,9 @@ class Chef
module_eval(<<-EOM, __FILE__, __LINE__ + 1)
def #{dsl_name}(*args, &block)
Chef.deprecated(:internal_api, "Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
- declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
+ declare_resource(#{dsl_name.inspect}, args[0], created_at: caller[0], &block)
end
EOM
- rescue SyntaxError
- # Handle the case where dsl_name has spaces, etc.
- define_method(dsl_name.to_sym) do |*args, &block|
- Chef.deprecated(:internal_api, "Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
- declare_resource(dsl_name, args[0], caller[0], &block)
- end
end
def self.remove_resource_dsl(dsl_name)
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index 545a2e51eb..621a122440 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -216,11 +216,6 @@ class Chef
end
end
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Environment#from_hash")
- from_hash(o)
- end
-
def self.from_hash(o)
environment = new
environment.name(o["name"])
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/json_compat.rb b/lib/chef/json_compat.rb
index c8f5496345..b819d5e57d 100644
--- a/lib/chef/json_compat.rb
+++ b/lib/chef/json_compat.rb
@@ -26,23 +26,6 @@ class Chef
class JSONCompat
JSON_MAX_NESTING = 1000
- JSON_CLASS = "json_class".freeze
-
- CHEF_APICLIENT = "Chef::ApiClient".freeze
- CHEF_CHECKSUM = "Chef::Checksum".freeze
- CHEF_COOKBOOKVERSION = "Chef::CookbookVersion".freeze
- CHEF_DATABAG = "Chef::DataBag".freeze
- CHEF_DATABAGITEM = "Chef::DataBagItem".freeze
- CHEF_ENVIRONMENT = "Chef::Environment".freeze
- CHEF_NODE = "Chef::Node".freeze
- CHEF_ROLE = "Chef::Role".freeze
- CHEF_SANDBOX = "Chef::Sandbox".freeze
- CHEF_RESOURCE = "Chef::Resource".freeze
- CHEF_RESOURCECOLLECTION = "Chef::ResourceCollection".freeze
- CHEF_RESOURCESET = "Chef::ResourceCollection::ResourceSet".freeze
- CHEF_RESOURCELIST = "Chef::ResourceCollection::ResourceList".freeze
- CHEF_RUNLISTEXPANSION = "Chef::RunListExpansion".freeze
-
class <<self
# API to use to avoid create_addtions
@@ -63,40 +46,7 @@ class Chef
raise Chef::Exceptions::JSON::ParseError, "Top level JSON object must be a Hash or Array. (actual: #{obj.class})"
end
- # The old default in the json gem (which we are mimicing because we
- # sadly rely on this misfeature) is to "create additions" i.e., convert
- # JSON objects into ruby objects. Explicit :create_additions => false
- # is required to turn it off.
- if opts[:create_additions].nil? || opts[:create_additions]
- map_to_rb_obj(obj)
- else
- obj
- end
- end
-
- # Look at an object that's a basic type (from json parse) and convert it
- # to an instance of Chef classes if desired.
- def map_to_rb_obj(json_obj)
- case json_obj
- when Hash
- mapped_hash = map_hash_to_rb_obj(json_obj)
- if json_obj.has_key?(JSON_CLASS) && (class_to_inflate = class_for_json_class(json_obj[JSON_CLASS]))
- class_to_inflate.json_create(mapped_hash)
- else
- mapped_hash
- end
- when Array
- json_obj.map { |e| map_to_rb_obj(e) }
- else
- json_obj
- end
- end
-
- def map_hash_to_rb_obj(json_hash)
- json_hash.each do |key, value|
- json_hash[key] = map_to_rb_obj(value)
- end
- json_hash
+ obj
end
def to_json(obj, opts = nil)
@@ -113,48 +63,6 @@ class Chef
to_json(obj, options_map).chomp
end
- # Map +json_class+ to a Class object. We use a +case+ instead of a Hash
- # assigned to a constant because otherwise this file could not be loaded
- # until all the constants were defined, which means you'd have to load
- # the world to get json, which would make knife very slow.
- def class_for_json_class(json_class)
- case json_class
- when CHEF_APICLIENT
- Chef::ApiClient
- when CHEF_CHECKSUM
- Chef::Checksum
- when CHEF_COOKBOOKVERSION
- Chef::CookbookVersion
- when CHEF_DATABAG
- Chef::DataBag
- when CHEF_DATABAGITEM
- Chef::DataBagItem
- when CHEF_ENVIRONMENT
- Chef::Environment
- when CHEF_NODE
- Chef::Node
- when CHEF_ROLE
- Chef::Role
- when CHEF_SANDBOX
- # a falsey return here will disable object inflation/"create
- # additions" in the caller. In Chef 11 this is correct, we just have
- # a dummy Chef::Sandbox class for compat with Chef 10 servers.
- false
- when CHEF_RESOURCE
- Chef::Resource
- when CHEF_RESOURCECOLLECTION
- Chef::ResourceCollection
- when CHEF_RESOURCESET
- Chef::ResourceCollection::ResourceSet
- when CHEF_RESOURCELIST
- Chef::ResourceCollection::ResourceList
- when /^Chef::Resource/
- Chef::Resource.find_descendants_by_name(json_class)
- else
- raise Chef::Exceptions::JSON::ParseError, "Unsupported `json_class` type '#{json_class}'"
- end
- end
-
end
end
end
diff --git a/lib/chef/key.rb b/lib/chef/key.rb
index c68fe1039c..bf8e533d62 100644
--- a/lib/chef/key.rb
+++ b/lib/chef/key.rb
@@ -222,11 +222,6 @@ class Chef
Chef::Key.from_hash(Chef::JSONCompat.from_json(json))
end
- def json_create(json)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Key#from_json or one of the load_by methods.")
- Chef::Key.from_json(json)
- end
-
def list_by_user(actor, inflate = false)
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys")
list(keys, actor, :load_by_user, inflate)
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/core/ui.rb b/lib/chef/knife/core/ui.rb
index 1fc6d3d0e2..d809a8fc45 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -180,8 +180,7 @@ class Chef
if parse_output
if object_class.nil?
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please pass in the class to inflate or use #edit_hash")
- Chef::JSONCompat.from_json(output)
+ raise ArgumentError, "Please pass in the object class to hydrate or use #edit_hash"
else
object_class.from_hash(Chef::JSONCompat.parse(output))
end
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/search.rb b/lib/chef/knife/search.rb
index 046d1c7c52..7fc76b28c0 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -37,12 +37,6 @@ class Chef
banner "knife search INDEX QUERY (options)"
- option :sort,
- :short => "-o SORT",
- :long => "--sort SORT",
- :description => "The order to sort the results in",
- :default => nil
-
option :start,
:short => "-b ROW",
:long => "--start ROW",
@@ -92,7 +86,6 @@ class Chef
result_count = 0
search_args = Hash.new
- search_args[:sort] = config[:sort] if config[:sort]
search_args[:start] = config[:start] if config[:start]
search_args[:rows] = config[:rows] if config[:rows]
if config[:filter_result]
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/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index 0db058c3ab..d90e38b916 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.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");
@@ -18,6 +18,7 @@
require "chef/constants"
require "chef/property"
require "chef/delayed_evaluator"
+require "chef/exceptions"
class Chef
module Mixin
@@ -332,7 +333,7 @@ class Chef
def _pv_name_property(opts, key, is_name_property = true)
if is_name_property
if opts[key].nil?
- raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
+ raise Exceptions::CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
opts[key] = instance_variable_get(:"@name")
end
end
@@ -404,7 +405,7 @@ class Chef
passed = to_be.any? do |tb|
case tb
when Proc
- raise CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
+ raise Exceptions::CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
instance_exec(value, &tb)
when Property
begin
@@ -448,10 +449,10 @@ class Chef
#
def _pv_coerce(opts, key, coercer)
if opts.has_key?(key.to_s)
- raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
+ raise Exceptions::CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
opts[key.to_s] = instance_exec(opts[key], &coercer)
elsif opts.has_key?(key.to_sym)
- raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
+ raise Exceptions::CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
opts[key.to_sym] = instance_exec(opts[key], &coercer)
end
end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index 808fb1dc6e..92bdb5887b 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
@@ -507,12 +508,6 @@ class Chef
self
end
- # Create a Chef::Node from JSON
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Node#from_hash")
- from_hash(o)
- end
-
def self.from_hash(o)
return o if o.kind_of? Chef::Node
node = new
@@ -599,11 +594,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 +659,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..57d1b0a4d3 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");
@@ -216,16 +216,12 @@ class Chef
# that precedence level, +value+ will be the symbol +:not_present+.
def debug_value(*args)
COMPONENTS.map do |component|
- ivar = instance_variable_get(component)
- value = args.inject(ivar) do |so_far, key|
- if so_far == :not_present
- :not_present
- elsif so_far.has_key?(key)
- so_far[key]
- else
+ value =
+ begin
+ instance_variable_get(component).read!(*args)
+ rescue
:not_present
end
- end
[component.to_s.sub(/^@/, ""), value]
end
end
@@ -476,25 +472,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..be9285a755 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");
@@ -22,8 +22,14 @@ require "chef/node/mixin/immutablize_hash"
class Chef
class Node
-
module Immutablize
+ # For elements like Fixnums, true, nil...
+ def safe_dup(e)
+ e.dup
+ rescue TypeError
+ e
+ end
+
def immutablize(value)
case value
when Hash
@@ -31,7 +37,7 @@ class Chef
when Array
ImmutableArray.new(value, __root__, __node__, __precedence__)
else
- value
+ safe_dup(value).freeze
end
end
end
@@ -70,21 +76,20 @@ class Chef
end
def to_a
- a = Array.new
- each do |v|
- a <<
- case v
- when ImmutableArray
- v.to_a
- when ImmutableMash
- v.to_hash
- else
- v
- end
- end
- a
+ Array.new(map do |v|
+ case v
+ when ImmutableArray
+ v.to_a
+ when ImmutableMash
+ v.to_h
+ else
+ safe_dup(v)
+ end
+ end)
end
+ alias_method :to_array, :to_a
+
# for consistency's sake -- integers 'converted' to integers
def convert_key(key)
key
@@ -125,26 +130,12 @@ 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
+ #
+ # FIXME? this seems wrong to do and i think is responsible for
+ # #dup needing to be more complicated than Mash.new(self)?
+ #
def convert_value(value)
value
end
@@ -155,25 +146,38 @@ class Chef
# Of course, 'default' has a specific meaning in Chef-land
def dup
- Mash.new(self)
+ h = Mash.new
+ each_pair do |k, v|
+ h[k] = safe_dup(v)
+ end
+ h
end
- def to_hash
+ def to_h
h = Hash.new
each_pair do |k, v|
h[k] =
case v
when ImmutableMash
- v.to_hash
+ v.to_h
when ImmutableArray
v.to_a
else
- v
+ safe_dup(v)
end
end
h
end
+ alias_method :to_hash, :to_h
+
+ # For elements like Fixnums, true, nil...
+ def safe_dup(e)
+ e.dup
+ rescue TypeError
+ e
+ end
+
prepend Chef::Node::Mixin::StateTracking
prepend Chef::Node::Mixin::ImmutablizeHash
end
diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb
index cfa7266b9a..bd330cf8a9 100644
--- a/lib/chef/node/mixin/immutablize_array.rb
+++ b/lib/chef/node/mixin/immutablize_array.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/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb
index f09e6944fc..f6b22ed7d7 100644
--- a/lib/chef/node/mixin/immutablize_hash.rb
+++ b/lib/chef/node/mixin/immutablize_hash.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/node_map.rb b/lib/chef/node_map.rb
index 552c90b8d1..7a1a09ae24 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@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");
@@ -31,10 +31,7 @@ class Chef
#
# @return [NodeMap] Returns self for possible chaining
#
- def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, on_platform: nil, on_platforms: nil, canonical: nil, override: nil, &block)
- Chef.deprecated(:internal_api, "The on_platform option to node_map has been deprecated") if on_platform
- Chef.deprecated(:internal_api, "The on_platforms option to node_map has been deprecated") if on_platforms
- platform ||= on_platform || on_platforms
+ def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, canonical: nil, override: nil, &block)
filters = {}
filters[:platform] = platform if platform
filters[:platform_version] = platform_version if platform_version
diff --git a/lib/chef/org.rb b/lib/chef/org.rb
index bed5600920..73a129c7c1 100644
--- a/lib/chef/org.rb
+++ b/lib/chef/org.rb
@@ -122,11 +122,6 @@ class Chef
Chef::Org.from_hash(Chef::JSONCompat.from_json(json))
end
- def self.json_create(json)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Org#from_json or Chef::Org#load.")
- Chef::Org.from_json(json)
- end
-
def self.load(org_name)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("organizations/#{org_name}")
Chef::Org.from_hash(response)
diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb
index 55e831c343..5dbe0bdab4 100644
--- a/lib/chef/platform/provider_mapping.rb
+++ b/lib/chef/platform/provider_mapping.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");
@@ -26,45 +26,6 @@ class Chef
class Platform
class << self
- attr_writer :platforms
-
- def platforms
- @platforms ||= { default: {} }
- end
-
- include Chef::Mixin::ParamsValidate
-
- def find(name, version)
- Chef.deprecated(:chef_platform_methods, "#{self.name}.find is deprecated")
- provider_map = platforms[:default].clone
-
- name_sym = name
- if name.kind_of?(String)
- name = name.downcase
- name.gsub!(/\s/, "_")
- name_sym = name.to_sym
- end
-
- if platforms.has_key?(name_sym)
- platform_versions = platforms[name_sym].select { |k, v| k != :default }
- if platforms[name_sym].has_key?(:default)
- provider_map.merge!(platforms[name_sym][:default])
- end
- platform_versions.each do |platform_version, provider|
- begin
- version_constraint = Chef::VersionConstraint::Platform.new(platform_version)
- if version_constraint.include?(version)
- Chef::Log.debug("Platform #{name} version #{version} found")
- provider_map.merge!(provider)
- end
- rescue Chef::Exceptions::InvalidPlatformVersion
- Chef::Log.debug("Chef::Version::Comparable does not know how to parse the platform version: #{version}")
- end
- end
- end
- provider_map
- end
-
def find_platform_and_version(node)
platform = nil
version = nil
@@ -89,134 +50,6 @@ class Chef
[platform, version]
end
-
- def provider_for_resource(resource, action = :nothing)
- Chef.deprecated(:chef_platform_methods, "#{name}.provider_for_resource is deprecated")
- node = resource.run_context && resource.run_context.node
- raise ArgumentError, "Cannot find the provider for a resource with no run context set" unless node
- provider = find_provider_for_node(node, resource).new(resource, resource.run_context)
- provider.action = action
- provider
- end
-
- def provider_for_node(node, resource_type)
- raise NotImplementedError, "#{name} no longer supports #provider_for_node"
- end
-
- def find_provider_for_node(node, resource_type)
- Chef.deprecated(:chef_platform_methods, "#{name}.find_provider_for_node is deprecated")
- platform, version = find_platform_and_version(node)
- find_provider(platform, version, resource_type)
- end
-
- def set(args)
- Chef.deprecated(:chef_platform_methods, "#{name}.set is deprecated")
- validate(
- args,
- {
- :platform => {
- :kind_of => Symbol,
- :required => false,
- },
- :version => {
- :kind_of => String,
- :required => false,
- },
- :resource => {
- :kind_of => Symbol,
- },
- :provider => {
- :kind_of => [ String, Symbol, Class ],
- },
- }
- )
- if args.has_key?(:platform)
- if args.has_key?(:version)
- if platforms.has_key?(args[:platform])
- if platforms[args[:platform]].has_key?(args[:version])
- platforms[args[:platform]][args[:version]][args[:resource].to_sym] = args[:provider]
- else
- platforms[args[:platform]][args[:version]] = {
- args[:resource].to_sym => args[:provider],
- }
- end
- else
- platforms[args[:platform]] = {
- args[:version] => {
- args[:resource].to_sym => args[:provider],
- },
- }
- end
- else
- if platforms.has_key?(args[:platform])
- if platforms[args[:platform]].has_key?(:default)
- platforms[args[:platform]][:default][args[:resource].to_sym] = args[:provider]
- elsif args[:platform] == :default
- platforms[:default][args[:resource].to_sym] = args[:provider]
- else
- platforms[args[:platform]] = { :default => { args[:resource].to_sym => args[:provider] } }
- end
- else
- platforms[args[:platform]] = {
- :default => {
- args[:resource].to_sym => args[:provider],
- },
- }
- end
- end
- else
- if platforms.has_key?(:default)
- platforms[:default][args[:resource].to_sym] = args[:provider]
- else
- platforms[:default] = {
- args[:resource].to_sym => args[:provider],
- }
- end
- end
- end
-
- def find_provider(platform, version, resource_type)
- Chef.deprecated(:chef_platform_methods, "#{name}.find_provider is deprecated")
- provider_klass = explicit_provider(platform, version, resource_type) ||
- platform_provider(platform, version, resource_type) ||
- resource_matching_provider(platform, version, resource_type)
-
- raise Chef::Exceptions::ProviderNotFound, "Cannot find a provider for #{resource_type} on #{platform} version #{version}" if provider_klass.nil?
-
- provider_klass
- end
-
- private
-
- def explicit_provider(platform, version, resource_type)
- resource_type.kind_of?(Chef::Resource) ? resource_type.provider : nil
- end
-
- def platform_provider(platform, version, resource_type)
- pmap = Chef::Platform.find(platform, version)
- rtkey = resource_type.kind_of?(Chef::Resource) ? resource_type.resource_name.to_sym : resource_type
- pmap.has_key?(rtkey) ? pmap[rtkey] : nil
- end
-
- include Chef::Mixin::ConvertToClassName
-
- def resource_matching_provider(platform, version, resource_type)
- if resource_type.kind_of?(Chef::Resource)
- class_name = if resource_type.class.name
- resource_type.class.name.split("::").last
- else
- convert_to_class_name(resource_type.resource_name.to_s)
- end
-
- if Chef::Provider.const_defined?(class_name, false)
- Chef::Log.warn("Class Chef::Provider::#{class_name} does not declare 'provides #{convert_to_snake_case(class_name).to_sym.inspect}'.")
- Chef::Log.warn("This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.")
- return Chef::Provider.const_get(class_name, false)
- end
- end
- nil
- end
-
end
end
end
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..c6f72e15a7 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -74,7 +74,7 @@ class Chef
# return `true` if the property is set *or* if `name` is set.
# @option options [Boolean] :nillable `true` opt-in to Chef-13 style behavior where
# attempting to set a nil value will really set a nil value instead of issuing
- # a warning and operating like a getter
+ # a warning and operating like a getter [DEPRECATED]
# @option options [Object] :default The value this property
# will return if the user does not set one. If this is `lazy`, it will
# be run in the context of the instance (and able to access other
@@ -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
@@ -273,32 +264,8 @@ class Chef
#
def call(resource, value = NOT_PASSED)
if value == NOT_PASSED
- return get(resource)
- end
-
- if value.nil? && !nillable?
- # In Chef 12, value(nil) does a *get* instead of a set, so we
- # warn if the value would have been changed. In Chef 13, it will be
- # equivalent to value = nil.
- result = get(resource, nil_set: true)
-
- # Warn about this becoming a set in Chef 13.
- begin
- input_to_stored_value(resource, value)
- # If nil is valid, and it would change the value, warn that this will change to a set.
- if !result.nil?
- Chef.deprecated(:custom_resource, "An attempt was made to change #{name} from #{result.inspect} to nil by calling #{name}(nil). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil.")
- end
- rescue Chef::Exceptions::DeprecatedFeatureError
- raise
- rescue
- # If nil is invalid, warn that this will become an error.
- Chef.deprecated(:custom_resource, "nil is an invalid value for #{self}. In Chef 13, this warning will change to an error. Error: #{$!}")
- end
-
- result
+ get(resource)
else
- # Anything else, such as myprop(value) is a set
set(resource, value)
end
end
@@ -327,10 +294,11 @@ class Chef
#
def get(resource, nil_set: false)
# If it's set, return it (and evaluate any lazy values)
+ value = nil
+
if is_set?(resource)
value = get_value(resource)
value = stored_value_to_output(resource, value)
-
else
# We are getting the default value.
@@ -375,13 +343,14 @@ class Chef
if !value.frozen? && !value.nil?
set_value(resource, value)
end
-
- value
-
- elsif required?
- raise Chef::Exceptions::ValidationFailed, "#{name} is required"
end
end
+
+ if value.nil? && required?
+ raise Chef::Exceptions::ValidationFailed, "#{name} is required"
+ else
+ value
+ end
end
#
@@ -400,7 +369,13 @@ class Chef
# this property.
#
def set(resource, value)
- set_value(resource, input_to_stored_value(resource, value))
+ value = set_value(resource, input_to_stored_value(resource, value))
+
+ if value.nil? && required?
+ raise Chef::Exceptions::ValidationFailed, "#{name} is required"
+ else
+ value
+ end
end
#
@@ -453,8 +428,8 @@ class Chef
#
def coerce(resource, value)
if options.has_key?(:coerce)
- # If we have no default value, `nil` is never coerced or validated
- unless !has_default? && value.nil?
+ # nil is never coerced
+ unless value.nil?
value = exec_in_resource(resource, options[:coerce], value)
end
end
@@ -475,8 +450,8 @@ class Chef
# this property.
#
def validate(resource, value)
- # If we have no default value, `nil` is never coerced or validated
- unless value.nil? && !has_default?
+ # nils are not validated unless we have an explicit default value
+ if !value.nil? || has_default?
if resource
resource.validate({ name => value }, { name => validation_options })
else
@@ -518,12 +493,15 @@ class Chef
# be using the existing getter/setter to manipulate it instead.
return if !instance_variable_name
- # We deprecate any attempt to create a property that already exists as a
- # method in some Classes that we know would cause our users problems.
- # For example, creating a `hash` property could cause issues when adding
- # a Chef::Resource instance to an data structure that expects to be able
- # to call the `#hash` method and get back an appropriate Fixnum.
- emit_property_redefinition_deprecations
+ # Properties may override existing properties up the inheritance heirarchy, but
+ # properties must not override inherited methods like Object#hash. When the Resource is
+ # placed into the resource collection the ruby Hash object will call the
+ # Object#hash method on the resource, and overriding that with a property will cause
+ # very confusing results.
+ if property_redefines_method?
+ resource_name = declared_in.respond_to?(:resource_name) ? declared_in.resource_name : declared_in
+ raise ArgumentError, "Property `#{name}` of resource `#{resource_name}` overwrites an existing method."
+ end
# We prefer this form because the property name won't show up in the
# stack trace if you use `define_method`.
@@ -537,16 +515,6 @@ class Chef
self.class.properties[#{name.inspect}].set(self, value)
end
EOM
- rescue SyntaxError
- # If the name is not a valid ruby name, we use define_method.
- declared_in.define_method(name) do |value = NOT_PASSED, &block|
- raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
- self.class.properties[name].call(self, value)
- end
- declared_in.define_method("#{name}=") do |value, &block|
- raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
- self.class.properties[name].set(self, value)
- end
end
#
@@ -639,28 +607,23 @@ class Chef
private
- def emit_property_redefinition_deprecations
+ def property_redefines_method?
# We only emit deprecations if this property already exists as an instance method.
# Weeding out class methods avoids unnecessary deprecations such Chef::Resource
# defining a `name` property when there's an already-existing `name` method
# for a Module.
- return unless declared_in.instance_methods.include?(name)
+ return false unless declared_in.instance_methods.include?(name)
# Only emit deprecations for some well-known classes. This will still
# allow more advanced users to subclass their own custom resources and
# override their own properties.
- return unless [ Object, BasicObject, Kernel, Chef::Resource ].include?(declared_in.instance_method(name).owner)
+ return false unless [ Object, BasicObject, Kernel, Chef::Resource ].include?(declared_in.instance_method(name).owner)
# Allow top-level Chef::Resource proprties, such as `name`, to be overridden.
# As of this writing, `name` is the only Chef::Resource property created with the
# `property` definition, but this will allow for future properties to be extended
# as needed.
- return if Chef::Resource.properties.keys.include?(name)
-
- # Emit the deprecation.
- resource_name = declared_in.respond_to?(:resource_name) ? declared_in.resource_name : declared_in
- Chef.deprecated(:property_name_collision, "Property `#{name}` of resource `#{resource_name}` overwrites an existing method. " \
- "Please use a different property name. This will raise an exception in Chef 13.")
+ !Chef::Resource.properties.keys.include?(name)
end
def exec_in_resource(resource, proc, *args)
@@ -697,31 +660,9 @@ class Chef
# valid.
def coerce_and_validate(resource, value, is_default: false)
result = coerce(resource, value)
- begin
- # If the input is from a default, we need to emit an invalid default warning on validate.
- validate(resource, result)
- rescue Chef::Exceptions::CannotValidateStaticallyError
- # This one gets re-raised
- raise
- rescue
- # Anything else is just an invalid default: in those cases, we just
- # warn and return the (possibly coerced) value to the user.
- if is_default
- if value.nil?
- Chef.deprecated(:custom_resource, "Default value nil is invalid for property #{self}. Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property #{name.inspect}, [ String, nil ], default: nil'). Error: #{$!}")
- else
- Chef.deprecated(:custom_resource, "Default value #{value.inspect} is invalid for property #{self}. In Chef 13 this will become an error: #{$!}.")
- end
- else
- raise
- end
- end
+ validate(resource, result)
result
end
-
- def nillable?
- !!options[:nillable]
- end
end
end
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 40c31e4371..bdc1114f0d 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
@@ -379,16 +379,11 @@ class Chef
def action(name, &block)
# We need the block directly in a method so that `super` works
define_method("compile_action_#{name}", &block)
- # We try hard to use `def` because define_method doesn't show the method name in the stack.
- begin
- class_eval <<-EOM
- def action_#{name}
- compile_and_converge_action { compile_action_#{name} }
- end
- EOM
- rescue SyntaxError
- define_method("action_#{name}") { send("compile_action_#{name}") }
- end
+ class_eval <<-EOM
+ def action_#{name}
+ compile_and_converge_action { compile_action_#{name} }
+ end
+ EOM
end
end
end
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/easy_install.rb b/lib/chef/provider/package/easy_install.rb
deleted file mode 100644
index cc915e606c..0000000000
--- a/lib/chef/provider/package/easy_install.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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/provider/package"
-require "chef/mixin/command"
-require "chef/resource/package"
-
-class Chef
- class Provider
- class Package
- class EasyInstall < Chef::Provider::Package
-
- provides :easy_install_package
-
- def install_check(name)
- check = false
-
- begin
- # first check to see if we can import it
- output = shell_out_compact_timeout!(python_binary_path, "-c", "import #{name}", returns: [0, 1]).stderr
- if output.include? "ImportError"
- # then check to see if its on the path
- output = shell_out_compact_timeout!(python_binary_path, "-c", "import sys; print sys.path", returns: [0, 1]).stdout
- if output.downcase.include? name.downcase.to_s
- check = true
- end
- else
- check = true
- end
- rescue
- # it's probably not installed
- end
-
- check
- end
-
- def easy_install_binary_path
- path = new_resource.easy_install_binary
- path ? path : "easy_install"
- end
-
- def python_binary_path
- path = new_resource.python_binary
- path ? path : "python"
- end
-
- def module_name
- m = new_resource.module_name
- m ? m : new_resource.name
- end
-
- def load_current_resource
- @current_resource = Chef::Resource::Package.new(new_resource.name)
- current_resource.package_name(new_resource.package_name)
-
- # get the currently installed version if installed
- package_version = nil
- if install_check(module_name)
- begin
- output = shell_out_compact_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
- package_version = output.strip
- rescue
- output = shell_out_compact_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", returns: [0, 1]).stdout
-
- output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/)
- package_path = ""
-
- output_array.each do |entry|
- if entry.downcase.include?(new_resource.package_name)
- package_path = entry
- end
- end
-
- package_path[/\S\S(.*)\/(.*)-(.*)-py(.*).egg\S/]
- package_version = $3
- end
- end
-
- if package_version == new_resource.version
- Chef::Log.debug("#{new_resource} at version #{new_resource.version}")
- current_resource.version(new_resource.version)
- else
- Chef::Log.debug("#{new_resource} at version #{package_version}")
- current_resource.version(package_version)
- end
-
- current_resource
- end
-
- def candidate_version
- return @candidate_version if @candidate_version
-
- # do a dry run to get the latest version
- result = shell_out_compact_timeout!("#{easy_install_binary_path} -n #{new_resource.package_name}", returns: [0, 1])
- @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
- @candidate_version
- end
-
- def install_package(name, version)
- Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
- shell_out_compact_timeout!(easy_install_binary_path, options, "#{name}==#{version}")
- end
-
- def upgrade_package(name, version)
- install_package(name, version)
- end
-
- def remove_package(name, version)
- Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
- shell_out_compact_timeout!(easy_install_binary_path, options, "-m", name)
- end
-
- def purge_package(name, version)
- remove_package(name, version)
- end
-
- end
- end
- end
-end
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/solaris.rb b/lib/chef/provider/service/solaris.rb
index f7f8eaf31b..c560bed011 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -56,11 +56,13 @@ class Chef
def enable_service
shell_out!(default_init_command, "clear", @new_resource.service_name) if @maintenance
- shell_out!(default_init_command, "enable", "-s", @new_resource.service_name)
+ enable_flags = [ "-s", @new_resource.options ].flatten.compact
+ shell_out!(default_init_command, "enable", *enable_flags, @new_resource.service_name)
end
def disable_service
- shell_out!(default_init_command, "disable", "-s", @new_resource.service_name)
+ disable_flags = [ "-s", @new_resource.options ].flatten.compact
+ shell_out!(default_init_command, "disable", *disable_flags, @new_resource.service_name)
end
alias_method :stop_service, :disable_service
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/provider_resolver.rb b/lib/chef/provider_resolver.rb
index 2eb4d72ba5..439a7e9f5f 100644
--- a/lib/chef/provider_resolver.rb
+++ b/lib/chef/provider_resolver.rb
@@ -59,7 +59,7 @@ class Chef
def resolve
maybe_explicit_provider(resource) ||
maybe_dynamic_provider_resolution(resource, action) ||
- maybe_chef_platform_lookup(resource)
+ raise(Chef::Exceptions::ProviderNotFound, "Cannot find a provider for #{resource} on #{node["platform"]} version #{node["platform_version"]}")
end
# Does NOT call provides? on the resource (it is assumed this is being
@@ -126,11 +126,6 @@ class Chef
handler
end
- # try the old static lookup of providers by platform
- def maybe_chef_platform_lookup(resource)
- Chef::Platform.find_provider_for_node(node, resource)
- end
-
def priority_map
Chef.provider_priority_map
end
diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb
index 35722840e6..0f19f56a8f 100644
--- a/lib/chef/providers.rb
+++ b/lib/chef/providers.rb
@@ -66,7 +66,6 @@ require "chef/provider/package/apt"
require "chef/provider/package/chocolatey"
require "chef/provider/package/dpkg"
require "chef/provider/package/dnf"
-require "chef/provider/package/easy_install"
require "chef/provider/package/freebsd/port"
require "chef/provider/package/freebsd/pkg"
require "chef/provider/package/freebsd/pkgng"
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 77d82f83ab..967703b629 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters (<cw@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");
@@ -104,5 +104,13 @@ class Chef
run_context.node.tags.delete(tag)
end
end
+
+ def to_s
+ "cookbook: #{cookbook_name ? cookbook_name : "(none)"}, recipe: #{recipe_name ? recipe_name : "(none)"} "
+ end
+
+ def inspect
+ to_s
+ end
end
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 40911cd2cc..f0d816cd89 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -23,6 +23,7 @@ require "chef/dsl/data_query"
require "chef/dsl/registry_helper"
require "chef/dsl/reboot_pending"
require "chef/dsl/resources"
+require "chef/json_compat"
require "chef/mixin/convert_to_class_name"
require "chef/guard_interpreter/resource_guard_interpreter"
require "chef/resource/conditional"
@@ -130,7 +131,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 +138,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 +149,6 @@ class Chef
@guard_interpreter = nil
@default_guard_interpreter = :default
@elapsed_time = 0
- @sensitive = false
end
#
@@ -437,10 +432,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 +440,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 +449,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
@@ -523,15 +504,6 @@ class Chef
end
#
- # Since there are collisions with LWRP parameters named 'state' this
- # method is not used by the resource_reporter and is most likely unused.
- # It certainly cannot be relied upon and cannot be fixed.
- #
- # @deprecated
- #
- alias_method :state, :state_for_resource_reporter
-
- #
# The value of the identity of this resource.
#
# - If there are no identity properties on the resource, `name` is returned.
@@ -561,10 +533,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.
@@ -620,7 +589,7 @@ class Chef
begin
return if should_skip?(action)
provider_for_action(action).run_action
- rescue Exception => e
+ rescue StandardError => e
if ignore_failure
Chef::Log.error("#{custom_exception_message(e)}; ignore_failure is set, continuing")
events.resource_failed(self, action, e)
@@ -738,7 +707,7 @@ class Chef
result
end
- def self.json_create(o)
+ def self.from_hash(o)
resource = new(o["instance_vars"]["@name"])
o["instance_vars"].each do |k, v|
resource.instance_variable_set("@#{k}".to_sym, v)
@@ -746,6 +715,14 @@ class Chef
resource
end
+ def self.json_create(o)
+ from_hash(o)
+ end
+
+ def self.from_json(j)
+ from_hash(Chef::JSONCompat.parse(j))
+ end
+
#
# Resource Definition Interface (for resource developers)
#
@@ -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/easy_install_package.rb b/lib/chef/resource/easy_install_package.rb
deleted file mode 100644
index dc5073a6f7..0000000000
--- a/lib/chef/resource/easy_install_package.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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/resource/package"
-
-class Chef
- class Resource
- class EasyInstallPackage < Chef::Resource::Package
- resource_name :easy_install_package
-
- property :easy_install_binary, String, desired_state: false
- property :python_binary, String, desired_state: false
- property :module_name, String, desired_state: false
-
- end
- end
-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..0231964fdf 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");
@@ -18,6 +18,7 @@
#
require "chef/resource"
+require "shellwords"
class Chef
class Resource
@@ -30,12 +31,17 @@ 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
@enabled = nil
@running = nil
@masked = nil
+ @options = nil
@parameters = nil
@pattern = service_name
@start_command = nil
@@ -48,7 +54,6 @@ class Chef
@timeout = nil
@run_levels = nil
@user = nil
- @supports = { :restart => nil, :reload => nil, :status => nil }
end
def service_name(arg = nil)
@@ -152,6 +157,14 @@ class Chef
)
end
+ def options(arg = nil)
+ set_or_return(
+ :options,
+ arg.respond_to?(:split) ? arg.shellsplit : arg,
+ :kind_of => [ Array, String ]
+ )
+ end
+
# Priority arguments can have two forms:
#
# - a simple number, in which the default start runlevels get
@@ -201,17 +214,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/resource_collection.rb b/lib/chef/resource_collection.rb
index 8eaa2961c4..e450f4f19e 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -117,6 +117,16 @@ class Chef
end
end
+ def self.from_hash(o)
+ collection = new()
+ { "@resource_list" => "ResourceList", "@resource_set" => "ResourceSet" }.each_pair do |name, klass|
+ obj = Chef::ResourceCollection.const_get(klass).from_hash(o["instance_vars"].delete(name))
+ collection.instance_variable_set(name.to_sym, obj)
+ end
+ collection.instance_variable_set(:@run_context, o["instance_vars"].delete("@run_context"))
+ collection
+ end
+
private
def lookup_recursive(rc, key)
diff --git a/lib/chef/resource_collection/resource_collection_serialization.rb b/lib/chef/resource_collection/resource_collection_serialization.rb
index 647d28dfd0..4da1ad5048 100644
--- a/lib/chef/resource_collection/resource_collection_serialization.rb
+++ b/lib/chef/resource_collection/resource_collection_serialization.rb
@@ -15,6 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
+require "chef/json_compat"
+
class Chef
class ResourceCollection
module ResourceCollectionSerialization
@@ -39,13 +42,17 @@ class Chef
end
module ClassMethods
- def json_create(o)
+ def from_hash(o)
collection = new()
o["instance_vars"].each do |k, v|
collection.instance_variable_set(k.to_sym, v)
end
collection
end
+
+ def from_json(j)
+ from_hash(Chef::JSONCompat.parse(j))
+ end
end
def is_chef_resource!(arg)
diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb
index 9fe012d4c3..75305f63a6 100644
--- a/lib/chef/resource_collection/resource_list.rb
+++ b/lib/chef/resource_collection/resource_list.rb
@@ -95,6 +95,12 @@ class Chef
end
end
+ def self.from_hash(o)
+ collection = new()
+ resources = o["instance_vars"]["@resources"].map { |r| Chef::Resource.from_hash(r) }
+ collection.instance_variable_set(:@resources, resources)
+ collection
+ end
end
end
end
diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb
index 1a73818790..2c7c0a0b91 100644
--- a/lib/chef/resource_collection/resource_set.rb
+++ b/lib/chef/resource_collection/resource_set.rb
@@ -132,6 +132,14 @@ class Chef
end
end
+ def self.from_hash(o)
+ collection = new()
+ rl = o["instance_vars"]["@resources_by_key"]
+ resources = rl.merge(rl) { |k, r| Chef::Resource.from_hash(r) }
+ collection.instance_variable_set(:@resources_by_key, resources)
+ collection
+ end
+
private
def create_key(resource_type, instance_name)
diff --git a/lib/chef/resources.rb b/lib/chef/resources.rb
index ab89ce66e0..a254fa601f 100644
--- a/lib/chef/resources.rb
+++ b/lib/chef/resources.rb
@@ -34,7 +34,6 @@ require "chef/resource/dpkg_package"
require "chef/resource/dnf_package"
require "chef/resource/dsc_script"
require "chef/resource/dsc_resource"
-require "chef/resource/easy_install_package"
require "chef/resource/env"
require "chef/resource/erl_call"
require "chef/resource/execute"
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
deleted file mode 100644
index 0705ca9f5a..0000000000
--- a/lib/chef/rest.rb
+++ /dev/null
@@ -1,210 +0,0 @@
-#--
-# Author:: Adam Jacob (<adam@chef.io>)
-# Author:: Thom May (<thom@clearairturbulence.org>)
-# Author:: Nuo Yan (<nuo@chef.io>)
-# Author:: Christopher Brown (<cb@chef.io>)
-# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2009-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 "chef/http"
-class Chef
- class HTTP; end
- class REST < HTTP; end
-end
-
-require "chef/http/authenticator"
-require "chef/http/decompressor"
-require "chef/http/json_input"
-require "chef/http/json_to_model_output"
-require "chef/http/cookie_manager"
-require "chef/http/validate_content_length"
-require "chef/config"
-require "chef/exceptions"
-require "chef/platform/query_helpers"
-require "chef/http/remote_request_id"
-require "chef/chef_class"
-
-class Chef
-
- # == Chef::REST
- # Chef's custom REST client with built-in JSON support and RSA signed header
- # authentication.
- class REST < HTTP
-
- # Backwards compatibility for things that use
- # Chef::REST::RESTRequest or its constants
- RESTRequest = HTTP::HTTPRequest
-
- attr_accessor :url, :cookies, :sign_on_redirect, :redirect_limit
-
- attr_reader :authenticator
-
- # Create a REST client object. The supplied +url+ is used as the base for
- # all subsequent requests. For example, when initialized with a base url
- # http://localhost:4000, a call to +get_rest+ with 'nodes' will make an
- # HTTP GET request to http://localhost:4000/nodes
- def initialize(url, client_name = Chef::Config[:node_name], signing_key_filename = Chef::Config[:client_key], options = {})
- Chef.deprecated(:chef_rest, "Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI.")
-
- signing_key_filename = nil if chef_zero_uri?(url)
-
- options = options.dup
- options[:client_name] = client_name
- options[:signing_key_filename] = signing_key_filename
-
- super(url, options)
-
- @decompressor = Decompressor.new(options)
- @authenticator = Authenticator.new(options)
- @request_id = RemoteRequestID.new(options)
-
- @middlewares << JSONInput.new(options)
- @middlewares << JSONToModelOutput.new(options)
- @middlewares << CookieManager.new(options)
- @middlewares << @decompressor
- @middlewares << @authenticator
- @middlewares << @request_id
-
- # ValidateContentLength should come after Decompressor
- # because the order of middlewares is reversed when handling
- # responses.
- @middlewares << ValidateContentLength.new(options)
- end
-
- def signing_key_filename
- authenticator.signing_key_filename
- end
-
- def auth_credentials
- authenticator.auth_credentials
- end
-
- def client_name
- authenticator.client_name
- end
-
- def signing_key
- authenticator.raw_key
- end
-
- def sign_requests?
- authenticator.sign_requests?
- end
-
- # Send an HTTP GET request to the path
- #
- # Using this method to +fetch+ a file is considered deprecated.
- #
- # === Parameters
- # path:: The path to GET
- # raw:: Whether you want the raw body returned, or JSON inflated. Defaults
- # to JSON inflated.
- def get(path, raw = false, headers = {})
- if raw
- streaming_request(path, headers)
- else
- request(:GET, path, headers)
- end
- end
-
- alias :get_rest :get
-
- alias :delete_rest :delete
-
- alias :post_rest :post
-
- alias :put_rest :put
-
- # Streams a download to a tempfile, then yields the tempfile to a block.
- # After the download, the tempfile will be closed and unlinked.
- # If you rename the tempfile, it will not be deleted.
- # Beware that if the server streams infinite content, this method will
- # stream it until you run out of disk space.
- def fetch(path, headers = {})
- streaming_request(create_url(path), headers) { |tmp_file| yield tmp_file }
- end
-
- alias :api_request :request
-
- # Do a HTTP request where no middleware is loaded (e.g. JSON input/output
- # conversion) but the standard Chef Authentication headers are added to the
- # request.
- def raw_http_request(method, path, headers, data)
- url = create_url(path)
- method, url, headers, data = @authenticator.handle_request(method, url, headers, data)
- method, url, headers, data = @request_id.handle_request(method, url, headers, data)
- response, rest_request, return_value = send_http_request(method, url, headers, data)
- response.error! unless success_response?(response)
- return_value
- rescue Exception => exception
- log_failed_request(response, return_value) unless response.nil?
-
- if exception.respond_to?(:chef_rest_request=)
- exception.chef_rest_request = rest_request
- end
- raise
- end
-
- # Deprecated:
- # Responsibilities of this method have been split up. The #http_client is
- # now responsible for making individual requests, while
- # #retrying_http_errors handles error/retry logic.
- def retriable_http_request(method, url, req_body, headers)
- rest_request = Chef::HTTP::HTTPRequest.new(method, url, req_body, headers)
-
- Chef::Log.debug("Sending HTTP request via #{method} to #{url.host}:#{url.port}#{rest_request.path}")
-
- retrying_http_errors(url) do
- yield rest_request
- end
- end
-
- # Customized streaming behavior; sets the accepted content type to "*/*"
- # if not otherwise specified for compatibility purposes
- def streaming_request(url, headers, &block)
- headers["Accept"] ||= "*/*"
- super
- end
-
- alias :retriable_rest_request :retriable_http_request
-
- def follow_redirect
- unless @sign_on_redirect
- @authenticator.sign_request = false
- end
- super
- ensure
- @authenticator.sign_request = true
- end
-
- public :create_url
-
- ############################################################################
- # DEPRECATED
- ############################################################################
-
- def decompress_body(body)
- @decompressor.decompress_body(body)
- end
-
- def authentication_headers(method, url, json_body = nil)
- authenticator.authentication_headers(method, url, json_body)
- end
-
- end
-end
diff --git a/lib/chef/role.rb b/lib/chef/role.rb
index 218894ef03..c22c77b70d 100644
--- a/lib/chef/role.rb
+++ b/lib/chef/role.rb
@@ -168,12 +168,6 @@ class Chef
self
end
- # Create a Chef::Role from JSON
- def self.json_create(o)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::Role#from_hash")
- from_hash(o)
- end
-
def self.from_hash(o)
role = new
role.name(o["name"])
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 6d84b7773d..a606585e80 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@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");
@@ -576,27 +576,6 @@ ERROR_MESSAGE
attr_reader :loaded_attributes_hash
attr_reader :loaded_recipes_hash
- module Deprecated
- ###
- # These need to be settable so deploy can run a resource_collection
- # independent of any cookbooks via +recipe_eval+
- def audits=(value)
- Chef.deprecated(:internal_api, "Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
- @audits = value
- end
-
- def immediate_notification_collection=(value)
- Chef.deprecated(:internal_api, "Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
- @immediate_notification_collection = value
- end
-
- def delayed_notification_collection=(value)
- Chef.deprecated(:internal_api, "Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.")
- @delayed_notification_collection = value
- end
- end
- prepend Deprecated
-
#
# A child run context. Delegates all root context calls to its parent.
#
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..7357dbf6be 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
@@ -128,10 +106,12 @@ WARNDEP
return args.first if args.first.is_a?(Hash)
args_h = Hash.new
- args_h[:sort] = args[0] if args[0]
- args_h[:start] = args[1] if args[1]
- args_h[:rows] = args[2]
- args_h[:filter_result] = args[3]
+ # If we have 4 arguments, the first is the now-removed sort option, so
+ # just ignore it.
+ args.pop(0) if args.length == 4
+ args_h[:start] = args[0] if args[0]
+ args_h[:rows] = args[1]
+ args_h[:filter_result] = args[2]
args_h
end
@@ -141,16 +121,15 @@ WARNDEP
s && Addressable::URI.encode_component(s.to_s, QUERY_PARAM_VALUE)
end
- def create_query_string(type, query, rows, start, sort)
+ def create_query_string(type, query, rows, start)
qstr = "search/#{type}?q=#{escape_value(query)}"
- qstr += "&sort=#{escape_value(sort)}" if sort
qstr += "&start=#{escape_value(start)}" if start
qstr += "&rows=#{escape_value(rows)}" if rows
qstr
end
- def call_rest_service(type, query: "*:*", rows: nil, start: 0, sort: "X_CHEF_id_CHEF_X asc", filter_result: nil)
- query_string = create_query_string(type, query, rows, start, sort)
+ def call_rest_service(type, query: "*:*", rows: nil, start: 0, filter_result: nil)
+ query_string = create_query_string(type, query, rows, start)
if filter_result
response = rest.post(query_string, filter_result)
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index e8c3704553..b4c0277c57 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -27,6 +27,7 @@ require "chef/config"
require "chef/config_fetcher"
require "chef/shell/shell_session"
+require "chef/workstation_config_loader"
require "chef/shell/ext"
require "chef/json_compat"
require "chef/util/path_helper"
@@ -62,6 +63,12 @@ module Shell
irb = IRB::Irb.new
+ if solo_mode?
+ # Setup the mocked ChefServer
+ Chef::Config.local_mode = true
+ Chef::LocalMode.setup_server_connectivity
+ end
+
init(irb.context.main)
irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC]
@@ -74,6 +81,13 @@ module Shell
catch(:IRB_EXIT) do
irb.eval_input
end
+ ensure
+ # We destroy the mocked ChefServer
+ Chef::LocalMode.destroy_server_connectivity if solo_mode?
+ end
+
+ def self.solo_mode?
+ Chef::Config[:solo]
end
def self.setup_logger
@@ -167,8 +181,9 @@ module Shell
def self.client_type
type = Shell::StandAloneSession
- type = Shell::SoloSession if Chef::Config[:shell_solo]
- type = Shell::ClientSession if Chef::Config[:client]
+ type = Shell::SoloSession if solo_mode?
+ type = Shell::SoloLegacySession if Chef::Config[:solo_legacy_shell]
+ type = Shell::ClientSession if Chef::Config[:client]
type = Shell::DoppelGangerSession if Chef::Config[:doppelganger]
type
end
@@ -196,8 +211,10 @@ module Shell
When no CONFIG is specified, chef-shell attempts to load a default configuration file:
* If a NAMED_CONF is given, chef-shell will load ~/.chef/NAMED_CONF/chef_shell.rb
* If no NAMED_CONF is given chef-shell will load ~/.chef/chef_shell.rb if it exists
-* chef-shell falls back to loading /etc/chef/client.rb or /etc/chef/solo.rb if -z or
- -s options are given and no chef_shell.rb can be found.
+* If no chef_shell.rb can be found, chef-shell falls back to load:
+ /etc/chef/client.rb if -z option is given.
+ /etc/chef/solo.rb if --solo-legacy-mode option is given.
+ .chef/knife.rb if -s option is given.
FOOTER
option :config_file,
@@ -226,7 +243,7 @@ FOOTER
:default => true,
:boolean => true
- option :shell_solo,
+ option :solo_shell,
:short => "-s",
:long => "--solo",
:description => "chef-solo session",
@@ -239,6 +256,12 @@ FOOTER
:description => "chef-client session",
:boolean => true
+ option :solo_legacy_shell,
+ :long => "--solo-legacy-mode",
+ :description => "chef-solo legacy session",
+ :boolean => true,
+ :proc => proc { Chef::Config[:solo_legacy_mode] = true }
+
option :json_attribs,
:short => "-j JSON_ATTRIBS",
:long => "--json-attributes JSON_ATTRIBS",
@@ -313,10 +336,12 @@ FOOTER
config_file_to_try
elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, "chef_shell.rb"))
File.join(dot_chef_dir, "chef_shell.rb")
- elsif config[:solo]
+ elsif config[:solo_legacy_shell]
Chef::Config.platform_specific_path("/etc/chef/solo.rb")
elsif config[:client]
Chef::Config.platform_specific_path("/etc/chef/client.rb")
+ elsif config[:solo_shell]
+ Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location
else
nil
end
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 3034e1cf5d..41d5bd64a0 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -159,9 +159,9 @@ module Shell
end
- class SoloSession < ShellSession
+ class SoloLegacySession < ShellSession
- session_type :solo
+ session_type :solo_legacy_mode
def definitions
@run_context.definitions
@@ -191,10 +191,14 @@ module Shell
end
- class ClientSession < SoloSession
+ class ClientSession < ShellSession
session_type :client
+ def definitions
+ @run_context.definitions
+ end
+
def save_node
@client.save_node
end
@@ -223,6 +227,12 @@ module Shell
end
+ class SoloSession < ClientSession
+
+ session_type :solo
+
+ end
+
class DoppelGangerClient < Chef::Client
attr_reader :node_name
diff --git a/lib/chef/shell_out.rb b/lib/chef/shell_out.rb
deleted file mode 100644
index 54ff718e8e..0000000000
--- a/lib/chef/shell_out.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require "mixlib/shellout"
-
-class Chef
- class ShellOut < Mixlib::ShellOut
-
- def initialize(*args)
- Chef::Log.warn("Chef::ShellOut is deprecated, please use Mixlib::ShellOut")
- called_from = caller[0..3].inject("Called from:\n") { |msg, trace_line| msg << " #{trace_line}\n" }
- Chef::Log.warn(called_from)
- super
- end
- end
-end
diff --git a/lib/chef/tasks/chef_repo.rake b/lib/chef/tasks/chef_repo.rake
deleted file mode 100644
index 543bd8d864..0000000000
--- a/lib/chef/tasks/chef_repo.rake
+++ /dev/null
@@ -1,200 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
-# Copyright:: Copyright 2014-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.
-#
-TOPDIR = "."
-require "rake"
-
-desc "By default, print deprecation notice"
-task :default do
- puts deprecation_notice
-end
-
-desc "Install the latest copy of the repository on this Chef Server"
-task :install do
- puts deprecation_notice
- puts "The `install` rake task, which included the `update`, `roles`, and"
- puts "`upload_cookbooks` rake tasks is replaced by the `knife upload`"
- puts 'sub-command. The notion of "installing" the chef-repo to the Chef'
- puts "Server. Previously the `install` task would manage server and"
- puts "client configuration. This will not work at all on Chef Server 11+"
- puts "and client configuration should be managed with the `chef-client`"
- puts "cookbook."
-end
-
-desc "Update your repository from source control"
-task :update do
- puts deprecation_notice
- puts "The `update` rake task previously updated the chef-repo from"
- puts "the detected version control system, either svn or git. However,"
- puts "it has not been recommended for users for years. Most users in"
- puts "the community use `git`, so the Subversion functionality is not"
- puts "required, and `git pull` is sufficient for many workflows. The"
- puts "world of git workflows is rather different now than it was when"
- puts "this rake task was created."
-end
-
-desc "Create a new cookbook (with COOKBOOK=name, optional CB_PREFIX=site-)"
-task :new_cookbook do
- cb = ENV["COOKBOOK"] || "my_cookbook_name"
- puts deprecation_notice
- puts "The `new_cookbook` rake task is replaced by the ChefDK cookbook"
- puts "generator. To generate a new cookbook run:"
- puts
- puts "chef generate cookbook #{ENV['COOKBOOK']}"
- puts
- puts "Or, if you are not using ChefDK, use `knife cookbook create`:"
- puts
- puts "knife cookbook create #{ENV['COOKBOOK']}"
-end
-
-desc "Create a new self-signed SSL certificate for FQDN=foo.example.com"
-task :ssl_cert do
- puts deprecation_notice
- puts "The `ssl_cert` rake task is superseded by using the CHEF-maintained"
- puts '`openssl` cookbook\'s `openssl_x509` resource which can generate'
- puts "self-signed certificate chains as convergent resources."
- puts
- puts "https://supermarket.getchef.com/cookbooks/openssl"
-end
-
-desc "Build cookbook metadata.json from metadata.rb"
-task :metadata do
- puts deprecation_notice
- puts "The `metadata` rake task is not recommended. Cookbook"
- puts "`metadata.json` is automatically generated from `metadata.rb`"
- puts "by `knife` when uploading cookbooks to the Chef Server."
-end
-
-desc "Update roles"
-task :roles do
- puts deprecation_notice
- puts "The `roles` rake task is not recommended. If you are using Ruby"
- puts "role files (roles/*.rb), you can upload them all with:"
- puts
- puts "knife role from file roles/*"
- puts
- puts "If you are using JSON role files (roles/*.json), you can upload"
- puts "them all with:"
- puts
- puts "knife upload roles/*.json"
-end
-
-desc "Update a specific role"
-task :role do
- puts deprecation_notice
- puts "The `role` rake task is not recommended. If you are using Ruby"
- puts "role files, you can upload a single role with:"
- puts
- puts "knife role from file rolename.rb"
- puts
- puts "If you are using JSON role files, you can upload a single role with"
- puts
- puts "knife upload roles/rolename.json"
-end
-
-desc "Upload all cookbooks"
-task :upload_cookbooks do
- puts deprecation_notice
- puts deprecated_cookbook_upload
-end
-
-desc "Upload a single cookbook"
-task :upload_cookbook do
- puts deprecation_notice
- puts deprecated_cookbook_upload
-end
-
-desc "Test all cookbooks"
-task :test_cookbooks do
- puts deprecation_notice
- puts "The `test_cookbooks` rake task is no longer recommended. Previously"
- puts "it only performed a syntax check, and did no other kind of testing,"
- puts "and the Chef Community has a rich ecosystem of testing tools for"
- puts "various purposes:"
- puts
- puts "- knife cookbook test will perform a syntax check, as this task did"
- puts " before."
- puts "- rubocop and foodcritic will perform lint checking for Ruby and"
- puts " Chef cookbook style according to community standards."
- puts "- ChefSpec will perform unit testing"
- puts "- Test Kitchen will perform convergence and post-convergence"
- puts " testing on virtual machines."
-end
-
-desc "Test a single cookbook"
-task :test_cookbook => [:test_cookbooks]
-
-namespace :databag do
- desc "Upload a single databag"
- task :upload do
- puts deprecation_notice
- puts "The `data_bags:upload` task is not recommended. You should use"
- puts "the `knife upload` sub-command for uploading data bag items."
- puts
- puts "knife upload data_bags/bagname/itemname.json"
- end
-
- desc "Upload all databags"
- task :upload_all do
- puts deprecation_notice
- puts "The `data_bags:upload_all` task is not recommended. You should"
- puts "use the `knife upload` sub-command for uploading data bag items."
- puts
- puts "knife upload data_bags/*"
- end
-
- desc "Create a databag"
- task :create do
- puts deprecation_notice
- puts deprecated_data_bag_creation
- end
-
- desc "Create a databag item stub"
- task :create_item do
- puts deprecation_notice
- puts deprecated_data_bag_creation
- end
-end
-
-def deprecation_notice
- %Q{*************************************************
-NOTICE: Chef Repository Rake Tasks Are Deprecated
-*************************************************
-}
-end
-
-def deprecated_cookbook_upload
- %Q{
-The `upload_cookbook` and `upload_cookbooks` rake tasks are not
-recommended. These tasks are replaced by other, better workflow
-tools, such as `knife cookbook upload`, `knife upload`, or `berks`
-}
-end
-
-def deprecated_data_bag_creation
- %Q{
-The `data_bags:create` and `data_bags:create_item` tasks are not
-recommended. You should create data bag items as JSON files in the data_bags
-directory, with a sub-directory for each bag, and use `knife upload` to
-upload them. For example, if you have a data bags named `users`, with
-`finn`, and `jake` items, you would have:
-
-./data_bags/users/finn.json
-./data-bags/users/jake.json
-}
-end
diff --git a/lib/chef/user.rb b/lib/chef/user.rb
index fffaa106f8..f52d0e2555 100644
--- a/lib/chef/user.rb
+++ b/lib/chef/user.rb
@@ -152,11 +152,6 @@ class Chef
Chef::User.from_hash(Chef::JSONCompat.from_json(json))
end
- def self.json_create(json)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::User#from_json or Chef::User#load.")
- Chef::User.from_json(json)
- end
-
def self.list(inflate = false)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users")
users = if response.is_a?(Array)
diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb
index b408bbe667..0ca17c6ed6 100644
--- a/lib/chef/user_v1.rb
+++ b/lib/chef/user_v1.rb
@@ -274,11 +274,6 @@ class Chef
Chef::UserV1.from_hash(Chef::JSONCompat.from_json(json))
end
- def self.json_create(json)
- Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::UserV1#from_json or Chef::UserV1#load.")
- Chef::UserV1.from_json(json)
- end
-
def self.list(inflate = false)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("users")
users = if response.is_a?(Array)
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb
index f9f8f011af..059a04d59a 100644
--- a/lib/chef/util/windows/net_user.rb
+++ b/lib/chef/util/windows/net_user.rb
@@ -112,7 +112,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
def add(args)
transformed_args = transform_usri3(args)
NetUser.net_user_add_l3(nil, transformed_args)
- NetUser.net_local_group_add_member(nil, "Users", args[:name])
+ NetUser.net_local_group_add_member(nil, Chef::ReservedNames::Win32::Security::SID.BuiltinUsers.account_simple_name, args[:name])
end
# FIXME: yard with @yield
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 82afd17006..6d1967957e 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.67"
end
#
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 983166ac70..c77616853c 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -59,6 +59,11 @@ class Chef
Chef::ReservedNames::Win32::Security.lookup_account_sid(self)
end
+ def account_simple_name
+ domain, name, use = account
+ name
+ end
+
def account_name
domain, name, use = account
(!domain.nil? && domain.length > 0) ? "#{domain}\\#{name}" : name
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..04324ad1e6 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: 544a9335549148037a4161ff4c6c9d9a71e39660
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: 443f42abe0b791b132fb27aa85448bb691af9102
specs:
omnibus (5.5.0)
aws-sdk (~> 2)
@@ -29,23 +19,32 @@ GIT
mixlib-shellout (~> 2.0)
mixlib-versioning
ohai (~> 8.0)
+ pedump
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.7)
+ aws-sdk-resources (= 2.8.7)
+ aws-sdk-core (2.8.7)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.7.5)
- aws-sdk-core (= 2.7.5)
+ aws-sdk-resources (2.8.7)
+ aws-sdk-core (= 2.8.7)
aws-sigv4 (1.0.0)
berkshelf (4.3.5)
addressable (~> 2.3, >= 2.3.4)
@@ -86,7 +85,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 +97,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 +106,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 +118,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 +145,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 +215,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 +231,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 +266,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/omnibus_overrides.rb b/omnibus_overrides.rb
index 69a5a7af05..6cf6dc7ece 100644
--- a/omnibus_overrides.rb
+++ b/omnibus_overrides.rb
@@ -11,7 +11,7 @@ override "libyaml", version: "0.1.6"
override "makedepend", version: "1.0.5"
override "ncurses", version: "5.9"
override "pkg-config-lite", version: "0.28-1"
-override "ruby", version: "2.3.1"
+override "ruby", version: "2.3.3"
override "ruby-windows-devkit-bash", version: "3.1.23-4-msys-1.0.18"
override "util-macros", version: "1.19.0"
override "xproto", version: "7.0.28"
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..efd601d6d8 100644
--- a/spec/data/shef-config.rb
+++ b/spec/data/shef-config.rb
@@ -1,10 +1,11 @@
-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"
+chef_repo_path File.dirname(__FILE__)
+cookbook_path "#{chef_repo_path}/cookbooks"
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index aea7585bb2..fba344649f 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"])
@@ -276,7 +304,7 @@ describe Chef::Knife::Ssh do
Chef::Config[:client_key] = nil
Chef::Config[:chef_server_url] = "http://localhost:9000"
- @api.post("/search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0", 200) do
+ @api.post("/search/node?q=*:*&start=0", 200) do
%({"total":1, "start":0, "rows":[{"data": {"fqdn":"the.fqdn", "config": "the_public_hostname", "knife_config": "the_public_hostname" }}]})
end
end
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/functional/rest_spec.rb b/spec/functional/rest_spec.rb
deleted file mode 100644
index 14e76087c4..0000000000
--- a/spec/functional/rest_spec.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# Author:: Lamont Granquist (<lamont@chef.io>)
-# Copyright:: Copyright 2014-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"
-require "tiny_server"
-require "support/shared/functional/http"
-
-describe Chef::REST do
- include ChefHTTPShared
-
- let(:http_client) { described_class.new(source) }
- let(:http_client_disable_gzip) { described_class.new(source, Chef::Config[:node_name], Chef::Config[:client_key], { :disable_gzip => true } ) }
-
- shared_examples_for "downloads requests correctly" do
- it "successfully downloads a streaming request" do
- tempfile = http_client.streaming_request(source, {})
- tempfile.close
- expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
- end
-
- it "successfully downloads a GET request" do
- tempfile = http_client.get(source, {})
- tempfile.close
- expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
- end
- end
-
- shared_examples_for "validates content length and throws an exception" do
- it "fails validation on a streaming download" do
- expect { http_client.streaming_request(source, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
-
- it "fails validation on a GET request" do
- expect { http_client.get(source, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
- end
-
- shared_examples_for "an endpoint that 403s" do
- it "fails with a Net::HTTPServerException on a streaming download" do
- expect { http_client.streaming_request(source, {}) }.to raise_error(Net::HTTPServerException)
- end
-
- it "fails with a Net::HTTPServerException on a GET request" do
- expect { http_client.get(source, {}) }.to raise_error(Net::HTTPServerException)
- end
- end
-
- # see CHEF-5100
- shared_examples_for "a 403 after a successful request when reusing the request object" do
- it "fails with a Net::HTTPServerException on a streaming download" do
- tempfile = http_client.streaming_request(source, {})
- tempfile.close
- expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
- expect { http_client.streaming_request(source2, {}) }.to raise_error(Net::HTTPServerException)
- end
-
- it "fails with a Net::HTTPServerException on a GET request" do
- tempfile = http_client.get(source, {})
- tempfile.close
- expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
- expect { http_client.get(source2, {}) }.to raise_error(Net::HTTPServerException)
- end
- end
-
- before do
- Chef::Config[:node_name] = "webmonkey.example.com"
- Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- end
-
- before(:each) do
- start_tiny_server
- end
-
- after(:each) do
- stop_tiny_server
- end
-
- it_behaves_like "downloading all the things"
-end
diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb
index 636162fb16..8c8d7ba482 100644
--- a/spec/functional/shell_spec.rb
+++ b/spec/functional/shell_spec.rb
@@ -135,6 +135,24 @@ describe Shell do
expect(exitstatus).to eq(0)
end
+ context "on solo mode" do
+ it "starts correctly" do
+ output, exitstatus = run_chef_shell_with("--solo")
+ expect(output).to include("done")
+ expect(exitstatus).to eq(0)
+ end
+
+ it "should be able to use the API" do
+ output, exitstatus = run_chef_shell_with("-s") do |out, keyboard|
+ simple_api_get = "api.get('data')"
+ keyboard.puts(simple_api_get)
+ read_until(out, simple_api_get)
+ end
+ expect(output).to include("{}")
+ expect(exitstatus).to eq(0)
+ end
+ end
+
it "sets the override_runlist from the command line" do
output, exitstatus = run_chef_shell_with("-o 'override::foo,override::bar'") do |out, keyboard|
show_recipes_code = %q[puts "#{node["recipes"].inspect}"]
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 7a8059066a..2a31638c0f 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -388,18 +388,8 @@ EOM
when_the_repository "has a cookbook that generates deprecation warnings" do
before do
file "cookbooks/x/recipes/default.rb", <<-EOM
- class ::MyResource < Chef::Resource
- use_automatic_resource_name
- property :x, default: []
- property :y, default: {}
- end
-
- my_resource 'blah' do
- 1.upto(10) do
- x nil
- end
- x nil
- end
+ Chef.deprecated(:internal_api, "Test deprecation")
+ Chef.deprecated(:internal_api, "Test deprecation")
EOM
end
@@ -432,7 +422,7 @@ EOM
expect(run_complete).to be >= 0
# Make sure there is exactly one result for each, and that it occurs *after* the complete message.
- expect(match_indices(/An attempt was made to change x from \[\] to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./, result.stdout)).to match([ be > run_complete ])
+ expect(match_indices(/Test deprecation/, result.stdout)).to match([ be > run_complete ])
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/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index e2fa7df1fc..32283393ce 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -81,52 +81,6 @@ describe "Recipe DSL methods" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
end
- context "with a resource 'backcompat_thingy' declared in Chef::Resource and Chef::Provider" do
- before(:context) do
-
- class Chef::Resource::BackcompatThingy < Chef::Resource
- default_action :create
- end
- class Chef::Provider::BackcompatThingy < Chef::Provider
- def load_current_resource
- end
-
- def action_create
- BaseThingy.created_resource = new_resource.class
- BaseThingy.created_provider = self.class
- end
- end
-
- end
-
- it "backcompat_thingy creates a Chef::Resource::BackcompatThingy" do
- recipe = converge do
- backcompat_thingy("blah") {}
- end
- expect(BaseThingy.created_resource).to eq Chef::Resource::BackcompatThingy
- expect(BaseThingy.created_provider).to eq Chef::Provider::BackcompatThingy
- end
-
- context "and another resource 'backcompat_thingy' in BackcompatThingy with 'provides'" do
- before(:context) do
-
- class RecipeDSLSpecNamespace::BackcompatThingy < BaseThingy
- provides :backcompat_thingy
- resource_name :backcompat_thingy
- end
-
- end
-
- it "backcompat_thingy creates a BackcompatThingy" do
- recipe = converge do
- backcompat_thingy("blah") {}
- end
- expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'provides :backcompat_thingy'./)
- expect(BaseThingy.created_resource).not_to be_nil
- end
- end
- end
-
context "with a resource named RecipeDSLSpecNamespace::Bar::BarThingy" do
before(:context) do
@@ -1220,35 +1174,6 @@ describe "Recipe DSL methods" do
end
end
- context "with provides? returning true to blarghle_blarghle_little_star and not resource_name" do
- before do
- temp_blarghle_blarghle_little_star = blarghle_blarghle_little_star
- resource_class.define_singleton_method(:provides?) do |node, resource_name|
- @called_provides = true
- resource_name == temp_blarghle_blarghle_little_star
- end
- end
-
- it "my_resource does not return the resource" do
- dsl_name = my_resource
- expect_converge do
- instance_eval("#{dsl_name} 'foo'")
- end.to raise_error(Chef::Exceptions::NoSuchResourceType)
- expect(resource_class.called_provides).to be_truthy
- end
-
- it "blarghle_blarghle_little_star 'foo' returns the resource and emits a warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- dsl_name = blarghle_blarghle_little_star
- recipe = converge do
- instance_eval("#{dsl_name} 'foo'")
- end
- expect(recipe.logged_warnings).to include "WARN: #{resource_class}.provides? returned true when asked if it provides DSL #{dsl_name}, but provides :#{dsl_name} was never called!"
- expect(BaseThingy.created_resource).to eq resource_class
- expect(resource_class.called_provides).to be_truthy
- end
- end
-
context "and a provider" do
let(:provider_class) do
Class.new(BaseThingy::Provider) do
@@ -1448,6 +1373,23 @@ describe "Recipe DSL methods" do
end
end
end
+
+ context "with UTF-8 provides" do
+ before(:context) do
+ class UTF8Thingy < BaseThingy
+ resource_name :Straße
+ provides :Straße
+ end
+ end
+
+ it "utf-8 dsl names work" do
+ recipe = converge do
+ Straße("blah") {}
+ end
+ expect(recipe.logged_warnings).to eq ""
+ expect(BaseThingy.created_resource).to eq(UTF8Thingy)
+ end
+ end
end
before(:all) { Namer.current_index = 0 }
@@ -1494,30 +1436,4 @@ describe "Recipe DSL methods" do
end
end
- context "with a dynamically defined resource and regular provider" do
- before(:context) do
- Class.new(Chef::Resource) do
- resource_name :lw_resource_with_hw_provider_test_case
- default_action :create
- attr_accessor :created_provider
- end
- class Chef::Provider::LwResourceWithHwProviderTestCase < Chef::Provider
- def load_current_resource
- end
-
- def action_create
- new_resource.created_provider = self.class
- end
- end
- end
-
- it "looks up the provider in Chef::Provider converting the resource name from snake case to camel case" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource = nil
- recipe = converge do
- resource = lw_resource_with_hw_provider_test_case("blah") {}
- end
- expect(resource.created_provider).to eq(Chef::Provider::LwResourceWithHwProviderTestCase)
- end
- end
end
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb
index f11696bae4..7a68164d41 100644
--- a/spec/integration/recipes/resource_action_spec.rb
+++ b/spec/integration/recipes/resource_action_spec.rb
@@ -357,7 +357,7 @@ module ResourceActionSpec
end
end
- context "With a resource with action a-b-c d" do
+ context "With a resource with a UTF-8 action" do
class WeirdActionJackson < Chef::Resource
use_automatic_resource_name
@@ -365,7 +365,7 @@ module ResourceActionSpec
attr_accessor :action_was
end
- action "a-b-c d" do
+ action :Straße do
WeirdActionJackson.action_was = action
end
end
@@ -374,7 +374,7 @@ module ResourceActionSpec
expect_recipe do
weird_action_jackson "hi"
end.to be_up_to_date
- expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
+ expect(WeirdActionJackson.action_was).to eq :Straße
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/data_collector/resource_report_spec.rb b/spec/unit/data_collector/resource_report_spec.rb
new file mode 100644
index 0000000000..b3523622c4
--- /dev/null
+++ b/spec/unit/data_collector/resource_report_spec.rb
@@ -0,0 +1,145 @@
+#
+# Author:: Salim Afiune (<afiune@chef.io)
+#
+# Copyright:: Copyright 2012-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.
+#
+
+require "spec_helper"
+
+describe Chef::DataCollector::ResourceReport do
+ let(:cookbook_repo_path) { File.join(CHEF_SPEC_DATA, "cookbooks") }
+ let(:cookbook_collection) { Chef::CookbookCollection.new(Chef::CookbookLoader.new(cookbook_repo_path)) }
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
+ let(:resource) { Chef::Resource.new("zelda", run_context) }
+ let(:report) { described_class.new(resource, :create) }
+
+ describe "#skipped" do
+ let(:conditional) { double("Chef::Resource::Conditional") }
+
+ it "should set status and conditional" do
+ report.skipped(conditional)
+ expect(report.conditional).to eq conditional
+ expect(report.status).to eq "skipped"
+ end
+ end
+
+ describe "#up_to_date" do
+ it "should set status" do
+ report.up_to_date
+ expect(report.status).to eq "up-to-date"
+ end
+ end
+
+ describe "#updated" do
+ it "should set status" do
+ report.updated
+ expect(report.status).to eq "updated"
+ end
+ end
+
+ describe "#elapsed_time_in_milliseconds" do
+
+ context "when elapsed_time is not set" do
+ it "should return nil" do
+ allow(report).to receive(:elapsed_time).and_return(nil)
+ expect(report.elapsed_time_in_milliseconds).to eq nil
+ end
+ end
+
+ context "when elapsed_time is set" do
+ it "should return it in milliseconds" do
+ allow(report).to receive(:elapsed_time).and_return(1)
+ expect(report.elapsed_time_in_milliseconds).to eq 1000
+ end
+ end
+ end
+
+ describe "#failed" do
+ let(:exception) { double("Chef::Exception::Test") }
+
+ it "should set exception and status" do
+ report.failed(exception)
+ expect(report.exception).to eq exception
+ expect(report.status).to eq "failed"
+ end
+ end
+
+ describe "#to_hash" do
+ context "for a simple_resource" do
+ let(:resource) do
+ klass = Class.new(Chef::Resource) do
+ resource_name "zelda"
+ end
+ klass.new("hyrule", run_context)
+ end
+ let(:hash) do
+ {
+ "after" => {},
+ "before" => {},
+ "delta" => "",
+ "duration" => "",
+ "id" => "hyrule",
+ "ignore_failure" => false,
+ "name" => "hyrule",
+ "result" => "create",
+ "status" => "unprocessed",
+ "type" => :zelda,
+ }
+ end
+
+ it "returns a hash containing the expected values" do
+ expect(report.to_hash).to eq hash
+ end
+ end
+
+ context "for a lazy_resource that got skipped" do
+ let(:resource) do
+ klass = Class.new(Chef::Resource) do
+ resource_name "link"
+ property :sword, String, name_property: true, identity: true
+ end
+ resource = klass.new("hyrule")
+ resource.sword = Chef::DelayedEvaluator.new { nil }
+ resource
+ end
+ let(:hash) do
+ {
+ "after" => {},
+ "before" => {},
+ "delta" => "",
+ "duration" => "",
+ "conditional" => "because",
+ "id" => "unknown identity (due to Chef::Exceptions::ValidationFailed)",
+ "ignore_failure" => false,
+ "name" => "hyrule",
+ "result" => "create",
+ "status" => "skipped",
+ "type" => :link,
+ }
+ end
+ let(:conditional) do
+ double("Chef::Resource::Conditional", :to_text => "because")
+ end
+
+ it "should handle any Exception and throw a helpful message by mocking the identity" do
+ report.skipped(conditional)
+ expect(report.to_hash).to eq hash
+ end
+ end
+ end
+end
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/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index 4da29fe4ec..38c2c60b2e 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -22,28 +22,6 @@ require "chef/json_compat"
describe Chef::JSONCompat do
before { Chef::Config[:treat_deprecation_warnings_as_errors] = false }
- describe "#from_json with JSON containing an existing class" do
- let(:json) { '{"json_class": "Chef::Role"}' }
-
- it "emits a deprecation warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = true
- expect { Chef::JSONCompat.from_json(json) }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Auto inflation of JSON data is deprecated. Please use Chef::Role#from_hash/
- end
-
- it "returns an instance of the class instead of a Hash" do
- expect(Chef::JSONCompat.from_json(json).class).to eq Chef::Role
- end
- end
-
- describe "#from_json with JSON containing comments" do
- let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
-
- it "returns an instance of the class instead of a Hash" do
- expect(Chef::JSONCompat.from_json(json).class).to eq Chef::Role
- end
- end
-
describe "#parse with JSON containing comments" do
let(:json) { %Q{{\n/* comment */\n// comment 2\n"json_class": "Chef::Role"}} }
@@ -52,16 +30,6 @@ describe Chef::JSONCompat do
end
end
- describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
- require "chef/sandbox" # Only needed for this test
-
- let(:json) { '{"json_class": "Chef::Sandbox", "arbitrary": "data"}' }
-
- it "returns a Hash, because Chef::Sandbox is a dummy class" do
- expect(Chef::JSONCompat.from_json(json)).to eq({ "json_class" => "Chef::Sandbox", "arbitrary" => "data" })
- end
- end
-
describe "when pretty printing an object that defines #to_json" do
class Foo
def to_json(*a)
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/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 38c72161e5..38614f44d9 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -34,16 +34,24 @@ describe Chef::Knife::UI do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
end
+ class TestObject < OpenStruct
+ def self.from_hash(hsh)
+ new(hsh)
+ end
+ end
+
describe "edit" do
ruby_for_json = { "foo" => "bar" }
+ ruby_from_json = TestObject.from_hash(ruby_for_json)
json_from_ruby = "{\n \"foo\": \"bar\"\n}"
json_from_editor = "{\n \"bar\": \"foo\"\n}"
- ruby_from_editor = { "bar" => "foo" }
+ ruby_from_editor = TestObject.from_hash({ "bar" => "foo" })
my_editor = "veeeye"
temp_path = "/tmp/bar/baz"
- let(:subject) { @ui.edit_data(ruby_for_json, parse_output) }
+ let(:subject) { @ui.edit_data(ruby_for_json, parse_output, object_class: klass) }
let(:parse_output) { false }
+ let(:klass) { nil }
context "when editing is disabled" do
before do
@@ -57,17 +65,18 @@ describe Chef::Knife::UI do
end
context "when parse_output is true" do
let(:parse_output) { true }
+ let(:klass) { TestObject }
it "returns a ruby object" do
- expect(subject).to eql(ruby_for_json)
+ expect(subject).to eql(ruby_from_json)
end
-
- it "gives a deprecation error" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = true
- expect { subject }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Auto inflation of JSON data is deprecated./
+ context "but no object class is provided" do
+ let(:klass) { nil }
+ it "raises an error" do
+ expect { subject }.to raise_error ArgumentError,
+ /Please pass in the object class to hydrate or use #edit_hash/
+ end
end
end
-
end
context "when editing is enabled" do
@@ -94,6 +103,7 @@ describe Chef::Knife::UI do
end
context "when parse_output is true" do
let(:parse_output) { true }
+ let(:klass) { TestObject }
it "returns an edited ruby object" do
expect(subject).to eql(ruby_from_editor)
end
@@ -145,6 +155,7 @@ describe Chef::Knife::UI do
context "when parse_output is true" do
let(:parse_output) { true }
+ let(:klass) { TestObject }
it "returns an edited ruby object" do
expect(subject).to eql(ruby_from_editor)
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..cf8d4d4a4f 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");
@@ -208,7 +208,7 @@ describe Chef::Node::Attribute do
end
describe "when debugging attributes" do
- before do
+ it "gives the value at each level of precedence for a path spec" do
@attributes.default[:foo][:bar] = "default"
@attributes.env_default[:foo][:bar] = "env_default"
@attributes.role_default[:foo][:bar] = "role_default"
@@ -219,9 +219,7 @@ describe Chef::Node::Attribute do
@attributes.env_override[:foo][:bar] = "env_override"
@attributes.force_override[:foo][:bar] = "force_override"
@attributes.automatic[:foo][:bar] = "automatic"
- end
- it "gives the value at each level of precedence for a path spec" do
expected = [
%w{default default},
%w{env_default env_default},
@@ -236,6 +234,25 @@ describe Chef::Node::Attribute do
]
expect(@attributes.debug_value(:foo, :bar)).to eq(expected)
end
+
+ it "works through arrays" do
+ @attributes.default["foo"] = [ { "bar" => "baz" } ]
+
+ expect(@attributes.debug_value(:foo, 0)).to eq(
+ [
+ ["default", { "bar" => "baz" }],
+ ["env_default", :not_present],
+ ["role_default", :not_present],
+ ["force_default", :not_present],
+ ["normal", :not_present],
+ ["override", :not_present],
+ ["role_override", :not_present],
+ ["env_override", :not_present],
+ ["force_override", :not_present],
+ ["automatic", :not_present],
+ ]
+ )
+ end
end
describe "when fetching values based on precedence" do
@@ -459,8 +476,7 @@ describe Chef::Node::Attribute do
expect(@attributes.default["foo"]).to eql({ "bar" => [ "fizz" ] })
end
- it "mutating strings should not mutate the attributes" do
- pending "this is a bug that should be fixed"
+ it "mutating strings should not mutate the attributes in a hash" do
@attributes.default["foo"]["bar"]["baz"] = "fizz"
hash = @attributes["foo"].to_hash
expect(hash).to eql({ "bar" => { "baz" => "fizz" } })
@@ -468,6 +484,15 @@ describe Chef::Node::Attribute do
expect(hash).to eql({ "bar" => { "baz" => "fizzbuzz" } })
expect(@attributes.default["foo"]).to eql({ "bar" => { "baz" => "fizz" } })
end
+
+ it "mutating array elements should not mutate the attributes" do
+ @attributes.default["foo"]["bar"] = [ "fizz" ]
+ hash = @attributes["foo"].to_hash
+ expect(hash).to eql({ "bar" => [ "fizz" ] })
+ hash["bar"][0] << "buzz"
+ expect(hash).to eql({ "bar" => [ "fizzbuzz" ] })
+ expect(@attributes.default["foo"]).to eql({ "bar" => [ "fizz" ] })
+ end
end
describe "dup" do
@@ -475,6 +500,24 @@ describe Chef::Node::Attribute do
@attributes.default[:foo] = %w{foo bar baz} + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ]
@attributes.default[:foo].dup
end
+
+ it "mutating strings should not mutate the attributes in a hash" do
+ @attributes.default["foo"]["bar"]["baz"] = "fizz"
+ hash = @attributes["foo"].dup
+ expect(hash).to eql({ "bar" => { "baz" => "fizz" } })
+ hash["bar"]["baz"] << "buzz"
+ expect(hash).to eql({ "bar" => { "baz" => "fizzbuzz" } })
+ expect(@attributes.default["foo"]).to eql({ "bar" => { "baz" => "fizz" } })
+ end
+
+ it "mutating array elements should not mutate the attributes" do
+ @attributes.default["foo"]["bar"] = [ "fizz" ]
+ hash = @attributes["foo"].dup
+ expect(hash).to eql({ "bar" => [ "fizz" ] })
+ hash["bar"][0] << "buzz"
+ expect(hash).to eql({ "bar" => [ "fizzbuzz" ] })
+ expect(@attributes.default["foo"]).to eql({ "bar" => [ "fizz" ] })
+ end
end
describe "has_key?" do
@@ -490,11 +533,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 +568,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 +1134,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 +1195,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
@@ -1241,4 +1261,16 @@ describe Chef::Node::Attribute do
@attributes.default["foo"]["bar"]["baz"] = "quux"
end
end
+
+ describe "frozen immutable strings" do
+ it "strings in hashes should be frozen" do
+ @attributes.default["foo"]["bar"]["baz"] = "fizz"
+ expect { @attributes["foo"]["bar"]["baz"] << "buzz" }.to raise_error(RuntimeError, "can't modify frozen String")
+ end
+
+ it "strings in arrays should be frozen" do
+ @attributes.default["foo"]["bar"] = [ "fizz" ]
+ expect { @attributes["foo"]["bar"][0] << "buzz" }.to raise_error(RuntimeError, "can't modify frozen String")
+ end
+ end
end
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index 81dd771df3..520bc1ba42 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.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");
@@ -78,7 +78,58 @@ describe Chef::Node::ImmutableMash do
it "should allow mutation" do
expect { @copy["m"] = "m" }.not_to raise_error
end
+ end
+
+ describe "dup" do
+ before do
+ @copy = @immutable_mash.dup
+ end
+
+ it "converts an immutable mash to a new mutable hash" do
+ expect(@copy).to be_instance_of(Mash)
+ end
+
+ it "converts an immutable nested mash to a new mutable hash" do
+ expect(@copy["top_level_4"]["level2"]).to be_instance_of(Mash)
+ end
+
+ it "converts an immutable nested array to a new mutable array" do
+ expect(@copy["top_level_2"]).to be_instance_of(Array)
+ end
+
+ it "should create a mash with the same content" do
+ expect(@copy).to eq(@immutable_mash)
+ end
+
+ it "should allow mutation" do
+ expect { @copy["m"] = "m" }.not_to raise_error
+ end
+ end
+ describe "to_h" do
+ before do
+ @copy = @immutable_mash.to_h
+ end
+
+ it "converts an immutable mash to a new mutable hash" do
+ expect(@copy).to be_instance_of(Hash)
+ end
+
+ it "converts an immutable nested mash to a new mutable hash" do
+ expect(@copy["top_level_4"]["level2"]).to be_instance_of(Hash)
+ end
+
+ it "converts an immutable nested array to a new mutable array" do
+ expect(@copy["top_level_2"]).to be_instance_of(Array)
+ end
+
+ it "should create a mash with the same content" do
+ expect(@copy).to eq(@immutable_mash)
+ end
+
+ it "should allow mutation" do
+ expect { @copy["m"] = "m" }.not_to raise_error
+ end
end
[
@@ -198,6 +249,58 @@ describe Chef::Node::ImmutableArray do
end
end
+ describe "dup" do
+ before do
+ @copy = @immutable_nested_array.dup
+ end
+
+ it "converts an immutable array to a new mutable array" do
+ expect(@copy).to be_instance_of(Array)
+ end
+
+ it "converts an immutable nested array to a new mutable array" do
+ expect(@copy[1]).to be_instance_of(Array)
+ end
+
+ it "converts an immutable nested mash to a new mutable hash" do
+ expect(@copy[2]).to be_instance_of(Mash)
+ end
+
+ it "should create an array with the same content" do
+ expect(@copy).to eq(@immutable_nested_array)
+ end
+
+ it "should allow mutation" do
+ expect { @copy << "m" }.not_to raise_error
+ end
+ end
+
+ describe "to_array" do
+ before do
+ @copy = @immutable_nested_array.to_array
+ end
+
+ it "converts an immutable array to a new mutable array" do
+ expect(@copy).to be_instance_of(Array)
+ end
+
+ it "converts an immutable nested array to a new mutable array" do
+ expect(@copy[1]).to be_instance_of(Array)
+ end
+
+ it "converts an immutable nested mash to a new mutable hash" do
+ expect(@copy[2]).to be_instance_of(Hash)
+ end
+
+ it "should create an array with the same content" do
+ expect(@copy).to eq(@immutable_nested_array)
+ end
+
+ it "should allow mutation" do
+ expect { @copy << "m" }.not_to raise_error
+ end
+ end
+
describe "#[]" do
it "works with array slices" do
expect(@immutable_array[1, 2]).to eql(%w{bar baz})
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index 0480a721af..822f689eab 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@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");
@@ -145,26 +145,4 @@ describe Chef::NodeMap do
end
end
- describe "resource back-compat testing" do
- before :each do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- end
-
- it "should handle :on_platforms => :all" do
- node_map.set(:chef_gem, :foo, :on_platforms => :all)
- allow(node).to receive(:[]).with(:platform).and_return("windows")
- expect(node_map.get(node, :chef_gem)).to eql(:foo)
- end
- it "should handle :on_platforms => [ 'windows' ]" do
- node_map.set(:dsc_script, :foo, :on_platforms => [ "windows" ])
- allow(node).to receive(:[]).with(:platform).and_return("windows")
- expect(node_map.get(node, :dsc_script)).to eql(:foo)
- end
- it "should handle :on_platform => :all" do
- node_map.set(:link, :foo, :on_platform => :all)
- allow(node).to receive(:[]).with(:platform).and_return("windows")
- expect(node_map.get(node, :link)).to eql(:foo)
- end
- end
-
end
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/platform_spec.rb b/spec/unit/platform_spec.rb
deleted file mode 100644
index 3a562d3ce6..0000000000
--- a/spec/unit/platform_spec.rb
+++ /dev/null
@@ -1,269 +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 Chef::Platform do
-
- context "while testing with fake data" do
- def expect_platform_warning(method_name, times: 1, recurse: true)
- expect(Chef).to receive(:deprecated).with(:chef_platform_methods, "Chef::Platform.#{method_name} is deprecated").exactly(times).times
- return unless recurse
-
- expect_platform_warning(:find_provider_for_node, times: times) if method_name == :provider_for_resource
- expect_platform_warning(:find_provider, times: times) if method_name == :find_provider_for_node
- expect_platform_warning(:find, times: times) if method_name == :find_provider
- end
-
- before :all do
- @original_platform_map = Chef::Platform.platforms
- end
-
- after :all do ||
- Chef::Platform.platforms = @original_platform_map
- end
-
- before(:each) do
- Chef::Platform.platforms = {
- :darwin => {
- ">= 10.11" => {
- :file => "new_darwinian",
- },
- "9.2.2" => {
- :file => "darwinian",
- :else => "thing",
- },
- :default => {
- :file => "old school",
- :snicker => "snack",
- },
- },
- :mars_volta => {
- },
- :default => {
- :file => Chef::Provider::File,
- :pax => "brittania",
- :cat => "nice",
- },
- }
- @events = Chef::EventDispatch::Dispatcher.new
- end
-
- it "should allow you to look up a platform by name and version, returning the provider map for it" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("Darwin", "9.2.2")
- expect(pmap).to be_a_kind_of(Hash)
- expect(pmap[:file]).to eql("darwinian")
- end
-
- it "should allow you to look up a platform by name and version using \"greater than\" style operators" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("Darwin", "11.1.0")
- expect(pmap).to be_a_kind_of(Hash)
- expect(pmap[:file]).to eql("new_darwinian")
- end
-
- it "should use the default providers for an os if the specific version does not exist" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("Darwin", "1")
- expect(pmap).to be_a_kind_of(Hash)
- expect(pmap[:file]).to eql("old school")
- end
-
- it "should use the default providers if the os doesn't give me a default, but does exist" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("mars_volta", "1")
- expect(pmap).to be_a_kind_of(Hash)
- expect(pmap[:file]).to eql(Chef::Provider::File)
- end
-
- it "should use the default provider if the os does not exist" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("AIX", "1")
- expect(pmap).to be_a_kind_of(Hash)
- expect(pmap[:file]).to eql(Chef::Provider::File)
- end
-
- it "should merge the defaults for an os with the specific version" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("Darwin", "9.2.2")
- expect(pmap[:file]).to eql("darwinian")
- expect(pmap[:snicker]).to eql("snack")
- end
-
- it "should merge the defaults for an os with the universal defaults" do
- expect_platform_warning(:find)
- pmap = Chef::Platform.find("Darwin", "9.2.2")
- expect(pmap[:file]).to eql("darwinian")
- expect(pmap[:pax]).to eql("brittania")
- end
-
- it "should allow you to look up a provider for a platform directly by symbol" do
- expect_platform_warning(:find_provider)
- expect(Chef::Platform.find_provider("Darwin", "9.2.2", :file)).to eql("darwinian")
- end
-
- it "should raise an exception if a provider cannot be found for a resource type" do
- expect_platform_warning(:find_provider)
- expect { Chef::Platform.find_provider("Darwin", "9.2.2", :coffee) }.to raise_error(Chef::Exceptions::ProviderNotFound)
- end
-
- it "should look up a provider for a resource with a Chef::Resource object" do
- kitty = Chef::Resource::Cat.new("loulou")
- expect_platform_warning(:find_provider)
- expect(Chef::Platform.find_provider("Darwin", "9.2.2", kitty)).to eql("nice")
- end
-
- it "should look up a provider with a node and a Chef::Resource object" do
- kitty = Chef::Resource::Cat.new("loulou")
- node = Chef::Node.new
- node.name("Intel")
- node.automatic_attrs[:platform] = "mac_os_x"
- node.automatic_attrs[:platform_version] = "9.2.2"
- expect_platform_warning(:find_provider_for_node)
- expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql("nice")
- end
-
- it "should not throw an exception when the platform version has an unknown format" do
- expect_platform_warning(:find_provider)
- expect(Chef::Platform.find_provider(:darwin, "bad-version", :file)).to eql("old school")
- end
-
- it "should prefer an explicit provider" do
- kitty = Chef::Resource::Cat.new("loulou")
- allow(kitty).to receive(:provider).and_return(Chef::Provider::File)
- node = Chef::Node.new
- node.name("Intel")
- node.automatic_attrs[:platform] = "mac_os_x"
- node.automatic_attrs[:platform_version] = "9.2.2"
- expect_platform_warning(:find_provider_for_node, recurse: false)
- expect_platform_warning(:find_provider, recurse: false)
- expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql(Chef::Provider::File)
- end
-
- it "should look up a provider based on the resource name if nothing else matches" do
- kitty = Chef::Resource::Cat.new("loulou")
- class Chef::Provider::Cat < Chef::Provider; end
- Chef::Platform.platforms[:default].delete(:cat)
- node = Chef::Node.new
- node.name("Intel")
- node.automatic_attrs[:platform] = "mac_os_x"
- node.automatic_attrs[:platform_version] = "8.5"
- expect_platform_warning(:find_provider_for_node)
- expect(Chef::Platform.find_provider_for_node(node, kitty)).to eql(Chef::Provider::Cat)
- end
-
- def setup_file_resource
- node = Chef::Node.new
- node.automatic_attrs[:platform] = "mac_os_x"
- node.automatic_attrs[:platform_version] = "9.2.2"
- run_context = Chef::RunContext.new(node, {}, @events)
- [ Chef::Resource::File.new("whateva", run_context), run_context ]
- end
-
- it "returns a provider object given a Chef::Resource object which has a valid run context and an action" do
- file, run_context = setup_file_resource
- expect_platform_warning(:provider_for_resource)
- provider = Chef::Platform.provider_for_resource(file, :foo)
- expect(provider).to be_an_instance_of(Chef::Provider::File)
- expect(provider.new_resource).to equal(file)
- expect(provider.run_context).to equal(run_context)
- end
-
- it "returns a provider object given a Chef::Resource object which has a valid run context without an action" do
- file, run_context = setup_file_resource
- expect_platform_warning(:provider_for_resource)
- provider = Chef::Platform.provider_for_resource(file)
- expect(provider).to be_an_instance_of(Chef::Provider::File)
- expect(provider.new_resource).to equal(file)
- expect(provider.run_context).to equal(run_context)
- end
-
- it "raises an error when trying to find the provider for a resource with no run context" do
- file = Chef::Resource::File.new("whateva")
- expect_platform_warning(:provider_for_resource, recurse: false)
- expect { Chef::Platform.provider_for_resource(file) }.to raise_error(ArgumentError)
- end
-
- it "does not support finding a provider by resource and node -- a run context is required" do
- expect { Chef::Platform.provider_for_node("node", "resource") }.to raise_error(NotImplementedError)
- end
-
- it "should update the provider map with map" do
- expect_platform_warning(:set, times: 7)
- Chef::Platform.set(
- :platform => :darwin,
- :version => "9.2.2",
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:darwin]["9.2.2"][:file]).to eql("masterful")
- Chef::Platform.set(
- :platform => :darwin,
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:darwin][:default][:file]).to eql("masterful")
- Chef::Platform.set(
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:default][:file]).to eql("masterful")
-
- Chef::Platform.set(
- :platform => :hero,
- :version => "9.2.2",
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:hero]["9.2.2"][:file]).to eql("masterful")
-
- Chef::Platform.set(
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:default][:file]).to eql("masterful")
-
- Chef::Platform.platforms = {}
-
- Chef::Platform.set(
- :resource => :file,
- :provider => "masterful"
- )
- expect(Chef::Platform.platforms[:default][:file]).to eql("masterful")
-
- Chef::Platform.platforms = { :neurosis => {} }
- Chef::Platform.set(:platform => :neurosis, :resource => :package, :provider => "masterful")
- expect(Chef::Platform.platforms[:neurosis][:default][:package]).to eql("masterful")
-
- end
-
- it "does not overwrite the platform map when using :default platform" do
- expect_platform_warning(:set)
- Chef::Platform.set(
- :resource => :file,
- :platform => :default,
- :provider => "new school"
- )
- expect(Chef::Platform.platforms[:default][:file]).to eql("new school")
- expect(Chef::Platform.platforms[:default][:cat]).to eql("nice")
- end
-
- 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/validation_spec.rb b/spec/unit/property/validation_spec.rb
index 4e1b252863..13afcdfbc2 100644
--- a/spec/unit/property/validation_spec.rb
+++ b/spec/unit/property/validation_spec.rb
@@ -100,13 +100,10 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to be_nil
end
unless tags.include?(:nillable)
- it "changing x to nil warns that the get will change to a set in Chef 13 and does not change the value" do
+ it "changing x to nil does a set" do
resource.instance_eval { @x = "default" }
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /An attempt was made to change x from "default" to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x nil).to eq "default"
- expect(resource.x).to eq "default"
+ expect(resource.x nil).to eq nil
+ expect(resource.x).to eq nil
end
end
end
@@ -116,13 +113,10 @@ describe "Chef::Resource.property validation" do
expect(resource.x nil).to be_nil
expect(resource.x).to be_nil
end
- it "changing x to nil warns that the get will change to a set in Chef 13 and does not change the value" do
+ it "changing x to nil does a set" do
resource.instance_eval { @x = "default" }
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /An attempt was made to change x from "default" to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x nil).to eq "default"
- expect(resource.x).to eq "default"
+ expect(resource.x nil).to eq nil
+ expect(resource.x).to eq nil
end
end
elsif tags.include?(:nillable)
@@ -134,26 +128,17 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to eq nil
end
end
- else
+ elsif tags.include?(:delayed_nil_default_failure)
it "property :x, #{validation}, default: nil warns that the default is invalid" do
- expect { resource_class.class_eval("property :x, #{validation}, default: nil", __FILE__, __LINE__) }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Default value nil is invalid for property x of resource chef_resource_property_spec_(\d+). Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property \(for example, 'property :x, \[ String, nil \], default: nil'\)./
+ expect { resource_class.class_eval("property :x, #{validation}, default: nil", __FILE__, __LINE__) }.not_to raise_error
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed, /Property x must be one of: .* You passed nil./
end
- context "With property :x, #{validation}, default: nil" do
- before do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource_class.class_eval("property :x, #{validation}, default: nil", __FILE__, __LINE__)
- Chef::Config[:treat_deprecation_warnings_as_errors] = true
- end
-
- it "changing x to nil emits a warning that the value is invalid and does not change the value" do
- resource.instance_eval { @x = "default" }
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /nil is an invalid value for x of resource chef_resource_property_spec_(\d+). In Chef 13, this warning will change to an error./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x nil).to eq "default"
- expect(resource.x).to eq "default"
- end
+ elsif tags.include?(:skip_nil_default)
+ # intentionally left blank
+ else
+ it "property :x, #{validation}, default: nil warns that the default is invalid" do
+ expect { resource_class.class_eval("property :x, #{validation}, default: nil", __FILE__, __LINE__) }.to raise_error Chef::Exceptions::ValidationFailed,
+ /Property x must be one of: .* You passed nil./
end
end
end
@@ -174,12 +159,10 @@ describe "Chef::Resource.property validation" do
it "set to invalid value raises ValidationFailed" do
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "set to nil emits a deprecation warning and does a get" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ it "set to nil does a set" do
resource.x "str"
- expect(resource.x nil).to eq "str"
- expect(resource.x).to eq "str"
+ expect(resource.x nil).to eq nil
+ expect(resource.x).to eq nil
end
end
context "when the variable does not have an initial value" do
@@ -206,12 +189,9 @@ describe "Chef::Resource.property validation" do
it "get succeeds" do
expect(resource.x).to eq "default"
end
- it "set(nil) emits a warning that the value will be set, but does not set the value" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /An attempt was made to change x from "default" to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x nil).to eq "default"
- expect(resource.x).to eq "default"
+ it "set(nil) does a set" do
+ expect(resource.x nil).to eq nil
+ expect(resource.x).to eq nil
end
it "set to valid value succeeds" do
expect(resource.x "str").to eq "str"
@@ -328,11 +308,17 @@ describe "Chef::Resource.property validation" do
# Proc
validation_test "is: proc { |x| x }",
[ true, 1 ],
- [ false ]
+ [ false ],
+ # this is somewhat complicated, we test adding `default: nil` and that the default fails, but with a proc the
+ # validation is delayed until access, so we have to test after access not after declaring the default
+ :delayed_nil_default_failure
validation_test "is: proc { |x| x > blah }",
[ 10 ],
- [ -1 ]
+ [ -1 ],
+ # here the test of adding `default: nil` just causes the proc to explode because nil gets passed to the proc
+ # which throws a NoMethodError on NilClass for the `>` method.
+ :skip_nil_default
validation_test "is: nil",
[ ],
@@ -589,15 +575,21 @@ describe "Chef::Resource.property validation" do
it "value nil emits a validation failed error because it must have a value" do
expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
end
- context "and value is set to something other than nil" do
- before { resource.x 10 }
- it "value nil emits a deprecation warning and does a get" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource.x 1
- expect(resource.x nil).to eq 1
- expect(resource.x).to eq 1
- end
+ end
+
+ with_property ":x, String, required: true" do
+ it "if x is not specified, retrieval fails" do
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
+ end
+ it "value nil is not valid (required means 'not nil')" do
+ expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
+ end
+ it "value '1' is valid" do
+ expect(resource.x "1").to eq "1"
+ expect(resource.x).to eq "1"
+ end
+ it "value 1 is invalid" do
+ expect { resource.x 1 }.to raise_error Chef::Exceptions::ValidationFailed
end
end
@@ -625,12 +617,8 @@ describe "Chef::Resource.property validation" do
expect(resource.x 1).to eq 1
expect(resource.x).to eq 1
end
- it "value nil emits a deprecation warning and does a get" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource.x 1
- expect(resource.x nil).to eq 1
- expect(resource.x).to eq 1
+ it "value nil is invalid" do
+ expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
end
end
@@ -643,11 +631,7 @@ describe "Chef::Resource.property validation" do
expect(resource.x).to eq 1
end
it "value nil is invalid" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource.x 1
- expect(resource.x nil).to eq 1
- expect(resource.x).to eq 1
+ expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
end
end
end
@@ -675,15 +659,13 @@ describe "Chef::Resource.property validation" do
end
it "value '1' is invalid" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil does a get" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ it "value nil does a set" do
resource.x 1
resource.x nil
- expect(resource.x).to eq 1
+ expect(resource.x).to eq nil
end
end
end
@@ -709,10 +691,10 @@ describe "Chef::Resource.property validation" do
expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil does a get" do
+ it "value nil does a set" do
resource.x 1
resource.x nil
- expect(resource.x).to eq 1
+ expect(resource.x).to eq nil
end
end
end
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 50ff3434f6..bd90891b63 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -82,12 +82,10 @@ describe "Chef::Resource.property" do
expect(resource.bare_property 10).to eq 10
expect(resource.bare_property).to eq 10
end
- it "emits a deprecation warning and does a get, if set to nil" do
+ it "nil does a set" do
expect(resource.bare_property 10).to eq 10
- expect { resource.bare_property nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.bare_property nil).to eq 10
- expect(resource.bare_property).to eq 10
+ expect(resource.bare_property nil).to eq nil
+ expect(resource.bare_property).to eq nil
end
it "can be updated" do
expect(resource.bare_property 10).to eq 10
@@ -110,6 +108,16 @@ describe "Chef::Resource.property" do
end
end
+ with_property ":Straße" do
+ it "properties with UTF-8 in their name work" do
+ expect(resource.Straße).to eql(nil)
+ expect(resource.Straße "foo").to eql("foo")
+ expect(resource.Straße).to eql("foo")
+ expect(resource.Straße = "bar").to eql("bar")
+ expect(resource.Straße).to eql("bar")
+ end
+ end
+
with_property ":x, name_property: true" do
context "and subclass" do
let(:subresource_class) do
@@ -585,24 +593,8 @@ describe "Chef::Resource.property" do
end
context "validation of defaults" do
- it "When a class is declared with property :x, String, default: 10, a warning is emitted" do
- expect { resource_class.class_eval { property :x, String, default: 10 } }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Default value 10 is invalid for property x of resource chef_resource_property_spec_(\d+). In Chef 13 this will become an error: Property x must be one of: String! You passed 10./
- end
- context "With property :x, String, default: 10" do
- before do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- resource_class.class_eval { property :x, String, default: 10 }
- Chef::Config[:treat_deprecation_warnings_as_errors] = true
- end
-
- it "when x is set, no error is raised" do
- expect(resource.x "hi").to eq "hi"
- expect(resource.x).to eq "hi"
- end
- it "when x is retrieved, no validation error is raised" do
- expect(resource.x).to eq 10
- end
+ it "When a class is declared with property :x, String, default: 10, it immediately fails validation" do
+ expect { resource_class.class_eval { property :x, String, default: 10 } }.to raise_error Chef::Exceptions::ValidationFailed
end
with_property ":x, String, default: lazy { Namer.next_index }" do
@@ -613,12 +605,9 @@ describe "Chef::Resource.property" do
expect(resource.x "hi").to eq "hi"
expect(resource.x).to eq "hi"
end
- it "when x is retrieved, an invalid default warning is emitted and the value is returned" do
- expect { resource.x }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Default value 1 is invalid for property x of resource chef_resource_property_spec_(\d+). In Chef 13 this will become an error: Property x must be one of: String! You passed 1./
+ it "when x is retrieved, it fails validation" do
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
expect(Namer.current_index).to eq 1
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x).to eq 2
end
end
@@ -731,11 +720,8 @@ describe "Chef::Resource.property" do
end
end
with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: 10' do
- it "when x is retrieved, it is coerced and emits an invalid default warning, but still returns the value" do
- expect { resource.x }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Default value 10 is invalid for property x of resource chef_resource_property_spec_(\d+). In Chef 13 this will become an error: Property x must be one of: Integer! You passed "101"./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x).to eq "102"
+ it "when x is retrieved, it is coerced and fails validation" do
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
end
with_property ':x, String, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
@@ -744,11 +730,8 @@ describe "Chef::Resource.property" do
end
end
with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
- it "when x is retrieved, it is coerced and emits an invalid default warning; the value is still returned." do
- expect { resource.x }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Default value 10 is invalid for property x of resource chef_resource_property_spec_(\d+). In Chef 13 this will become an error: Property x must be one of: Integer! You passed "101"./
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect(resource.x).to eq "102"
+ it "when x is retrieved, it is coerced and fails validation" do
+ expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
end
with_property ':x, proc { |v| Namer.next_index; true }, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do
@@ -1019,74 +1002,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
@@ -1108,7 +1040,7 @@ describe "Chef::Resource.property" do
include Chef::Mixin::Properties
property_type(is: [:a, :b], default: :c)
end
- end.to raise_error(Chef::Exceptions::DeprecatedFeatureError, /Default value :c is invalid for property <property type>./)
+ end.to raise_error(Chef::Exceptions::ValidationFailed)
expect do
module ::PropertySpecPropertyTypes
include Chef::Mixin::Properties
@@ -1177,6 +1109,20 @@ describe "Chef::Resource.property" do
end
+ context "redefining Object methods" do
+ it "disallows redefining Object methods" do
+ expect { resource_class.class_eval { property :hash } }.to raise_error(ArgumentError)
+ end
+
+ it "disallows redefining Chef::Resource methods" do
+ expect { resource_class.class_eval { property :action } }.to raise_error(ArgumentError)
+ end
+
+ it "allows redefining properties on Chef::Resource" do
+ expect { resource_class.class_eval { property :sensitive } }.not_to raise_error
+ end
+ end
+
context "with a custom property type" do
class CustomPropertyType < Chef::Property
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/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb
deleted file mode 100644
index 910f01bfeb..0000000000
--- a/spec/unit/provider/package/easy_install_spec.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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 Chef::Provider::Package::EasyInstall do
- before(:each) do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::EasyInstallPackage.new("boto")
- @new_resource.version("1.8d")
-
- @provider = Chef::Provider::Package::EasyInstall.new(@new_resource, @run_context)
-
- @stdin = StringIO.new
- @stdout = StringIO.new
- @status = double("Status", :exitstatus => 0)
- @stderr = StringIO.new
- @pid = 2342
- allow(@provider).to receive(:popen4).and_return(@status)
- end
-
- describe "easy_install_binary_path" do
- it "should return a Chef::Provider::EasyInstall object" do
- provider = Chef::Provider::Package::EasyInstall.new(@node, @new_resource)
- expect(provider).to be_a_kind_of(Chef::Provider::Package::EasyInstall)
- end
-
- it "should set the current resources package name to the new resources package name" do
- allow($stdout).to receive(:write)
- @provider.load_current_resource
- expect(@provider.current_resource.package_name).to eq(@new_resource.package_name)
- end
-
- it "should return a relative path to easy_install if no easy_install_binary is given" do
- expect(@provider.easy_install_binary_path).to eql("easy_install")
- end
-
- it "should return a specific path to easy_install if a easy_install_binary is given" do
- expect(@new_resource).to receive(:easy_install_binary).and_return("/opt/local/bin/custom/easy_install")
- expect(@provider.easy_install_binary_path).to eql("/opt/local/bin/custom/easy_install")
- end
-
- end
-
- describe "actions_on_package" do
- it "should run easy_install with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "boto==1.8d", { timeout: 900 }
- )
- @provider.install_package("boto", "1.8d")
- end
-
- it "should run easy_install with the package name and version and specified options" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "--always-unzip", "boto==1.8d", { timeout: 900 }
- )
- allow(@new_resource).to receive(:options).and_return("--always-unzip")
- @provider.install_package("boto", "1.8d")
- end
-
- it "should run easy_install with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "boto==1.8d", { timeout: 900 }
- )
- @provider.upgrade_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-m", "boto", { timeout: 900 }
- )
- @provider.remove_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version and specified options" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-x", "-m", "boto", { timeout: 900 }
- )
- allow(@new_resource).to receive(:options).and_return("-x")
- @provider.remove_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-m", "boto", { timeout: 900 }
- )
- @provider.purge_package("boto", "1.8d")
- end
-
- 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/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb
index c6835bed64..584176b944 100644
--- a/spec/unit/provider/service/solaris_smf_service_spec.rb
+++ b/spec/unit/provider/service/solaris_smf_service_spec.rb
@@ -198,6 +198,33 @@ describe Chef::Provider::Service::Solaris do
end
end
+ describe "when enabling the service recursively" do
+ before(:each) do
+ @provider.current_resource = @current_resource
+ end
+
+ it "should call svcadm enable -s -r chef" do
+ @new_resource.options("-r")
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.enable_service).to be_truthy
+ expect(@current_resource.enabled).to be_truthy
+ end
+
+ it "should call svcadm enable -s -r -t chef when passed an array of options" do
+ @new_resource.options(["-r", "-t"])
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
+ expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.enable_service).to be_truthy
+ expect(@current_resource.enabled).to be_truthy
+ end
+
+ end
+
describe "when disabling the service" do
before(:each) do
@provider.current_resource = @current_resource
@@ -215,7 +242,16 @@ describe Chef::Provider::Service::Solaris do
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success)
@provider.load_current_resource
- expect(@provider.stop_service).to be_truthy
+ expect(@provider.disable_service).to be_truthy
+ expect(@current_resource.enabled).to be_falsey
+ end
+
+ it "should call svcadm disable chef with options" do
+ @new_resource.options("-t")
+ expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status)
+ expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success)
+ @provider.load_current_resource
+ expect(@provider.disable_service).to be_truthy
expect(@current_resource.enabled).to be_falsey
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_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index ec102209ab..9a66df82b3 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -561,7 +561,6 @@ describe Chef::ProviderResolver do
deploy: [ Chef::Resource::Deploy, Chef::Provider::Deploy::Timestamped ],
deploy_revision: [ Chef::Resource::DeployRevision, Chef::Provider::Deploy::Revision ],
directory: [ Chef::Resource::Directory, Chef::Provider::Directory ],
- easy_install_package: [ Chef::Resource::EasyInstallPackage, Chef::Provider::Package::EasyInstall ],
erl_call: [ Chef::Resource::ErlCall, Chef::Provider::ErlCall ],
execute: [ Chef::Resource::Execute, Chef::Provider::Execute ],
file: [ Chef::Resource::File, Chef::Provider::File ],
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..cb500da34a 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,19 +248,11 @@ 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)
end
- it "does not insert two resources if create_if_missing is used" do
- zm_resource
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- recipe.declare_resource(:zen_master, "klopp", create_if_missing: true)
- expect(run_context.resource_collection.count).to eql(1)
- end
-
context "injecting a different run_context" do
let(:run_context2) do
events = Chef::EventDispatch::Dispatcher.new
@@ -418,7 +307,7 @@ describe Chef::Recipe do
it "gives a sane error message when using method_missing" do
expect do
recipe.no_such_resource("foo")
- end.to raise_error(NoMethodError, %q{No resource or method named `no_such_resource' for `Chef::Recipe "test"'})
+ end.to raise_error(NoMethodError, /undefined method `no_such_resource' for cookbook: hjk, recipe: test :Chef::Recipe/)
end
it "gives a sane error message when using method_missing 'bare'" do
@@ -427,7 +316,7 @@ describe Chef::Recipe do
# Giving an argument will change this from NameError to NoMethodError
no_such_resource
end
- end.to raise_error(NameError, %q{No resource, method, or local variable named `no_such_resource' for `Chef::Recipe "test"'})
+ end.to raise_error(NameError, /undefined local variable or method `no_such_resource' for cookbook: hjk, recipe: test :Chef::Recipe/)
end
it "gives a sane error message when using build_resource" do
@@ -453,58 +342,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/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index 6886ce1f31..05c37446a6 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software, Inc.
+# Copyright:: Copyright 2010-2017, Chef Software Inc.
#p License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -64,7 +64,7 @@ describe Chef::Resource::CookbookFile do
end
it "describes the state" do
- state = @cookbook_file.state
+ state = @cookbook_file.state_for_resource_reporter
if Chef::Platform.windows?
puts state
expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb
index 6e867b75e1..e2bfc321e8 100644
--- a/spec/unit/resource/cron_spec.rb
+++ b/spec/unit/resource/cron_spec.rb
@@ -170,7 +170,7 @@ describe Chef::Resource::Cron do
end
it "describes the state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:minute]).to eq("1")
expect(state[:hour]).to eq("2")
expect(state[:day]).to eq("3")
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb
index 33f16b4a89..e008d79c29 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
@@ -270,7 +270,7 @@ describe Chef::Resource::Deploy do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:deploy_to]).to eq("/")
expect(state[:revision]).to eq("1.2.3")
end
diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb
index cfb3ade135..b3a0134024 100644
--- a/spec/unit/resource/directory_spec.rb
+++ b/spec/unit/resource/directory_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");
@@ -69,7 +69,7 @@ describe Chef::Resource::Directory do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0664")
expect(state[:owner]).to eq("root")
diff --git a/spec/unit/resource/easy_install_package_spec.rb b/spec/unit/resource/easy_install_package_spec.rb
deleted file mode 100644
index ce8e6d8bf6..0000000000
--- a/spec/unit/resource/easy_install_package_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "spec_helper"
-require "support/shared/unit/resource/static_provider_resolution"
-
-describe Chef::Resource::EasyInstallPackage, "initialize" do
-
- static_provider_resolution(
- resource: Chef::Resource::EasyInstallPackage,
- provider: Chef::Provider::Package::EasyInstall,
- name: :easy_install_package,
- action: :install
- )
-
- before(:each) do
- @resource = Chef::Resource::EasyInstallPackage.new("foo")
- end
-
- it "should allow you to set the easy_install_binary attribute" do
- @resource.easy_install_binary "/opt/local/bin/easy_install"
- expect(@resource.easy_install_binary).to eql("/opt/local/bin/easy_install")
- end
-end
diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb
index cff862b69e..1c63ab519f 100644
--- a/spec/unit/resource/env_spec.rb
+++ b/spec/unit/resource/env_spec.rb
@@ -73,7 +73,7 @@ describe Chef::Resource::Env do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:value]).to eq("level7")
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/file_spec.rb b/spec/unit/resource/file_spec.rb
index 19304cb6b8..4004798dad 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_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");
@@ -101,7 +101,7 @@ describe Chef::Resource::File do
context "on unix", :unix_only do
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:owner]).to eq("root")
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0644")
@@ -121,7 +121,7 @@ describe Chef::Resource::File do
@resource.rights :full_control, "DOMAIN\User"
end
it "describes its state including windows ACL attributes" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:rights]).to eq([ { :permissions => :read, :principals => "Everyone" },
{ :permissions => :full_control, :principals => "DOMAIN\User" } ])
end
diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb
index 9d9b5c1111..8772f37a2b 100644
--- a/spec/unit/resource/group_spec.rb
+++ b/spec/unit/resource/group_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@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");
@@ -151,7 +151,7 @@ describe Chef::Resource::Group, "append" do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:members]).to eql(%w{blastoise pikachu})
end
diff --git a/spec/unit/resource/ifconfig_spec.rb b/spec/unit/resource/ifconfig_spec.rb
index eceba0c319..699ebf1233 100644
--- a/spec/unit/resource/ifconfig_spec.rb
+++ b/spec/unit/resource/ifconfig_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Resource::Ifconfig do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:inet_addr]).to eq("434.2343.23")
expect(state[:mask]).to eq("255.255.545")
end
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index bd0976d8ea..adfd0020f5 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_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");
@@ -121,7 +121,7 @@ describe Chef::Resource::Link do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:to]).to eq("/to/dir/file.tar")
expect(state[:owner]).to eq("root")
expect(state[:group]).to eq("0664")
diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb
index fe9acf807b..f3cadbe499 100644
--- a/spec/unit/resource/mdadm_spec.rb
+++ b/spec/unit/resource/mdadm_spec.rb
@@ -93,7 +93,7 @@ describe Chef::Resource::Mdadm do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:devices]).to eql(%w{device1 device2})
expect(state[:level]).to eq(1)
expect(state[:chunk]).to eq(42)
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index 832f7644ac..466b6ac8c0 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.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");
@@ -181,7 +181,7 @@ describe Chef::Resource::Mount do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:mount_point]).to eq("123.456")
expect(state[:device_type]).to eql(:device)
expect(state[:fstype]).to eq("ranked")
@@ -202,7 +202,7 @@ describe Chef::Resource::Mount do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:mount_point]).to eq("T:")
expect(state[:username]).to eq("Administrator")
expect(state[:password]).to eq("Jetstream123!")
diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb
index cf1748002b..574c09eeba 100644
--- a/spec/unit/resource/ohai_spec.rb
+++ b/spec/unit/resource/ohai_spec.rb
@@ -49,7 +49,7 @@ describe Chef::Resource::Ohai do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:plugin]).to eq("passwd")
end
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index 7ec3c198e4..8c00ea2bdd 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_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");
@@ -72,7 +72,7 @@ describe Chef::Resource::Package do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:version]).to eq("10.9.8")
expect(state[:options]).to eq("-al")
end
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index d378da3ed0..067f2da36a 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@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");
@@ -210,6 +210,6 @@ describe Chef::Resource::RegistryKey, "state" do
it "should return scrubbed values" do
@resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ])
- expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] } )
+ expect(@resource.state_for_resource_reporter).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] } )
end
end
diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb
index cdca214db6..370b8d8225 100644
--- a/spec/unit/resource/remote_directory_spec.rb
+++ b/spec/unit/resource/remote_directory_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");
@@ -84,7 +84,7 @@ describe Chef::Resource::RemoteDirectory do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:files_owner]).to eq("root")
expect(state[:files_group]).to eq("supergroup")
expect(state[:files_mode]).to eq("0664")
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 274f98e7f4..eca3db3420 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_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");
@@ -183,7 +183,7 @@ describe Chef::Resource::RemoteFile do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
if Chef::Platform.windows?
puts state
expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
diff --git a/spec/unit/resource/route_spec.rb b/spec/unit/resource/route_spec.rb
index 259ccf7eab..884b477365 100644
--- a/spec/unit/resource/route_spec.rb
+++ b/spec/unit/resource/route_spec.rb
@@ -95,7 +95,7 @@ describe Chef::Resource::Route do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:netmask]).to eq("lemask")
expect(state[:gateway]).to eq("111.111.111")
end
diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb
index f39334348e..679b3bc1fc 100644
--- a/spec/unit/resource/scm_spec.rb
+++ b/spec/unit/resource/scm_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Daniel DeLeo (<dan@kallistec.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");
@@ -174,7 +174,7 @@ describe Chef::Resource::Scm do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:revision]).to eq("1.2.3")
end
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..67a4635983 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");
@@ -124,6 +124,27 @@ describe Chef::Resource::Service do
end.to raise_error(ArgumentError)
end
+ it "should accept an array for options" do
+ @resource.options ["-r", "-s"]
+ expect(@resource.options).to eql(["-r", "-s"])
+ end
+
+ it "should accept a string for options" do
+ @resource.options "-r"
+ expect(@resource.options).to eql(["-r"])
+ end
+
+ it "should accept a string with multiple flags for options" do
+ @resource.options "-r -s"
+ expect(@resource.options).to eql(["-r", "-s"])
+ end
+
+ it "should not accept a boolean for options" do
+ expect do
+ @resource.options true
+ end.to raise_error(ArgumentError)
+ end
+
%w{enabled running}.each do |attrib|
it "should accept true for #{attrib}" do
@resource.send(attrib, true)
@@ -146,13 +167,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
@@ -166,7 +187,7 @@ describe Chef::Resource::Service do
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:enabled]).to eql(true)
expect(state[:running]).to eql(false)
end
@@ -175,5 +196,4 @@ describe Chef::Resource::Service do
expect(@resource.identity).to eq("superfriend")
end
end
-
end
diff --git a/spec/unit/resource/systemd_unit_spec.rb b/spec/unit/resource/systemd_unit_spec.rb
index 7e46872525..ab1004fab0 100644
--- a/spec/unit/resource/systemd_unit_spec.rb
+++ b/spec/unit/resource/systemd_unit_spec.rb
@@ -109,7 +109,7 @@ describe Chef::Resource::SystemdUnit do
@resource.masked false
@resource.static false
@resource.content "test"
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:active]).to eq(true)
expect(state[:enabled]).to eq(true)
expect(state[:masked]).to eq(false)
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 9060f02d29..966a86ba6b 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_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");
@@ -88,7 +88,7 @@ describe Chef::Resource::Template do
context "on unix", :unix_only do
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:owner]).to eq("root")
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0644")
diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb
index 138ffb1bfe..1a3f0284e3 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
@@ -119,7 +119,7 @@ end
end
it "describes its state" do
- state = @resource.state
+ state = @resource.state_for_resource_reporter
expect(state[:uid]).to eq(123)
expect(state[:gid]).to eq(456)
expect(state[:home]).to eq("/usr/local/root/")
diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb
index 5feb34833a..76038e51b9 100644
--- a/spec/unit/resource_collection_spec.rb
+++ b/spec/unit/resource_collection_spec.rb
@@ -291,10 +291,10 @@ describe Chef::ResourceCollection do
expect(rc.respond_to?(:from_json)).to eq(false)
end
- it "should convert from json using the CHEF::JSONCompat library" do
+ it "should convert from json using the Chef::JSONCompat library" do
rc << resource
json = Chef::JSONCompat.to_json(rc)
- s_rc = Chef::JSONCompat.from_json(json)
+ s_rc = Chef::ResourceCollection.from_json(json)
expect(s_rc).to be_a_kind_of(Chef::ResourceCollection)
expect(s_rc[0].name).to eql(resource.name)
end
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 84cfb52418..4fcfb01233 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -3,7 +3,7 @@
# Author:: Prajakta Purohit (<prajakta@chef.io>)
# Author:: Tyler Cloke (<tyler@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");
@@ -399,11 +399,11 @@ describe Chef::ResourceReporter do
end
it "includes an updated resource's initial state" do
- expect(@first_update_report["before"]).to eq(current_resource.state)
+ expect(@first_update_report["before"]).to eq(current_resource.state_for_resource_reporter)
end
it "includes an updated resource's final state" do
- expect(@first_update_report["after"]).to eq(new_resource.state)
+ expect(@first_update_report["after"]).to eq(new_resource.state_for_resource_reporter)
end
it "includes the resource's name" do
@@ -540,11 +540,11 @@ describe Chef::ResourceReporter do
end
it "includes an updated resource's initial state" do
- expect(@first_update_report["before"]).to eq(@current_resource.state)
+ expect(@first_update_report["before"]).to eq(@current_resource.state_for_resource_reporter)
end
it "includes an updated resource's final state" do
- expect(@first_update_report["after"]).to eq(@new_resource.state)
+ expect(@first_update_report["after"]).to eq(@new_resource.state_for_resource_reporter)
end
it "includes the resource's name" do
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 2f75ba0241..a806c5d1d9 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");
@@ -160,7 +160,7 @@ describe Chef::Resource do
end
it "describes its state" do
- resource_state = file_resource.state
+ resource_state = file_resource.state_for_resource_reporter
expect(resource_state.keys).to match_array([:checksum, :owner, :group, :mode])
expect(resource_state[:checksum]).to eq("abc123")
expect(resource_state[:owner]).to eq("root")
@@ -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")
@@ -506,24 +484,12 @@ describe Chef::Resource do
describe "self.json_create" do
it "should deserialize itself from json" do
json = Chef::JSONCompat.to_json(resource)
- serialized_node = Chef::JSONCompat.from_json(json)
+ serialized_node = Chef::Resource.from_json(json)
expect(serialized_node).to be_a_kind_of(Chef::Resource)
expect(serialized_node.name).to eql(resource.name)
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)
@@ -583,31 +549,18 @@ describe Chef::Resource do
expect { retriable_resource.run_action(:purr) }.to raise_error(RuntimeError)
expect(retriable_resource.retries).to eq(3)
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
+ it "should not rescue from non-StandardError exceptions" do
+ retriable_resource.retries(3)
+ retriable_resource.retry_delay(0) # No need to wait.
- expect(OverrideProviderBaseTest.provider_base).to eq(Chef::Provider::Package)
- end
+ provider = Chef::Provider::SnakeOil.new(retriable_resource, run_context)
+ allow(Chef::Provider::SnakeOil).to receive(:new).and_return(provider)
+ allow(provider).to receive(:action_purr).and_raise(LoadError)
- 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)
+ expect(retriable_resource).not_to receive(:sleep)
+ expect { retriable_resource.run_action(:purr) }.to raise_error(LoadError)
end
-
end
it "runs an action by finding its provider, loading the current resource and then running the action" do
@@ -857,11 +810,7 @@ describe Chef::Resource do
snitch_var1 = snitch_var2 = 0
runner = Chef::Runner.new(run_context)
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- Chef::Platform.set(
- :resource => :cat,
- :provider => Chef::Provider::SnakeOil
- )
+ Chef::Provider::SnakeOil.provides :cat
resource1.only_if { snitch_var1 = 1 }
resource1.not_if { snitch_var2 = 2 }
diff --git a/spec/unit/rest/auth_credentials_spec.rb b/spec/unit/rest/auth_credentials_spec.rb
deleted file mode 100644
index 2728463c81..0000000000
--- a/spec/unit/rest/auth_credentials_spec.rb
+++ /dev/null
@@ -1,292 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@chef.io>)
-# Author:: Christopher Brown (<cb@chef.io>)
-# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
-# Copyright:: Copyright 2010-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"
-require "uri"
-require "net/https"
-
-describe Chef::REST::AuthCredentials do
- before do
- @key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key.pem"
- @key = OpenSSL::PKey::RSA.new(IO.read(@key_file_fixture).strip)
- @auth_credentials = Chef::REST::AuthCredentials.new("client-name", @key)
- end
-
- it "has a client name" do
- expect(@auth_credentials.client_name).to eq("client-name")
- end
-
- it "loads the private key when initialized with the path to the key" do
- expect(@auth_credentials.key).to respond_to(:private_encrypt)
- expect(@auth_credentials.key).to eq(@key)
- end
-
- describe "when loading the private key" do
- it "strips extra whitespace before checking the key" do
- key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key_with_whitespace.pem"
- expect { Chef::REST::AuthCredentials.new("client-name", @key_file_fixture) }.not_to raise_error
- end
- end
-
- describe "generating signature headers for a request" do
- before do
- @request_time = Time.at(1270920860)
- @request_params = { :http_method => :POST, :path => "/clients", :body => '{"some":"json"}', :host => "localhost" }
- allow(Chef::Config).to(
- receive(:[]).with(:authentication_protocol_version).and_return(protocol_version))
- end
-
- context "when configured for version 1.0 of the authn protocol" do
- let(:protocol_version) { "1.0" }
-
- it "generates signature headers for the request" do
- allow(Time).to receive(:now).and_return(@request_time)
- actual = @auth_credentials.signature_headers(@request_params)
- expect(actual["HOST"]).to eq("localhost")
- expect(actual["X-OPS-AUTHORIZATION-1"]).to eq("kBssX1ENEwKtNYFrHElN9vYGWS7OeowepN9EsYc9csWfh8oUovryPKDxytQ/")
- expect(actual["X-OPS-AUTHORIZATION-2"]).to eq("Wc2/nSSyxdWJjjfHzrE+YrqNQTaArOA7JkAf5p75eTUonCWcvNPjFrZVgKGS")
- expect(actual["X-OPS-AUTHORIZATION-3"]).to eq("yhzHJQh+lcVA9wwARg5Hu9q+ddS8xBOdm3Vp5atl5NGHiP0loiigMYvAvzPO")
- expect(actual["X-OPS-AUTHORIZATION-4"]).to eq("r9853eIxwYMhn5hLGhAGFQznJbE8+7F/lLU5Zmk2t2MlPY8q3o1Q61YD8QiJ")
- expect(actual["X-OPS-AUTHORIZATION-5"]).to eq("M8lIt53ckMyUmSU0DDURoiXLVkE9mag/6Yq2tPNzWq2AdFvBqku9h2w+DY5k")
- expect(actual["X-OPS-AUTHORIZATION-6"]).to eq("qA5Rnzw5rPpp3nrWA9jKkPw4Wq3+4ufO2Xs6w7GCjA==")
- expect(actual["X-OPS-CONTENT-HASH"]).to eq("1tuzs5XKztM1ANrkGNPah6rW9GY=")
- expect(actual["X-OPS-SIGN"]).to match(%r{(version=1\.0)|(algorithm=sha1;version=1.0;)})
- expect(actual["X-OPS-TIMESTAMP"]).to eq("2010-04-10T17:34:20Z")
- expect(actual["X-OPS-USERID"]).to eq("client-name")
- end
- end
-
- context "when configured for version 1.1 of the authn protocol" do
- let(:protocol_version) { "1.1" }
-
- it "generates the correct signature for version 1.1" do
- allow(Time).to receive(:now).and_return(@request_time)
- actual = @auth_credentials.signature_headers(@request_params)
- expect(actual["HOST"]).to eq("localhost")
- expect(actual["X-OPS-CONTENT-HASH"]).to eq("1tuzs5XKztM1ANrkGNPah6rW9GY=")
- expect(actual["X-OPS-SIGN"]).to eq("algorithm=sha1;version=1.1;")
- expect(actual["X-OPS-TIMESTAMP"]).to eq("2010-04-10T17:34:20Z")
- expect(actual["X-OPS-USERID"]).to eq("client-name")
-
- # mixlib-authN will test the actual signature stuff for each version of
- # the protocol so we won't test it again here.
- end
- end
- end
-end
-
-describe Chef::REST::RESTRequest do
- let(:url) { URI.parse("http://chef.example.com:4000/?q=chef_is_awesome") }
-
- def new_request(method = nil)
- method ||= :POST
- Chef::REST::RESTRequest.new(method, url, @req_body, @headers)
- end
-
- before do
- @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + "/ssl/private_key.pem")
- @req_body = '{"json_data":"as_a_string"}'
- @headers = { "Content-type" => "application/json",
- "Accept" => "application/json",
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => "chef.example.com:4000" }
- @request = Chef::REST::RESTRequest.new(:POST, url, @req_body, @headers)
- end
-
- it "stores the url it was created with" do
- expect(@request.url).to eq(url)
- end
-
- it "stores the HTTP method" do
- expect(@request.method).to eq(:POST)
- end
-
- it "adds the chef version header" do
- expect(@request.headers).to eq(@headers.merge("X-Chef-Version" => ::Chef::VERSION))
- end
-
- describe "configuring the HTTP request" do
- let(:url) do
- URI.parse("http://homie:theclown@chef.example.com:4000/?q=chef_is_awesome")
- end
-
- it "configures GET requests" do
- @req_body = nil
- rest_req = new_request(:GET)
- expect(rest_req.http_request).to be_a_kind_of(Net::HTTP::Get)
- expect(rest_req.http_request.path).to eq("/?q=chef_is_awesome")
- expect(rest_req.http_request.body).to be_nil
- end
-
- it "configures POST requests, including the body" do
- expect(@request.http_request).to be_a_kind_of(Net::HTTP::Post)
- expect(@request.http_request.path).to eq("/?q=chef_is_awesome")
- expect(@request.http_request.body).to eq(@req_body)
- end
-
- it "configures PUT requests, including the body" do
- rest_req = new_request(:PUT)
- expect(rest_req.http_request).to be_a_kind_of(Net::HTTP::Put)
- expect(rest_req.http_request.path).to eq("/?q=chef_is_awesome")
- expect(rest_req.http_request.body).to eq(@req_body)
- end
-
- it "configures DELETE requests" do
- rest_req = new_request(:DELETE)
- expect(rest_req.http_request).to be_a_kind_of(Net::HTTP::Delete)
- expect(rest_req.http_request.path).to eq("/?q=chef_is_awesome")
- expect(rest_req.http_request.body).to be_nil
- end
-
- it "configures HTTP basic auth" do
- rest_req = new_request(:GET)
- expect(rest_req.http_request.to_hash["authorization"]).to eq(["Basic aG9taWU6dGhlY2xvd24="])
- end
- end
-
- describe "configuring the HTTP client" do
- it "configures the HTTP client for the host and port" do
- http_client = new_request.http_client
- expect(http_client.address).to eq("chef.example.com")
- expect(http_client.port).to eq(4000)
- end
-
- it "configures the HTTP client with the read timeout set in the config file" do
- Chef::Config[:rest_timeout] = 9001
- expect(new_request.http_client.read_timeout).to eq(9001)
- end
-
- describe "for proxy" do
- before do
- stub_const("ENV", "http_proxy" => "http://proxy.example.com:3128",
- "https_proxy" => "http://sproxy.example.com:3129",
- "http_proxy_user" => nil,
- "http_proxy_pass" => nil,
- "https_proxy_user" => nil,
- "https_proxy_pass" => nil,
- "no_proxy" => nil
- )
- end
-
- describe "with :no_proxy nil" do
- it "configures the proxy address and port when using http scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(true)
- expect(http_client.proxy_address).to eq("proxy.example.com")
- expect(http_client.proxy_port).to eq(3128)
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
-
- context "when the url has an https scheme" do
- let(:url) { URI.parse("https://chef.example.com:4000/?q=chef_is_awesome") }
-
- it "configures the proxy address and port when using https scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(true)
- expect(http_client.proxy_address).to eq("sproxy.example.com")
- expect(http_client.proxy_port).to eq(3129)
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
- end
- end
-
- describe "with :no_proxy set" do
- before do
- stub_const("ENV", "no_proxy" => "10.*,*.example.com")
- end
-
- it "does not configure the proxy address and port when using http scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(false)
- expect(http_client.proxy_address).to be_nil
- expect(http_client.proxy_port).to be_nil
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
-
- context "when the url has an https scheme" do
- let(:url) { URI.parse("https://chef.example.com:4000/?q=chef_is_awesome") }
-
- it "does not configure the proxy address and port when using https scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(false)
- expect(http_client.proxy_address).to be_nil
- expect(http_client.proxy_port).to be_nil
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
- end
- end
-
- describe "with :http_proxy_user and :http_proxy_pass set" do
- before do
- stub_const("ENV", "http_proxy" => "http://homie:theclown@proxy.example.com:3128")
- end
-
- it "configures the proxy user and pass when using http scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(true)
- expect(http_client.proxy_user).to eq("homie")
- expect(http_client.proxy_pass).to eq("theclown")
- end
-
- context "when the url has an https scheme" do
- let(:url) { URI.parse("https://chef.example.com:4000/?q=chef_is_awesome") }
-
- it "does not configure the proxy user and pass when using https scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(false)
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
- end
- end
-
- describe "with :https_proxy_user and :https_proxy_pass set" do
- before do
- stub_const("ENV", "http_proxy" => "http://proxy.example.com:3128",
- "https_proxy" => "https://homie:theclown@sproxy.example.com:3129"
- )
- end
-
- it "does not configure the proxy user and pass when using http scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(true)
- expect(http_client.proxy_user).to be_nil
- expect(http_client.proxy_pass).to be_nil
- end
-
- context "when the url has an https scheme" do
- let(:url) { URI.parse("https://chef.example.com:4000/?q=chef_is_awesome") }
-
- it "configures the proxy user and pass when using https scheme" do
- http_client = new_request.http_client
- expect(http_client.proxy?).to eq(true)
- expect(http_client.proxy_user).to eq("homie")
- expect(http_client.proxy_pass).to eq("theclown")
- end
- end
- end
- end
- end
-end
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb
deleted file mode 100644
index ea3bd88023..0000000000
--- a/spec/unit/rest_spec.rb
+++ /dev/null
@@ -1,753 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@chef.io>)
-# Author:: Christopher Brown (<cb@chef.io>)
-# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
-# Copyright:: Copyright 2010-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"
-require "uri"
-require "net/https"
-require "stringio"
-
-SIGNING_KEY_DOT_PEM = "-----BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEA49TA0y81ps0zxkOpmf5V4/c4IeR5yVyQFpX3JpxO4TquwnRh
-8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE6915kXSuk/cWIcNozujLK7tkuPEy
-YVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXrWqYCnhxgOjxocenREYNhZ/OETIei
-PbOku47vB4nJK/0GhKBytL2XnsRgfKgDxf42BqAi1jglIdeq8lAWZNF9TbNBU21A
-O1iuT7Pm6LyQujhggPznR5FJhXKRUARXBJZawxpGV4dGtdcahwXNE4601aXPra+x
-PcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1QYwIDAQABAoIBAGF05q7vqOGbMaSD
-2Q7YbuE/JTHKTBZIlBI1QC2x+0P5GDxyEFttNMOVzcs7xmNhkpRw8eX1LrInrpMk
-WsIBKAFFEfWYlf0RWtRChJjNl+szE9jQxB5FJnWtJH/FHa78tR6PsF24aQyzVcJP
-g0FGujBihwgfV0JSCNOBkz8MliQihjQA2i8PGGmo4R4RVzGfxYKTIq9vvRq/+QEa
-Q4lpVLoBqnENpnY/9PTl6JMMjW2b0spbLjOPVwDaIzXJ0dChjNXo15K5SHI5mALJ
-I5gN7ODGb8PKUf4619ez194FXq+eob5YJdilTFKensIUvt3YhP1ilGMM+Chi5Vi/
-/RCTw3ECgYEA9jTw4wv9pCswZ9wbzTaBj9yZS3YXspGg26y6Ohq3ZmvHz4jlT6uR
-xK+DDcUiK4072gci8S4Np0fIVS7q6ivqcOdzXPrTF5/j+MufS32UrBbUTPiM1yoO
-ECcy+1szl/KoLEV09bghPbvC58PFSXV71evkaTETYnA/F6RK12lEepcCgYEA7OSy
-bsMrGDVU/MKJtwqyGP9ubA53BorM4Pp9VVVSCrGGVhb9G/XNsjO5wJC8J30QAo4A
-s59ZzCpyNRy046AB8jwRQuSwEQbejSdeNgQGXhZ7aIVUtuDeFFdaIz/zjVgxsfj4
-DPOuzieMmJ2MLR4F71ocboxNoDI7xruPSE8dDhUCgYA3vx732cQxgtHwAkeNPJUz
-dLiE/JU7CnxIoSB9fYUfPLI+THnXgzp7NV5QJN2qzMzLfigsQcg3oyo6F2h7Yzwv
-GkjlualIRRzCPaCw4Btkp7qkPvbs1QngIHALt8fD1N69P3DPHkTwjG4COjKWgnJq
-qoHKS6Fe/ZlbigikI6KsuwKBgQCTlSLoyGRHr6oj0hqz01EDK9ciMJzMkZp0Kvn8
-OKxlBxYW+jlzut4MQBdgNYtS2qInxUoAnaz2+hauqhSzntK3k955GznpUatCqx0R
-b857vWviwPX2/P6+E3GPdl8IVsKXCvGWOBZWTuNTjQtwbDzsUepWoMgXnlQJSn5I
-YSlLxQKBgQD16Gw9kajpKlzsPa6XoQeGmZALT6aKWJQlrKtUQIrsIWM0Z6eFtX12
-2jjHZ0awuCQ4ldqwl8IfRogWMBkHOXjTPVK0YKWWlxMpD/5+bGPARa5fir8O1Zpo
-Y6S6MeZ69Rp89ma4ttMZ+kwi1+XyHqC/dlcVRW42Zl5Dc7BALRlJjQ==
------END RSA PRIVATE KEY-----"
-
-describe Chef::REST do
- let(:base_url) { "http://chef.example.com:4000" }
-
- let(:monkey_uri) { URI.parse("http://chef.example.com:4000/monkey") }
-
- let(:log_stringio) { StringIO.new }
-
- let(:request_id) { "1234" }
-
- let(:rest) do
- allow(Chef::REST::CookieJar).to receive(:instance).and_return({})
- allow(Chef::RequestID.instance).to receive(:request_id).and_return(request_id)
- rest = Chef::REST.new(base_url, nil, nil)
- Chef::REST::CookieJar.instance.clear
- rest
- end
-
- let(:standard_read_headers) { { "Accept" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID" => request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION } }
- let(:standard_write_headers) { { "Accept" => "application/json", "Content-Type" => "application/json", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID" => request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION } }
-
- before(:each) do
- Chef::Log.init(log_stringio)
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- end
-
- it "should have content length validation middleware after compressor middleware" do
- middlewares = rest.instance_variable_get(:@middlewares)
- content_length = middlewares.find_index { |e| e.is_a? Chef::HTTP::ValidateContentLength }
- decompressor = middlewares.find_index { |e| e.is_a? Chef::HTTP::Decompressor }
-
- expect(content_length).not_to be_nil
- expect(decompressor).not_to be_nil
- expect(decompressor < content_length).to be_truthy
- end
-
- it "should allow the options hash to be frozen" do
- options = {}.freeze
- # should not raise any exception
- Chef::REST.new(base_url, nil, nil, options)
- end
-
- it "emits a deprecation warning" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = true
- expect { Chef::REST.new(base_url) }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
- /Chef::REST is deprecated. Please use Chef::ServerAPI, or investigate Ridley or ChefAPI./
- end
-
- context "when created with a chef zero URL" do
-
- let(:url) { "chefzero://localhost:1" }
-
- it "does not load the signing key" do
- expect { Chef::REST.new(url) }.to_not raise_error
- end
- end
-
- describe "calling an HTTP verb on a path or absolute URL" do
- it "adds a relative URL to the base url it was initialized with" do
- expect(rest.create_url("foo/bar/baz")).to eq(URI.parse(base_url + "/foo/bar/baz"))
- end
-
- it "replaces the base URL when given an absolute URL" do
- expect(rest.create_url("http://chef-rulez.example.com:9000")).to eq(URI.parse("http://chef-rulez.example.com:9000"))
- end
-
- it "makes a :GET request with the composed url object" do
- expect(rest).to receive(:send_http_request).
- with(:GET, monkey_uri, standard_read_headers, false).
- and_return([1, 2, 3])
- expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.get_rest("monkey")
- end
-
- it "makes a :GET reqest for a streaming download with the composed url" do
- expect(rest).to receive(:streaming_request).with("monkey", {})
- rest.get_rest("monkey", true)
- end
-
- it "makes a :DELETE request with the composed url object" do
- expect(rest).to receive(:send_http_request).
- with(:DELETE, monkey_uri, standard_read_headers, false).
- and_return([1, 2, 3])
- expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.delete_rest("monkey")
- end
-
- it "makes a :POST request with the composed url object and data" do
- expect(rest).to receive(:send_http_request).
- with(:POST, monkey_uri, standard_write_headers, "\"data\"").
- and_return([1, 2, 3])
- expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.post_rest("monkey", "data")
- end
-
- it "makes a :PUT request with the composed url object and data" do
- expect(rest).to receive(:send_http_request).
- with(:PUT, monkey_uri, standard_write_headers, "\"data\"").
- and_return([1, 2, 3])
- expect(rest).to receive(:apply_response_middleware).with(1, 2, 3).and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.put_rest("monkey", "data")
- end
- end
-
- describe "legacy API" do
- let(:rest) do
- Chef::REST.new(base_url)
- end
-
- before(:each) do
- Chef::Config[:node_name] = "webmonkey.example.com"
- Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
- end
-
- it "responds to raw_http_request as a public method" do
- expect(rest.public_methods.map(&:to_s)).to include("raw_http_request")
- end
-
- it "calls the authn middleware" do
- data = "\"secure data\""
-
- auth_headers = standard_write_headers.merge({ "auth_done" => "yep" })
-
- expect(rest.authenticator).to receive(:handle_request).
- with(:POST, monkey_uri, standard_write_headers, data).
- and_return([:POST, monkey_uri, auth_headers, data])
- expect(rest).to receive(:send_http_request).
- with(:POST, monkey_uri, auth_headers, data).
- and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data)
- end
-
- it "sets correct authn headers" do
- data = "\"secure data\""
- method, uri, auth_headers, d = rest.authenticator.handle_request(:POST, monkey_uri, standard_write_headers, data)
-
- expect(rest).to receive(:send_http_request).
- with(:POST, monkey_uri, auth_headers, data).
- and_return([1, 2, 3])
- expect(rest).to receive("success_response?".to_sym).with(1).and_return(true)
- rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data)
- end
- end
-
- describe "when configured to authenticate to the Chef server" do
- let(:base_url) { URI.parse("http://chef.example.com:4000") }
-
- let(:rest) do
- Chef::REST.new(base_url)
- end
-
- before do
- Chef::Config[:node_name] = "webmonkey.example.com"
- Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
- end
-
- it "configures itself to use the node_name and client_key in the config by default" do
- expect(rest.client_name).to eq("webmonkey.example.com")
- expect(rest.signing_key_filename).to eq(CHEF_SPEC_DATA + "/ssl/private_key.pem")
- end
-
- it "provides access to the raw key data" do
- expect(rest.signing_key).to eq(SIGNING_KEY_DOT_PEM)
- end
-
- it "does not error out when initialized without credentials" do
- rest = Chef::REST.new(base_url, nil, nil) #should_not raise_error hides the bt from you, so screw it.
- expect(rest.client_name).to be_nil
- expect(rest.signing_key).to be_nil
- end
-
- it "indicates that requests should not be signed when it has no credentials" do
- rest = Chef::REST.new(base_url, nil, nil)
- expect(rest.sign_requests?).to be_falsey
- end
-
- it "raises PrivateKeyMissing when the key file doesn't exist" do
- expect { Chef::REST.new(base_url, "client-name", "/dev/null/nothing_here") }.to raise_error(Chef::Exceptions::PrivateKeyMissing)
- end
-
- it "raises InvalidPrivateKey when the key file doesnt' look like a key" do
- invalid_key_file = CHEF_SPEC_DATA + "/bad-config.rb"
- expect { Chef::REST.new(base_url, "client-name", invalid_key_file) }.to raise_error(Chef::Exceptions::InvalidPrivateKey)
- end
-
- it "can take private key as a sting :raw_key in options during initializaton" do
- expect(Chef::REST.new(base_url, "client-name", nil, :raw_key => SIGNING_KEY_DOT_PEM).signing_key).to eq(SIGNING_KEY_DOT_PEM)
- end
-
- it "raises InvalidPrivateKey when the key passed as string :raw_key in options doesnt' look like a key" do
- expect { Chef::REST.new(base_url, "client-name", nil, :raw_key => "bad key string") }.to raise_error(Chef::Exceptions::InvalidPrivateKey)
- end
-
- end
-
- context "when making REST requests" do
- let(:body) { "ninja" }
-
- let(:http_response) do
- http_response = Net::HTTPSuccess.new("1.1", "200", "successful rest req")
- allow(http_response).to receive(:read_body)
- allow(http_response).to receive(:body).and_return(body)
- http_response["Content-Length"] = body.bytesize.to_s
- http_response
- end
-
- let(:host_header) { "one" }
-
- let(:url) { URI.parse("http://one:80/?foo=bar") }
-
- let(:base_url) { "http://chef.example.com:4000" }
-
- let!(:http_client) do
- http_client = Net::HTTP.new(url.host, url.port)
- allow(http_client).to receive(:request).and_yield(http_response).and_return(http_response)
- http_client
- end
-
- let(:rest) do
- allow(Net::HTTP).to receive(:new).and_return(http_client)
- allow(Chef::REST::CookieJar).to receive(:instance).and_return({})
- allow(Chef::RequestID.instance).to receive(:request_id).and_return(request_id)
- rest = Chef::REST.new(base_url, nil, nil)
- Chef::REST::CookieJar.instance.clear
- rest
- end
-
- before(:each) do
- Chef::Config[:ssl_client_cert] = nil
- Chef::Config[:ssl_client_key] = nil
- end
-
- describe "as JSON API requests" do
- let(:request_mock) { {} }
-
- let(:base_headers) do #FIXME: huh?
- {
- "Accept" => "application/json",
- "X-Chef-Version" => Chef::VERSION,
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => host_header,
- "X-REMOTE-REQUEST-ID" => request_id,
- "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
- }
- end
-
- before do
- allow(Net::HTTP::Get).to receive(:new).and_return(request_mock)
- end
-
- it "should always include the X-Chef-Version header" do
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers).and_return(request_mock)
- rest.request(:GET, url, {})
- end
-
- it "should always include the X-Remote-Request-Id header" do
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers).and_return(request_mock)
- rest.request(:GET, url, {})
- end
-
- it "sets the user agent to chef-client" do
- # XXX: must reset to default b/c knife changes the UA
- Chef::REST::RESTRequest.user_agent = Chef::REST::RESTRequest::DEFAULT_UA
- rest.request(:GET, url, {})
- expect(request_mock["User-Agent"]).to match(/^Chef Client\/#{Chef::VERSION}/)
- end
-
- # CHEF-3140
- context "when configured to disable compression" do
- let(:rest) do
- allow(Net::HTTP).to receive(:new).and_return(http_client)
- Chef::REST.new(base_url, nil, nil, :disable_gzip => true)
- end
-
- it "does not accept encoding gzip" do
- expect(rest.send(:build_headers, :GET, url, {})).not_to have_key("Accept-Encoding")
- end
-
- it "does not decompress a response encoded as gzip" do
- http_response.add_field("content-encoding", "gzip")
- request = Net::HTTP::Get.new(url.path)
- expect(Net::HTTP::Get).to receive(:new).and_return(request)
- # will raise a Zlib error if incorrect
- expect(rest.request(:GET, url, {})).to eq("ninja")
- end
- end
-
- context "when configured with custom http headers" do
- let(:custom_headers) do
- {
- "X-Custom-ChefSecret" => "sharpknives",
- "X-Custom-RequestPriority" => "extremely low",
- }
- end
-
- before(:each) do
- Chef::Config[:custom_http_headers] = custom_headers
- end
-
- after(:each) do
- Chef::Config[:custom_http_headers] = nil
- end
-
- it "should set them on the http request" do
- url_string = an_instance_of(String)
- header_hash = hash_including(custom_headers)
- expect(Net::HTTP::Get).to receive(:new).with(url_string, header_hash)
- rest.request(:GET, url, {})
- end
- end
-
- context "when setting cookies" do
- let(:rest) do
- allow(Net::HTTP).to receive(:new).and_return(http_client)
- Chef::REST::CookieJar.instance["#{url.host}:#{url.port}"] = "cookie monster"
- allow(Chef::RequestID.instance).to receive(:request_id).and_return(request_id)
- rest = Chef::REST.new(base_url, nil, nil)
- rest
- end
-
- it "should set the cookie for this request if one exists for the given host:port" do
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers.merge("Cookie" => "cookie monster")).and_return(request_mock)
- rest.request(:GET, url, {})
- end
- end
-
- it "should build a new HTTP GET request" do
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers).and_return(request_mock)
- rest.request(:GET, url, {})
- end
-
- it "should build a new HTTP POST request" do
- request = Net::HTTP::Post.new(url.path)
- expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13")
-
- expect(Net::HTTP::Post).to receive(:new).with("/?foo=bar", expected_headers).and_return(request)
- rest.request(:POST, url, {}, { :one => :two })
- expect(request.body).to eq('{"one":"two"}')
- end
-
- it "should build a new HTTP PUT request" do
- request = Net::HTTP::Put.new(url.path)
- expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13")
- expect(Net::HTTP::Put).to receive(:new).with("/?foo=bar", expected_headers).and_return(request)
- rest.request(:PUT, url, {}, { :one => :two })
- expect(request.body).to eq('{"one":"two"}')
- end
-
- it "should build a new HTTP DELETE request" do
- expect(Net::HTTP::Delete).to receive(:new).with("/?foo=bar", base_headers).and_return(request_mock)
- rest.request(:DELETE, url)
- end
-
- it "should raise an error if the method is not GET/PUT/POST/DELETE" do
- expect { rest.request(:MONKEY, url) }.to raise_error(ArgumentError)
- end
-
- it "returns nil when the response is successful but content-type is not JSON" do
- expect(rest.request(:GET, url)).to eq("ninja")
- end
-
- it "should fail if the response is truncated" do
- http_response["Content-Length"] = (body.bytesize + 99).to_s
- expect { rest.request(:GET, url) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
-
- context "when JSON is returned" do
- let(:body) { '{"ohai2u":"json_api"}' }
- it "should inflate the body as to an object" do
- http_response.add_field("content-type", "application/json")
- expect(rest.request(:GET, url, {})).to eq({ "ohai2u" => "json_api" })
- end
-
- it "should fail if the response is truncated" do
- http_response.add_field("content-type", "application/json")
- http_response["Content-Length"] = (body.bytesize + 99).to_s
- expect { rest.request(:GET, url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
- end
-
- %w{ HTTPFound HTTPMovedPermanently HTTPSeeOther HTTPUseProxy HTTPTemporaryRedirect HTTPMultipleChoice }.each do |resp_name|
- describe "when encountering a #{resp_name} redirect" do
- let(:http_response) do
- resp_cls = Net.const_get(resp_name)
- resp_code = Net::HTTPResponse::CODE_TO_OBJ.keys.detect { |k| Net::HTTPResponse::CODE_TO_OBJ[k] == resp_cls }
- http_response = Net::HTTPFound.new("1.1", resp_code, "bob is somewhere else again")
- http_response.add_field("location", url.path)
- allow(http_response).to receive(:read_body)
- http_response
- end
- it "should call request again" do
-
- expect { rest.request(:GET, url) }.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
-
- [:PUT, :POST, :DELETE].each do |method|
- expect { rest.request(method, url) }.to raise_error(Chef::Exceptions::InvalidRedirect)
- end
- end
- end
- end
-
- context "when the response is 304 NotModified" do
- let (:http_response) do
- http_response = Net::HTTPNotModified.new("1.1", "304", "it's the same as when you asked 5 minutes ago")
- allow(http_response).to receive(:read_body)
- http_response
- end
-
- it "should return `false`" do
- expect(rest.request(:GET, url)).to be_falsey
- end
- end
-
- describe "when the request fails" do
- before do
- @original_log_level = Chef::Log.level
- Chef::Log.level = :info
- end
-
- after do
- Chef::Log.level = @original_log_level
- end
-
- context "on an unsuccessful response with a JSON error" do
- let(:http_response) do
- http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
- http_response.add_field("content-type", "application/json")
- allow(http_response).to receive(:body).and_return('{ "error":[ "Ears get sore!", "Not even four" ] }')
- allow(http_response).to receive(:read_body)
- http_response
- end
-
- it "should show the JSON error message" do
- allow(rest).to receive(:sleep)
-
- expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
- expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four"))
- end
- end
-
- context "on an unsuccessful response with a JSON error that is compressed" do
- let(:http_response) do
- http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
- http_response.add_field("content-type", "application/json")
- http_response.add_field("content-encoding", "deflate")
- unzipped_body = '{ "error":[ "Ears get sore!", "Not even four" ] }'
- gzipped_body = Zlib::Deflate.deflate(unzipped_body)
- gzipped_body.force_encoding(Encoding::BINARY) if "strings".respond_to?(:force_encoding)
-
- allow(http_response).to receive(:body).and_return gzipped_body
- allow(http_response).to receive(:read_body)
- http_response
- end
-
- before do
- allow(rest).to receive(:sleep)
- allow(rest).to receive(:http_retry_count).and_return(0)
- end
-
- it "decompresses the JSON error message" do
- expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
- expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four"))
- end
-
- it "fails when the compressed body is truncated" do
- http_response["Content-Length"] = (body.bytesize + 99).to_s
- expect { rest.request(:GET, url) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
- end
-
- context "on a generic unsuccessful request" do
- let(:http_response) do
- http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
- allow(http_response).to receive(:body)
- allow(http_response).to receive(:read_body)
- http_response
- end
-
- it "retries then throws an exception" do
- allow(rest).to receive(:sleep)
- expect { rest.request(:GET, url) }.to raise_error(Net::HTTPFatalError)
- count = Chef::Config[:http_retry_count]
- expect(log_stringio.string).to match(Regexp.escape("ERROR: Server returned error 500 for #{url}, retrying #{count}/#{count}"))
- end
- end
- end
- end # as JSON API requests
-
- context "when streaming downloads to a tempfile" do
- let!(:tempfile) { Tempfile.open("chef-rspec-rest_spec-line-@{__LINE__}--") }
-
- let(:request_mock) { {} }
-
- let(:http_response) do
- http_response = Net::HTTPSuccess.new("1.1", "200", "it-works")
-
- allow(http_response).to receive(:read_body)
- expect(http_response).not_to receive(:body)
- http_response["Content-Length"] = "0" # call set_content_length (in test), if otherwise
- http_response
- end
-
- def set_content_length
- content_length = 0
- http_response.read_body do |chunk|
- content_length += chunk.bytesize
- end
- http_response["Content-Length"] = content_length.to_s
- end
-
- before do
- allow(Tempfile).to receive(:new).with("chef-rest").and_return(tempfile)
- allow(Net::HTTP::Get).to receive(:new).and_return(request_mock)
- end
-
- after do
- tempfile.close!
- end
-
- it " build a new HTTP GET request without the application/json accept header" do
- expected_headers = { "Accept" => "*/*",
- "X-Chef-Version" => Chef::VERSION,
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => host_header,
- "X-REMOTE-REQUEST-ID" => request_id,
- "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
- }
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock)
- rest.streaming_request(url, {})
- end
-
- it "build a new HTTP GET request with the X-Remote-Request-Id header" do
- expected_headers = { "Accept" => "*/*",
- "X-Chef-Version" => Chef::VERSION,
- "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE,
- "Host" => host_header,
- "X-REMOTE-REQUEST-ID" => request_id,
- "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION,
- }
- expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock)
- rest.streaming_request(url, {})
- end
-
- it "returns a tempfile containing the streamed response body" do
- expect(rest.streaming_request(url, {})).to equal(tempfile)
- end
-
- it "writes the response body to a tempfile" do
- allow(http_response).to receive(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
- set_content_length
- rest.streaming_request(url, {})
- expect(IO.read(tempfile.path).chomp).to eq("realultimatepower")
- end
-
- it "closes the tempfile" do
- rest.streaming_request(url, {})
- expect(tempfile).to be_closed
- end
-
- it "yields the tempfile containing the streamed response body and then unlinks it when given a block" do
- allow(http_response).to receive(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
- set_content_length
- tempfile_path = nil
- rest.streaming_request(url, {}) do |tempfile|
- tempfile_path = tempfile.path
- expect(File.exist?(tempfile.path)).to be_truthy
- expect(IO.read(tempfile.path).chomp).to eq("realultimatepower")
- end
- expect(File.exist?(tempfile_path)).to be_falsey
- end
-
- it "does not raise a divide by zero exception if the content's actual size is 0" do
- http_response["Content-Length"] = "5"
- allow(http_response).to receive(:read_body).and_yield("")
- expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
-
- it "does not raise a divide by zero exception when the Content-Length is 0" do
- http_response["Content-Length"] = "0"
- allow(http_response).to receive(:read_body).and_yield("ninja")
- expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
-
- it "it raises an exception when the download is truncated" do
- http_response["Content-Length"] = (body.bytesize + 99).to_s
- allow(http_response).to receive(:read_body).and_yield("ninja")
- expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
- end
-
- it "fetches a file and yields the tempfile it is streamed to" do
- allow(http_response).to receive(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
- set_content_length
- tempfile_path = nil
- rest.fetch("cookbooks/a_cookbook") do |tempfile|
- tempfile_path = tempfile.path
- expect(IO.read(tempfile.path).chomp).to eq("realultimatepower")
- end
- expect(File.exist?(tempfile_path)).to be_falsey
- end
-
- it "closes and unlinks the tempfile if there is an error while streaming the content to the tempfile" do
- path = tempfile.path
- expect(path).not_to be_nil
- allow(tempfile).to receive(:write).and_raise(IOError)
- rest.fetch("cookbooks/a_cookbook") { |tmpfile| "shouldn't get here" }
- expect(File.exists?(path)).to be_falsey
- end
-
- it "closes and unlinks the tempfile when the response is a redirect" do
- tempfile = double("A tempfile", :path => "/tmp/ragefist", :close => true, :binmode => true)
- expect(tempfile).to receive(:close!).at_least(1).times
- allow(Tempfile).to receive(:new).with("chef-rest").and_return(tempfile)
-
- redirect = Net::HTTPFound.new("1.1", "302", "bob is taking care of that one for me today")
- redirect.add_field("location", url.path)
- allow(redirect).to receive(:read_body)
-
- expect(http_client).to receive(:request).and_yield(redirect).and_return(redirect)
- expect(http_client).to receive(:request).and_yield(http_response).and_return(http_response)
- rest.fetch("cookbooks/a_cookbook") { |tmpfile| "shouldn't get here" }
- end
-
- it "passes the original block to the redirected request" do
- http_redirect = Net::HTTPFound.new("1.1", "302", "bob is taking care of that one for me today")
- http_redirect.add_field("location", "/that-thing-is-here-now")
- allow(http_redirect).to receive(:read_body)
-
- block_called = false
- allow(http_client).to receive(:request).and_yield(http_response).and_return(http_redirect, http_response)
- rest.fetch("cookbooks/a_cookbook") do |tmpfile|
- block_called = true
- end
- expect(block_called).to be_truthy
- end
- end
- end # when making REST requests
-
- context "when following redirects" do
- let(:rest) do
- Chef::REST.new(base_url)
- end
-
- before do
- Chef::Config[:node_name] = "webmonkey.example.com"
- Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
- end
-
- it "raises a RedirectLimitExceeded when redirected more than 10 times" do
- redirected = lambda { rest.follow_redirect { redirected.call } }
- expect { redirected.call }.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
- end
-
- it "does not count redirects from previous calls against the redirect limit" do
- total_redirects = 0
- redirected = lambda do
- rest.follow_redirect do
- total_redirects += 1
- redirected.call unless total_redirects >= 9
- end
- end
- expect { redirected.call }.not_to raise_error
- total_redirects = 0
- expect { redirected.call }.not_to raise_error
- end
-
- it "does not sign the redirected request when sign_on_redirect is false" do
- rest.sign_on_redirect = false
- rest.follow_redirect { expect(rest.sign_requests?).to be_falsey }
- end
-
- it "resets sign_requests to the original value after following an unsigned redirect" do
- rest.sign_on_redirect = false
- expect(rest.sign_requests?).to be_truthy
-
- rest.follow_redirect { expect(rest.sign_requests?).to be_falsey }
- expect(rest.sign_requests?).to be_truthy
- end
-
- it "configures the redirect limit" do
- total_redirects = 0
- redirected = lambda do
- rest.follow_redirect do
- total_redirects += 1
- redirected.call unless total_redirects >= 9
- end
- end
- expect { redirected.call }.not_to raise_error
-
- total_redirects = 0
- rest.redirect_limit = 3
- expect { redirected.call }.to raise_error(Chef::Exceptions::RedirectLimitExceeded)
- end
-
- end
-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/runner_spec.rb b/spec/unit/runner_spec.rb
index 4e7f4d6671..eeb471608e 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_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");
@@ -98,25 +98,6 @@ describe Chef::Runner do
run_context.resource_collection << first_resource
end
- context "when we fall through to old Chef::Platform resolution" do
- let(:provider_resolver) { Chef::ProviderResolver.new(node, first_resource, nil) }
- before do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- # set up old Chef::Platform resolution instead of provider_resolver
- Chef::Platform.set(
- :resource => :cat,
- :provider => Chef::Provider::SnakeOil
- )
- allow(Chef::ProviderResolver).to receive(:new).and_return(provider_resolver)
- allow(provider_resolver).to receive(:maybe_dynamic_provider_resolution).with(first_resource, anything()).and_return(nil)
- end
-
- it "should use the platform provider if it has one" do
- expect(Chef::Platform).to receive(:find_provider_for_node).with(node, first_resource).and_call_original
- runner.converge
- end
- end
-
context "when we are doing dynamic provider resolution" do
it "should pass each resource in the collection to a provider" do
@@ -141,25 +122,26 @@ describe Chef::Runner do
it "should raise exceptions as thrown by a provider" do
provider = Chef::Provider::SnakeOil.new(run_context.resource_collection[0], run_context)
- allow(Chef::Provider::SnakeOil).to receive(:new).once.and_return(provider)
- allow(provider).to receive(:action_sell).once.and_raise(ArgumentError)
+ expect(Chef::Provider::SnakeOil).to receive(:new).once.and_return(provider)
+ expect(provider).to receive(:action_sell).once.and_raise(ArgumentError)
expect { runner.converge }.to raise_error(ArgumentError)
end
it "should not raise exceptions thrown by providers if the resource has ignore_failure set to true" do
allow(run_context.resource_collection[0]).to receive(:ignore_failure).and_return(true)
provider = Chef::Provider::SnakeOil.new(run_context.resource_collection[0], run_context)
- allow(Chef::Provider::SnakeOil).to receive(:new).once.and_return(provider)
- allow(provider).to receive(:action_sell).once.and_raise(ArgumentError)
+ expect(Chef::Provider::SnakeOil).to receive(:new).once.and_return(provider)
+ expect(provider).to receive(:action_sell).once.and_raise(ArgumentError)
expect { runner.converge }.not_to raise_error
end
it "should retry with the specified delay if retries are specified" do
- first_resource.retries 3
+ num_retries = 3
+ allow(run_context.resource_collection[0]).to receive(:retries).and_return(num_retries)
provider = Chef::Provider::SnakeOil.new(run_context.resource_collection[0], run_context)
- allow(Chef::Provider::SnakeOil).to receive(:new).once.and_return(provider)
- allow(provider).to receive(:action_sell).and_raise(ArgumentError)
- expect(first_resource).to receive(:sleep).with(2).exactly(3).times
+ expect(Chef::Provider::SnakeOil).to receive(:new).exactly(num_retries + 1).times.and_return(provider)
+ expect(provider).to receive(:action_sell).exactly(num_retries + 1).times.and_raise(ArgumentError)
+ expect(run_context.resource_collection[0]).to receive(:sleep).with(2).exactly(num_retries).times
expect { runner.converge }.to raise_error(ArgumentError)
end
diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb
index 51667784fb..0837410b3c 100644
--- a/spec/unit/search/query_spec.rb
+++ b/spec/unit/search/query_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Search::Query do
let(:query) { Chef::Search::Query.new }
shared_context "filtered search" do
- let(:query_string) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0" }
+ let(:query_string) { "search/node?q=platform:rhel&start=0" }
let(:server_url) { "https://api.opscode.com/organizations/opscode/nodes" }
let(:args) { { filter_key => filter_hash } }
let(:filter_hash) do
@@ -81,10 +81,10 @@ describe Chef::Search::Query do
end
describe "search" do
- let(:query_string) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0" }
- let(:query_string_continue) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=4" }
- let(:query_string_with_rows) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=4" }
- let(:query_string_continue_with_rows) { "search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=4&rows=4" }
+ let(:query_string) { "search/node?q=platform:rhel&start=0" }
+ let(:query_string_continue) { "search/node?q=platform:rhel&start=4" }
+ let(:query_string_with_rows) { "search/node?q=platform:rhel&start=0&rows=4" }
+ let(:query_string_continue_with_rows) { "search/node?q=platform:rhel&start=4&rows=4" }
let(:response) do
{
@@ -178,27 +178,22 @@ describe Chef::Search::Query do
end
it "queries for every object of a type by default" do
- expect(rest).to receive(:get).with("search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0").and_return(response)
+ expect(rest).to receive(:get).with("search/node?q=*:*&start=0").and_return(response)
query.search(:node)
end
it "allows a custom query" do
- expect(rest).to receive(:get).with("search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0").and_return(response)
+ expect(rest).to receive(:get).with("search/node?q=platform:rhel&start=0").and_return(response)
query.search(:node, "platform:rhel")
end
- it "lets you set a sort order" do
- expect(rest).to receive(:get).with("search/node?q=platform:rhel&sort=id%20desc&start=0").and_return(response)
- query.search(:node, "platform:rhel", sort: "id desc")
- end
-
it "lets you set a starting object" do
- expect(rest).to receive(:get).with("search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=2").and_return(response)
+ expect(rest).to receive(:get).with("search/node?q=platform:rhel&start=2").and_return(response)
query.search(:node, "platform:rhel", start: 2)
end
it "lets you set how many rows to return" do
- expect(rest).to receive(:get).with("search/node?q=platform:rhel&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=40").and_return(response)
+ expect(rest).to receive(:get).with("search/node?q=platform:rhel&start=0&rows=40").and_return(response)
query.search(:node, "platform:rhel", rows: 40)
end
@@ -223,7 +218,7 @@ describe Chef::Search::Query do
it "pages through the responses" do
@call_me = double("blocky")
response["rows"].each { |r| expect(@call_me).to receive(:do).with(Chef::Node.from_hash(r)) }
- query.search(:node, "*:*", sort: nil, start: 0, rows: 4) { |r| @call_me.do(r) }
+ query.search(:node, "*:*", start: 0, rows: 4) { |r| @call_me.do(r) }
end
it "sends multiple API requests when the server indicates there is more data" do
@@ -269,22 +264,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/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index 259e6096a4..170767fbd6 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -77,6 +77,37 @@ describe Shell::ClientSession do
end
+describe Shell::SoloSession do
+ before do
+ Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ @chef_rest = double("Chef::ServerAPI")
+ @session = Shell::SoloSession.instance
+ @node = Chef::Node.build("foo")
+ @session.node = @node
+ @client = double("Chef::Client.new",
+ :run_ohai => true,
+ :load_node => true,
+ :build_node => true,
+ :register => true,
+ :sync_cookbooks => {})
+ end
+
+ it "builds the node's run_context with the proper environment" do
+ @session.instance_variable_set(:@client, @client)
+ @expansion = Chef::RunList::RunListExpansion.new(@node.chef_environment, [])
+
+ expect(@node.run_list).to receive(:expand).with(@node.chef_environment).and_return(@expansion)
+ expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest)
+ @session.rebuild_context
+ end
+
+ it "passes the shell CLI args to the client" do
+ expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
+ @session.send(:rebuild_node)
+ end
+
+end
+
describe Shell::StandAloneSession do
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
@@ -128,11 +159,11 @@ describe Shell::StandAloneSession do
end
-describe Shell::SoloSession do
+describe Shell::SoloLegacySession do
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
Chef::Config[:shell_solo] = true
- @session = Shell::SoloSession.instance
+ @session = Shell::SoloLegacySession.instance
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = @session.run_context = Chef::RunContext.new(@node, {}, @events)
diff --git a/spec/unit/shell_out_spec.rb b/spec/unit/shell_out_spec.rb
deleted file mode 100644
index 35844f4961..0000000000
--- a/spec/unit/shell_out_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require File.expand_path("../../spec_helper", __FILE__)
-
-describe "Chef::ShellOut deprecation notices" do
- it "logs a warning when initializing a new Chef::ShellOut object" do
- expect(Chef::Log).to receive(:warn).with("Chef::ShellOut is deprecated, please use Mixlib::ShellOut")
- expect(Chef::Log).to receive(:warn).with(/Called from\:/)
- Chef::ShellOut.new("pwd")
- end
-end
-
-describe "Chef::Exceptions::ShellCommandFailed deprecation notices" do
-
- it "logs a warning when referencing the constant Chef::Exceptions::ShellCommandFailed" do
- expect(Chef::Log).to receive(:warn).with("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed")
- expect(Chef::Log).to receive(:warn).with(/Called from\:/)
- Chef::Exceptions::ShellCommandFailed
- 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..b703e22111 100644
--- a/version_policy.rb
+++ b/version_policy.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");
@@ -33,7 +33,7 @@ OMNIBUS_OVERRIDES = {
"makedepend" => "1.0.5",
"ncurses" => "5.9",
"pkg-config-lite" => "0.28-1",
- "ruby" => "2.3.1",
+ "ruby" => "2.3.3",
# Leave dev-kit pinned to 4.5 on 32-bit, because 4.7 is 20MB larger and we don't want
# to unnecessarily make the client any fatter. (Since it's different between
# 32 and 64, we have to do it in the project file still.)
@@ -108,7 +108,7 @@ GEMS_ALLOWED_TO_FLOAT = [
# our test phase a lot easier.
#
INSTALL_WITHOUT_GROUPS = %w{
- changelog
+ ci
development
docgen
guard