Class: Sambot::Domain::Chef::Kitchen

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/domain/chef/kitchen.rb

Constant Summary collapse

KITCHEN_LOCAL_YML =
".kitchen.yml"
KITCHEN_GCP_YML =
".kitchen.gcp.yml"
KITCHEN_RACKSPACE_YML =
".kitchen.rackspace.yml"

Class Method Summary collapse

Class Method Details

.generate_yml(cookbook_name, platforms, suites = nil) ⇒ Object

Raises:

  • (ApplicationError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sambot/domain/chef/kitchen.rb', line 11

def self.generate_yml(cookbook_name, platforms, suites = nil)
  raise ApplicationError, 'Missing platforms when trying to generate Test-Kitchen YAML.' unless platforms
  raise ApplicationError, 'Missing cookbook name when trying to generate Test-Kitchen YAML.' unless cookbook_name
  test_kitchen_configs = {
    "#{KITCHEN_LOCAL_YML}": read_template(KITCHEN_LOCAL_YML, cookbook_name, platforms),
    "#{KITCHEN_GCP_YML}": read_template(KITCHEN_GCP_YML, cookbook_name, platforms),
    "#{KITCHEN_RACKSPACE_YML}": read_template(KITCHEN_RACKSPACE_YML, cookbook_name, platforms)
  }
  test_kitchen_configs.each do |key, value|
    value['suites'] = suites if suites
    test_kitchen_configs[key] = value.to_yaml
  end
  test_kitchen_configs
end