Sha256: c3e412cffbc4c6816188376ed4a827ac3cfe5ed0c7b2107258de1ff78acc4faf

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module Lono::Files::Concerns
  module PostProcessing
    extend Memoist

    def build
      Lono::Files::Builder.new(@options.merge(files: self)).run
    end

    def build_lambda_layer(cfn)
      Lono::Files::Builder::LambdaLayer.new(@options.merge(files: self, cfn: cfn)).run
    end

    def compress
      Lono::Files::Compressor.new(@options.merge(files: self)).run
    end

    def upload
      uploader.upload # Lono::S3::Uploader#upload
    end

    delegate :s3_path, :s3_key, to: :uploader
    def uploader
      Lono::S3::Uploader.new(zip_path)
    end
    memoize :uploader

    def zip_name
      name = File.basename(full_path)
      name << "-layer" if layer
      "#{name}-#{Lono::Md5.sum(full_path)}.zip"
    end

    def zip_path
      "#{File.dirname(output_path)}/#{zip_name}"
    end

    def output_path
      if layer
        # For Lambda Layer the final output path is the opt folder, where final artifact is zipped
        "#{Lono.root}/output/#{@blueprint.name}/layer/#{path}/opt" # Note: layer and opt
      else
        # For normal files the final output path in the compiled path
        compiled_path
      end
    end

    # Also used by LambdaLayer::RubyPackager#compiled_area
    def compiled_path
      "#{Lono.root}/output/#{@blueprint.name}/normal/#{path}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/files/concerns/post_processing.rb
lono-8.0.0.pre.rc5 lib/lono/files/concerns/post_processing.rb
lono-8.0.0.pre.rc4 lib/lono/files/concerns/post_processing.rb