diff options
author | Brett and Tristan <brett+brettchalupa+tristanoneil@gofullstack.com> | 2014-08-25 11:25:18 -0400 |
---|---|---|
committer | Brett Chalupa <brettchalupa@gmail.com> | 2014-08-25 11:25:18 -0400 |
commit | e15e376668cfa638da83d9a78edf3232cd07890f (patch) | |
tree | 54b61ec56d4dfaa2a5093d90bb6b30a323fb509c /lib/chef/cookbook/metadata.rb | |
parent | b49767dd1ed9c778f94bef597e52a61d48491b50 (diff) | |
download | chef-e15e376668cfa638da83d9a78edf3232cd07890f.tar.gz |
Add supermarket_attributes to Metadata
Allow the metadata.rb in a cookbook to specify arbitrary attributes for
use from Supermarket. The usecase for this right now would be setting the issues
and source URLs for that Cookbook instead of specifying them in the
Supermarket UI.
Diffstat (limited to 'lib/chef/cookbook/metadata.rb')
-rw-r--r-- | lib/chef/cookbook/metadata.rb | 88 |
1 files changed, 54 insertions, 34 deletions
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index 3964354d50..e176302b06 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -35,23 +35,24 @@ class Chef # about Chef Cookbooks. class Metadata - NAME = 'name'.freeze - DESCRIPTION = 'description'.freeze - LONG_DESCRIPTION = 'long_description'.freeze - MAINTAINER = 'maintainer'.freeze - MAINTAINER_EMAIL = 'maintainer_email'.freeze - LICENSE = 'license'.freeze - PLATFORMS = 'platforms'.freeze - DEPENDENCIES = 'dependencies'.freeze - RECOMMENDATIONS = 'recommendations'.freeze - SUGGESTIONS = 'suggestions'.freeze - CONFLICTING = 'conflicting'.freeze - PROVIDING = 'providing'.freeze - REPLACING = 'replacing'.freeze - ATTRIBUTES = 'attributes'.freeze - GROUPINGS = 'groupings'.freeze - RECIPES = 'recipes'.freeze - VERSION = 'version'.freeze + NAME = 'name'.freeze + DESCRIPTION = 'description'.freeze + LONG_DESCRIPTION = 'long_description'.freeze + MAINTAINER = 'maintainer'.freeze + MAINTAINER_EMAIL = 'maintainer_email'.freeze + LICENSE = 'license'.freeze + PLATFORMS = 'platforms'.freeze + DEPENDENCIES = 'dependencies'.freeze + RECOMMENDATIONS = 'recommendations'.freeze + SUGGESTIONS = 'suggestions'.freeze + CONFLICTING = 'conflicting'.freeze + PROVIDING = 'providing'.freeze + REPLACING = 'replacing'.freeze + ATTRIBUTES = 'attributes'.freeze + GROUPINGS = 'groupings'.freeze + RECIPES = 'recipes'.freeze + VERSION = 'version'.freeze + SUPERMARKET_ATTRIBUTES = 'supermarket_attributes'.freeze COMPARISON_FIELDS = [ :name, :description, :long_description, :maintainer, :maintainer_email, :license, :platforms, :dependencies, @@ -111,6 +112,7 @@ class Chef @groupings = Mash.new @recipes = Mash.new @version = Version.new("0.0.0") + @supermarket_attributes = Hash.new @errors = [] end @@ -469,23 +471,24 @@ class Chef def to_hash { - NAME => self.name, - DESCRIPTION => self.description, - LONG_DESCRIPTION => self.long_description, - MAINTAINER => self.maintainer, - MAINTAINER_EMAIL => self.maintainer_email, - LICENSE => self.license, - PLATFORMS => self.platforms, - DEPENDENCIES => self.dependencies, - RECOMMENDATIONS => self.recommendations, - SUGGESTIONS => self.suggestions, - CONFLICTING => self.conflicting, - PROVIDING => self.providing, - REPLACING => self.replacing, - ATTRIBUTES => self.attributes, - GROUPINGS => self.groupings, - RECIPES => self.recipes, - VERSION => self.version + NAME => self.name, + DESCRIPTION => self.description, + LONG_DESCRIPTION => self.long_description, + MAINTAINER => self.maintainer, + MAINTAINER_EMAIL => self.maintainer_email, + LICENSE => self.license, + PLATFORMS => self.platforms, + DEPENDENCIES => self.dependencies, + RECOMMENDATIONS => self.recommendations, + SUGGESTIONS => self.suggestions, + CONFLICTING => self.conflicting, + PROVIDING => self.providing, + REPLACING => self.replacing, + ATTRIBUTES => self.attributes, + GROUPINGS => self.groupings, + RECIPES => self.recipes, + VERSION => self.version, + SUPERMARKET_ATTRIBUTES => self.supermarket_attributes } end @@ -517,6 +520,7 @@ class Chef @groupings = o[GROUPINGS] if o.has_key?(GROUPINGS) @recipes = o[RECIPES] if o.has_key?(RECIPES) @version = o[VERSION] if o.has_key?(VERSION) + @supermarket_attributes = o[SUPERMARKET_ATTRIBUTES] if o.has_key?(SUPERMARKET_ATTRIBUTES) self end @@ -543,6 +547,22 @@ class Chef from_hash(o) end + # Sets the cookbooks supermarket_attributes, or returns it. + # + # === Parameters + # supermarket_attributes<Hash>:: Attributes specific to Supermarket + # + # === Returns + # supermarket_attributes<Hash>:: Returns the current Supermarket + # attributes + def supermarket_attributes(arg=nil) + set_or_return( + :supermarket_attributes, + arg, + :kind_of => [ Hash ] + ) + end + private def run_validation |