chef 12.13.37-universal-mingw32 → 12.14.60-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +48 -95
- data/Gemfile +6 -1
- data/README.md +9 -11
- data/VERSION +1 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
- data/acceptance/Gemfile +4 -7
- data/acceptance/Gemfile.lock +59 -92
- data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
- data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
- data/chef.gemspec +3 -2
- data/lib/chef/application/client.rb +4 -4
- data/lib/chef/application/solo.rb +2 -2
- data/lib/chef/chef_fs/command_line.rb +36 -34
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +139 -137
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
- data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +3 -3
- data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -6
- data/lib/chef/dsl/powershell.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_cache.rb +1 -1
- data/lib/chef/formatters/base.rb +2 -2
- data/lib/chef/formatters/doc.rb +2 -2
- data/lib/chef/http.rb +48 -18
- data/lib/chef/http/auth_credentials.rb +1 -1
- data/lib/chef/http/basic_client.rb +11 -2
- data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
- data/lib/chef/key.rb +55 -56
- data/lib/chef/knife.rb +70 -61
- data/lib/chef/knife/client_delete.rb +2 -2
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +19 -21
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/mixin/command/unix.rb +2 -2
- data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
- data/lib/chef/mixin/properties.rb +3 -0
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +30 -0
- data/lib/chef/mixin/uris.rb +2 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
- data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
- data/lib/chef/monologger.rb +1 -1
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node/attribute.rb +3 -3
- data/lib/chef/platform/provider_mapping.rb +5 -2
- data/lib/chef/property.rb +14 -3
- data/lib/chef/provider/apt_repository.rb +3 -7
- data/lib/chef/provider/apt_update.rb +4 -6
- data/lib/chef/provider/cron.rb +1 -2
- data/lib/chef/provider/dsc_script.rb +4 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/link.rb +10 -3
- data/lib/chef/provider/osx_profile.rb +10 -10
- data/lib/chef/provider/package.rb +2 -12
- data/lib/chef/provider/package/rubygems.rb +17 -16
- data/lib/chef/provider/package/windows.rb +2 -0
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/remote_file/ftp.rb +2 -2
- data/lib/chef/provider/remote_file/sftp.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/simple.rb +4 -3
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +8 -5
- data/lib/chef/provider/support/yum_repo.erb +125 -0
- data/lib/chef/provider/systemd_unit.rb +11 -2
- data/lib/chef/provider/template_finder.rb +1 -1
- data/lib/chef/provider/user.rb +20 -16
- data/lib/chef/provider/user/aix.rb +5 -2
- data/lib/chef/provider/user/dscl.rb +1 -0
- data/lib/chef/provider/user/linux.rb +128 -0
- data/lib/chef/provider/user/pw.rb +2 -1
- data/lib/chef/provider/user/solaris.rb +3 -2
- data/lib/chef/provider/user/useradd.rb +5 -4
- data/lib/chef/provider/user/windows.rb +1 -1
- data/lib/chef/provider/windows_script.rb +5 -2
- data/lib/chef/provider/yum_repository.rb +121 -0
- data/lib/chef/providers.rb +4 -2
- data/lib/chef/resource.rb +7 -9
- data/lib/chef/resource/conditional.rb +9 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/user/aix_user.rb +31 -0
- data/lib/chef/resource/user/dscl_user.rb +31 -0
- data/lib/chef/resource/user/linux_user.rb +51 -0
- data/lib/chef/resource/user/pw_user.rb +31 -0
- data/lib/chef/resource/user/solaris_user.rb +31 -0
- data/lib/chef/resource/user/windows_user.rb +31 -0
- data/lib/chef/resource/yum_package.rb +13 -12
- data/lib/chef/resource/yum_repository.rb +76 -0
- data/lib/chef/resource_builder.rb +1 -1
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
- data/lib/chef/resource_reporter.rb +5 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +5 -3
- data/lib/chef/run_context/cookbook_compiler.rb +3 -2
- data/lib/chef/run_list.rb +2 -2
- data/lib/chef/search/query.rb +11 -8
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +5 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +2 -2
- data/lib/chef/version_constraint.rb +2 -2
- data/lib/chef/win32/api/error.rb +2 -2
- data/lib/chef/win32/api/net.rb +1 -1
- data/lib/chef/win32/eventlog.rb +1 -1
- data/lib/chef/win32/net.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/assets/testchefsubsys +2 -3
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
- data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
- data/spec/functional/http/simple_spec.rb +2 -2
- data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
- data/spec/functional/knife/exec_spec.rb +6 -6
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/notifications_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +5 -5
- data/spec/functional/resource/bash_spec.rb +2 -2
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dpkg_package_spec.rb +2 -2
- data/spec/functional/resource/dsc_resource_spec.rb +5 -5
- data/spec/functional/resource/dsc_script_spec.rb +27 -22
- data/spec/functional/resource/env_spec.rb +4 -4
- data/spec/functional/resource/execute_spec.rb +4 -4
- data/spec/functional/resource/group_spec.rb +20 -8
- data/spec/functional/resource/link_spec.rb +34 -0
- data/spec/functional/resource/ohai_spec.rb +6 -6
- data/spec/functional/resource/reboot_spec.rb +2 -2
- data/spec/functional/resource/remote_file_spec.rb +16 -7
- data/spec/functional/resource/user/dscl_spec.rb +3 -3
- data/spec/functional/resource/user/useradd_spec.rb +32 -26
- data/spec/functional/resource/windows_service_spec.rb +15 -15
- data/spec/functional/rest_spec.rb +2 -2
- data/spec/functional/run_lock_spec.rb +9 -9
- data/spec/functional/tiny_server_spec.rb +9 -8
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +8 -8
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
- data/spec/integration/recipes/noop_resource_spec.rb +4 -4
- data/spec/integration/recipes/provider_choice.rb +3 -3
- data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
- data/spec/integration/recipes/resource_action_spec.rb +50 -54
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
- data/spec/integration/recipes/resource_load_spec.rb +24 -24
- data/spec/integration/solo/solo_spec.rb +21 -30
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/stress/win32/security_spec.rb +4 -4
- data/spec/support/chef_helpers.rb +22 -0
- data/spec/support/platform_helpers.rb +5 -1
- data/spec/support/shared/context/client.rb +3 -2
- data/spec/support/shared/functional/file_resource.rb +5 -4
- data/spec/support/shared/functional/http.rb +16 -16
- data/spec/support/shared/functional/securable_resource.rb +5 -5
- data/spec/support/shared/functional/win32_service.rb +5 -7
- data/spec/support/shared/integration/app_server_support.rb +1 -3
- data/spec/support/shared/integration/knife_support.rb +0 -2
- data/spec/support/shared/shared_examples.rb +2 -2
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/support/shared/unit/application_dot_d.rb +9 -6
- data/spec/support/shared/unit/provider/file.rb +2 -2
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
- data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
- data/spec/tiny_server.rb +51 -66
- data/spec/unit/api_client_v1_spec.rb +2 -2
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
- data/spec/unit/audit/audit_reporter_spec.rb +32 -23
- data/spec/unit/audit/control_group_data_spec.rb +19 -14
- data/spec/unit/chef_class_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system_spec.rb +2 -2
- data/spec/unit/chef_fs/parallelizer.rb +5 -7
- data/spec/unit/cookbook/metadata_spec.rb +98 -98
- data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
- data/spec/unit/cookbook_loader_spec.rb +24 -24
- data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/data_bag_item_spec.rb +18 -18
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
- data/spec/unit/data_collector/messages_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +19 -19
- data/spec/unit/dsl/audit_spec.rb +3 -3
- data/spec/unit/dsl/data_query_spec.rb +3 -2
- data/spec/unit/dsl/declare_resource_spec.rb +10 -10
- data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
- data/spec/unit/environment_spec.rb +6 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
- data/spec/unit/file_access_control_spec.rb +3 -3
- data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
- data/spec/unit/http/basic_client_spec.rb +20 -0
- data/spec/unit/http/validate_content_length_spec.rb +8 -8
- data/spec/unit/http_spec.rb +14 -0
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
- data/spec/unit/knife/bootstrap_spec.rb +8 -6
- data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
- data/spec/unit/knife/client_edit_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
- data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
- data/spec/unit/knife/core/node_editor_spec.rb +3 -3
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
- data/spec/unit/knife/data_bag_show_spec.rb +3 -2
- data/spec/unit/knife/key_create_spec.rb +14 -14
- data/spec/unit/knife/key_delete_spec.rb +2 -2
- data/spec/unit/knife/key_edit_spec.rb +16 -16
- data/spec/unit/knife/key_list_spec.rb +6 -6
- data/spec/unit/knife/key_show_spec.rb +4 -4
- data/spec/unit/knife/status_spec.rb +3 -2
- data/spec/unit/knife/user_create_spec.rb +4 -4
- data/spec/unit/knife_spec.rb +7 -6
- data/spec/unit/lwrp_spec.rb +6 -6
- data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
- data/spec/unit/mixin/command_spec.rb +17 -14
- data/spec/unit/mixin/deprecation_spec.rb +1 -1
- data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
- data/spec/unit/mixin/params_validate_spec.rb +53 -52
- data/spec/unit/mixin/powershell_out_spec.rb +2 -2
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
- data/spec/unit/mixin/shell_out_spec.rb +1 -1
- data/spec/unit/mixin/xml_escape_spec.rb +3 -3
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/platform/query_helpers_spec.rb +3 -3
- data/spec/unit/property_spec.rb +4 -4
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron/unix_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/deploy_spec.rb +8 -8
- data/spec/unit/provider/dsc_resource_spec.rb +11 -10
- data/spec/unit/provider/dsc_script_spec.rb +9 -9
- data/spec/unit/provider/env/windows_spec.rb +8 -8
- data/spec/unit/provider/file/content_spec.rb +6 -6
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/launchd_spec.rb +2 -1
- data/spec/unit/provider/link_spec.rb +155 -0
- data/spec/unit/provider/mount/mount_spec.rb +5 -5
- data/spec/unit/provider/mount/solaris_spec.rb +48 -48
- data/spec/unit/provider/osx_profile_spec.rb +6 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
- data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
- data/spec/unit/provider/package/rubygems_spec.rb +50 -44
- data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
- data/spec/unit/provider/package/yum_spec.rb +61 -60
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +1 -1
- data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
- data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file_spec.rb +4 -4
- data/spec/unit/provider/script_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +4 -4
- data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
- data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
- data/spec/unit/provider/service/windows_spec.rb +10 -10
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/template/content_spec.rb +8 -8
- data/spec/unit/provider/template_spec.rb +8 -8
- data/spec/unit/provider/user/dscl_spec.rb +51 -51
- data/spec/unit/provider/user/linux_spec.rb +76 -0
- data/spec/unit/provider/user/pw_spec.rb +3 -6
- data/spec/unit/provider/user/solaris_spec.rb +5 -5
- data/spec/unit/provider/user/windows_spec.rb +3 -3
- data/spec/unit/provider/user_spec.rb +2 -2
- data/spec/unit/provider/yum_repository_spec.rb +35 -0
- data/spec/unit/provider_resolver_spec.rb +306 -264
- data/spec/unit/recipe_spec.rb +8 -7
- data/spec/unit/resource/apt_repository_spec.rb +4 -4
- data/spec/unit/resource/apt_update_spec.rb +4 -4
- data/spec/unit/resource/conditional_spec.rb +46 -0
- data/spec/unit/resource/dsc_resource_spec.rb +8 -8
- data/spec/unit/resource/dsc_script_spec.rb +4 -4
- data/spec/unit/resource/freebsd_package_spec.rb +6 -6
- data/spec/unit/resource/launchd_spec.rb +3 -2
- data/spec/unit/resource/osx_profile_spec.rb +3 -2
- data/spec/unit/resource/remote_file_spec.rb +6 -6
- data/spec/unit/resource/service_spec.rb +14 -14
- data/spec/unit/resource/user_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +49 -0
- data/spec/unit/resource_collection_spec.rb +4 -4
- data/spec/unit/resource_definition_spec.rb +11 -11
- data/spec/unit/resource_reporter_spec.rb +4 -4
- data/spec/unit/resource_resolver_spec.rb +6 -6
- data/spec/unit/resource_spec.rb +36 -16
- data/spec/unit/run_context/child_run_context_spec.rb +4 -4
- data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
- data/spec/unit/run_context_spec.rb +8 -8
- data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/search/query_spec.rb +15 -14
- data/spec/unit/user_v1_spec.rb +8 -8
- data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
- data/spec/unit/util/dsc/resource_store.rb +8 -6
- data/spec/unit/util/editor_spec.rb +6 -6
- data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
- data/tasks/bin/bundle-platform +1 -0
- data/tasks/bin/bundler_patch.rb +27 -0
- data/tasks/cbgb.rb +2 -2
- data/tasks/maintainers.rb +2 -2
- metadata +37 -8
- data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -184,9 +184,7 @@ class Chef
|
|
184
184
|
sleep(0.01)
|
185
185
|
end
|
186
186
|
|
187
|
-
until @unconsumed_output.empty?
|
188
|
-
yield @unconsumed_output.pop
|
189
|
-
end
|
187
|
+
yield @unconsumed_output.pop until @unconsumed_output.empty?
|
190
188
|
|
191
189
|
# If no one is working on our tasks and we're allowed to
|
192
190
|
# work on them in the main thread, process an input to
|
@@ -227,9 +225,7 @@ class Chef
|
|
227
225
|
|
228
226
|
def stop
|
229
227
|
@unconsumed_input.clear
|
230
|
-
while @in_process.size > 0
|
231
|
-
sleep(0.05)
|
232
|
-
end
|
228
|
+
sleep(0.05) while @in_process.size > 0
|
233
229
|
@unconsumed_output.clear
|
234
230
|
end
|
235
231
|
|
@@ -3,6 +3,7 @@ require "chef/cookbook_version"
|
|
3
3
|
require "chef/cookbook/chefignore"
|
4
4
|
require "chef/cookbook/metadata"
|
5
5
|
require "chef/util/path_helper"
|
6
|
+
require "find"
|
6
7
|
|
7
8
|
class Chef
|
8
9
|
class Cookbook
|
@@ -168,7 +169,7 @@ class Chef
|
|
168
169
|
when /\.json$/
|
169
170
|
apply_json_metadata(metadata_file)
|
170
171
|
else
|
171
|
-
raise
|
172
|
+
raise "Invalid metadata file: #{metadata_file} for cookbook: #{cookbook_version}"
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
@@ -223,27 +224,31 @@ class Chef
|
|
223
224
|
# however if the file is named ".uploaded-cookbook-version.json" it is
|
224
225
|
# assumed to be managed by chef-zero and not part of the cookbook.
|
225
226
|
def load_all_files
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
next
|
227
|
+
return unless File.exist?(cookbook_path)
|
228
|
+
|
229
|
+
# If cookbook_path is a symlink, Find on Windows Ruby 2.3 will not traverse it.
|
230
|
+
# Dir.entries will do so on all platforms, so we iterate the top level using
|
231
|
+
# Dir.entries. Since we have different behavior at the top anyway (hidden
|
232
|
+
# directories at the top level are not included for backcompat), this
|
233
|
+
# actually keeps things a bit cleaner.
|
234
|
+
Dir.entries(cookbook_path).each do |top_filename|
|
235
|
+
# Skip top-level directories starting with "."
|
236
|
+
top_path = File.join(cookbook_path, top_filename)
|
237
|
+
next if File.directory?(top_path) && top_filename.start_with?(".")
|
238
|
+
|
239
|
+
# Use Find.find because it:
|
240
|
+
# (a) returns any children, recursively
|
241
|
+
# (b) includes top_path as well
|
242
|
+
# (c) skips symlinks, which is backcompat (no judgement on whether it was *right*)
|
243
|
+
Find.find(top_path) do |path|
|
244
|
+
# Only add files, not directories
|
245
|
+
next unless File.file?(path)
|
246
|
+
# Don't add .uploaded-cookbook-version.json
|
247
|
+
next if File.basename(path) == UPLOADED_COOKBOOK_VERSION_FILE
|
248
|
+
|
249
|
+
relative_path = Chef::Util::PathHelper.relative_path_from(cookbook_path, path)
|
250
|
+
path = Pathname.new(path).cleanpath.to_s
|
251
|
+
cookbook_settings[:all_files][relative_path] = path
|
247
252
|
end
|
248
253
|
end
|
249
254
|
end
|
@@ -152,11 +152,11 @@ class Chef
|
|
152
152
|
queue << lambda do |lock|
|
153
153
|
full_file_path = sync_file(file)
|
154
154
|
|
155
|
-
lock.synchronize
|
155
|
+
lock.synchronize do
|
156
156
|
# Save the full_path of the downloaded file to be restored in the manifest later
|
157
157
|
save_full_file_path(file, full_file_path)
|
158
158
|
mark_file_synced(file)
|
159
|
-
|
159
|
+
end
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -291,7 +291,7 @@ class Chef
|
|
291
291
|
end
|
292
292
|
|
293
293
|
def server_api
|
294
|
-
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
|
294
|
+
Thread.current[:server_api] ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], keepalives: true)
|
295
295
|
end
|
296
296
|
|
297
297
|
end
|
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
# inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
|
32
32
|
class CookbookSiteStreamingUploader
|
33
33
|
|
34
|
-
DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION }
|
34
|
+
DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION } # rubocop:disable Style/ConstantName
|
35
35
|
|
36
36
|
class << self
|
37
37
|
|
@@ -149,11 +149,11 @@ class Chef
|
|
149
149
|
alias :to_s :body
|
150
150
|
|
151
151
|
# BUGBUG this makes the response compatible with what respsonse_steps expects to test headers (response.headers[] -> response[])
|
152
|
-
def headers
|
152
|
+
def headers # rubocop:disable Lint/NestedMethodDefinition
|
153
153
|
self
|
154
154
|
end
|
155
155
|
|
156
|
-
def status
|
156
|
+
def status # rubocop:disable Lint/NestedMethodDefinition
|
157
157
|
code.to_i
|
158
158
|
end
|
159
159
|
end
|
@@ -55,7 +55,7 @@ class Chef
|
|
55
55
|
checksum_files.merge!(cb.checksums)
|
56
56
|
end
|
57
57
|
|
58
|
-
checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil
|
58
|
+
checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil; memo }
|
59
59
|
new_sandbox = rest.post("sandboxes", { :checksums => checksums })
|
60
60
|
|
61
61
|
Chef::Log.info("Uploading files")
|
@@ -316,13 +316,13 @@ class Chef
|
|
316
316
|
error_message << error_locations.join("\n")
|
317
317
|
existing_files = segment_filenames(segment)
|
318
318
|
# Strip the root_dir prefix off all files for readability
|
319
|
-
pretty_existing_files = existing_files.map
|
319
|
+
pretty_existing_files = existing_files.map do |path|
|
320
320
|
if root_dir
|
321
321
|
path[root_dir.length + 1..-1]
|
322
322
|
else
|
323
323
|
path
|
324
324
|
end
|
325
|
-
|
325
|
+
end
|
326
326
|
# Show the files that the cookbook does have. If the user made a typo,
|
327
327
|
# hopefully they'll see it here.
|
328
328
|
unless pretty_existing_files.empty?
|
@@ -599,12 +599,12 @@ class Chef
|
|
599
599
|
end
|
600
600
|
end
|
601
601
|
|
602
|
-
def <=>(
|
603
|
-
raise Chef::Exceptions::CookbookVersionNameMismatch if self.name !=
|
602
|
+
def <=>(other)
|
603
|
+
raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != other.name
|
604
604
|
# FIXME: can we change the interface to the Metadata class such
|
605
605
|
# that metadata.version returns a Chef::Version instance instead
|
606
606
|
# of a string?
|
607
|
-
Chef::Version.new(self.version) <=> Chef::Version.new(
|
607
|
+
Chef::Version.new(self.version) <=> Chef::Version.new(other.version)
|
608
608
|
end
|
609
609
|
|
610
610
|
private
|
@@ -623,7 +623,7 @@ class Chef
|
|
623
623
|
# For each filename, produce a mapping of base filename (i.e. recipe name
|
624
624
|
# or attribute file) to on disk location
|
625
625
|
def filenames_by_name(filenames)
|
626
|
-
filenames.select { |filename| filename =~ /\.rb$/ }.inject({}) { |memo, filename| memo[File.basename(filename, ".rb")] = filename
|
626
|
+
filenames.select { |filename| filename =~ /\.rb$/ }.inject({}) { |memo, filename| memo[File.basename(filename, ".rb")] = filename; memo }
|
627
627
|
end
|
628
628
|
|
629
629
|
def file_vendor
|
data/lib/chef/dsl/powershell.rb
CHANGED
@@ -21,7 +21,7 @@ require "chef/util/powershell/ps_credential"
|
|
21
21
|
class Chef
|
22
22
|
module DSL
|
23
23
|
module Powershell
|
24
|
-
def ps_credential(username = "placeholder", password)
|
24
|
+
def ps_credential(username = "placeholder", password) # rubocop:disable Style/OptionalArguments
|
25
25
|
Chef::Util::Powershell::PSCredential.new(username, password)
|
26
26
|
end
|
27
27
|
end
|
@@ -232,11 +232,11 @@ class Chef
|
|
232
232
|
end
|
233
233
|
|
234
234
|
# Called after the recipe has been loaded
|
235
|
-
def recipe_file_loaded(path)
|
235
|
+
def recipe_file_loaded(path, recipe)
|
236
236
|
end
|
237
237
|
|
238
238
|
# Called after a recipe file fails to load
|
239
|
-
def recipe_file_load_failed(path, exception)
|
239
|
+
def recipe_file_load_failed(path, exception, recipe)
|
240
240
|
end
|
241
241
|
|
242
242
|
# Called when a recipe cannot be resolved
|
data/lib/chef/exceptions.rb
CHANGED
@@ -184,7 +184,7 @@ class Chef
|
|
184
184
|
|
185
185
|
# A different version of a cookbook was added to a
|
186
186
|
# VersionedRecipeList than the one already there.
|
187
|
-
class CookbookVersionConflict < ArgumentError
|
187
|
+
class CookbookVersionConflict < ArgumentError; end
|
188
188
|
|
189
189
|
# does not follow X.Y.Z format. ArgumentError?
|
190
190
|
class InvalidPlatformVersion < ArgumentError; end
|
data/lib/chef/file_cache.rb
CHANGED
data/lib/chef/formatters/base.rb
CHANGED
@@ -203,12 +203,12 @@ class Chef
|
|
203
203
|
end
|
204
204
|
|
205
205
|
# Delegates to #file_loaded
|
206
|
-
def recipe_file_loaded(path)
|
206
|
+
def recipe_file_loaded(path, recipe)
|
207
207
|
file_loaded(path)
|
208
208
|
end
|
209
209
|
|
210
210
|
# Delegates to #file_load_failed
|
211
|
-
def recipe_file_load_failed(path, exception)
|
211
|
+
def recipe_file_load_failed(path, exception, recipe)
|
212
212
|
file_load_failed(path, exception)
|
213
213
|
end
|
214
214
|
|
data/lib/chef/formatters/doc.rb
CHANGED
@@ -32,9 +32,9 @@ class Chef
|
|
32
32
|
|
33
33
|
def pretty_elapsed_time
|
34
34
|
time = elapsed_time
|
35
|
-
if time < 60
|
35
|
+
if time < 60
|
36
36
|
message = Time.at(time).utc.strftime("%S seconds")
|
37
|
-
elsif time < 3600
|
37
|
+
elsif time < 3600
|
38
38
|
message = Time.at(time).utc.strftime("%M minutes %S seconds")
|
39
39
|
else
|
40
40
|
message = Time.at(time).utc.strftime("%H hours %M minutes %S seconds")
|
data/lib/chef/http.rb
CHANGED
@@ -77,6 +77,9 @@ class Chef
|
|
77
77
|
|
78
78
|
attr_reader :middlewares
|
79
79
|
|
80
|
+
# [Boolean] if we're doing keepalives or not
|
81
|
+
attr_reader :keepalives
|
82
|
+
|
80
83
|
# Create a HTTP client object. The supplied +url+ is used as the base for
|
81
84
|
# all subsequent requests. For example, when initialized with a base url
|
82
85
|
# http://localhost:4000, a call to +get+ with 'nodes' will make an
|
@@ -87,6 +90,7 @@ class Chef
|
|
87
90
|
@sign_on_redirect = true
|
88
91
|
@redirects_followed = 0
|
89
92
|
@redirect_limit = 10
|
93
|
+
@keepalives = options[:keepalives] || false
|
90
94
|
@options = options
|
91
95
|
|
92
96
|
@middlewares = []
|
@@ -228,6 +232,33 @@ class Chef
|
|
228
232
|
|
229
233
|
def http_client(base_url = nil)
|
230
234
|
base_url ||= url
|
235
|
+
if keepalives && !base_url.nil?
|
236
|
+
# only reuse the http_client if we want keepalives and have a base_url
|
237
|
+
@http_client ||= {}
|
238
|
+
# the per-host per-port cache here gets peristent connections correct when
|
239
|
+
# redirecting to different servers
|
240
|
+
if base_url.is_a?(String) # sigh, this kind of abuse can't happen with strongly typed languages
|
241
|
+
@http_client[base_url] ||= build_http_client(base_url)
|
242
|
+
else
|
243
|
+
@http_client[base_url.host] ||= {}
|
244
|
+
@http_client[base_url.host][base_url.port] ||= build_http_client(base_url)
|
245
|
+
end
|
246
|
+
else
|
247
|
+
build_http_client(base_url)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# DEPRECATED: This is only kept around to provide access to cache control data in
|
252
|
+
# lib/chef/provider/remote_file/http.rb
|
253
|
+
# FIXME: Find a better API.
|
254
|
+
def last_response
|
255
|
+
@last_response
|
256
|
+
end
|
257
|
+
|
258
|
+
private
|
259
|
+
|
260
|
+
# @api private
|
261
|
+
def build_http_client(base_url)
|
231
262
|
if chef_zero_uri?(base_url)
|
232
263
|
# PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick
|
233
264
|
# via chef-zero and that hits DNS (at *require* time) which may timeout,
|
@@ -239,12 +270,11 @@ class Chef
|
|
239
270
|
|
240
271
|
SocketlessChefZeroClient.new(base_url)
|
241
272
|
else
|
242
|
-
BasicClient.new(base_url, :
|
273
|
+
BasicClient.new(base_url, ssl_policy: Chef::HTTP::APISSLPolicy, keepalives: keepalives)
|
243
274
|
end
|
244
275
|
end
|
245
276
|
|
246
|
-
|
247
|
-
|
277
|
+
# @api private
|
248
278
|
def create_url(path)
|
249
279
|
return path if path.is_a?(URI)
|
250
280
|
if path =~ /^(http|https|chefzero):\/\//i
|
@@ -259,6 +289,7 @@ class Chef
|
|
259
289
|
end
|
260
290
|
end
|
261
291
|
|
292
|
+
# @api private
|
262
293
|
def apply_request_middleware(method, url, headers, data)
|
263
294
|
middlewares.inject([method, url, headers, data]) do |req_data, middleware|
|
264
295
|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_request")
|
@@ -266,6 +297,7 @@ class Chef
|
|
266
297
|
end
|
267
298
|
end
|
268
299
|
|
300
|
+
# @api private
|
269
301
|
def apply_response_middleware(response, rest_request, return_value)
|
270
302
|
middlewares.reverse.inject([response, rest_request, return_value]) do |res_data, middleware|
|
271
303
|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_response")
|
@@ -273,6 +305,7 @@ class Chef
|
|
273
305
|
end
|
274
306
|
end
|
275
307
|
|
308
|
+
# @api private
|
276
309
|
def apply_stream_complete_middleware(response, rest_request, return_value)
|
277
310
|
middlewares.reverse.inject([response, rest_request, return_value]) do |res_data, middleware|
|
278
311
|
Chef::Log.debug("Chef::HTTP calling #{middleware.class}#handle_stream_complete")
|
@@ -280,6 +313,7 @@ class Chef
|
|
280
313
|
end
|
281
314
|
end
|
282
315
|
|
316
|
+
# @api private
|
283
317
|
def log_failed_request(response, return_value)
|
284
318
|
return_value ||= {}
|
285
319
|
error_message = "HTTP Request Returned #{response.code} #{response.message}: "
|
@@ -287,12 +321,14 @@ class Chef
|
|
287
321
|
Chef::Log.info(error_message)
|
288
322
|
end
|
289
323
|
|
324
|
+
# @api private
|
290
325
|
def success_response?(response)
|
291
326
|
response.kind_of?(Net::HTTPSuccess) || response.kind_of?(Net::HTTPRedirection)
|
292
327
|
end
|
293
328
|
|
294
329
|
# Runs a synchronous HTTP request, with no middleware applied (use #request
|
295
330
|
# to have the middleware applied). The entire response will be loaded into memory.
|
331
|
+
# @api private
|
296
332
|
def send_http_request(method, url, headers, body, &response_handler)
|
297
333
|
headers = build_headers(method, url, headers, body)
|
298
334
|
|
@@ -328,6 +364,7 @@ class Chef
|
|
328
364
|
# Wraps an HTTP request with retry logic.
|
329
365
|
# === Arguments
|
330
366
|
# url:: URL of the request, used for error messages
|
367
|
+
# @api private
|
331
368
|
def retrying_http_errors(url)
|
332
369
|
http_attempts = 0
|
333
370
|
begin
|
@@ -377,18 +414,22 @@ class Chef
|
|
377
414
|
end
|
378
415
|
end
|
379
416
|
|
417
|
+
# @api private
|
380
418
|
def http_retry_delay
|
381
419
|
config[:http_retry_delay]
|
382
420
|
end
|
383
421
|
|
422
|
+
# @api private
|
384
423
|
def http_retry_count
|
385
424
|
config[:http_retry_count]
|
386
425
|
end
|
387
426
|
|
427
|
+
# @api private
|
388
428
|
def config
|
389
429
|
Chef::Config
|
390
430
|
end
|
391
431
|
|
432
|
+
# @api private
|
392
433
|
def follow_redirect
|
393
434
|
raise Chef::Exceptions::RedirectLimitExceeded if @redirects_followed >= redirect_limit
|
394
435
|
@redirects_followed += 1
|
@@ -399,13 +440,13 @@ class Chef
|
|
399
440
|
@redirects_followed = 0
|
400
441
|
end
|
401
442
|
|
402
|
-
private
|
403
|
-
|
443
|
+
# @api private
|
404
444
|
def chef_zero_uri?(uri)
|
405
445
|
uri = URI.parse(uri) unless uri.respond_to?(:scheme)
|
406
446
|
uri.scheme == "chefzero"
|
407
447
|
end
|
408
448
|
|
449
|
+
# @api private
|
409
450
|
def redirected_to(response)
|
410
451
|
return nil unless response.kind_of?(Net::HTTPRedirection)
|
411
452
|
# Net::HTTPNotModified is undesired subclass of Net::HTTPRedirection so test for this
|
@@ -413,6 +454,7 @@ class Chef
|
|
413
454
|
response["location"]
|
414
455
|
end
|
415
456
|
|
457
|
+
# @api private
|
416
458
|
def build_headers(method, url, headers = {}, json_body = false)
|
417
459
|
headers = @default_headers.merge(headers)
|
418
460
|
headers["Content-Length"] = json_body.bytesize.to_s if json_body
|
@@ -420,6 +462,7 @@ class Chef
|
|
420
462
|
headers
|
421
463
|
end
|
422
464
|
|
465
|
+
# @api private
|
423
466
|
def stream_to_tempfile(url, response, &progress_block)
|
424
467
|
content_length = response["Content-Length"]
|
425
468
|
tf = Tempfile.open("chef-rest")
|
@@ -443,18 +486,5 @@ class Chef
|
|
443
486
|
raise
|
444
487
|
end
|
445
488
|
|
446
|
-
public
|
447
|
-
|
448
|
-
############################################################################
|
449
|
-
# DEPRECATED
|
450
|
-
############################################################################
|
451
|
-
|
452
|
-
# This is only kept around to provide access to cache control data in
|
453
|
-
# lib/chef/provider/remote_file/http.rb
|
454
|
-
# Find a better API.
|
455
|
-
def last_response
|
456
|
-
@last_response
|
457
|
-
end
|
458
|
-
|
459
489
|
end
|
460
490
|
end
|