summaryrefslogtreecommitdiff
path: root/lib/chef/resource
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:11:54 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-02 15:11:54 -0700
commite71560df5cebbfb209089c6255e37e65f0e34d95 (patch)
tree5cd0a1d01eb9609d7f5681b2e04faa902de67e84 /lib/chef/resource
parent7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (diff)
downloadchef-e71560df5cebbfb209089c6255e37e65f0e34d95.tar.gz
Style/SymbolArray
start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/resource')
-rw-r--r--lib/chef/resource/dsc_resource.rb2
-rw-r--r--lib/chef/resource/link.rb2
-rw-r--r--lib/chef/resource/log.rb2
-rw-r--r--lib/chef/resource/registry_key.rb6
-rw-r--r--lib/chef/resource/remote_file.rb2
-rw-r--r--lib/chef/resource/route.rb2
-rw-r--r--lib/chef/resource/windows_ad_join.rb2
-rw-r--r--lib/chef/resource/windows_feature.rb2
-rw-r--r--lib/chef/resource/windows_firewall_rule.rb8
-rw-r--r--lib/chef/resource/windows_service.rb2
-rw-r--r--lib/chef/resource/windows_task.rb30
-rw-r--r--lib/chef/resource/windows_uac.rb8
-rw-r--r--lib/chef/resource/windows_workgroup.rb2
13 files changed, 35 insertions, 35 deletions
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index 8d03231367..3ccc30f0fb 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -99,7 +99,7 @@ class Chef
# If the set method of the DSC resource indicate that a reboot
# is necessary, reboot_action provides the mechanism for a reboot to
# be requested.
- property :reboot_action, Symbol, default: :nothing, equal_to: [:nothing, :reboot_now, :request_reboot],
+ property :reboot_action, Symbol, default: :nothing, equal_to: %i{nothing reboot_now request_reboot},
introduced: "12.6",
description: "Use to request an immediate reboot or to queue a reboot using the :reboot_now (immediate reboot) or :request_reboot (queued reboot) actions built into the reboot resource."
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index 66388a6463..dd618845bf 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -57,7 +57,7 @@ class Chef
property :link_type, [String, Symbol],
description: "The type of link: :symbolic or :hard.",
coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
- equal_to: [ :symbolic, :hard ], default: :symbolic
+ equal_to: %i{symbolic hard}, default: :symbolic
property :group, [String, Integer],
description: "A group name or ID number that identifies the group associated with a symbolic link.",
diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb
index 4f76ea12de..98cf0fb204 100644
--- a/lib/chef/resource/log.rb
+++ b/lib/chef/resource/log.rb
@@ -43,7 +43,7 @@ class Chef
description: "The message to be added to a log file. If not specified we'll use the resource's name instead."
property :level, Symbol,
- equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info,
+ equal_to: %i{debug info warn error fatal}, default: :info,
description: "The logging level to display this message at."
allowed_actions :write
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index cd4edda5a9..a5c99313bf 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -88,7 +88,7 @@ class Chef
raise ArgumentError, "Missing name key in RegistryKey values hash" unless v.key?(:name)
v.each_key do |key|
- raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name, :type, :data].include?(key)
+ raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless %i{name type data}.include?(key)
end
raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String)
@@ -103,7 +103,7 @@ class Chef
end
property :recursive, [TrueClass, FalseClass], default: false
- property :architecture, Symbol, default: :machine, equal_to: [:machine, :x86_64, :i386]
+ property :architecture, Symbol, default: :machine, equal_to: %i{machine x86_64 i386}
private
@@ -123,7 +123,7 @@ class Chef
# Some data types may raise errors when sent as json. Returns true if this
# value's data may need to be converted to a checksum.
def needs_checksum?(value)
- unsafe_types = [:binary, :dword, :dword_big_endian, :qword]
+ unsafe_types = %i{binary dword dword_big_endian qword}
unsafe_types.include?(value[:type])
end
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index d654829ee7..7dcfeb3c2c 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -98,7 +98,7 @@ class Chef
property :remote_password, String, sensitive: true
- property :authentication, equal_to: [:remote, :local], default: :remote
+ property :authentication, equal_to: %i{remote local}, default: :remote
def after_created
validate_identity_platform(remote_user, remote_password, remote_domain)
diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb
index 42302afe6a..ecd63966cf 100644
--- a/lib/chef/resource/route.rb
+++ b/lib/chef/resource/route.rb
@@ -50,7 +50,7 @@ class Chef
property :route_type, [Symbol, String],
description: "",
- equal_to: [:host, :net], default: :host, desired_state: false
+ equal_to: %i{host net}, default: :host, desired_state: false
end
end
end
diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb
index e62b931a75..23faa60ee5 100644
--- a/lib/chef/resource/windows_ad_join.rb
+++ b/lib/chef/resource/windows_ad_join.rb
@@ -48,7 +48,7 @@ class Chef
description: "The path to the Organizational Unit where the host will be placed."
property :reboot, Symbol,
- equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now],
+ equal_to: %i{immediate delayed never request_reboot reboot_now},
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)",
description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.",
default: :immediate
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index e937c6f990..cc80284019 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -44,7 +44,7 @@ class Chef
property :install_method, Symbol,
description: "The underlying installation method to use for feature installation. Specify ':windows_feature_dism' for DISM or ':windows_feature_powershell' for PowerShell.",
- equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd],
+ equal_to: %i{windows_feature_dism windows_feature_powershell windows_feature_servermanagercmd},
default: :windows_feature_dism
property :timeout, Integer,
diff --git a/lib/chef/resource/windows_firewall_rule.rb b/lib/chef/resource/windows_firewall_rule.rb
index f933ba9139..5ac38bc8b7 100644
--- a/lib/chef/resource/windows_firewall_rule.rb
+++ b/lib/chef/resource/windows_firewall_rule.rb
@@ -54,7 +54,7 @@ class Chef
description: "The remote port the firewall rule applies to."
property :direction, [Symbol, String],
- default: :inbound, equal_to: [:inbound, :outbound],
+ default: :inbound, equal_to: %i{inbound outbound},
description: "The direction of the firewall rule. Direction means either inbound or outbound traffic.",
coerce: proc { |d| d.is_a?(String) ? d.downcase.to_sym : d }
@@ -63,12 +63,12 @@ class Chef
description: "The protocol the firewall rule applies to."
property :firewall_action, [Symbol, String],
- default: :allow, equal_to: [:allow, :block, :notconfigured],
+ default: :allow, equal_to: %i{allow block notconfigured},
description: "The action of the firewall rule.",
coerce: proc { |f| f.is_a?(String) ? f.downcase.to_sym : f }
property :profile, [Symbol, String],
- default: :any, equal_to: [:public, :private, :domain, :any, :notapplicable],
+ default: :any, equal_to: %i{public private domain any notapplicable},
description: "The profile the firewall rule applies to.",
coerce: proc { |p| p.is_a?(String) ? p.downcase.to_sym : p }
@@ -79,7 +79,7 @@ class Chef
description: "The service the firewall rule applies to."
property :interface_type, [Symbol, String],
- default: :any, equal_to: [:any, :wireless, :wired, :remoteaccess],
+ default: :any, equal_to: %i{any wireless wired remoteaccess},
description: "The interface type the firewall rule applies to.",
coerce: proc { |i| i.is_a?(String) ? i.downcase.to_sym : i }
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index 91c3450603..b8ee4edf9c 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -58,7 +58,7 @@ class Chef
# - :manual
# - :disabled
# Reference: https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L49-L54
- property :startup_type, [Symbol], equal_to: [:automatic, :manual, :disabled], default: :automatic, coerce: proc { |x|
+ property :startup_type, [Symbol], equal_to: %i{automatic manual disabled}, default: :automatic, coerce: proc { |x|
if x.is_a?(Integer)
ALLOWED_START_TYPES.invert.fetch(x) do
Chef::Log.warn("Unsupported startup_type #{x}, falling back to :automatic")
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index db3eb11b96..0ce5bf2031 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -49,7 +49,7 @@ class Chef
property :password, String,
description: "The user’s password. The user property must be set if using this property."
- property :run_level, Symbol, equal_to: [:highest, :limited],
+ property :run_level, Symbol, equal_to: %i{highest limited},
description: "Run with ':limited' or ':highest' privileges.",
default: :limited
@@ -64,16 +64,16 @@ class Chef
property :frequency_modifier, [Integer, String],
default: 1
- property :frequency, Symbol, equal_to: [:minute,
- :hourly,
- :daily,
- :weekly,
- :monthly,
- :once,
- :on_logon,
- :onstart,
- :on_idle,
- :none],
+ property :frequency, Symbol, equal_to: %i{minute
+ hourly
+ daily
+ weekly
+ monthly
+ once
+ on_logon
+ onstart
+ on_idle
+ none},
description: "The frequency with which to run the task."
property :start_day, String,
@@ -175,7 +175,7 @@ class Chef
end
def validate_frequency(frequency)
- if frequency.nil? || !([:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none].include?(frequency))
+ if frequency.nil? || !(%i{minute hourly daily weekly monthly once on_logon onstart on_idle none}.include?(frequency))
raise ArgumentError, "Frequency needs to be provided. Valid frequencies are :minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none."
end
end
@@ -201,7 +201,7 @@ class Chef
end
def validate_random_delay(random_delay, frequency)
- if [:on_logon, :onstart, :on_idle, :none].include? frequency
+ if %i{on_logon onstart on_idle none}.include? frequency
raise ArgumentError, "`random_delay` property is supported only for frequency :once, :minute, :hourly, :daily, :weekly and :monthly"
end
@@ -256,7 +256,7 @@ class Chef
alias non_system_user? password_required?
def validate_create_frequency_modifier(frequency, frequency_modifier)
- if ([:on_logon, :onstart, :on_idle, :none].include?(frequency)) && ( frequency_modifier != 1)
+ if (%i{on_logon onstart on_idle none}.include?(frequency)) && ( frequency_modifier != 1)
raise ArgumentError, "frequency_modifier property not supported with frequency :#{frequency}"
end
@@ -288,7 +288,7 @@ class Chef
end
def validate_create_day(day, frequency, frequency_modifier)
- raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless [:weekly, :monthly].include?(frequency)
+ raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless %i{weekly monthly}.include?(frequency)
# This has been verified with schtask.exe https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks#d-dayday--
# verified with earlier code if day "*" is given with frequency it raised exception Invalid value for /D option
diff --git a/lib/chef/resource/windows_uac.rb b/lib/chef/resource/windows_uac.rb
index f53767f4b8..c4d5b53c14 100644
--- a/lib/chef/resource/windows_uac.rb
+++ b/lib/chef/resource/windows_uac.rb
@@ -44,12 +44,12 @@ class Chef
property :consent_behavior_admins, Symbol,
description: 'Behavior of the elevation prompt for administrators in Admin Approval Mode. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorAdmin.',
- equal_to: [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries],
+ equal_to: %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries},
default: :prompt_for_consent_non_windows_binaries
property :consent_behavior_users, Symbol,
description: 'Behavior of the elevation prompt for standard users. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorUser.',
- equal_to: [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds],
+ equal_to: %i{auto_deny secure_prompt_for_creds prompt_for_creds},
default: :prompt_for_creds
action :configure do
@@ -79,14 +79,14 @@ class Chef
#
# @return [Integer]
def consent_behavior_admins_symbol_to_reg(sym)
- [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries].index(sym)
+ %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.index(sym)
end
# converts the symbols we use in the consent_behavior_users property into numbers 0-2 based on their array index
#
# @return [Integer]
def consent_behavior_users_symbol_to_reg(sym)
- [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds].index(sym)
+ %i{auto_deny secure_prompt_for_creds prompt_for_creds}.index(sym)
end
end
end
diff --git a/lib/chef/resource/windows_workgroup.rb b/lib/chef/resource/windows_workgroup.rb
index f455c013af..b1ae5c2b95 100644
--- a/lib/chef/resource/windows_workgroup.rb
+++ b/lib/chef/resource/windows_workgroup.rb
@@ -45,7 +45,7 @@ class Chef
desired_state: false
property :reboot, Symbol,
- equal_to: [:never, :request_reboot, :reboot_now],
+ equal_to: %i{never request_reboot reboot_now},
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)",
description: "Controls the system reboot behavior post workgroup joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.",
coerce: proc { |x| clarify_reboot(x) },