Class: Lono::AppFile::Upload

Inherits:
Base
  • Object
show all
Extended by:
Memoist
Includes:
Lono::AwsServices
Defined in:
lib/lono/app_file/upload.rb

Instance Method Summary collapse

Methods included from Lono::AwsServices

#cfn, #ec2, #iam, #s3, #s3_presigner, #s3_resource, #sts

Methods included from Lono::AwsServices::Util

#find_stack, #rollback_complete?, #stack_exists?, #testing_update?

Methods inherited from Base

#initialize_variables

Methods included from Blueprint::Root

#bundler_groups, #find_blueprint_root, #require_bundle_gems, #set_blueprint_root

Constructor Details

#initialize(blueprint, options = {}) ⇒ Upload

Returns a new instance of Upload.



6
7
8
# File 'lib/lono/app_file/upload.rb', line 6

def initialize(blueprint, options={})
  @blueprint, @options = blueprint, options
end

Instance Method Details

#s3_bucketObject



35
36
37
# File 'lib/lono/app_file/upload.rb', line 35

def s3_bucket
  Lono::S3::Bucket.name
end

#s3_upload(item) ⇒ Object

TODO: check md5sum and only upload if it changes



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lono/app_file/upload.rb', line 19

def s3_upload(item)
  filepath = item.zip_file_path
  s3_key = item.s3_path
  s3_path = "s3://#{s3_bucket}/#{s3_key}"
  message = "Uploading: #{filepath} to #{s3_path}".color(:green)
  message = "NOOP: #{message}" if @options[:noop]
  puts message
  return if @options[:noop]

  s3.put_object(
    body: IO.read(filepath),
    bucket: s3_bucket,
    key: s3_key,
  )
end

#uploadObject



10
11
12
13
14
15
16
# File 'lib/lono/app_file/upload.rb', line 10

def upload
  puts "Uploading app/files..."

  Registry.items.each do |item|
    s3_upload(item)
  end
end