Class: Chef::MinimalCookbookVersion
- Includes:
- Comparable
- Defined in:
- lib/chef/cookbook_version.rb
Overview
Chef::MinimalCookbookVersion
MinimalCookbookVersion is a duck type of CookbookVersion, used internally by Chef Server as an optimization when determining the optimal cookbook set for a chef-client.
MinimalCookbookVersion objects contain only enough information to solve the cookbook collection for a given run list. They *do not* contain enough information to generate the response.
See also: Chef::CookbookVersionSelector
Constant Summary collapse
- ID =
"id".freeze
- NAME =
'name'.freeze
- KEY =
'key'.freeze
- VERSION =
'version'.freeze
- VALUE =
'value'.freeze
- DEPS =
'deps'.freeze
- DEPENDENCIES =
'dependencies'.freeze
Instance Attribute Summary collapse
-
#couchdb_id ⇒ Object
readonly
Returns the value of attribute couchdb_id.
-
#deps ⇒ Object
readonly
Returns the value of attribute deps.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.load_all(couchdb) ⇒ Object
Loads the full list of cookbooks, using a couchdb view to fetch only the id, name, version, and dependency constraints.
-
.load_full_versions_of(minimal_cookbook_versions, couchdb) ⇒ Object
Loads the non-minimal CookbookVersion objects corresponding to
minimal_cookbook_versions
from couchdb using a bulk GET.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#initialize(params) ⇒ MinimalCookbookVersion
constructor
A new instance of MinimalCookbookVersion.
- #legit_version ⇒ Object
-
#metadata ⇒ Object
Returns the Cookbook::MinimalMetadata object for this cookbook version.
Constructor Details
Instance Attribute Details
#couchdb_id ⇒ Object (readonly)
Returns the value of attribute couchdb_id.
78 79 80 |
# File 'lib/chef/cookbook_version.rb', line 78 def couchdb_id @couchdb_id end |
#deps ⇒ Object (readonly)
Returns the value of attribute deps.
81 82 83 |
# File 'lib/chef/cookbook_version.rb', line 81 def deps @deps end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
79 80 81 |
# File 'lib/chef/cookbook_version.rb', line 79 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
80 81 82 |
# File 'lib/chef/cookbook_version.rb', line 80 def version @version end |
Class Method Details
.load_all(couchdb) ⇒ Object
Loads the full list of cookbooks, using a couchdb view to fetch only the id, name, version, and dependency constraints. This is enough information to solve for the cookbook collection for a given run list. After solving for the cookbook collection, you need to call load_full_versions_of
to convert MinimalCookbookVersion objects to their non-minimal counterparts
63 64 65 66 67 68 |
# File 'lib/chef/cookbook_version.rb', line 63 def self.load_all(couchdb) # Example: # {"id"=>"1a806f1c-b409-4d8e-abab-fa414ff5b96d", "key"=>"activemq", "value"=>{"version"=>"0.3.3", "deps"=>{"java"=>">= 0.0.0", "runit"=>">= 0.0.0"}}} couchdb ||= Chef::CouchDB.new couchdb.get_view("cookbooks", "all_with_version_and_deps")["rows"].map {|params| self.new(params) } end |
.load_full_versions_of(minimal_cookbook_versions, couchdb) ⇒ Object
Loads the non-minimal CookbookVersion objects corresponding to minimal_cookbook_versions
from couchdb using a bulk GET.
72 73 74 75 76 |
# File 'lib/chef/cookbook_version.rb', line 72 def self.load_full_versions_of(minimal_cookbook_versions, couchdb) database_ids = Array(minimal_cookbook_versions).map {|mcv| mcv.couchdb_id } couchdb ||= Chef::CouchDB.new couchdb.bulk_get(*database_ids) end |
Instance Method Details
#<=>(o) ⇒ Object
100 101 102 103 104 |
# File 'lib/chef/cookbook_version.rb', line 100 def <=>(o) raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != o.name raise "Unexpected comparison to #{o}" unless o.respond_to?(:legit_version) legit_version <=> o.legit_version end |
#legit_version ⇒ Object
96 97 98 |
# File 'lib/chef/cookbook_version.rb', line 96 def legit_version @legit_version ||= Chef::Version.new(@version) end |
#metadata ⇒ Object
Returns the Cookbook::MinimalMetadata object for this cookbook version.
92 93 94 |
# File 'lib/chef/cookbook_version.rb', line 92 def @metadata ||= Cookbook::MinimalMetadata.new(@name, DEPENDENCIES => @deps) end |