Class Chef::CookbookVersion
In: lib/chef/cookbook_version.rb
Parent: Object

Chef::CookbookVersion

CookbookVersion is a model object encapsulating the data about a Chef cookbook. Chef supports maintaining multiple versions of a cookbook on a single server; each version is represented by a distinct instance of this class.

Methods

Included Modules

Chef::IndexQueue::Indexable

Constants

COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ]
DESIGN_DOCUMENT = { "version" => 7, "language" => "javascript", "views" => { "all" => { "map" => <<-EOJS function(doc) { if (doc.chef_type == "cookbook_version") { emit(doc.name, doc); } } EOJS

External Aliases

attribute_filenames -> attribute_files
  BACKCOMPAT/DEPRECATED - Remove these and fix breakage before release [DAN - 5/20/2010]##
recipe_filenames -> recipe_files
  BACKCOMPAT/DEPRECATED - Remove these and fix breakage before release [DAN - 5/20/2010]##

Attributes

attribute_filenames  [R]  attribute_filenames also has a setter that has non-default functionality.
attribute_filenames_by_short_filename  [R] 
couchdb  [RW] 
couchdb_id  [R] 
couchdb_rev  [RW] 
definition_filenames  [RW] 
file_filenames  [RW] 
library_filenames  [RW] 
metadata  [RW] 
metadata_filenames  [RW] 
name  [RW] 
provider_filenames  [RW] 
recipe_filenames  [R]  recipe_filenames also has a setter that has non-default functionality.
recipe_filenames_by_name  [R] 
resource_filenames  [RW] 
root_dir  [RW] 
root_filenames  [RW] 
status  [RW] 
template_filenames  [RW] 

Public Class methods

Given a cookbook_name, get a list of all versions that exist on the server.

Returns

String]:
Array of cookbook versions, which are strings like ‘x.y.z‘
nil:if the cookbook doesn‘t exist. an error will also be logged.

This is the one and only method that knows how cookbook files’ checksums are generated.

Iterates over cached cookbooks’ files, removing files belonging to cookbooks that don‘t appear in cookbook_hash

Get the newest version of all cookbooks

Update the file caches for a given cache segment. Takes a segment name and a hash that matches one of the cookbooks/_attribute_files style remote file listings.

Parameters

cookbook<Chef::Cookbook>:The cookbook to update
valid_cache_entries<Hash>:Out-param; Added to this hash are the files that

were referred to by this cookbook

Synchronizes all the cookbooks from the chef-server.

Returns

true:Always returns true

Keep track of the filenames that we use in both eager cookbook downloading (during sync_cookbooks) and lazy (during the run itself, through FileVendor). After the run is over, clean up the cache.

Public Instance methods

attribute_files=(*filenames)

Alias for attribute_filenames=

Returns a hash of checksums to either nil or the on disk path (which is done by generate_manifest).

create()

Alias for save

Return recipe names in the form of cookbook_name::recipe_name

A manifest is a Mash that maps segment names to arrays of manifest records (see preferred_manifest_record for format of manifest records), as well as describing cookbook metadata. The manifest follows a form like the following:

  {
    :cookbook_name = "apache2",
    :version = "1.0",
    :name = "Apache 2"
    :metadata = ???TODO: timh/cw: 5-24-2010: describe this format,

    :files => [
      {
        :name => "afile.rb",
        :path => "files/ubuntu-9.10/afile.rb",
        :checksum => "2222",
        :specificity => "ubuntu-9.10"
      },
    ],
    :templates => [ manifest_record1, ... ],
    ...
  }

Determine the most specific manifest record for the given segment/filename, given information in the node. Throws FileNotFound if there is no such segment and filename in the manifest.

A manifest record is a Mash that follows the following form: {

  :name => "example.rb",
  :path => "files/default/example.rb",
  :specificity => "default",
  :checksum => "1234"

}

Determine the manifest records from the most specific directory for the given node. See preferred_manifest_record for a description of entries of the returned Array.

Runs on Chef Server (API); deletes the cookbook from couchdb and also destroys associated checksum documents

recipe_files=(*filenames)

Alias for recipe_filenames=

[Validate]