Class: Kitchen::GzippedChefDataUploader

Inherits:
ChefDataUploader
  • Object
show all
Defined in:
lib/kitchen/sshgzip.rb

Instance Method Summary collapse

Instance Method Details

#upload_path(scp, path, dir = File.basename(path)) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kitchen/sshgzip.rb', line 7

def upload_path(scp, path, dir = File.basename(path))
  if File.directory?(path)
    tmp_root = Dir.mktmpdir('gzipped_chef_upload')
    gzip_path = "#{tmp_root}/#{dir}.tar.gz"
    info("Compressing #{dir} into #{dir}.tar.gz")
    system "cd #{path} && tar -zcf #{gzip_path} ."
    super(scp, gzip_path, "#{dir}.tar.gz")
    scp.session.exec! "cd #{chef_home} && mkdir #{dir} && " +
      "tar -zxf #{dir}.tar.gz -C #{dir} && rm #{dir}.tar.gz"
  else
    super
  end
end