Class: BoringBuilder::Builder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, progress: BuildProgress.silent) ⇒ Builder

Returns a new instance of Builder.



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

def initialize(configuration, progress: BuildProgress.silent)
  @configuration = configuration
  @progress = progress
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



7
8
9
# File 'lib/boringbuilder/builder.rb', line 7

def configuration
  @configuration
end

#progressObject (readonly)

Returns the value of attribute progress.



7
8
9
# File 'lib/boringbuilder/builder.rb', line 7

def progress
  @progress
end

Instance Method Details

#buildObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/boringbuilder/builder.rb', line 14

def build
  project = Project.new(configuration).validate!
  runtime = Runtime.new(configuration.runtime)
  resolved_runtime = runtime.resolve
  dagger_configuration = DaggerRuby::Config.new(
    runtime: runtime.dagger_runtime(resolved_runtime),
    progress: configuration.progress,
    silent: configuration.progress.nil?
  )

  DaggerRuby.connection(dagger_configuration) do |client|
    container = project.container(client, progress: progress)
    Exporter.new(project, client, container, runtime: resolved_runtime, progress: progress).call
  end
rescue DaggerRuby::DaggerError => e
  message = e.message.sub(/\s*\[traceparent:[^\]]+\]\s*\z/, "")
  raise BuildError, "Dagger build failed: #{message}"
end