Class: BoringBuilder::Configuration

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

Constant Summary collapse

FORMATS =
%i[directory tar tar_zst oci docker].freeze
RUNTIMES =
%i[auto apple docker].freeze
FORMAT_ALIASES =
{
  "tar.zst" => :tar_zst,
  "tar-zst" => :tar_zst,
  "tar_zst" => :tar_zst
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root: Dir.pwd, runtime: :auto, platform: nil, format: :tar_zst, output: nil, base_image: nil, paths: nil, files: nil, host_paths: nil, publish: nil, load: nil, progress: nil, assets: nil, bootsnap: nil, artifact: nil, command: nil, port: nil, exporter: :auto, artifact_name: nil, pipeline: nil, build_packages: nil, runtime_packages: nil, build_environment: nil) ⇒ Configuration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/boringbuilder/configuration.rb', line 22

def initialize(root: Dir.pwd, runtime: :auto, platform: nil, format: :tar_zst,
               output: nil, base_image: nil, paths: nil,
               files: nil, host_paths: nil, publish: nil, load: nil,
               progress: nil, assets: nil, bootsnap: nil,
               artifact: nil, command: nil, port: nil,
               exporter: :auto, artifact_name: nil, pipeline: nil,
               build_packages: nil, runtime_packages: nil, build_environment: nil)
  @root = Pathname.new(root).expand_path
  @runtime = normalize_runtime(runtime)
  @platform = platform
  @format = normalize_format(format)
  @output = output && Pathname.new(output).expand_path(@root)
  @base_image = base_image
  @paths = Array(paths).compact
  @files = Array(files).compact
  @host_paths = Array(host_paths).compact
  @publish = publish
  @load = load
  @progress = progress
  @assets = assets
  @bootsnap = bootsnap
  @artifact = artifact || Artifact.new(root: @root)
  @command = command
  @port = port
  @exporter = normalize_exporter(exporter)
  @artifact_name = artifact_name
  @pipeline = pipeline
  @build_packages = normalize_packages(build_packages)
  @runtime_packages = normalize_packages(runtime_packages)
  @build_environment = normalize_environment(build_environment)
end

Instance Attribute Details

#artifactObject

Returns the value of attribute artifact.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def artifact
  @artifact
end

#artifact_nameObject

Returns the value of attribute artifact_name.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def artifact_name
  @artifact_name
end

#assetsObject

Returns the value of attribute assets.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def assets
  @assets
end

#base_imageObject

Returns the value of attribute base_image.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def base_image
  @base_image
end

#bootsnapObject

Returns the value of attribute bootsnap.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def bootsnap
  @bootsnap
end

#build_environmentObject

Returns the value of attribute build_environment.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def build_environment
  @build_environment
end

#build_packagesObject

Returns the value of attribute build_packages.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def build_packages
  @build_packages
end

#commandObject

Returns the value of attribute command.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def command
  @command
end

#exporterObject

Returns the value of attribute exporter.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def exporter
  @exporter
end

#filesObject

Returns the value of attribute files.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def files
  @files
end

#formatObject

Returns the value of attribute format.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def format
  @format
end

#host_pathsObject

Returns the value of attribute host_paths.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def host_paths
  @host_paths
end

#loadObject

Returns the value of attribute load.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def load
  @load
end

#outputObject

Returns the value of attribute output.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def output
  @output
end

#pathsObject

Returns the value of attribute paths.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def paths
  @paths
end

#pipeline(&block) ⇒ Object



74
75
76
77
# File 'lib/boringbuilder/configuration.rb', line 74

def pipeline(&block)
  @pipeline = block if block
  @pipeline
end

#platformObject

Returns the value of attribute platform.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def platform
  @platform
end

#portObject

Returns the value of attribute port.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def port
  @port
end

#progressObject

Returns the value of attribute progress.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def progress
  @progress
end

#publishObject

Returns the value of attribute publish.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def publish
  @publish
end

#rootObject

Returns the value of attribute root.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def root
  @root
end

#runtimeObject

Returns the value of attribute runtime.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def runtime
  @runtime
end

#runtime_packagesObject

Returns the value of attribute runtime_packages.



15
16
17
# File 'lib/boringbuilder/configuration.rb', line 15

def runtime_packages
  @runtime_packages
end

Instance Method Details

#apply(options) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/boringbuilder/configuration.rb', line 64

def apply(options)
  options.each do |name, value|
    writer = "#{name}="
    raise ConfigurationError, "Unknown configuration option: #{name}" unless respond_to?(writer)

    public_send(writer, value)
  end
  self
end

#validate!Object



54
55
56
57
58
59
60
61
62
# File 'lib/boringbuilder/configuration.rb', line 54

def validate!
  normalize!
  validate_project_directory!
  validate_option_combinations!
  validate_port!
  validate_artifact!
  validate_output_path!
  self
end