Class: BoringBuilder::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/boringbuilder/exporter.rb

Constant Summary collapse

PACKER_IMAGE =
"alpine:3.22@sha256:14358309a308569c32bdc37e2e0e9694be33a9d99e68afb0f5ff33cc1f695dce"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, client, container, runtime:, command_runner: nil, exporters: nil, progress: BuildProgress.silent) ⇒ Exporter

Returns a new instance of Exporter.



12
13
14
15
16
17
18
19
20
21
# File 'lib/boringbuilder/exporter.rb', line 12

def initialize(project, client, container, runtime:, command_runner: nil, exporters: nil,
               progress: BuildProgress.silent)
  @project = project
  @client = client
  @container = container
  @runtime = runtime
  @command_runner = command_runner || ->(*command) { Open3.capture3(*command) }
  @exporters = exporters || Exporters::Resolver.new(project, client).destinations
  @progress = progress
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def client
  @client
end

#containerObject (readonly)

Returns the value of attribute container.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def container
  @container
end

#exportersObject (readonly)

Returns the value of attribute exporters.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def exporters
  @exporters
end

#progressObject (readonly)

Returns the value of attribute progress.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def progress
  @progress
end

#projectObject (readonly)

Returns the value of attribute project.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def project
  @project
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



10
11
12
# File 'lib/boringbuilder/exporter.rb', line 10

def runtime
  @runtime
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/boringbuilder/exporter.rb', line 23

def call
  exporters.each(&:validate!)
  asset = build_asset unless exporters.empty?
  receipt = exporters.reduce(Exporters::Receipt.new) do |result, adapter|
    received = progress.step(export_step_name(adapter)) { adapter.export(asset) }
    merge_receipts(result, received)
  end
  reference = export_reference
  Result.new(
    format: configuration.format,
    path: receipt.path,
    reference: reference,
    runtime: runtime,
    platform: configuration.platform,
    artifact_id: receipt.artifact_id,
    artifact_name: receipt.artifact_name
  )
rescue DaggerRuby::DaggerError => e
  raise ExportError, "Dagger could not export the build: #{e.message}"
end