Class: Terraspace::Cloud::Upload::Package

Inherits:
Base show all
Defined in:
lib/terraspace/cloud/upload/package.rb

Instance Method Summary collapse

Methods inherited from Base

#artifacts_path, #initialize, #zip_path

Methods inherited from Base

#cancelled?, #changes?, #clean_cache2_stage, #cloud_upload, #initialize, #record?, #sh, #stage_attrs, #success_status

Methods included from Util::Pretty

#pretty_path, #pretty_time

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Methods included from Context

#setup_context

Methods included from Api::Validate

#validate

Methods included from Api::Concern

#api, #cloud_stack_name, #expander, #region

Methods included from Api::Concern::Errors

#error_message, #errors?

Methods inherited from Terraspace::CLI::Base

#initialize

Constructor Details

This class inherits a constructor from Terraspace::Cloud::Upload::Base

Instance Method Details

#buildObject



5
6
7
8
9
# File 'lib/terraspace/cloud/upload/package.rb', line 5

def build
  copy
  tidy
  zip # returns zip path
end

#copyObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/terraspace/cloud/upload/package.rb', line 11

def copy
  FileUtils.rm_rf(artifacts_path)
  FileUtils.mkdir_p(File.dirname(artifacts_path))

  expr = "#{@mod.cache_dir}/.terraspace-cache/.cache2/#{@type}/*"
  Dir.glob(expr).each do |src|
    dest = "#{artifacts_path}/#{File.basename(src)}"
    FileUtils.mkdir_p(File.dirname(dest))
    FileUtils.cp(src, dest)
  end
end

#tidyObject



23
24
25
# File 'lib/terraspace/cloud/upload/package.rb', line 23

def tidy
  Tidy.new(@options).cleanup
end

#zipObject



27
28
29
30
31
# File 'lib/terraspace/cloud/upload/package.rb', line 27

def zip
  FileUtils.rm_f(zip_path)
  ZipFolder.zip(artifacts_path, zip_path)
  zip_path
end