From 9df4e0f67dd510d6b12cabf0322f9bb2cceaff1b Mon Sep 17 00:00:00 2001 From: Franklin Webber Date: Thu, 8 Mar 2018 09:28:45 -0600 Subject: [PATCH] Adds a kitchen flag that gives options for different kitchen configs To provide support out-of-the-box for kitchen-dokken there is a flag now to specify which base kitchen configuration to use. Signed-off-by: Franklin Webber --- .../command/generator_commands/cookbook.rb | 10 ++++++ .../code_generator/recipes/cookbook.rb | 5 ++- .../templates/default/kitchen_dokken.yml.erb | 31 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 lib/chef-dk/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb 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: