Class: DaggerRuby::Config
- Inherits:
-
Object
- Object
- DaggerRuby::Config
- Defined in:
- lib/dagger_ruby/config.rb
Constant Summary collapse
- ENGINE_IMAGE =
"registry.dagger.io/engine".freeze
- RUNTIMES =
%i[auto apple docker].freeze
- PROGRESS_MODES =
%w[auto pretty plain tty dots logs].freeze
Instance Attribute Summary collapse
-
#dagger_version ⇒ Object
readonly
Returns the value of attribute dagger_version.
-
#log_output ⇒ Object
readonly
Returns the value of attribute log_output.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
-
#runner_host ⇒ Object
readonly
Returns the value of attribute runner_host.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#silent ⇒ Object
readonly
Returns the value of attribute silent.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#verify_version ⇒ Object
readonly
Returns the value of attribute verify_version.
-
#workdir ⇒ Object
readonly
Returns the value of attribute workdir.
Instance Method Summary collapse
- #dagger_progress ⇒ Object
- #environment ⇒ Object
- #expected_engine_version ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #pretty_progress? ⇒ Boolean
- #progress_reporter(out: $stdout, enabled: true, environment: ENV) ⇒ Object
- #streaming_logs? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dagger_ruby/config.rb', line 13 def initialize( = {}) @log_output = [:log_output] @workdir = [:workdir] @timeout = [:timeout] || 600 @quiet = [:quiet] || ENV["DAGGER_QUIET"]&.to_i @silent = [:silent] || ENV["DAGGER_SILENT"] == "true" @progress = normalize_progress([:progress] || ENV.fetch("DAGGER_PROGRESS", nil)) @runtime = normalize_runtime(.fetch(:runtime, ENV.fetch("DAGGER_RUBY_RUNTIME", "auto"))) @runner_host = [:runner_host] @dagger_version = .fetch(:dagger_version, DAGGER_VERSION).to_s.delete_prefix("v") @verify_version = .fetch(:verify_version, true) raise ArgumentError, "runner_host and runtime cannot both be configured" if @runner_host && @runtime != :auto end |
Instance Attribute Details
#dagger_version ⇒ Object (readonly)
Returns the value of attribute dagger_version.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def dagger_version @dagger_version end |
#log_output ⇒ Object (readonly)
Returns the value of attribute log_output.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def log_output @log_output end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def progress @progress end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def quiet @quiet end |
#runner_host ⇒ Object (readonly)
Returns the value of attribute runner_host.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def runner_host @runner_host end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def runtime @runtime end |
#silent ⇒ Object (readonly)
Returns the value of attribute silent.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def silent @silent end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def timeout @timeout end |
#verify_version ⇒ Object (readonly)
Returns the value of attribute verify_version.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def verify_version @verify_version end |
#workdir ⇒ Object (readonly)
Returns the value of attribute workdir.
10 11 12 |
# File 'lib/dagger_ruby/config.rb', line 10 def workdir @workdir end |
Instance Method Details
#dagger_progress ⇒ Object
42 43 44 |
# File 'lib/dagger_ruby/config.rb', line 42 def dagger_progress pretty_progress? ? "logs" : progress end |
#environment ⇒ Object
28 29 30 31 32 |
# File 'lib/dagger_ruby/config.rb', line 28 def environment environment = {} environment["_EXPERIMENTAL_DAGGER_RUNNER_HOST"] = resolved_runner_host if resolved_runner_host environment end |
#expected_engine_version ⇒ Object
34 35 36 |
# File 'lib/dagger_ruby/config.rb', line 34 def expected_engine_version "v#{dagger_version}" end |
#pretty_progress? ⇒ Boolean
38 |
# File 'lib/dagger_ruby/config.rb', line 38 def pretty_progress? = progress == "pretty" |
#progress_reporter(out: $stdout, enabled: true, environment: ENV) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/dagger_ruby/config.rb', line 46 def progress_reporter(out: $stdout, enabled: true, environment: ENV) enabled &&= pretty_progress? color = enabled && out.respond_to?(:tty?) && out.tty? && !environment.key?("NO_COLOR") && environment.fetch("TERM", "") != "dumb" Progress.new(out: out, enabled: enabled, streaming: streaming_logs?, color: color, relay: enabled && Progress::Relay.from_environment(environment)) end |
#streaming_logs? ⇒ Boolean
40 |
# File 'lib/dagger_ruby/config.rb', line 40 def streaming_logs? = %w[pretty logs].include?(progress) |