summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:50:39 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:50:39 -0700
commitf50ffe2b1b3b0afc7aa2b01a9356e439f78a5fcd (patch)
tree204cefb3c64929278dc7e6a7f3de220475154533 /lib/chef
parent36075b93536da78cd50ffe4eebe1ae4613a04ec9 (diff)
downloadchef-f50ffe2b1b3b0afc7aa2b01a9356e439f78a5fcd.tar.gz
tweak Lint/BlockAlignment
Lint/BlockAlignment: Enabled: true EnforcedStyleAlignWith: start_of_block this works better with Layout/MultilineMethodCallIndentation to force indentation of multiline method calls that wind up with multiline blocks. i'd probably pull back the end to match with the start of the expression but this gets the indentation level inside the block correct. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/provider/package/windows/exe.rb6
-rw-r--r--lib/chef/provider/package/windows/msi.rb12
-rw-r--r--lib/chef/provider/remote_file.rb18
-rw-r--r--lib/chef/provider/service/debian.rb18
-rw-r--r--lib/chef/provider/service/windows.rb4
-rw-r--r--lib/chef/resource/dnf_package.rb24
-rw-r--r--lib/chef/resource/launchd.rb76
-rw-r--r--lib/chef/resource/locale.rb26
-rw-r--r--lib/chef/resource/windows_firewall_rule.rb6
-rw-r--r--lib/chef/win32/security/sid.rb12
10 files changed, 101 insertions, 101 deletions
diff --git a/lib/chef/provider/package/windows/exe.rb b/lib/chef/provider/package/windows/exe.rb
index c7460f938e..947f66e238 100644
--- a/lib/chef/provider/package/windows/exe.rb
+++ b/lib/chef/provider/package/windows/exe.rb
@@ -72,9 +72,9 @@ class Chef
uninstall_version = new_resource.version || current_installed_version
uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
.map(&:uninstall_string).uniq.each do |uninstall_string|
- logger.trace("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
- shell_out!(uninstall_command(uninstall_string), timeout: new_resource.timeout, returns: new_resource.returns)
- end
+ logger.trace("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
+ shell_out!(uninstall_command(uninstall_string), timeout: new_resource.timeout, returns: new_resource.returns)
+ end
end
private
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb
index 0298ad17c5..a6807afc17 100644
--- a/lib/chef/provider/package/windows/msi.rb
+++ b/lib/chef/provider/package/windows/msi.rb
@@ -82,12 +82,12 @@ class Chef
uninstall_version = new_resource.version || installed_version
uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
.map(&:uninstall_string).uniq.each do |uninstall_string|
- uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}"
- uninstall_string += expand_options(new_resource.options)
- uninstall_string += " /q" unless uninstall_string.downcase =~ / \/q/
- logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'")
- shell_out!(uninstall_string, timeout: new_resource.timeout, returns: new_resource.returns)
- end
+ uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}"
+ uninstall_string += expand_options(new_resource.options)
+ uninstall_string += " /q" unless uninstall_string.downcase =~ / \/q/
+ logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'")
+ shell_out!(uninstall_string, timeout: new_resource.timeout, returns: new_resource.returns)
+ end
end
end
end
diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb
index 4427680b51..a2506d6a15 100644
--- a/lib/chef/provider/remote_file.rb
+++ b/lib/chef/provider/remote_file.rb
@@ -32,18 +32,18 @@ class Chef
def define_resource_requirements
[ new_resource.remote_user, new_resource.remote_domain,
new_resource.remote_password ].each do |prop|
- requirements.assert(:all_actions) do |a|
- a.assertion do
- if prop
- node[:platform_family] == "windows"
- else
- true
+ requirements.assert(:all_actions) do |a|
+ a.assertion do
+ if prop
+ node[:platform_family] == "windows"
+ else
+ true
+ end
end
+ a.failure_message Chef::Exceptions::UnsupportedPlatform, "'remote_user', 'remote_domain' and 'remote_password' properties are supported only for Windows platform"
+ a.whyrun("Assuming that the platform is Windows while passing 'remote_user', 'remote_domain' and 'remote_password' properties")
end
- a.failure_message Chef::Exceptions::UnsupportedPlatform, "'remote_user', 'remote_domain' and 'remote_password' properties are supported only for Windows platform"
- a.whyrun("Assuming that the platform is Windows while passing 'remote_user', 'remote_domain' and 'remote_password' properties")
end
- end
super
end
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 3e1d6e7652..de76ed1416 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -58,15 +58,15 @@ class Chef
a.whyrun ["Unable to determine priority of service, assuming service would have been correctly installed earlier in the run.",
"Assigning temporary priorities to continue.",
"If this service is not properly installed prior to this point, this will fail."] do
- temp_priorities = { "6" => [:stop, "20"],
- "0" => [:stop, "20"],
- "1" => [:stop, "20"],
- "2" => [:start, "20"],
- "3" => [:start, "20"],
- "4" => [:start, "20"],
- "5" => [:start, "20"] }
- current_resource.priority(temp_priorities)
- end
+ temp_priorities = { "6" => [:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"] }
+ current_resource.priority(temp_priorities)
+ end
end
end
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb
index 750da6d1fd..e1bdabce42 100644
--- a/lib/chef/provider/service/windows.rb
+++ b/lib/chef/provider/service/windows.rb
@@ -211,8 +211,8 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
converge_if_changed :service_type, :startup_type, :error_control,
:binary_path_name, :load_order_group, :dependencies,
:run_as_user, :display_name, :description do
- Win32::Service.configure(windows_service_config(:configure))
- end
+ Win32::Service.configure(windows_service_config(:configure))
+ end
converge_delayed_start
end
diff --git a/lib/chef/resource/dnf_package.rb b/lib/chef/resource/dnf_package.rb
index a89f6bfcff..52c739beb9 100644
--- a/lib/chef/resource/dnf_package.rb
+++ b/lib/chef/resource/dnf_package.rb
@@ -56,18 +56,18 @@ class Chef
description: "Flush the in-memory cache before or after a DNF operation that installs, upgrades, or removes a package. DNF automatically synchronizes remote metadata to a local cache. The #{Chef::Dist::CLIENT} creates a copy of the local cache, and then stores it in-memory during the #{Chef::Dist::CLIENT} run. The in-memory cache allows packages to be installed during the #{Chef::Dist::CLIENT} run without the need to continue synchronizing the remote metadata to the local cache while the #{Chef::Dist::CLIENT} run is in-progress.",
default: { before: false, after: false },
coerce: proc { |v|
- if v.is_a?(Hash)
- v
- elsif v.is_a?(Array)
- v.each_with_object({}) { |arg, obj| obj[arg] = true }
- elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
- { before: v, after: v }
- elsif v == :before
- { before: true, after: false }
- elsif v == :after
- { after: true, before: false }
- end
- }
+ if v.is_a?(Hash)
+ v
+ elsif v.is_a?(Array)
+ v.each_with_object({}) { |arg, obj| obj[arg] = true }
+ elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
+ { before: v, after: v }
+ elsif v == :before
+ { before: true, after: false }
+ elsif v == :after
+ { after: true, before: false }
+ end
+ }
def allow_downgrade(arg = nil)
if !arg.nil?
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 6cc697eee8..39d95bbf69 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -77,54 +77,54 @@ class Chef
description: "A Hash (similar to crontab) that defines the calendar frequency at which a job is started or an Array.",
coerce: proc { |type|
# Coerce into an array of hashes to make validation easier
- array = if type.is_a?(Array)
- type
- else
- [type]
- end
+ array = if type.is_a?(Array)
+ type
+ else
+ [type]
+ end
# Check to make sure that our array only has hashes
- unless array.all? { |obj| obj.is_a?(Hash) }
- error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
+ unless array.all? { |obj| obj.is_a?(Hash) }
+ error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
# Make sure the hashes don't have any incorrect keys/values
- array.each do |entry|
- allowed_keys = %w{Minute Hour Day Weekday Month}
- unless entry.keys.all? { |key| allowed_keys.include?(key) }
- failed_keys = entry.keys.reject { |k| allowed_keys.include?(k) }.join(", ")
- error_msg = "The following key(s): #{failed_keys} are invalid for start_calendar_interval, must be one of: #{allowed_keys.join(", ")}"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
-
- unless entry.values.all? { |val| val.is_a?(Integer) }
- failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
- error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- end
+ array.each do |entry|
+ allowed_keys = %w{Minute Hour Day Weekday Month}
+ unless entry.keys.all? { |key| allowed_keys.include?(key) }
+ failed_keys = entry.keys.reject { |k| allowed_keys.include?(k) }.join(", ")
+ error_msg = "The following key(s): #{failed_keys} are invalid for start_calendar_interval, must be one of: #{allowed_keys.join(", ")}"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+
+ unless entry.values.all? { |val| val.is_a?(Integer) }
+ failed_values = entry.values.reject { |val| val.is_a?(Integer) }.join(", ")
+ error_msg = "Invalid value(s) (#{failed_values}) for start_calendar_interval item. Values must be integers!"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ end
# Don't return array if we only have one entry
- if array.size == 1
- array.first
- else
- array
- end
- }
+ if array.size == 1
+ array.first
+ else
+ array
+ end
+ }
property :type, String,
description: "The type of resource. Possible values: daemon (default), agent.",
default: "daemon", coerce: proc { |type|
- type = type ? type.downcase : "daemon"
- types = %w{daemon agent}
-
- unless types.include?(type)
- error_msg = "type must be daemon or agent"
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- type
- }
+ type = type ? type.downcase : "daemon"
+ types = %w{daemon agent}
+
+ unless types.include?(type)
+ error_msg = "type must be daemon or agent"
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ type
+ }
# Apple LaunchD Keys
property :abandon_process_group, [ TrueClass, FalseClass ],
diff --git a/lib/chef/resource/locale.rb b/lib/chef/resource/locale.rb
index f833a4e7d3..331786a02f 100644
--- a/lib/chef/resource/locale.rb
+++ b/lib/chef/resource/locale.rb
@@ -40,19 +40,19 @@ class Chef
description: "A Hash of LC_* env variables in the form of ({ 'LC_ENV_VARIABLE' => 'VALUE' }).",
default: lazy { {} },
coerce: proc { |h|
- if h.respond_to?(:keys)
- invalid_keys = h.keys - LC_VARIABLES
- unless invalid_keys.empty?
- error_msg = "Key of option lc_env must be equal to one of: \"#{LC_VARIABLES.join('", "')}\"! You passed \"#{invalid_keys.join(', ')}\"."
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- end
- unless h.values.all? { |x| x =~ LOCALE_REGEX }
- error_msg = "Values of option lc_env should be non-empty string without any leading whitespaces."
- raise Chef::Exceptions::ValidationFailed, error_msg
- end
- h
- }
+ if h.respond_to?(:keys)
+ invalid_keys = h.keys - LC_VARIABLES
+ unless invalid_keys.empty?
+ error_msg = "Key of option lc_env must be equal to one of: \"#{LC_VARIABLES.join('", "')}\"! You passed \"#{invalid_keys.join(', ')}\"."
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ end
+ unless h.values.all? { |x| x =~ LOCALE_REGEX }
+ error_msg = "Values of option lc_env should be non-empty string without any leading whitespaces."
+ raise Chef::Exceptions::ValidationFailed, error_msg
+ end
+ h
+ }
# @deprecated Use {#lc_env} instead of this property.
# {#lc_env} uses Hash with specific LC var as key.
diff --git a/lib/chef/resource/windows_firewall_rule.rb b/lib/chef/resource/windows_firewall_rule.rb
index 5ac38bc8b7..28144d2805 100644
--- a/lib/chef/resource/windows_firewall_rule.rb
+++ b/lib/chef/resource/windows_firewall_rule.rb
@@ -121,9 +121,9 @@ class Chef
if current_resource
converge_if_changed :rule_name, :local_address, :local_port, :remote_address, :remote_port, :direction,
:protocol, :firewall_action, :profile, :program, :service, :interface_type, :enabled do
- cmd = firewall_command("Set")
- powershell_out!(cmd)
- end
+ cmd = firewall_command("Set")
+ powershell_out!(cmd)
+ end
else
converge_by("create firewall rule #{new_resource.rule_name}") do
cmd = firewall_command("New")
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 0d1a9138ae..a8dbb56a2f 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -249,15 +249,15 @@ class Chef
SERVICE_ACCOUNT_USERS = [self.LocalSystem,
self.NtLocal,
self.NtNetwork].flat_map do |user_type|
- [user_type.account_simple_name.upcase,
- user_type.account_name.upcase]
- end.freeze
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
BUILT_IN_GROUPS = [self.BuiltinAdministrators,
self.BuiltinUsers, self.Guests].flat_map do |user_type|
- [user_type.account_simple_name.upcase,
- user_type.account_name.upcase]
- end.freeze
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
SYSTEM_USER = SERVICE_ACCOUNT_USERS + BUILT_IN_GROUPS