diff options
Diffstat (limited to 'lib/chef')
31 files changed, 56 insertions, 56 deletions
diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index d56f662c5c..260666b65f 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -13,7 +13,7 @@ class Chef # chef_type and data_bag come back in PUT and POST results, but we don't # use those in knife-essentials. normalize_hash(data_bag_item, { - "id" => remove_dot_json(entry.name) + "id" => remove_dot_json(entry.name), },) end diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index 9cdb8a8522..cd3bbd96ff 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -59,7 +59,7 @@ class Chef set_or_return( :name, arg, - { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String } + { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String }, ) end @@ -102,7 +102,7 @@ class Chef { :kind_of => Hash, :callbacks => { - "should be a valid set of cookbook version requirements" => lambda { |cv| Chef::Environment.validate_cookbook_versions(cv) } + "should be a valid set of cookbook version requirements" => lambda { |cv| Chef::Environment.validate_cookbook_versions(cv) }, }, }, ) @@ -110,11 +110,11 @@ class Chef def cookbook(cookbook, version) validate({ - :version => version + :version => version, }, { :version => { - :callbacks => { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } } - } + :callbacks => { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } }, + }, },) @cookbook_versions[cookbook] = version end diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index cb8bf9bd11..b4f3de236a 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -105,10 +105,10 @@ class Chef def load(path, read = true) validate( { - :path => path + :path => path, }, { - :path => { :kind_of => String } + :path => { :kind_of => String }, }, ) cache_path = create_cache_path(path, false) @@ -131,10 +131,10 @@ class Chef def delete(path) validate( { - :path => path + :path => path, }, { - :path => { :kind_of => String } + :path => { :kind_of => String }, }, ) cache_path = create_cache_path(path, false) @@ -178,10 +178,10 @@ class Chef def has_key?(path) validate( { - :path => path + :path => path, }, { - :path => { :kind_of => String } + :path => { :kind_of => String }, }, ) full_path = create_cache_path(path, false) diff --git a/lib/chef/key.rb b/lib/chef/key.rb index ef29bd7288..1c25c5daad 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -117,7 +117,7 @@ class Chef def to_hash result = { - @actor_field_name => @actor + @actor_field_name => @actor, } result["name"] = @name if @name result["public_key"] = @public_key if @public_key diff --git a/lib/chef/knife/data_bag_create.rb b/lib/chef/knife/data_bag_create.rb index 196278bb80..3576ec7379 100644 --- a/lib/chef/knife/data_bag_create.rb +++ b/lib/chef/knife/data_bag_create.rb @@ -66,7 +66,7 @@ class Chef Chef::EncryptedDataBagItem.encrypt_data_bag_item(output, read_secret) else output - end + end, ) item.data_bag(@data_bag_name) rest.post("data/#{@data_bag_name}", item) diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index af3e10126b..9cde53d66f 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -54,7 +54,7 @@ class Chef else Integer(m) <= 07777 && Integer(m) >= 0 end - } + }, }, ) end diff --git a/lib/chef/mixin/windows_env_helper.rb b/lib/chef/mixin/windows_env_helper.rb index 65b4b33cf0..47f1aeb865 100644 --- a/lib/chef/mixin/windows_env_helper.rb +++ b/lib/chef/mixin/windows_env_helper.rb @@ -47,7 +47,7 @@ class Chef Chef::ReservedNames::Win32::Error.raise! end if SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string( - utf8_to_wide("Environment") + utf8_to_wide("Environment"), ).address, flags, 5000, nil) == 0 Chef::ReservedNames::Win32::Error.raise! end diff --git a/lib/chef/monologger.rb b/lib/chef/monologger.rb index 49f744e314..a1dd594c7a 100644 --- a/lib/chef/monologger.rb +++ b/lib/chef/monologger.rb @@ -79,7 +79,7 @@ class MonoLogger < Logger def add_log_header(file) file.write( - "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName] + "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName], ) end diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 0471fe1171..c7813eb2aa 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -114,7 +114,7 @@ class Chef { :name => arg }, { :name => { :kind_of => String, :cannot_be => :blank, - :regex => /^[\-[:alnum:]_:.]+$/ } + :regex => /^[\-[:alnum:]_:.]+$/ }, },) @name = arg else @@ -126,7 +126,7 @@ class Chef set_or_return( :chef_environment, arg, - { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String } + { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String }, ) end diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb index d24cd8c18c..1a5da902ef 100644 --- a/lib/chef/platform/provider_mapping.rb +++ b/lib/chef/platform/provider_mapping.rb @@ -119,10 +119,10 @@ class Chef :required => false, }, :resource => { - :kind_of => Symbol + :kind_of => Symbol, }, :provider => { - :kind_of => [ String, Symbol, Class ] + :kind_of => [ String, Symbol, Class ], }, }, ) @@ -133,14 +133,14 @@ class Chef platforms[args[:platform]][args[:version]][args[:resource].to_sym] = args[:provider] else platforms[args[:platform]][args[:version]] = { - args[:resource].to_sym => args[:provider] + args[:resource].to_sym => args[:provider], } end else platforms[args[:platform]] = { args[:version] => { - args[:resource].to_sym => args[:provider] - } + args[:resource].to_sym => args[:provider], + }, } end else @@ -155,8 +155,8 @@ class Chef else platforms[args[:platform]] = { :default => { - args[:resource].to_sym => args[:provider] - } + args[:resource].to_sym => args[:provider], + }, } end end @@ -165,7 +165,7 @@ class Chef platforms[:default][args[:resource].to_sym] = args[:provider] else platforms[:default] = { - args[:resource].to_sym => args[:provider] + args[:resource].to_sym => args[:provider], } end end diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb index 87b87d4c72..28c4c5ec59 100644 --- a/lib/chef/platform/service_helpers.rb +++ b/lib/chef/platform/service_helpers.rb @@ -105,7 +105,7 @@ class Chef def has_systemd_service_unit?(svc_name) %w{ /etc /usr/lib /lib /run }.any? do |load_path| ::File.exist?( - Chef.path_to("#{load_path}/systemd/system/#{svc_name.gsub(/@.*$/, '@')}.service") + Chef.path_to("#{load_path}/systemd/system/#{svc_name.gsub(/@.*$/, '@')}.service"), ) end end diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index b69ecfe6a8..6a006ec992 100644 --- a/lib/chef/policy_builder/expand_node_object.rb +++ b/lib/chef/policy_builder/expand_node_object.rb @@ -237,7 +237,7 @@ class Chef def setup_run_list_override runlist_override_sanity_check! - unless(override_runlist.empty?) + unless override_runlist.empty? node.override_runlist(*override_runlist) Chef::Log.warn "Run List override has been provided." Chef::Log.warn "Original Run List: [#{node.primary_runlist}]" @@ -253,7 +253,7 @@ class Chef end @override_runlist = [override_runlist].flatten.compact override_runlist.map! do |item| - if(item.is_a?(Chef::RunList::RunListItem)) + if item.is_a?(Chef::RunList::RunListItem) item else Chef::RunList::RunListItem.new(item) diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 45f0ad5488..4e7d8e1454 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -117,7 +117,7 @@ class Chef def sentinel_file Pathname.new(Chef::Util::PathHelper.cleanpath( - ( cwd && creates_relative? ) ? ::File.join(cwd, creates) : creates + ( cwd && creates_relative? ) ? ::File.join(cwd, creates) : creates, )) end end diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb index efcbef8014..fcae24f8f9 100644 --- a/lib/chef/provider/group.rb +++ b/lib/chef/provider/group.rb @@ -90,7 +90,7 @@ class Chef @change_desc << "change gid #{@current_resource.gid} to #{@new_resource.gid}" end - if(@new_resource.append) + if @new_resource.append missing_members = [] @new_resource.members.each do |member| next if has_current_group_member?(member) diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb index 08661f21b8..00b4ce2b93 100644 --- a/lib/chef/provider/group/dscl.rb +++ b/lib/chef/provider/group/dscl.rb @@ -72,7 +72,7 @@ class Chef def get_free_gid(search_limit = 1000) gid = nil; next_gid_guess = 200 groups_gids = safe_dscl("list /Groups gid") - while(next_gid_guess < search_limit + 200) + while next_gid_guess < search_limit + 200 if groups_gids =~ Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n") next_gid_guess += 1 else diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb index 41c61eafde..c58d4bfa34 100644 --- a/lib/chef/provider/launchd.rb +++ b/lib/chef/provider/launchd.rb @@ -40,7 +40,7 @@ class Chef :path, :source, :session_type, - :type + :type, ] def load_current_resource @@ -51,7 +51,7 @@ class Chef def gen_path_from_type types = { "daemon" => "/Library/LaunchDaemons/#{label}.plist", - "agent" => "/Library/LaunchAgents/#{label}.plist" + "agent" => "/Library/LaunchAgents/#{label}.plist", } types[type] end diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index d184094bbb..85c46ada98 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -52,7 +52,7 @@ class Chef if file_class.symlink?(@current_resource.target_file) @current_resource.link_type(:symbolic) @current_resource.to( - canonicalize(file_class.readlink(@current_resource.target_file)) + canonicalize(file_class.readlink(@current_resource.target_file)), ) else @current_resource.link_type(:hard) diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index 635a4f6ea2..265911b54c 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -44,7 +44,7 @@ class Chef # only check for existence of non-remote devices if device_should_exist? && !::File.exists?(device_real) raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist" - elsif( @new_resource.mount_point != "none" && !::File.exists?(@new_resource.mount_point) ) + elsif @new_resource.mount_point != "none" && !::File.exists?(@new_resource.mount_point) raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist" end return true diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb index 3747a917fa..f232dede83 100644 --- a/lib/chef/provider/osx_profile.rb +++ b/lib/chef/provider/osx_profile.rb @@ -40,7 +40,7 @@ class Chef all_profiles = get_installed_profiles @new_resource.profile( @new_resource.profile || - @new_resource.profile_name + @new_resource.profile_name, ) @new_profile_hash = get_profile_hash(@new_resource.profile) @@ -141,7 +141,7 @@ class Chef def get_cache_dir cache_dir = Chef::FileCache.create_cache_path( - "profiles/#{@new_resource.cookbook_name}" + "profiles/#{@new_resource.cookbook_name}", ) end @@ -151,7 +151,7 @@ class Chef "profiles", @new_resource.cookbook_name, ::File.dirname(cookbook_file), - ) + ), ) remote_file = Chef::Resource::CookbookFile.new( ::File.join( diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb index e111beb9b5..ad4db0c4e6 100644 --- a/lib/chef/provider/package/chocolatey.rb +++ b/lib/chef/provider/package/chocolatey.rb @@ -162,7 +162,7 @@ EOS # lets us mock out an incorrect value for testing. def choco_install_path @choco_install_path ||= powershell_out!( - PATHFINDING_POWERSHELL_COMMAND + PATHFINDING_POWERSHELL_COMMAND, ).stdout.chomp end diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb index fe321037bd..bd8028d881 100644 --- a/lib/chef/provider/package/pacman.rb +++ b/lib/chef/provider/package/pacman.rb @@ -54,7 +54,7 @@ class Chef repos = %w{extra core community} - if(::File.exists?("/etc/pacman.conf")) + if ::File.exists?("/etc/pacman.conf") pacman = ::File.read("/etc/pacman.conf") repos = pacman.scan(/\[(.+)\]/).flatten end diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb index e1b2ea1cf4..557e7ebc22 100644 --- a/lib/chef/provider/package/paludis.rb +++ b/lib/chef/provider/package/paludis.rb @@ -54,7 +54,7 @@ class Chef end def install_package(name, version) - if(version) + if version pkg = "=#{name}-#{version}" else pkg = "#{@new_resource.package_name}" @@ -67,7 +67,7 @@ class Chef end def remove_package(name, version) - if(version) + if version pkg = "=#{@new_resource.package_name}-#{version}" else pkg = "#{@new_resource.package_name}" diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb index 688509889c..a514dcc66c 100644 --- a/lib/chef/provider/package/portage.rb +++ b/lib/chef/provider/package/portage.rb @@ -41,7 +41,7 @@ class Chef globsafe_pkg = Chef::Util::PathHelper.escape_glob(pkg) possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") } versions = possibilities.map do |entry| - if(entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)}) + if entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)} [$&, $1] end end.compact @@ -108,7 +108,7 @@ class Chef def install_package(name, version) pkg = "=#{name}-#{version}" - if(version =~ /^\~(.+)/) + if version =~ /^\~(.+)/ # If we start with a tilde pkg = "~#{name}-#{$1}" end @@ -121,7 +121,7 @@ class Chef end def remove_package(name, version) - if(version) + if version pkg = "=#{@new_resource.package_name}-#{version}" else pkg = "#{@new_resource.package_name}" diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 66f2f10f23..1bfd46ef14 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -39,7 +39,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init readable = ::File.readable? file Chef::Log.debug "#{@new_resource} exists: #{exists}, readable: #{readable}" exists and readable - end + end, ) Chef::Log.debug "#{@new_resource} enabled: #{@current_resource.enabled}" diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index 63485903c3..cdd5d934ff 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -224,7 +224,7 @@ class Chef # plist files can come in XML or Binary formats. this command # will make sure we get XML every time. plist_xml = shell_out_with_systems_locale!( - "plutil -convert xml1 -o - #{@plist}" + "plutil -convert xml1 -o - #{@plist}", ).stdout plist_doc = REXML::Document.new(plist_xml) @@ -236,7 +236,7 @@ class Chef plists = PLIST_DIRS.inject([]) do |results, dir| edir = ::File.expand_path(dir) entries = Dir.glob( - "#{edir}/*#{Chef::Util::PathHelper.escape_glob(@current_resource.service_name)}*.plist" + "#{edir}/*#{Chef::Util::PathHelper.escape_glob(@current_resource.service_name)}*.plist", ) entries.any? ? results << entries : results end diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 8c282b0d7e..1659e324c0 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -230,7 +230,7 @@ user password using shadow hash.") base_uid = new_resource.system ? 200 : 500 next_uid_guess = base_uid users_uids = run_dscl("list /Users uid") - while(next_uid_guess < search_limit + base_uid) + while next_uid_guess < search_limit + base_uid if users_uids =~ Regexp.new("#{Regexp.escape(next_uid_guess.to_s)}\n") next_uid_guess += 1 else diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index e08bacc625..4445bf0f89 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -26,7 +26,7 @@ class Chef property :gem_binary, default: "#{RbConfig::CONFIG['bindir']}/gem", callbacks: { - "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" } + "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG['bindir']}/gem" }, } property :compile_time, [ true, false, nil ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb index e11035d33f..15ed27347f 100644 --- a/lib/chef/resource/file/verification.rb +++ b/lib/chef/resource/file/verification.rb @@ -110,7 +110,7 @@ class Chef # is interpolated. Until `file` can be deprecated, interpolate both. Chef.log_deprecation( "%{file} is deprecated in verify command and will not be "\ - "supported in Chef 13. Please use %{path} instead." + "supported in Chef 13. Please use %{path} instead.", ) if @command.include?("%{file}") command = @command % { :file => path, :path => path } interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts) diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index 36f1c614d1..933092ec82 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -51,7 +51,7 @@ class Chef ret = set_or_return(:source, arg, { :callbacks => { - :validate_source => method(:validate_source) + :validate_source => method(:validate_source), } }) if ret.is_a? String Array(ret) diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index 3b7dc330df..db44ced9d4 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -114,7 +114,7 @@ class Chef def to_hash result = { - "username" => @username + "username" => @username, } result["display_name"] = @display_name unless @display_name.nil? result["first_name"] = @first_name unless @first_name.nil? diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb index 665cba8880..9951b931c9 100644 --- a/lib/chef/win32/security/sid.rb +++ b/lib/chef/win32/security/sid.rb @@ -275,7 +275,7 @@ class Chef status = ERROR_MORE_DATA - while(status == ERROR_MORE_DATA) + while status == ERROR_MORE_DATA status = NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle) if status == NERR_Success || status == ERROR_MORE_DATA |