Class: Lono::AppFile::Upload

Inherits:
Base 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::Helper

#rollback_complete?, #testing_update?

Methods included from Lono::AwsServices::StackSet

#find_stack_set, #stack_set_exists?

Methods included from Lono::AwsServices::Stack

#find_stack, #stack_exists?

Methods inherited from Base

#initialize, #initialize_variables

Methods inherited from Lono::AbstractBase

#initialize, #reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

This class inherits a constructor from Lono::AppFile::Base

Instance Method Details

#s3_bucketObject



32
33
34
# File 'lib/lono/app_file/upload.rb', line 32

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

#s3_upload(item) ⇒ Object

TODO: check md5sum and only upload if it changes



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

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



6
7
8
9
10
11
12
13
# File 'lib/lono/app_file/upload.rb', line 6

def upload
  return unless Registry.items.size > 0
  puts "Uploading app/files..."

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