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



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/kitchen/helpers.rb', line 179

def call(state)
  create_sandbox
  sandbox_dirs = Dir.glob(File.join(sandbox_path, "*"))
  
  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



162
163
164
165
166
167
168
# File 'lib/kitchen/helpers.rb', line 162

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

#instance_nameObject



174
175
176
177
# File 'lib/kitchen/helpers.rb', line 174

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

#sandbox_pathObject



170
171
172
# File 'lib/kitchen/helpers.rb', line 170

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