chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -37,16 +37,14 @@ class Chef
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def read
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
49
|
-
end
|
40
|
+
tmpfile = rest.streaming_request(file[:url])
|
41
|
+
File.open(tmpfile, "rb") { |f| f.read }
|
42
|
+
rescue Timeout::Error => e
|
43
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
|
44
|
+
rescue Net::HTTPServerException => e
|
45
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "#{e.message} retrieving #{file[:url]}")
|
46
|
+
rescue Errno::ENOENT
|
47
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
50
48
|
end
|
51
49
|
|
52
50
|
def rest
|
@@ -30,16 +30,14 @@ class Chef
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def children
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error getting children: #{e}")
|
42
|
-
end
|
33
|
+
@children ||= root.get_json(api_path).keys.sort.map { |entry| make_child_entry(entry, true) }
|
34
|
+
rescue Timeout::Error => e
|
35
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout getting children: #{e}")
|
36
|
+
rescue Net::HTTPServerException => e
|
37
|
+
if e.response.code == "404"
|
38
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
|
39
|
+
else
|
40
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error getting children: #{e}")
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -28,18 +28,16 @@ class Chef
|
|
28
28
|
class NodesDir < RestListDir
|
29
29
|
# Identical to RestListDir.children, except supports environments
|
30
30
|
def children
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
42
|
-
end
|
31
|
+
@children ||= root.get_json(env_api_path).keys.sort.map do |key|
|
32
|
+
make_child_entry(key, true)
|
33
|
+
end
|
34
|
+
rescue Timeout::Error => e
|
35
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
|
36
|
+
rescue Net::HTTPServerException => e
|
37
|
+
if $!.response.code == "404"
|
38
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
39
|
+
else
|
40
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -66,42 +66,40 @@ class Chef
|
|
66
66
|
# }
|
67
67
|
# }
|
68
68
|
def children
|
69
|
-
begin
|
70
69
|
# Grab the names of the children, append json, and make child entries
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
70
|
+
@children ||= begin
|
71
|
+
result = []
|
72
|
+
data = root.get_json(api_path)
|
73
|
+
data.keys.sort.each do |policy_name|
|
74
|
+
data[policy_name]["revisions"].keys.each do |policy_revision|
|
75
|
+
filename = "#{policy_name}-#{policy_revision}.json"
|
76
|
+
result << make_child_entry(filename, true)
|
79
77
|
end
|
80
|
-
result
|
81
78
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
raise Chef::ChefFS::FileSystem::
|
79
|
+
result
|
80
|
+
end
|
81
|
+
rescue Timeout::Error => e
|
82
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
|
83
|
+
rescue Net::HTTPServerException => e
|
84
|
+
# 404 = NotFoundError
|
85
|
+
if $!.response.code == "404"
|
86
|
+
# GET /organizations/ORG/policies returned 404, but that just might be because
|
87
|
+
# we are talking to an older version of the server that doesn't support policies.
|
88
|
+
# Do GET /orgqanizations/ORG to find out if the org exists at all.
|
89
|
+
# TODO use server API version instead of a second network request.
|
90
|
+
begin
|
91
|
+
root.get_json(parent.api_path)
|
92
|
+
# Return empty list if the organization exists but /policies didn't work
|
93
|
+
[]
|
94
|
+
rescue Net::HTTPServerException => e
|
95
|
+
if e.response.code == "404"
|
96
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
100
97
|
end
|
101
|
-
# Anything else is unexpected (OperationFailedError)
|
102
|
-
else
|
103
98
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
104
99
|
end
|
100
|
+
# Anything else is unexpected (OperationFailedError)
|
101
|
+
else
|
102
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
105
103
|
end
|
106
104
|
end
|
107
105
|
|
@@ -71,40 +71,38 @@ class Chef
|
|
71
71
|
# Children are foo.json and bar.json in this case.
|
72
72
|
#
|
73
73
|
def children
|
74
|
-
begin
|
75
74
|
# Grab the names of the children, append json, and make child entries
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
75
|
+
@children ||= root.get_json(api_path).keys.sort.map do |key|
|
76
|
+
make_child_entry(key, true)
|
77
|
+
end
|
78
|
+
rescue Timeout::Error => e
|
79
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
|
80
|
+
rescue Net::HTTPServerException => e
|
81
|
+
# 404 = NotFoundError
|
82
|
+
if $!.response.code == "404"
|
83
|
+
|
84
|
+
if parent.is_a?(ChefServerRootDir)
|
85
|
+
# GET /organizations/ORG/<container> returned 404, but that just might be because
|
86
|
+
# we are talking to an older version of the server that doesn't support policies.
|
87
|
+
# Do GET /organizations/ORG to find out if the org exists at all.
|
88
|
+
# TODO use server API version instead of a second network request.
|
89
|
+
begin
|
90
|
+
root.get_json(parent.api_path)
|
91
|
+
# Return empty list if the organization exists but /policies didn't work
|
92
|
+
[]
|
93
|
+
rescue Net::HTTPServerException => e
|
94
|
+
if e.response.code == "404"
|
95
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
99
96
|
end
|
100
|
-
|
101
|
-
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
97
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
102
98
|
end
|
103
|
-
|
104
|
-
# Anything else is unexpected (OperationFailedError)
|
105
99
|
else
|
106
|
-
raise Chef::ChefFS::FileSystem::
|
100
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
107
101
|
end
|
102
|
+
|
103
|
+
# Anything else is unexpected (OperationFailedError)
|
104
|
+
else
|
105
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "HTTP error retrieving children: #{e}")
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
@@ -85,16 +85,14 @@ class Chef
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def delete(recurse)
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
rest.delete(api_path)
|
89
|
+
rescue Timeout::Error => e
|
90
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e, "Timeout deleting: #{e}")
|
91
|
+
rescue Net::HTTPServerException => e
|
92
|
+
if e.response.code == "404"
|
93
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
|
94
|
+
else
|
91
95
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e, "Timeout deleting: #{e}")
|
92
|
-
rescue Net::HTTPServerException => e
|
93
|
-
if e.response.code == "404"
|
94
|
-
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
|
95
|
-
else
|
96
|
-
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e, "Timeout deleting: #{e}")
|
97
|
-
end
|
98
96
|
end
|
99
97
|
end
|
100
98
|
|
@@ -103,17 +101,15 @@ class Chef
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def _read_json
|
106
|
-
begin
|
107
104
|
# Minimize the value (get rid of defaults) so the results don't look terrible
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
105
|
+
root.get_json(api_path)
|
106
|
+
rescue Timeout::Error => e
|
107
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading: #{e}")
|
108
|
+
rescue Net::HTTPServerException => e
|
109
|
+
if $!.response.code == "404"
|
110
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
|
111
|
+
else
|
112
|
+
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "HTTP error reading: #{e}")
|
117
113
|
end
|
118
114
|
end
|
119
115
|
|
@@ -190,11 +186,9 @@ class Chef
|
|
190
186
|
end
|
191
187
|
|
192
188
|
def api_error_text(response)
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
response.body
|
197
|
-
end
|
189
|
+
Chef::JSONCompat.parse(response.body)["error"].join("\n")
|
190
|
+
rescue
|
191
|
+
response.body
|
198
192
|
end
|
199
193
|
end
|
200
194
|
|
@@ -17,22 +17,20 @@ class Chef
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def children
|
20
|
-
|
21
|
-
|
22
|
-
seen = {}
|
20
|
+
result = []
|
21
|
+
seen = {}
|
23
22
|
# If multiple things have the same name, the first one wins.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
23
|
+
multiplexed_dirs.each do |dir|
|
24
|
+
dir.children.each do |child|
|
25
|
+
if seen[child.name]
|
26
|
+
Chef::Log.warn("Child with name '#{child.name}' found in multiple directories: #{seen[child.name].path_for_printing} and #{child.path_for_printing}") unless seen[child.name].path_for_printing == child.path_for_printing
|
27
|
+
else
|
28
|
+
result << child
|
29
|
+
seen[child.name] = child
|
32
30
|
end
|
33
31
|
end
|
34
|
-
result
|
35
32
|
end
|
33
|
+
result
|
36
34
|
end
|
37
35
|
|
38
36
|
def make_child_entry(name)
|
@@ -80,18 +80,16 @@ class Chef
|
|
80
80
|
# Customizations of base class
|
81
81
|
|
82
82
|
def chef_object
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
raise "Cookbook #{file_path} empty."
|
88
|
-
end
|
89
|
-
cb
|
90
|
-
rescue => e
|
91
|
-
Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{e}")
|
92
|
-
Chef::Log.error(e.backtrace.join("\n"))
|
93
|
-
raise
|
83
|
+
cb = cookbook_version
|
84
|
+
if !cb
|
85
|
+
Chef::Log.error("Cookbook #{file_path} empty.")
|
86
|
+
raise "Cookbook #{file_path} empty."
|
94
87
|
end
|
88
|
+
cb
|
89
|
+
rescue => e
|
90
|
+
Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{e}")
|
91
|
+
Chef::Log.error(e.backtrace.join("\n"))
|
92
|
+
raise
|
95
93
|
end
|
96
94
|
|
97
95
|
def children
|
@@ -112,7 +110,7 @@ class Chef
|
|
112
110
|
def self.canonical_cookbook_name(entry_name)
|
113
111
|
name_match = Chef::ChefFS::FileSystem::ChefServer::VersionedCookbookDir::VALID_VERSIONED_COOKBOOK_NAME.match(entry_name)
|
114
112
|
return nil if name_match.nil?
|
115
|
-
|
113
|
+
name_match[1]
|
116
114
|
end
|
117
115
|
|
118
116
|
def canonical_cookbook_name(entry_name)
|
@@ -52,14 +52,12 @@ class Chef
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def children
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
62
|
-
end
|
55
|
+
entries = Dir.entries(file_path).sort.
|
56
|
+
map { |child_name| make_child_entry(child_name) }.
|
57
|
+
select { |child| child && can_have_child?(child.name, child.dir?) }
|
58
|
+
entries.select { |entry| !(entry.dir? && entry.children.size == 0 ) }
|
59
|
+
rescue Errno::ENOENT
|
60
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
63
61
|
end
|
64
62
|
|
65
63
|
def can_have_child?(name, is_dir)
|
@@ -140,11 +138,9 @@ class Chef
|
|
140
138
|
end
|
141
139
|
|
142
140
|
def read
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
147
|
-
end
|
141
|
+
File.open(file_path, "rb") { |f| f.read }
|
142
|
+
rescue Errno::ENOENT
|
143
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
148
144
|
end
|
149
145
|
|
150
146
|
def write(content)
|
@@ -113,9 +113,11 @@ class Chef
|
|
113
113
|
Dir.mkdir(path, 0700)
|
114
114
|
if Chef::Platform.windows?
|
115
115
|
all_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_ALL
|
116
|
+
administrators = Chef::ReservedNames::Win32::Security::SID.Administrators
|
116
117
|
owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
|
117
118
|
dacl = Chef::ReservedNames::Win32::Security::ACL.create([
|
118
119
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, all_mask),
|
120
|
+
Chef::ReservedNames::Win32::Security::ACE.access_allowed(administrators, all_mask),
|
119
121
|
])
|
120
122
|
so = Chef::ReservedNames::Win32::Security::SecurableObject.new(path)
|
121
123
|
so.owner = owner
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
class CookbooksDir < Repository::Directory
|
29
29
|
|
30
30
|
def chefignore
|
31
|
-
@chefignore ||= Chef::Cookbook::Chefignore.new(
|
31
|
+
@chefignore ||= Chef::Cookbook::Chefignore.new(file_path)
|
32
32
|
rescue Errno::EISDIR, Errno::EACCES
|
33
33
|
# Work around a bug in Chefignore when chefignore is a directory
|
34
34
|
end
|
@@ -38,10 +38,13 @@ class Chef
|
|
38
38
|
if Chef::Platform.windows?
|
39
39
|
read_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_READ
|
40
40
|
write_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE
|
41
|
+
administrators = Chef::ReservedNames::Win32::Security::SID.Administrators
|
41
42
|
owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
|
42
43
|
dacl = Chef::ReservedNames::Win32::Security::ACL.create([
|
43
44
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, read_mask),
|
44
45
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, write_mask),
|
46
|
+
Chef::ReservedNames::Win32::Security::ACE.access_allowed(administrators, read_mask),
|
47
|
+
Chef::ReservedNames::Win32::Security::ACE.access_allowed(administrators, write_mask),
|
45
48
|
])
|
46
49
|
so = Chef::ReservedNames::Win32::Security::SecurableObject.new(child.file_path)
|
47
50
|
so.owner = owner
|