summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-01-12 09:56:40 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-01-12 09:56:40 -0800
commit6610ebd39d19c3b8776d69a56a39c3b496b8b29f (patch)
treea5c282b16f71e3f8be0f3ed99310c82cc41ecd6d /lib/chef/provider
parent812101f11a6c33e49f401ad72598ca6ffb38adc4 (diff)
downloadchef-6610ebd39d19c3b8776d69a56a39c3b496b8b29f.tar.gz
really fix copslcg/really-fix-cops
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/env.rb20
-rw-r--r--lib/chef/provider/mount/aix.rb16
-rw-r--r--lib/chef/provider/mount/mount.rb22
-rw-r--r--lib/chef/provider/mount/solaris.rb10
-rw-r--r--lib/chef/provider/package/rubygems.rb48
-rw-r--r--lib/chef/provider/remote_file/content.rb10
-rw-r--r--lib/chef/provider/service/macosx.rb4
-rw-r--r--lib/chef/provider/user/dscl.rb16
8 files changed, 73 insertions, 73 deletions
diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb
index 8bd7b3e6ca..654ecf9d6a 100644
--- a/lib/chef/provider/env.rb
+++ b/lib/chef/provider/env.rb
@@ -108,15 +108,15 @@ class Chef
not new_values.include?(item)
end.join(@new_resource.delim)
- if new_value.empty?
- return false #nothing left here, delete the key
- else
- old_value = @new_resource.value(new_value)
- create_env
- Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
- @new_resource.updated_by_last_action(true)
- return true #we removed the element and updated; do not delete the key
- end
+ if new_value.empty?
+ return false #nothing left here, delete the key
+ else
+ old_value = @new_resource.value(new_value)
+ create_env
+ Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
+ @new_resource.updated_by_last_action(true)
+ return true #we removed the element and updated; do not delete the key
+ end
end
end
@@ -164,6 +164,6 @@ class Chef
def new_values
@new_values ||= @new_resource.value.split(@new_resource.delim)
end
- end
+ end
end
end
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb
index 510dfde46d..41a2ae1176 100644
--- a/lib/chef/provider/mount/aix.rb
+++ b/lib/chef/provider/mount/aix.rb
@@ -99,13 +99,13 @@ class Chef
end
command << case @new_resource.device_type
- when :device
- " #{device_real}"
- when :label
- " -L #{@new_resource.device}"
- when :uuid
- " -U #{@new_resource.device}"
- end
+ when :device
+ " #{device_real}"
+ when :label
+ " -L #{@new_resource.device}"
+ when :uuid
+ " -U #{@new_resource.device}"
+ end
command << " #{@new_resource.mount_point}"
shell_out!(command)
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
@@ -174,7 +174,7 @@ class Chef
end
end
+ end
end
- end
end
end
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index ef074166a9..9ffdf3a557 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -104,13 +104,13 @@ class Chef
command = "mount -t #{@new_resource.fstype}"
command << " -o #{@new_resource.options.join(',')}" unless @new_resource.options.nil? || @new_resource.options.empty?
command << case @new_resource.device_type
- when :device
- " #{device_real}"
- when :label
- " -L #{@new_resource.device}"
- when :uuid
- " -U #{@new_resource.device}"
- end
+ when :device
+ " #{device_real}"
+ when :label
+ " -L #{@new_resource.device}"
+ when :uuid
+ " -U #{@new_resource.device}"
+ end
command << " #{@new_resource.mount_point}"
shell_out!(command)
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
@@ -170,7 +170,7 @@ class Chef
found = false
::File.readlines("/etc/fstab").reverse_each do |line|
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s/
- found = true
+ found = true
Chef::Log.debug("#{@new_resource} is removed from fstab")
next
else
@@ -259,9 +259,9 @@ class Chef
def mount_options_unchanged?
@current_resource.fstype == @new_resource.fstype and
- @current_resource.options == @new_resource.options and
- @current_resource.dump == @new_resource.dump and
- @current_resource.pass == @new_resource.pass
+ @current_resource.options == @new_resource.options and
+ @current_resource.dump == @new_resource.dump and
+ @current_resource.pass == @new_resource.pass
end
end
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index deb04d4d7b..062696ac53 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -221,10 +221,10 @@ class Chef
def vfstab_entry
actual_options = unless options.nil?
- tempops = options.dup
- tempops.delete('noauto')
- tempops
- end
+ tempops = options.dup
+ tempops.delete('noauto')
+ tempops
+ end
autostr = mount_at_boot? ? 'yes' : 'no'
passstr = pass == 0 ? '-' : pass
optstr = (actual_options.nil? || actual_options.empty?) ? '-' : actual_options.join(',')
@@ -236,7 +236,7 @@ class Chef
found = false
::File.readlines(VFSTAB).reverse_each do |line|
if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
- found = true
+ found = true
Chef::Log.debug("#{new_resource} is removed from vfstab")
next
end
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 0ea739e8d1..3272624f62 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2008, 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -161,17 +161,17 @@ class Chef
def find_newest_remote_version(gem_dependency, *sources)
available_gems = dependency_installer.find_gems_with_sources(gem_dependency)
spec, source = if available_gems.respond_to?(:last)
- # DependencyInstaller sorts the results such that the last one is
- # always the one it considers best.
- spec_with_source = available_gems.last
- spec_with_source && spec_with_source
- else
- # Rubygems 2.0 returns a Gem::Available set, which is a
- # collection of AvailableSet::Tuple structs
- available_gems.pick_best!
- best_gem = available_gems.set.first
- best_gem && [best_gem.spec, best_gem.source]
- end
+ # DependencyInstaller sorts the results such that the last one is
+ # always the one it considers best.
+ spec_with_source = available_gems.last
+ spec_with_source && spec_with_source
+ else
+ # Rubygems 2.0 returns a Gem::Available set, which is a
+ # collection of AvailableSet::Tuple structs
+ available_gems.pick_best!
+ best_gem = available_gems.set.first
+ best_gem && [best_gem.spec, best_gem.source]
+ end
version = spec && spec.version
if version
@@ -438,8 +438,8 @@ class Chef
gemspec = matching_installed_versions.last
logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}"}
gemspec
- # If no version matching the requirements exists, the latest installed
- # version is the current version.
+ # If no version matching the requirements exists, the latest installed
+ # version is the current version.
elsif !all_installed_versions.empty?
gemspec = all_installed_versions.last
logger.debug { "#{@new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
@@ -456,8 +456,8 @@ class Chef
def all_installed_versions
@all_installed_versions ||= begin
- @gem_env.installed_versions(Gem::Dependency.new(gem_dependency.name, '>= 0'))
- end
+ @gem_env.installed_versions(Gem::Dependency.new(gem_dependency.name, '>= 0'))
+ end
end
def gem_sources
@@ -482,14 +482,14 @@ class Chef
def candidate_version
@candidate_version ||= begin
- if target_version_already_installed?(@current_resource.version, @new_resource.version)
- nil
- elsif source_is_remote?
- @gem_env.candidate_version_from_remote(gem_dependency, *gem_sources).to_s
- else
- @gem_env.candidate_version_from_file(gem_dependency, @new_resource.source).to_s
- end
- end
+ if target_version_already_installed?(@current_resource.version, @new_resource.version)
+ nil
+ elsif source_is_remote?
+ @gem_env.candidate_version_from_remote(gem_dependency, *gem_sources).to_s
+ else
+ @gem_env.candidate_version_from_file(gem_dependency, @new_resource.source).to_s
+ end
+ end
end
def target_version_already_installed?(current_version, new_version)
diff --git a/lib/chef/provider/remote_file/content.rb b/lib/chef/provider/remote_file/content.rb
index 01193907a1..e9d85b4087 100644
--- a/lib/chef/provider/remote_file/content.rb
+++ b/lib/chef/provider/remote_file/content.rb
@@ -1,7 +1,7 @@
#
# Author:: Jesse Campbell (<hikeit@gmail.com>)
# Author:: Lamont Granquist (<lamont@opscode.com>)
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,10 +49,10 @@ class Chef
source = sources.shift
begin
uri = if Chef::Provider::RemoteFile::Fetcher.network_share?(source)
- source
- else
- as_uri(source)
- end
+ source
+ else
+ as_uri(source)
+ end
raw_file = grab_file_from_uri(uri)
rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPServerException, Net::HTTPFatalError, Net::FTPError => e
Chef::Log.warn("#{@new_resource} cannot be downloaded from #{source}: #{e}")
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 9c733da493..47c74f9425 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -160,7 +160,7 @@ class Chef
end
end
- def load_service
+ def load_service
session = @session_type ? "-S #{@session_type} " : ''
cmd = 'launchctl load -w ' + session + @plist
shell_out_as_user(cmd)
@@ -206,7 +206,7 @@ class Chef
end
end
- private
+ private
def find_service_label
# CHEF-5223 "you can't glob for a file that hasn't been converged
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 1faf2438ac..5b506daf81 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -363,7 +363,7 @@ user password using shadow hash.")
# Shadow info is saved as binary plist. Convert the info to binary plist.
shadow_info_binary = StringIO.new
command = Mixlib::ShellOut.new("plutil -convert binary1 -o - -",
- :input => shadow_info.to_plist, :live_stream => shadow_info_binary)
+ :input => shadow_info.to_plist, :live_stream => shadow_info_binary)
command.run_command
if user_info.nil?
@@ -391,13 +391,13 @@ user password using shadow hash.")
if mac_osx_version_10_7?
hash_value = if salted_sha512?(new_resource.password)
- new_resource.password
- else
- # Create a random 4 byte salt
- salt = OpenSSL::Random.random_bytes(4)
- encoded_password = OpenSSL::Digest::SHA512.hexdigest(salt + new_resource.password)
- hash_value = salt.unpack('H*').first + encoded_password
- end
+ new_resource.password
+ else
+ # Create a random 4 byte salt
+ salt = OpenSSL::Random.random_bytes(4)
+ encoded_password = OpenSSL::Digest::SHA512.hexdigest(salt + new_resource.password)
+ hash_value = salt.unpack('H*').first + encoded_password
+ end
shadow_info["SALTED-SHA512"] = StringIO.new
shadow_info["SALTED-SHA512"].string = convert_to_binary(hash_value)