Class: Kitchen::Verifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/helpers.rb

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/kitchen/helpers.rb', line 340

def call(state)
  create_sandbox
  instance.transport.connection(state) do |conn|
    conn.execute(install_command)

    unless state[:data_container].nil?
      conn.execute(init_command)
      info("Transferring files to #{instance.to_str}")
      conn.upload(sandbox_dirs, config[:root_path])
      debug("Transfer complete")
    end

    conn.execute(prepare_command)
    conn.execute(run_command)
  end
rescue Kitchen::Transport::TransportFailed => ex
  raise ActionFailed, ex.message
end

#create_sandboxObject



324
325
326
327
328
329
# File 'lib/kitchen/helpers.rb', line 324

def create_sandbox
  info("Creating kitchen sandbox in #{sandbox_path}")
  unless ::Dir.exist?(sandbox_path)
    FileUtils.mkdir_p(sandbox_path, mode: 0o755)
  end
end

#instance_nameObject



335
336
337
338
# File 'lib/kitchen/helpers.rb', line 335

def instance_name
  prefix = (Digest::SHA2.hexdigest FileUtils.pwd)[0, 10]
  "#{prefix}-#{instance.name}".downcase
end

#sandbox_pathObject



331
332
333
# File 'lib/kitchen/helpers.rb', line 331

def sandbox_path
  "#{Dir.home}/.dokken/verifier_sandbox/#{instance_name}"
end