diff --git a/lib/chef-dk/command/generator_commands/cookbook.rb b/lib/chef-dk/command/generator_commands/cookbook.rb index ee363372f..2f40cdd6c 100644 --- a/lib/chef-dk/command/generator_commands/cookbook.rb +++ b/lib/chef-dk/command/generator_commands/cookbook.rb @@ -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", @@ -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 diff --git a/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb b/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb index 753e3bd22..d6f87750b 100644 --- a/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +++ b/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb @@ -66,7 +66,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' diff --git a/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb b/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb new file mode 100644 index 000000000..5922f54e0 --- /dev/null +++ b/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb @@ -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: