summaryrefslogtreecommitdiff
path: root/lib/chef/provider/file
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2013-04-18 16:56:36 -0700
committerLamont Granquist <lamont@opscode.com>2013-04-18 16:56:36 -0700
commitd0991759dcfd135d8ffce3f851d86387eb935fa0 (patch)
tree0e5b53421db943d18346ed67576553a1dd49e76a /lib/chef/provider/file
parent86fbcb043eb99062d836e1da522770724a9ab5a8 (diff)
downloadchef-d0991759dcfd135d8ffce3f851d86387eb935fa0.tar.gz
use deploy_with :copy or :move as external API in resources
Diffstat (limited to 'lib/chef/provider/file')
-rw-r--r--lib/chef/provider/file/deploy.rb18
-rw-r--r--lib/chef/provider/file/deploy/cp.rb (renamed from lib/chef/provider/file/deploy/cp_unix.rb)14
2 files changed, 8 insertions, 24 deletions
diff --git a/lib/chef/provider/file/deploy.rb b/lib/chef/provider/file/deploy.rb
index 50cc6e4b6e..d6be159c07 100644
--- a/lib/chef/provider/file/deploy.rb
+++ b/lib/chef/provider/file/deploy.rb
@@ -4,18 +4,14 @@ class Chef
class Provider
class File
class Deploy
- def self.strategy(deployment_strategy)
- deployment_strategy ||= Chef::Config[:file_deployment_strategy]
- deployment_strategy ||= Chef::Platform.windows? ? :mv_windows : :mv_unix
- case deployment_strategy
- when :mv_windows
- Chef::Provider::File::Deploy::MvWindows.new()
- when :mv_unix
- Chef::Provider::File::Deploy::MvUnix.new()
- when :cp_unix
- Chef::Provider::File::Deploy::CpUnix.new()
+ def self.strategy(deploy_with)
+ case deploy_with
+ when :move
+ Chef::Platform.windows? ? MvWindows.new() : MvUnix.new()
+ when :copy
+ Cp.new()
else
- raise "invalid deployment strategy use :mv_unix, :mv_windows or :cp_unix"
+ raise "invalid deployment strategy use :move or :copy"
end
end
end
diff --git a/lib/chef/provider/file/deploy/cp_unix.rb b/lib/chef/provider/file/deploy/cp.rb
index e27a679b96..109b2b137f 100644
--- a/lib/chef/provider/file/deploy/cp_unix.rb
+++ b/lib/chef/provider/file/deploy/cp.rb
@@ -27,27 +27,15 @@ class Chef
class Provider
class File
class Deploy
- class CpUnix
+ class Cp
def create(file)
Chef::Log.debug("touching #{file} to create it")
FileUtils.touch(file)
end
def deploy(src, dst)
- Chef::Log.debug("reading modes from #{dst} file")
- mode = ::File.stat(dst).mode & 07777
- uid = ::File.stat(dst).uid
- gid = ::File.stat(dst).gid
- Chef::Log.debug("read mode = #{mode.to_s(8)}, uid = #{uid}, gid = #{gid} to #{dst}")
-
Chef::Log.debug("copying temporary file #{src} into place at #{dst}")
FileUtils.cp(src, dst)
-
- Chef::Log.debug("reading modes from #{dst} file")
- mode = ::File.stat(dst).mode & 07777
- uid = ::File.stat(dst).uid
- gid = ::File.stat(dst).gid
- Chef::Log.debug("read mode = #{mode.to_s(8)}, uid = #{uid}, gid = #{gid} to #{dst}")
end
end
end