Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1517 from burtlo/feature/cookbook_generator-kitch…
Browse files Browse the repository at this point in the history
…en_flag

Adds a --kitchen flag that gives options for different kitchen configs
  • Loading branch information
marcparadise authored Nov 28, 2018
2 parents dc9cecd + e7fd003 commit 21d6504
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/chef-dk/command/generator_commands/cookbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Cookbook < Base
boolean: true,
default: nil

option :kitchen,
long: "--kitchen CONFIGURATION",
description: "Generate cookbooks with a specific kitchen configuration (dokken|vagrant) - defaults to vagrant",
default: "vagrant"

option :policy,
short: "-P",
long: "--policy",
Expand Down Expand Up @@ -131,6 +136,11 @@ def setup_context

Generator.add_attr_to_context(:use_berkshelf, berks_mode?)
Generator.add_attr_to_context(:pipeline, pipeline)
Generator.add_attr_to_context(:kitchen, kitchen)
end

def kitchen
config[:kitchen]
end

def pipeline
Expand Down
5 changes: 4 additions & 1 deletion lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@

# Test Kitchen
template "#{cookbook_dir}/.kitchen.yml" do
if context.use_berkshelf
if context.kitchen == 'dokken'
# kitchen-dokken configuration works with berkshelf and policyfiles
source 'kitchen_dokken.yml.erb'
elsif context.use_berkshelf
source 'kitchen.yml.erb'
else
source 'kitchen_policyfile.yml.erb'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
driver:
name: dokken

provisioner:
name: dokken

transport:
name: dokken

verifier:
name: inspec

platforms:
# @see https://github.com/someara/dokken-images
# @see https://hub.docker.com/r/dokken/
- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
- name: centos-7
driver:
image: dokken/centos-7

suites:
- name: default
run_list:
- recipe[<%= cookbook_name %>::default]
verifier:
inspec_tests:
- test/integration/default
attributes:

0 comments on commit 21d6504

Please sign in to comment.