summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-04-06 14:32:03 -0700
committerDaniel DeLeo <dan@opscode.com>2011-04-06 14:32:03 -0700
commit1f59eafe5584f5ebe9bed720c4b19d8bc2c78cd6 (patch)
tree22eca306ad8a532b9d8b7721b5b175e363cd17e6
parentdff8822425ccccd1db01dac93a0b8248003aecc3 (diff)
downloadchef-1f59eafe5584f5ebe9bed720c4b19d8bc2c78cd6.tar.gz
[CHEF-2184] there is no such thing as a sensible mix of tabs and spaces
-rw-r--r--chef/lib/chef/mixin/shell_out.rb3
-rw-r--r--chef/lib/chef/provider/directory.rb12
-rw-r--r--chef/lib/chef/provider/execute.rb4
-rw-r--r--chef/lib/chef/provider/ifconfig.rb16
-rw-r--r--chef/lib/chef/provider/link.rb60
-rw-r--r--chef/lib/chef/provider/ohai.rb4
-rw-r--r--chef/lib/chef/provider/package/apt.rb28
-rw-r--r--chef/lib/chef/provider/remote_directory.rb26
-rw-r--r--chef/lib/chef/provider/service/freebsd.rb24
-rw-r--r--chef/lib/chef/provider/service/simple.rb6
-rw-r--r--chef/lib/chef/resource.rb6
11 files changed, 93 insertions, 96 deletions
diff --git a/chef/lib/chef/mixin/shell_out.rb b/chef/lib/chef/mixin/shell_out.rb
index 99c2072af7..147bdb0d0a 100644
--- a/chef/lib/chef/mixin/shell_out.rb
+++ b/chef/lib/chef/mixin/shell_out.rb
@@ -33,9 +33,6 @@ class Chef
def shell_out!(*command_args)
cmd= shell_out(*command_args)
- if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.debug?
- cmd.live_stream = STDOUT
- end
cmd.error!
cmd
end
diff --git a/chef/lib/chef/provider/directory.rb b/chef/lib/chef/provider/directory.rb
index 15816533b6..884a2ae185 100644
--- a/chef/lib/chef/provider/directory.rb
+++ b/chef/lib/chef/provider/directory.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,8 +36,8 @@ class Chef
@current_resource.mode("%o" % (cstats.mode & 007777))
end
@current_resource
- end
-
+ end
+
def action_create
unless ::File.exists?(@new_resource.path)
if @new_resource.recursive == true
@@ -46,13 +46,13 @@ class Chef
::Dir.mkdir(@new_resource.path)
end
@new_resource.updated_by_last_action(true)
- Chef::Log.info("#{@new_resource} created directory #{@new_resource.path}")
+ Chef::Log.info("#{@new_resource} created directory #{@new_resource.path}")
end
set_owner if @new_resource.owner != nil
set_group if @new_resource.group != nil
set_mode if @new_resource.mode != nil
end
-
+
def action_delete
if ::File.directory?(@new_resource.path) && ::File.writable?(@new_resource.path)
if @new_resource.recursive == true
diff --git a/chef/lib/chef/provider/execute.rb b/chef/lib/chef/provider/execute.rb
index debf4e1864..fde4f965e5 100644
--- a/chef/lib/chef/provider/execute.rb
+++ b/chef/lib/chef/provider/execute.rb
@@ -49,8 +49,8 @@ class Chef
opts[:group] = @new_resource.group if @new_resource.group
opts[:cwd] = @new_resource.cwd if @new_resource.cwd
opts[:umask] = @new_resource.umask if @new_resource.umask
- opts[:command_log_level] = :info
- opts[:command_log_prepend] = @new_resource.to_s
+ opts[:command_log_level] = :info
+ opts[:command_log_prepend] = @new_resource.to_s
if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info?
opts[:live_stream] = STDOUT
end
diff --git a/chef/lib/chef/provider/ifconfig.rb b/chef/lib/chef/provider/ifconfig.rb
index bf2146df86..98159c8d90 100644
--- a/chef/lib/chef/provider/ifconfig.rb
+++ b/chef/lib/chef/provider/ifconfig.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -76,11 +76,11 @@ class Chef
command << " metric #{@new_resource.metric}" if @new_resource.metric
command << " mtu #{@new_resource.mtu}" if @new_resource.mtu
end
-
+
run_command(
:command => command
)
- Chef::Log.info("#{@new_resource} added")
+ Chef::Log.info("#{@new_resource} added")
@new_resource.updated_by_last_action(true)
end
@@ -92,11 +92,11 @@ class Chef
# check to see if load_current_resource found the interface
if @current_resource.device
command = "ifconfig #{@new_resource.device} down"
-
+
run_command(
:command => command
)
- Chef::Log.info("#{@new_resource} deleted")
+ Chef::Log.info("#{@new_resource} deleted")
@new_resource.updated_by_last_action(true)
else
Chef::Log.debug("#{@new_resource} does not exist - nothing to do")
@@ -122,13 +122,13 @@ class Chef
network_file = ::File.new("/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}", "w")
network_file.puts(template.result(b))
network_file.close
- Chef::Log.info("#{@new_resource} created configuration file")
+ Chef::Log.info("#{@new_resource} created configuration file")
when "debian","ubuntu"
# template
when "slackware"
# template
end
- end
+ end
end
end
end
diff --git a/chef/lib/chef/provider/link.rb b/chef/lib/chef/provider/link.rb
index 87b6617954..f5ba0d67f4 100644
--- a/chef/lib/chef/provider/link.rb
+++ b/chef/lib/chef/provider/link.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,12 +36,12 @@ class Chef
end
private :negative_complement
-
+
def load_current_resource
@current_resource = Chef::Resource::Link.new(@new_resource.name)
@current_resource.target_file(@new_resource.target_file)
@current_resource.link_type(@new_resource.link_type)
- if @new_resource.link_type == :symbolic
+ if @new_resource.link_type == :symbolic
if ::File.exists?(@current_resource.target_file) && ::File.symlink?(@current_resource.target_file)
@current_resource.to(
::File.expand_path(::File.readlink(@current_resource.target_file))
@@ -64,71 +64,71 @@ class Chef
end
end
@current_resource
- end
-
+ end
+
# Compare the ownership of a symlink. Returns true if they are the same, false if they are not.
def compare_owner
return false if @new_resource.owner.nil?
-
+
@set_user_id = case @new_resource.owner
when /^\d+$/, Integer
@new_resource.owner.to_i
else
- # This raises an ArgumentError if you can't find the user
+ # This raises an ArgumentError if you can't find the user
Etc.getpwnam(@new_resource.owner).uid
end
-
+
@set_user_id == @current_resource.owner
end
-
+
# Set the ownership on the symlink, assuming it is not set correctly already.
def set_owner
unless compare_owner
@set_user_id = negative_complement(@set_user_id)
::File.lchown(@set_user_id, nil, @new_resource.target_file)
- Chef::Log.info("#{@new_resource} owner changed to #{@set_user_id}")
+ Chef::Log.info("#{@new_resource} owner changed to #{@set_user_id}")
@new_resource.updated_by_last_action(true)
end
end
-
+
# Compares the group of a symlink. Returns true if they are the same, false if they are not.
def compare_group
return false if @new_resource.group.nil?
-
+
@set_group_id = case @new_resource.group
when /^\d+$/, Integer
@new_resource.group.to_i
else
Etc.getgrnam(@new_resource.group).gid
end
-
+
@set_group_id == @current_resource.group
end
-
+
def set_group
unless compare_group
@set_group_id = negative_complement(@set_group_id)
::File.lchown(nil, @set_group_id, @new_resource.target_file)
- Chef::Log.info("#{@new_resource} group changed to #{@set_group_id}")
+ Chef::Log.info("#{@new_resource} group changed to #{@set_group_id}")
@new_resource.updated_by_last_action(true)
end
end
-
+
def action_create
if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file)
if @new_resource.link_type == :symbolic
- unless (::File.symlink?(@new_resource.target_file) && ::File.readlink(@new_resource.target_file) == @new_resource.to)
- if ::File.symlink?(@new_resource.target_file) || ::File.exist?(@new_resource.target_file)
- ::File.unlink(@new_resource.target_file)
- end
- ::File.symlink(@new_resource.to,@new_resource.target_file)
- Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file}")
- Chef::Log.info("#{@new_resource} created")
- end
+ unless (::File.symlink?(@new_resource.target_file) && ::File.readlink(@new_resource.target_file) == @new_resource.to)
+ if ::File.symlink?(@new_resource.target_file) || ::File.exist?(@new_resource.target_file)
+ ::File.unlink(@new_resource.target_file)
+ end
+ ::File.symlink(@new_resource.to,@new_resource.target_file)
+ Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file}")
+ Chef::Log.info("#{@new_resource} created")
+ end
elsif @new_resource.link_type == :hard
::File.link(@new_resource.to, @new_resource.target_file)
- Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file}")
- Chef::Log.info("#{@new_resource} created")
+ Chef::Log.debug("#{@new_resource} created #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file}")
+ Chef::Log.info("#{@new_resource} created")
end
@new_resource.updated_by_last_action(true)
end
@@ -137,9 +137,9 @@ class Chef
set_group unless @new_resource.group.nil?
end
end
-
+
def action_delete
- if @new_resource.link_type == :symbolic
+ if @new_resource.link_type == :symbolic
if ::File.symlink?(@new_resource.target_file)
::File.delete(@new_resource.target_file)
Chef::Log.info("#{@new_resource} deleted")
@@ -147,7 +147,7 @@ class Chef
elsif ::File.exists?(@new_resource.target_file)
raise Chef::Exceptions::Link, "Cannot delete #{@new_resource} at #{@new_resource.target_file}! Not a symbolic link."
end
- elsif @new_resource.link_type == :hard
+ elsif @new_resource.link_type == :hard
if ::File.exists?(@new_resource.target_file)
if ::File.exists?(@new_resource.to) && ::File.stat(@current_resource.target_file).ino == ::File.stat(@new_resource.to).ino
::File.delete(@new_resource.target_file)
diff --git a/chef/lib/chef/provider/ohai.rb b/chef/lib/chef/provider/ohai.rb
index a92e7a086e..c34ba7dc8d 100644
--- a/chef/lib/chef/provider/ohai.rb
+++ b/chef/lib/chef/provider/ohai.rb
@@ -34,8 +34,8 @@ class Chef
ohai.all_plugins
end
node.automatic_attrs.merge! ohai.data
- Chef::Log.info("#{@new_resource} reloaded")
- @new_resource.updated_by_last_action(true)
+ Chef::Log.info("#{@new_resource} reloaded")
+ @new_resource.updated_by_last_action(true)
end
end
end
diff --git a/chef/lib/chef/provider/package/apt.rb b/chef/lib/chef/provider/package/apt.rb
index c29daaf71d..5f7ff0d204 100644
--- a/chef/lib/chef/provider/package/apt.rb
+++ b/chef/lib/chef/provider/package/apt.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,12 +23,12 @@ require 'chef/resource/package'
class Chef
class Provider
class Package
- class Apt < Chef::Provider::Package
-
+ class Apt < Chef::Provider::Package
+
def load_current_resource
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
-
+
Chef::Log.debug("#{@new_resource} checking apt-cache policy")
status = popen4("apt-cache policy #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
stdout.each do |line|
@@ -43,7 +43,7 @@ class Chef
@current_resource.version(installed_version)
end
when /^\s{2}Candidate: (.+)$/
- Chef::Log.debug("#{@new_resource} candidate version is #{$1}")
+ Chef::Log.debug("#{@new_resource} candidate version is #{$1}")
@candidate_version = $1
end
end
@@ -52,14 +52,14 @@ class Chef
unless status.exitstatus == 0
raise Chef::Exceptions::Package, "apt-cache failed - #{status.inspect}!"
end
-
+
if @candidate_version == "(none)"
raise Chef::Exceptions::Package, "apt does not have a version of package #{@new_resource.package_name}"
end
-
+
@current_resource
end
-
+
def install_package(name, version)
run_command_with_systems_locale(
:command => "apt-get -q -y#{expand_options(@new_resource.options)} install #{name}=#{version}",
@@ -68,11 +68,11 @@ class Chef
}
)
end
-
+
def upgrade_package(name, version)
install_package(name, version)
end
-
+
def remove_package(name, version)
run_command_with_systems_locale(
:command => "apt-get -q -y#{expand_options(@new_resource.options)} remove #{@new_resource.package_name}",
@@ -81,7 +81,7 @@ class Chef
}
)
end
-
+
def purge_package(name, version)
run_command_with_systems_locale(
:command => "apt-get -q -y#{expand_options(@new_resource.options)} purge #{@new_resource.package_name}",
@@ -90,7 +90,7 @@ class Chef
}
)
end
-
+
def preseed_package(name, version)
preseed_file = get_preseed_file(name, version)
if preseed_file
@@ -103,7 +103,7 @@ class Chef
)
end
end
-
+
end
end
end
diff --git a/chef/lib/chef/provider/remote_directory.rb b/chef/lib/chef/provider/remote_directory.rb
index b045a35ec0..2fb25ca063 100644
--- a/chef/lib/chef/provider/remote_directory.rb
+++ b/chef/lib/chef/provider/remote_directory.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ class Chef
def action_create
super
-
+
files_to_purge = Set.new(
Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
@@ -44,8 +44,8 @@ class Chef
files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
end
purge_unmanaged_files(files_to_purge)
- Chef::Log.info("#{@new_resource} created")
- @new_resource.updated_by_last_action(true)
+ Chef::Log.info("#{@new_resource} created")
+ @new_resource.updated_by_last_action(true)
end
def action_create_if_missing
@@ -75,15 +75,15 @@ class Chef
files = cookbook.relative_filenames_in_preferred_directory(node, :files, @new_resource.source)
files.sort.reverse
end
-
+
def directory_root_in_cookbook_cache
@directory_root_in_cookbook_cache ||= begin
cookbook = run_context.cookbook_collection[resource_cookbook]
cookbook.preferred_filename_on_disk_location(node, :files, @new_resource.source, @new_resource.path)
end
end
-
- # Determine the cookbook to get the file from. If new resource sets an
+
+ # Determine the cookbook to get the file from. If new resource sets an
# explicit cookbook, use it, otherwise fall back to the implicit cookbook
# i.e., the cookbook the resource was declared in.
def resource_cookbook
@@ -92,9 +92,9 @@ class Chef
def create_cookbook_file(cookbook_file_relative_path)
full_path = ::File.join(@new_resource.path, cookbook_file_relative_path)
-
+
ensure_directory_exists(::File.dirname(full_path))
-
+
file_to_fetch = cookbook_file_resource(full_path, cookbook_file_relative_path)
if @new_resource.overwrite
file_to_fetch.run_action(:create)
@@ -103,7 +103,7 @@ class Chef
end
@new_resource.updated_by_last_action(true) if file_to_fetch.updated?
end
-
+
def cookbook_file_resource(target_path, relative_source_path)
cookbook_file = Chef::Resource::CookbookFile.new(target_path, run_context)
cookbook_file.cookbook_name = @new_resource.cookbook || @new_resource.cookbook_name
@@ -112,10 +112,10 @@ class Chef
cookbook_file.group(@new_resource.files_group) if @new_resource.files_group
cookbook_file.owner(@new_resource.files_owner) if @new_resource.files_owner
cookbook_file.backup(@new_resource.files_backup) if @new_resource.files_backup
-
+
cookbook_file
end
-
+
def ensure_directory_exists(path)
unless ::File.directory?(path)
directory_to_create = resource_for_directory(path)
diff --git a/chef/lib/chef/provider/service/freebsd.rb b/chef/lib/chef/provider/service/freebsd.rb
index 4c2ea256b9..1a4aadc658 100644
--- a/chef/lib/chef/provider/service/freebsd.rb
+++ b/chef/lib/chef/provider/service/freebsd.rb
@@ -30,19 +30,19 @@ class Chef
# Determine if we're talking about /etc/rc.d or /usr/local/etc/rc.d
if ::File.exists?("/etc/rc.d/#{current_resource.service_name}")
- @init_command = "/etc/rc.d/#{current_resource.service_name}"
+ @init_command = "/etc/rc.d/#{current_resource.service_name}"
elsif ::File.exists?("/usr/local/etc/rc.d/#{current_resource.service_name}")
- @init_command = "/usr/local/etc/rc.d/#{current_resource.service_name}"
+ @init_command = "/usr/local/etc/rc.d/#{current_resource.service_name}"
else
raise Chef::Exceptions::Service, "#{@new_resource}: unable to locate the rc.d script"
end
Chef::Log.debug("#{@current_resource} found at #{@init_command}")
-
+
if @new_resource.supports[:status]
begin
if run_command(:command => "#{@init_command} status") == 0
@current_resource.running true
- Chef::Log.debug("#{@new_resource} is running")
+ Chef::Log.debug("#{@new_resource} is running")
end
rescue Chef::Exceptions::Exec
@current_resource.running false
@@ -53,7 +53,7 @@ class Chef
begin
if run_command(:command => @new_resource.status_command) == 0
@current_resource.running true
- Chef::Log.debug("#{@new_resource} is running")
+ Chef::Log.debug("#{@new_resource} is running")
end
rescue Chef::Exceptions::Exec
@current_resource.running false
@@ -100,21 +100,21 @@ class Chef
unless @current_resource.enabled
Chef::Log.debug("#{@new_resource.name} enable/disable state unknown")
end
-
+
@current_resource
end
def read_rc_conf
::File.open("/etc/rc.conf", 'r') { |file| file.readlines }
end
-
+
def write_rc_conf(lines)
::File.open("/etc/rc.conf", 'w') do |file|
lines.each { |line| file.puts(line) }
end
end
-
-
+
+
# The variable name used in /etc/rc.conf for enabling this service
def service_enable_variable_name
# Look for name="foo" in the shell script @init_command. Use this for determining the variable name in /etc/rc.conf
@@ -130,7 +130,7 @@ class Chef
end
raise Chef::Exceptions::Service, "Could not find name=\"service\" line in #{@init_command}"
end
-
+
def set_service_enable(value)
lines = read_rc_conf
# Remove line that set the old value
@@ -139,7 +139,7 @@ class Chef
lines << "#{service_enable_variable_name}=\"#{value}\""
write_rc_conf(lines)
end
-
+
def enable_service()
set_service_enable("YES") unless @current_resource.enabled
end
@@ -147,7 +147,7 @@ class Chef
def disable_service()
set_service_enable("NO") if @current_resource.enabled
end
-
+
end
end
end
diff --git a/chef/lib/chef/provider/service/simple.rb b/chef/lib/chef/provider/service/simple.rb
index 85fb7e157e..6316b50444 100644
--- a/chef/lib/chef/provider/service/simple.rb
+++ b/chef/lib/chef/provider/service/simple.rb
@@ -32,7 +32,7 @@ class Chef
begin
if run_command(:command => @new_resource.status_command) == 0
@current_resource.running true
- Chef::Log.debug("#{@new_resource} is running")
+ Chef::Log.debug("#{@new_resource} is running")
end
rescue Chef::Exceptions::Exec
@current_resource.running false
@@ -45,7 +45,7 @@ class Chef
begin
if run_command(:command => "#{@init_command} status") == 0
@current_resource.running true
- Chef::Log.debug("#{@new_resource} is running")
+ Chef::Log.debug("#{@new_resource} is running")
end
rescue Chef::Exceptions::Exec
@current_resource.running false
@@ -110,7 +110,7 @@ class Chef
raise Chef::Exceptions::Service, "#{self.to_s} requires that reload_command to be set"
end
end
-
+
def ps_cmd
@run_context.node[:command] && @run_context.node[:command][:ps]
end
diff --git a/chef/lib/chef/resource.rb b/chef/lib/chef/resource.rb
index 591798273c..6dbbdec29e 100644
--- a/chef/lib/chef/resource.rb
+++ b/chef/lib/chef/resource.rb
@@ -419,9 +419,9 @@ F
Chef::Log.error("#{self} (#{defined_at}) had an error: #{e.message}")
else
Chef::Log.error("#{self} (#{defined_at}) has had an error")
- new_exception = e.exception("#{self} (#{defined_at}) had an error: #{e.message}")
- new_exception.set_backtrace(e.backtrace)
- raise new_exception
+ new_exception = e.exception("#{self} (#{defined_at}) had an error: #{e.message}")
+ new_exception.set_backtrace(e.backtrace)
+ raise new_exception
end
end
end