- From: "FitzGibbon, James" <
>
- To: "
" <
>
- Subject: [chef-dev] Re: Announce: chef-dk-template-plugin - easy distribution of ChefDK templates as gems
- Date: Thu, 14 May 2015 13:52:20 +0000
- Accept-language: en-US
Ohai again.
At Chef’s request, I have renamed this framework so as to not pollute the
ChefDK namespace.
I hereby present: chef-gen-flavors. That’s as cute as I’m willing to go. :)
New repos:
https://github.com/Nordstrom/chef-gen-flavors
https://github.com/Nordstrom/chef-gen-flavor-example
I also uploaded a transitional version of the chef-dk-template-plugin gem
that nags you about the rename if you happened to jump on board first. Sorry
for the mixup, I should have floated the name choice here before releasing.
Cheers
From: <FitzGibbon>, James FitzGibbon
<
<mailto:
>>
Date: Monday, May 11, 2015 at 6:23 PM
To:
"
<mailto:
>"
<
<mailto:
>>
Subject: Announce: chef-dk-template-plugin - easy distribution of ChefDK
templates as gems
Ohai Chefs!
I would like to announce the first release of chef-dk-template-plugin, a stab
at making it easy to distribute custom ChefDK templates inside and outside of
your organization.
Here’s a brief demo. Let’s assume you have a plugin class like this:
require 'chef-dk/template/plugin_base'
require 'chef-dk/template/mixins'
# the Chef Development Kit
module ChefDK
# templates for 'chef generate'
module Template
# a pluggable framework for distributing templates as ruby gems
class Plugin
# an example plugin for chef-dk-template-plugin
class Example < PluginBase
include ChefDK::Template::Mixin::CookbookBase
# the version of the gem
VERSION = '0.1.0'
class << self
def description
'Example cookbook template'
end
end
end
end
end
end
And you have a generator recipe like this:
template = ChefDK::Template::Plugin::Example.new(self)
template.generate
Now when you run ‘chef generate cookbook foo’, you’ll get a cookbook that has
all the things provided by the ‘CookbookBase’ mixin (things like a README,
CHANGELOG, metadata.rb, etc.)
Because the generators are Ruby classes:
- you can extend, inherit and metaprogram them to your heart’s delight
- you can test them using RSpec or minitest or Aruba/Cucumber
- you can create mixins for other people to use
- you can distribute your mixins or templates as ruby gems
- you can update them using ‘chef gem install’
My hope is that this will spur more sharing of good cookbook practice while
still allowing you to compose templates that meet the various needs you have
inside your organization.
Feedback and PRs are welcome.
Plugin Framework:
https://github.com/Nordstrom/chef-dk-template-plugin
Example Plugin:
https://github.com/Nordstrom/chef-dk-template-example
Cheers
Archive powered by MHonArc 2.6.16.