summaryrefslogtreecommitdiff
path: root/lib/chef/knife/cookbook_create.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-01-17 13:43:28 -0800
committerdanielsdeleo <dan@opscode.com>2013-01-17 15:02:54 -0800
commit62f9b0e3be8e22eef092163c331b7d3f8d350f94 (patch)
tree6b37c7a275918580b59c16de32a16c24f5dbe77f /lib/chef/knife/cookbook_create.rb
parent30ec971df95264b39e5e403c08b634d4708f5bee (diff)
parentb568c4d060765e75023f50f24d0a394ada5aed0b (diff)
downloadchef-62f9b0e3be8e22eef092163c331b7d3f8d350f94.tar.gz
Merge branch '10-stable' into integrate-chef-10-18-0
Conflicts: .gitattributes chef-expander/Rakefile chef-expander/lib/chef/expander/version.rb chef-server-api/Rakefile chef-server-api/chef-server-api.gemspec chef-server-api/lib/chef-server-api/version.rb chef-server-webui/Rakefile chef-server-webui/chef-server-webui.gemspec chef-server-webui/lib/chef-server-webui/version.rb chef-server/Rakefile chef-server/lib/chef-server/version.rb chef-solr/lib/chef/solr/version.rb chef.gemspec chef/Rakefile chef/spec/support/platform_helpers.rb chef/spec/support/shared/functional/file_resource.rb chef/spec/unit/api_client_spec.rb chef/spec/unit/provider/directory_spec.rb ci/jenkins_run_tests.bat ci/jenkins_run_tests.sh distro/common/html/chef-client.8.html distro/common/html/chef-expander.8.html distro/common/html/chef-expanderctl.8.html distro/common/html/chef-server-webui.8.html distro/common/html/chef-server.8.html distro/common/html/chef-shell.1.html distro/common/html/chef-solo.8.html distro/common/html/chef-solr.8.html distro/common/html/knife-bootstrap.1.html distro/common/html/knife-client.1.html distro/common/html/knife-configure.1.html distro/common/html/knife-cookbook-site.1.html distro/common/html/knife-cookbook.1.html distro/common/html/knife-data-bag.1.html distro/common/html/knife-environment.1.html distro/common/html/knife-exec.1.html distro/common/html/knife-index.1.html distro/common/html/knife-node.1.html distro/common/html/knife-role.1.html distro/common/html/knife-search.1.html distro/common/html/knife-ssh.1.html distro/common/html/knife-status.1.html distro/common/html/knife-tag.1.html distro/common/html/knife.1.html distro/common/man/man1/chef-shell.1 distro/common/man/man1/knife-bootstrap.1 distro/common/man/man1/knife-client.1 distro/common/man/man1/knife-configure.1 distro/common/man/man1/knife-cookbook-site.1 distro/common/man/man1/knife-cookbook.1 distro/common/man/man1/knife-data-bag.1 distro/common/man/man1/knife-environment.1 distro/common/man/man1/knife-exec.1 distro/common/man/man1/knife-index.1 distro/common/man/man1/knife-node.1 distro/common/man/man1/knife-role.1 distro/common/man/man1/knife-search.1 distro/common/man/man1/knife-ssh.1 distro/common/man/man1/knife-status.1 distro/common/man/man1/knife-tag.1 distro/common/man/man1/knife.1 distro/common/man/man8/chef-client.8 distro/common/man/man8/chef-expander.8 distro/common/man/man8/chef-expanderctl.8 distro/common/man/man8/chef-server-webui.8 distro/common/man/man8/chef-server.8 distro/common/man/man8/chef-solo.8 distro/common/man/man8/chef-solr.8 lib/chef/api_client.rb lib/chef/rest.rb lib/chef/version.rb spec/functional/knife/ssh_spec.rb spec/functional/resource/cookbook_file_spec.rb spec/spec_helper.rb spec/stress/win32/security_spec.rb spec/support/shared/functional/securable_resource.rb spec/unit/config_spec.rb spec/unit/knife/ssh_spec.rb
Diffstat (limited to 'lib/chef/knife/cookbook_create.rb')
-rw-r--r--lib/chef/knife/cookbook_create.rb206
1 files changed, 178 insertions, 28 deletions
diff --git a/lib/chef/knife/cookbook_create.rb b/lib/chef/knife/cookbook_create.rb
index c2e92e6b42..1e6797e4e3 100644
--- a/lib/chef/knife/cookbook_create.rb
+++ b/lib/chef/knife/cookbook_create.rb
@@ -73,10 +73,10 @@ class Chef
email = config[:cookbook_email] || "YOUR_EMAIL"
license = ((config[:cookbook_license] != "false") && config[:cookbook_license]) || "none"
readme_format = ((config[:readme_format] != "false") && config[:readme_format]) || "md"
- create_cookbook(cookbook_path,cookbook_name, copyright, license)
- create_readme(cookbook_path,cookbook_name,readme_format)
- create_changelog(cookbook_path,cookbook_name)
- create_metadata(cookbook_path,cookbook_name, copyright, email, license,readme_format)
+ create_cookbook(cookbook_path, cookbook_name, copyright, license)
+ create_readme(cookbook_path, cookbook_name, readme_format)
+ create_changelog(cookbook_path, cookbook_name)
+ create_metadata(cookbook_path, cookbook_name, copyright, email, license, readme_format)
end
def create_cookbook(dir, cookbook_name, copyright, license)
@@ -193,7 +193,7 @@ This file is used to list changes made in each version of #{cookbook_name}.
* Initial release of #{cookbook_name}
-- - -
+- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
@@ -202,54 +202,203 @@ EOH
end
end
- def create_readme(dir, cookbook_name,readme_format)
+ def create_readme(dir, cookbook_name, readme_format)
msg("** Creating README for cookbook: #{cookbook_name}")
unless File.exists?(File.join(dir, cookbook_name, "README.#{readme_format}"))
open(File.join(dir, cookbook_name, "README.#{readme_format}"), "w") do |file|
case readme_format
when "rdoc"
file.puts <<-EOH
-= DESCRIPTION:
-
-= REQUIREMENTS:
-
-= ATTRIBUTES:
-
-= USAGE:
-
+= #{cookbook_name} Cookbook
+TODO: Enter the cookbook description here.
+
+e.g.
+This cookbook makes your favorite breakfast sandwhich.
+
+== Requirements
+TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+e.g.
+==== packages
+- +toaster+ - #{cookbook_name} needs toaster to brown your bagel.
+
+== Attributes
+TODO: List you cookbook attributes here.
+
+e.g.
+==== #{cookbook_name}::default
+<table>
+ <tr>
+ <th>Key</th>
+ <th>Type</th>
+ <th>Description</th>
+ <th>Default</th>
+ </tr>
+ <tr>
+ <td><tt>['#{cookbook_name}']['bacon']</tt></td>
+ <td>Boolean</td>
+ <td>whether to include bacon</td>
+ <td><tt>true</tt></td>
+ </tr>
+</table>
+
+== Usage
+==== #{cookbook_name}::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include +#{cookbook_name}+ in your node's +run_list+:
+
+ {
+ "name":"my_node",
+ "run_list": [
+ "recipe[#{cookbook_name}]"
+ ]
+ }
+
+== Contributing
+TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+e.g.
+1. Fork the repository on Github
+2. Create a named feature branch (like `add_component_x`)
+3. Write you change
+4. Write tests for your change (if applicable)
+5. Run the tests, ensuring they all pass
+6. Submit a Pull Request using Github
+
+== License and Authors
+Authors: TODO: List authors
EOH
when "md","mkd","txt"
file.puts <<-EOH
-Description
-===========
+#{cookbook_name} Cookbook
+#{'='*"#{cookbook_name} Cookbook".length}
+TODO: Enter the cookbook description here.
+
+e.g.
+This cookbook makes your favorite breakfast sandwhich.
Requirements
-============
+------------
+TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+e.g.
+#### packages
+- `toaster` - #{cookbook_name} needs toaster to brown your bagel.
Attributes
-==========
+----------
+TODO: List you cookbook attributes here.
+
+e.g.
+#### #{cookbook_name}::default
+<table>
+ <tr>
+ <th>Key</th>
+ <th>Type</th>
+ <th>Description</th>
+ <th>Default</th>
+ </tr>
+ <tr>
+ <td><tt>['#{cookbook_name}']['bacon']</tt></td>
+ <td>Boolean</td>
+ <td>whether to include bacon</td>
+ <td><tt>true</tt></td>
+ </tr>
+</table>
Usage
-=====
-
+-----
+#### #{cookbook_name}::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `#{cookbook_name}` in your node's `run_list`:
+
+```json
+{
+ "name":"my_node",
+ "run_list": [
+ "recipe[#{cookbook_name}]"
+ ]
+}
+```
+
+Contributing
+------------
+TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+e.g.
+1. Fork the repository on Github
+2. Create a named feature branch (like `add_component_x`)
+3. Write you change
+4. Write tests for your change (if applicable)
+5. Run the tests, ensuring they all pass
+6. Submit a Pull Request using Github
+
+License and Authors
+-------------------
+Authors: TODO: List authors
EOH
else
file.puts <<-EOH
-Description
+#{cookbook_name} Cookbook
+#{'='*"#{cookbook_name} Cookbook".length}
+ TODO: Enter the cookbook description here.
+
+ e.g.
+ This cookbook makes your favorite breakfast sandwhich.
Requirements
+ TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+ e.g.
+ toaster #{cookbook_name} needs toaster to brown your bagel.
Attributes
+ TODO: List you cookbook attributes here.
-Usage
+ #{cookbook_name}
+ Key Type Description Default
+ ['#{cookbook_name}']['bacon'] Boolean whether to include bacon true
+Usage
+ #{cookbook_name}
+ TODO: Write usage instructions for each cookbook.
+
+ e.g.
+ Just include `#{cookbook_name}` in your node's `run_list`:
+
+ [code]
+ {
+ "name":"my_node",
+ "run_list": [
+ "recipe[#{cookbook_name}]"
+ ]
+ }
+ [/code]
+
+Contributing
+ TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+ e.g.
+ 1. Fork the repository on Github
+ 2. Create a named feature branch (like `add_component_x`)
+ 3. Write you change
+ 4. Write tests for your change (if applicable)
+ 5. Run the tests, ensuring they all pass
+ 6. Submit a Pull Request using Github
+
+License and Authors
+ Authors: TODO: List authors
EOH
end
end
end
end
- def create_metadata(dir, cookbook_name, copyright, email, license,readme_format)
+ def create_metadata(dir, cookbook_name, copyright, email, license, readme_format)
msg("** Creating metadata for cookbook: #{cookbook_name}")
license_name = case license
@@ -271,12 +420,13 @@ EOH
long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.#{readme_format}'))"
end
file.puts <<-EOH
-maintainer "#{copyright}"
-maintainer_email "#{email}"
-license "#{license_name}"
-description "Installs/Configures #{cookbook_name}"
+name '#{cookbook_name}'
+maintainer '#{copyright}'
+maintainer_email '#{email}'
+license '#{license_name}'
+description 'Installs/Configures #{cookbook_name}'
#{long_description}
-version "0.1.0"
+version '0.1.0'
EOH
end
end