Class: Lemans::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/lemans/setup.rb

Overview

Makes one shared image into this task's sandbox at start-up: uploads the declared files and runs the setup commands. A failure here is never the model's.

Constant Summary collapse

ROOT =

Uploads land under one harness-owned directory, wiped once the steps have run: an agent whose first ls / finds the seed patch is reading the harness.

"/lemans"
DIR =
"#{ROOT}/setup".freeze

Instance Method Summary collapse

Constructor Details

#initialize(commands:, task:, phase:, timeout_sec:) ⇒ Setup

Returns a new instance of Setup.



14
15
16
17
18
19
# File 'lib/lemans/setup.rb', line 14

def initialize(commands:, task:, phase:, timeout_sec:)
  @commands = commands
  @task = task
  @phase = phase
  @timeout_sec = timeout_sec
end

Instance Method Details

#call(environment) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/lemans/setup.rb', line 21

def call(environment)
  return if commands.empty? && files.empty?

  files.each { |local, remote| environment.upload(local, remote) }
  apply_seed(environment)
  commands.each { environment.exec!(_1, timeout: timeout_sec) }
  environment.exec!("rm -rf #{Shellwords.escape(ROOT)}")
end