chef 15.4.45-universal-mingw32 → 15.5.9-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/ext/win32-eventlog/Rakefile +9 -1
- data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +33 -9
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
data/lib/chef/mash.rb
CHANGED
@@ -1,232 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
# ---
|
23
|
-
# ---
|
24
|
-
|
25
|
-
# Some portions of blank.rb and mash.rb are verbatim copies of software
|
26
|
-
# licensed under the MIT license. That license is included below:
|
27
|
-
|
28
|
-
# Copyright 2005-2016, David Heinemeier Hansson
|
29
|
-
|
30
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
31
|
-
# a copy of this software and associated documentation files (the
|
32
|
-
# "Software"), to deal in the Software without restriction, including
|
33
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
34
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
35
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
36
|
-
# the following conditions:
|
37
|
-
|
38
|
-
# The above copyright notice and this permission notice shall be
|
39
|
-
# included in all copies or substantial portions of the Software.
|
40
|
-
|
41
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
42
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
43
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
44
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
45
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
46
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
47
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
|
-
|
49
|
-
# This class has dubious semantics and we only have it so that people can write
|
50
|
-
# params[:key] instead of params['key'].
|
51
|
-
class Mash < Hash
|
52
|
-
|
53
|
-
# @param constructor<Object>
|
54
|
-
# The default value for the mash. Defaults to an empty hash.
|
55
|
-
#
|
56
|
-
# @details [Alternatives]
|
57
|
-
# If constructor is a Hash, a new mash will be created based on the keys of
|
58
|
-
# the hash and no default value will be set.
|
59
|
-
def initialize(constructor = {})
|
60
|
-
if constructor.is_a?(Hash)
|
61
|
-
super()
|
62
|
-
update(constructor)
|
63
|
-
else
|
64
|
-
super(constructor)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# @param orig<Object> Mash being copied
|
69
|
-
#
|
70
|
-
# @return [Object] A new copied Mash
|
71
|
-
def initialize_copy(orig)
|
72
|
-
super
|
73
|
-
# Handle nested values
|
74
|
-
each do |k, v|
|
75
|
-
if v.is_a?(Mash) || v.is_a?(Array)
|
76
|
-
self[k] = v.dup
|
77
|
-
end
|
78
|
-
end
|
79
|
-
self
|
80
|
-
end
|
81
|
-
|
82
|
-
# @param key<Object> The default value for the mash. Defaults to nil.
|
83
|
-
#
|
84
|
-
# @details [Alternatives]
|
85
|
-
# If key is a Symbol and it is a key in the mash, then the default value will
|
86
|
-
# be set to the value matching the key.
|
87
|
-
def default(key = nil)
|
88
|
-
if key.is_a?(Symbol) && include?(key = key.to_s)
|
89
|
-
self[key]
|
90
|
-
else
|
91
|
-
super
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
96
|
-
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
97
|
-
|
98
|
-
# @param key<Object> The key to set.
|
99
|
-
# @param value<Object>
|
100
|
-
# The value to set the key to.
|
101
|
-
#
|
102
|
-
# @see Mash#convert_key
|
103
|
-
# @see Mash#convert_value
|
104
|
-
def []=(key, value)
|
105
|
-
regular_writer(convert_key(key), convert_value(value))
|
106
|
-
end
|
107
|
-
|
108
|
-
# internal API for use by Chef's deep merge cache
|
109
|
-
# @api private
|
110
|
-
def internal_set(key, value)
|
111
|
-
regular_writer(key, convert_value(value))
|
112
|
-
end
|
113
|
-
|
114
|
-
# @param other_hash<Hash>
|
115
|
-
# A hash to update values in the mash with. The keys and the values will be
|
116
|
-
# converted to Mash format.
|
117
|
-
#
|
118
|
-
# @return [Mash] The updated mash.
|
119
|
-
def update(other_hash)
|
120
|
-
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
|
121
|
-
self
|
122
|
-
end
|
123
|
-
|
124
|
-
alias_method :merge!, :update
|
125
|
-
|
126
|
-
# @param key<Object> The key to check for. This will be run through convert_key.
|
127
|
-
#
|
128
|
-
# @return [Boolean] True if the key exists in the mash.
|
129
|
-
def key?(key)
|
130
|
-
super(convert_key(key))
|
131
|
-
end
|
132
|
-
|
133
|
-
# def include? def has_key? def member?
|
134
|
-
alias_method :include?, :key?
|
135
|
-
alias_method :has_key?, :key?
|
136
|
-
alias_method :member?, :key?
|
137
|
-
|
138
|
-
# @param key<Object> The key to fetch. This will be run through convert_key.
|
139
|
-
# @param *extras<Array> Default value.
|
140
|
-
#
|
141
|
-
# @return [Object] The value at key or the default value.
|
142
|
-
def fetch(key, *extras)
|
143
|
-
super(convert_key(key), *extras)
|
144
|
-
end
|
145
|
-
|
146
|
-
# @param *indices<Array>
|
147
|
-
# The keys to retrieve values for. These will be run through +convert_key+.
|
148
|
-
#
|
149
|
-
# @return [Array] The values at each of the provided keys
|
150
|
-
def values_at(*indices)
|
151
|
-
indices.collect { |key| self[convert_key(key)] }
|
152
|
-
end
|
153
|
-
|
154
|
-
# @param hash<Hash> The hash to merge with the mash.
|
155
|
-
#
|
156
|
-
# @return [Mash] A new mash with the hash values merged in.
|
157
|
-
def merge(hash)
|
158
|
-
dup.update(hash)
|
159
|
-
end
|
160
|
-
|
161
|
-
# @param key<Object>
|
162
|
-
# The key to delete from the mash.\
|
163
|
-
def delete(key)
|
164
|
-
super(convert_key(key))
|
165
|
-
end
|
166
|
-
|
167
|
-
# @param *rejected<Array[(String, Symbol)] The mash keys to exclude.
|
168
|
-
#
|
169
|
-
# @return [Mash] A new mash without the selected keys.
|
170
|
-
#
|
171
|
-
# @example
|
172
|
-
# { :one => 1, :two => 2, :three => 3 }.except(:one)
|
173
|
-
# #=> { "two" => 2, "three" => 3 }
|
174
|
-
def except(*keys)
|
175
|
-
super(*keys.map { |k| convert_key(k) })
|
176
|
-
end
|
177
|
-
|
178
|
-
# Used to provide the same interface as Hash.
|
179
|
-
#
|
180
|
-
# @return [Mash] This mash unchanged.
|
181
|
-
def stringify_keys!; self end
|
182
|
-
|
183
|
-
# @return [Hash] The mash as a Hash with symbolized keys.
|
184
|
-
def symbolize_keys
|
185
|
-
h = Hash.new(default)
|
186
|
-
each { |key, val| h[key.to_sym] = val }
|
187
|
-
h
|
188
|
-
end
|
189
|
-
|
190
|
-
# @return [Hash] The mash as a Hash with string keys.
|
191
|
-
def to_hash
|
192
|
-
Hash.new(default).merge(self)
|
193
|
-
end
|
194
|
-
|
195
|
-
# @return [Mash] Convert a Hash into a Mash
|
196
|
-
# The input Hash's default value is maintained
|
197
|
-
def self.from_hash(hash)
|
198
|
-
mash = Mash.new(hash)
|
199
|
-
mash.default = hash.default
|
200
|
-
mash
|
201
|
-
end
|
202
|
-
|
203
|
-
protected
|
204
|
-
|
205
|
-
# @param key<Object> The key to convert.
|
206
|
-
#
|
207
|
-
# @param [Object]
|
208
|
-
# The converted key. If the key was a symbol, it will be converted to a
|
209
|
-
# string.
|
210
|
-
#
|
211
|
-
# @api private
|
212
|
-
def convert_key(key)
|
213
|
-
key.is_a?(Symbol) ? key.to_s : key
|
214
|
-
end
|
215
|
-
|
216
|
-
# @param value<Object> The value to convert.
|
217
|
-
#
|
218
|
-
# @return [Object]
|
219
|
-
# The converted value. A Hash or an Array of hashes, will be converted to
|
220
|
-
# their Mash equivalents.
|
221
|
-
#
|
222
|
-
# @api private
|
223
|
-
def convert_value(value)
|
224
|
-
if value.class == Hash
|
225
|
-
Mash.from_hash(value)
|
226
|
-
elsif value.is_a?(Array)
|
227
|
-
value.collect { |e| convert_value(e) }
|
228
|
-
else
|
229
|
-
value
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "chef-utils/mash" unless defined?(ChefUtils::Mash)
|
19
|
+
|
20
|
+
# For historical reasons we inject Mash directly into the top level class namespace
|
21
|
+
Mash = ChefUtils::Mash unless defined?(Mash)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Mark Mzyk <mmzyk@chef.io>
|
3
3
|
# Author:: Seth Chisamore <schisamo@chef.io>
|
4
4
|
# Author:: Bryan McLellan <btm@chef.io>
|
5
|
-
# Copyright:: Copyright 2011-
|
5
|
+
# Copyright:: Copyright 2011-2019, Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
module FileClass
|
24
24
|
|
25
25
|
def file_class
|
26
|
-
@host_os_file ||= if
|
26
|
+
@host_os_file ||= if ChefUtils.windows?
|
27
27
|
require_relative "../win32/file"
|
28
28
|
Chef::ReservedNames::Win32::File
|
29
29
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
-
# Copyright:: Copyright 2011-
|
3
|
+
# Copyright:: Copyright 2011-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,49 +18,13 @@
|
|
18
18
|
|
19
19
|
class Chef
|
20
20
|
module Mixin
|
21
|
+
# @ deprecated
|
21
22
|
module PathSanity
|
22
|
-
|
23
23
|
def enforce_path_sanity(env = ENV)
|
24
24
|
if Chef::Config[:enforce_path_sanity]
|
25
|
-
env["PATH"] = sanitized_path(env)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def sanitized_path(env = ENV)
|
30
|
-
env_path = env["PATH"].nil? ? "" : env["PATH"].dup
|
31
|
-
path_separator = Chef::Platform.windows? ? ";" : ":"
|
32
|
-
# ensure the Ruby and Gem bindirs are included
|
33
|
-
# mainly for 'full-stack' Chef installs
|
34
|
-
new_paths = env_path.split(path_separator)
|
35
|
-
[ ruby_bindir, gem_bindir ].compact.each do |path|
|
36
|
-
new_paths = [ path ] + new_paths unless new_paths.include?(path)
|
37
|
-
end
|
38
|
-
sane_paths.each do |path|
|
39
|
-
new_paths << path unless new_paths.include?(path)
|
40
|
-
end
|
41
|
-
new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def sane_paths
|
47
|
-
@sane_paths ||= begin
|
48
|
-
if Chef::Platform.windows?
|
49
|
-
%w{}
|
50
|
-
else
|
51
|
-
%w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}
|
52
|
-
end
|
25
|
+
env["PATH"] = ChefUtils::DSL::PathSanity.sanitized_path(env)
|
53
26
|
end
|
54
27
|
end
|
55
|
-
|
56
|
-
def ruby_bindir
|
57
|
-
RbConfig::CONFIG["bindir"]
|
58
|
-
end
|
59
|
-
|
60
|
-
def gem_bindir
|
61
|
-
Gem.bindir
|
62
|
-
end
|
63
|
-
|
64
28
|
end
|
65
29
|
end
|
66
30
|
end
|
data/lib/chef/mixin/securable.rb
CHANGED
data/lib/chef/mixin/shell_out.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,12 +16,11 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
18
|
require "mixlib/shellout" unless defined?(Mixlib::ShellOut::DEFAULT_READ_TIMEOUT)
|
19
|
-
|
19
|
+
require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
module Mixin
|
23
23
|
module ShellOut
|
24
|
-
extend Chef::Mixin::PathSanity
|
25
24
|
|
26
25
|
# PREFERRED APIS:
|
27
26
|
#
|
@@ -97,7 +96,7 @@ class Chef
|
|
97
96
|
"LC_ALL" => Chef::Config[:internal_locale],
|
98
97
|
"LANGUAGE" => Chef::Config[:internal_locale],
|
99
98
|
"LANG" => Chef::Config[:internal_locale],
|
100
|
-
env_path => sanitized_path,
|
99
|
+
env_path => ChefUtils::DSL::PathSanity.sanitized_path,
|
101
100
|
}.update(options[env_key] || {})
|
102
101
|
end
|
103
102
|
options
|
@@ -182,7 +181,7 @@ class Chef
|
|
182
181
|
end
|
183
182
|
|
184
183
|
def self.env_path
|
185
|
-
if
|
184
|
+
if ChefUtils.windows?
|
186
185
|
"Path"
|
187
186
|
else
|
188
187
|
"PATH"
|
data/lib/chef/mixin/template.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Edwards (<adamed@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2016 Chef Software
|
3
|
+
# Copyright:: Copyright (c) 2016-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require_relative "../util/windows/logon_session" if
|
19
|
+
require_relative "../util/windows/logon_session" if ChefUtils.windows?
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
module Mixin
|
@@ -26,7 +26,7 @@ class Chef
|
|
26
26
|
# When authentication = :local, we use the credentials to create a logon session against the local system, and then try to access the files.
|
27
27
|
# When authentication = :remote, we continue with the current user but pass the provided credentials to the remote system.
|
28
28
|
def with_user_context(user, password, domain = nil, authentication = :remote, &block)
|
29
|
-
unless
|
29
|
+
unless ChefUtils.windows?
|
30
30
|
raise Exceptions::UnsupportedPlatform, "User context impersonation is supported only on the Windows platform"
|
31
31
|
end
|
32
32
|
|
data/lib/chef/mixin/which.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Lamont Granquist <lamont@chef.io>
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -15,49 +15,21 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
+
require "chef-utils/dsl/which" unless defined?(ChefUtils::DSL::Which)
|
19
|
+
require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
|
20
|
+
|
18
21
|
class Chef
|
19
22
|
module Mixin
|
20
23
|
module Which
|
21
|
-
|
22
|
-
|
23
|
-
def which(*cmds, extra_path: nil, &block)
|
24
|
-
where(*cmds, extra_path: extra_path, &block).first || false
|
25
|
-
end
|
26
|
-
|
27
|
-
def where(*cmds, extra_path: nil, &block)
|
28
|
-
# NOTE: unnecessarily duplicates function of path_sanity
|
29
|
-
extra_path ||= [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
|
30
|
-
paths = env_path.split(File::PATH_SEPARATOR) + Array(extra_path)
|
31
|
-
cmds.map do |cmd|
|
32
|
-
paths.map do |path|
|
33
|
-
filename = Chef.path_to(File.join(path, cmd))
|
34
|
-
filename if valid_executable?(filename, &block)
|
35
|
-
end.compact
|
36
|
-
end.flatten
|
37
|
-
end
|
24
|
+
include ChefUtils::DSL::Which
|
38
25
|
|
39
26
|
private
|
40
27
|
|
41
|
-
# for
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ENV["PATH"]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def valid_executable?(filename, &block)
|
51
|
-
is_executable =
|
52
|
-
if Chef::Config.target_mode?
|
53
|
-
connection = Chef.run_context.transport_connection
|
54
|
-
connection.file(filename).stat[:mode] & 1 && !connection.file(filename).directory?
|
55
|
-
else
|
56
|
-
File.executable?(filename) && !File.directory?(filename)
|
57
|
-
end
|
58
|
-
return false unless is_executable
|
59
|
-
|
60
|
-
block ? yield(filename) : true
|
28
|
+
# we dep-inject path sanity into this API for historical reasons
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def __extra_path
|
32
|
+
ChefUtils::DSL::PathSanity.sane_paths
|
61
33
|
end
|
62
34
|
end
|
63
35
|
end
|