Class: Sambot::Chef::Kitchen

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

Constant Summary collapse

GENERATED_FILE =
'.kitchen.yml'

Class Method Summary collapse

Class Method Details

.cleanObject



17
18
19
# File 'lib/sambot/chef/kitchen.rb', line 17

def clean
  FS.delete(GENERATED_FILE)
end

.generate_yml(cloud, cookbook_name, platforms, forwarded_ports = [], suites = nil, vault_setup = nil) ⇒ Object

Raises:



21
22
23
24
25
26
27
28
29
30
# File 'lib/sambot/chef/kitchen.rb', line 21

def generate_yml(cloud, cookbook_name, platforms, forwarded_ports = [], suites = nil, vault_setup = 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
  template = read_template(cloud, cookbook_name, platforms, vault_setup, forwarded_ports)
  if suites
    template['suites'] = Marshal.load(Marshal.dump(suites))
    add_platform_identifier(template, cloud)
  end
  template.to_yaml
end

.setup(cloud, config, vault_setup) ⇒ Object



11
12
13
14
15
# File 'lib/sambot/chef/kitchen.rb', line 11

def setup(cloud, config, vault_setup)
  contents = generate_yml(cloud, config.name, config.available_platforms, config.forwarded_ports, config.suites, vault_setup)
  File.write(GENERATED_FILE, contents)
  UI.debug("#{GENERATED_FILE} has been added to the cookbook.")
end