class Kitchen::Loader::Microwave

A customized version of Test Kitchen's YAML loader to allow auto-generating a config.

@author Jonathan Hartman <jonathan.hartman@socrata.com>

Public Class Methods

new(options = {}) click to toggle source

Write out the generated hash for this loader after instantiating it.

(see Kitchen::Loader::YAML.initialize)

Calls superclass method
# File lib/kitchen/loader/microwave.rb, line 45
def initialize(options = {})
  super
  write!
end

Public Instance Methods

combined_hash() click to toggle source

Add a fourth layer of config at the top and then merge the regular three layers of .kitchen.ymls into it. Then delete any excluded platforms that have been set globally via:


microwave:

excludes:
  - platform: ubuntu
    version: 14.04
    chef: 14
  - platform: debian
    # version: implicit "all"
    # chef: implicit "all"

(see Kitchen::Loader::YAML#combined_hash)

Calls superclass method
# File lib/kitchen/loader/microwave.rb, line 86
def combined_hash
  hsh = microwave_hash.rmerge(super)
  @excludes = hsh['microwave']['excludes']
  hsh
end
microwave_hash() click to toggle source

Return the new top layer we're going to merge all the traditional YAML layers into. The new layer should have:

  • An empty set of platforms to be excluded

  • A static, simple driver config for dokken

  • A static, simple transport config for dokken

  • A static, simple provisioner config for dokken

  • A static, simple verifier config for dokken

  • A set of platforms generated from metadata.rb's supported platforms*Chef versions

  • A set of suites generated from recipes present in the `test` wrapper cookbook

@return [Hash] the top-level Microwave hash for the config

# File lib/kitchen/loader/microwave.rb, line 107
def microwave_hash
  path = File.dirname(@config_file)
  normalize(
    'microwave' => { 'excludes' => [] },
    'driver' => Kitchen::Microwave::Driver.new,
    'transport' => Kitchen::Microwave::Transport.new,
    'provisioner' => Kitchen::Microwave::Provisioner.new,
    'verifier' => Kitchen::Microwave::Verifier.new,
    'platforms' => Kitchen::Microwave::Platforms.new(path, @excludes),
    'suites' => Kitchen::Microwave::Suites.new(path)
  )
end
read() click to toggle source

Don't bother raising an error if the .kitchen.yml doesn't exist.

(see Kitchen::Loader::YAML#read)

# File lib/kitchen/loader/microwave.rb, line 55
def read
  Util.symbolized_hash(combined_hash)
end
write!() click to toggle source

Write the merged config out to a file for easier debugging.

# File lib/kitchen/loader/microwave.rb, line 62
def write!
  path = File.expand_path('.kitchen/.microwave.yml',
                          File.dirname(@config_file))
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, Util.stringified_hash(read).to_yaml)
end