Module: CFoundry::UploadHelpers

Included in:
V1::App, V2::App
Defined in:
lib/cfoundry/upload_helpers.rb

Constant Summary collapse

UPLOAD_EXCLUDE =

Default paths to exclude from upload payload. for cloulu uploads : glusterfs 디렉토리 활성화 될 수 있도록 제거

%w{.git _darcs .svn uploads}
RESOURCE_CHECK_LIMIT =

Minimum size for an application payload to bother checking resources.

1024 * 1024 * 1024

Instance Method Summary collapse

Instance Method Details

#upload(path, check_resources = true) ⇒ Object

Upload application’s code to target. Do this after #create! and before #start!

path

A path pointing to either a directory, or a .jar, .war, or .zip file.

If a .vmcignore file is detected under the given path, it will be used to exclude paths from the payload, similar to a .gitignore.

check_resources

If set to ‘false`, the entire payload will be uploaded without checking the resource cache.

Only do this if you know what you’re doing.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cfoundry/upload_helpers.rb', line 33

def upload(path, check_resources = true)
  unless File.exist? path
    raise CFoundry::Error, "Invalid application path '#{path}'"
  end

  zipfile = "#{Dir.tmpdir}/#{@guid}.zip"
  tmpdir = "#{Dir.tmpdir}/.vmc_#{@guid}_files"

  FileUtils.rm_f(zipfile)
  FileUtils.rm_rf(tmpdir)

  prepare_package(path, tmpdir)

  resources = determine_resources(tmpdir) if check_resources

  packed = CFoundry::Zip.pack(tmpdir, zipfile)

  @client.base.upload_app(@guid, packed && zipfile, resources || [])
ensure
  FileUtils.rm_f(zipfile) if zipfile
  FileUtils.rm_rf(tmpdir) if tmpdir
end