summaryrefslogtreecommitdiff
path: root/chef/lib
diff options
context:
space:
mode:
authortim@opscode.com <tim@opscode.com>2010-06-01 23:17:37 -0700
committerDaniel DeLeo <dan@opscode.com>2010-06-03 12:22:13 -0700
commit6dd706699003754602eb5d63f330ca6b2e7d3fef (patch)
tree4618077cfeb287b13205286110b7c0b3b288f243 /chef/lib
parentf024c2a05103fafdde63bd362bcecc356e34b79e (diff)
downloadchef-6dd706699003754602eb5d63f330ca6b2e7d3fef.tar.gz
Renamed Chef::Cookbook -> CookbookVersion; reorganized Cookbook features tests
Diffstat (limited to 'chef/lib')
-rw-r--r--chef/lib/chef/client.rb4
-rw-r--r--chef/lib/chef/cookbook/cookbook_collection.rb8
-rw-r--r--chef/lib/chef/cookbook/metadata/version.rb2
-rw-r--r--chef/lib/chef/cookbook_loader.rb4
-rw-r--r--chef/lib/chef/cookbook_version.rb (renamed from chef/lib/chef/cookbook.rb)44
-rw-r--r--chef/lib/chef/knife/cookbook_bulk_delete.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_delete.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_download.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_show.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_upload.rb2
10 files changed, 36 insertions, 36 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb
index fe7ca74ad6..1dc2004fd8 100644
--- a/chef/lib/chef/client.rb
+++ b/chef/lib/chef/client.rb
@@ -220,7 +220,7 @@ class Chef
filenames_seen = Hash.new
- Chef::Cookbook::COOKBOOK_SEGMENTS.each do |segment|
+ Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment|
cookbook.manifest[segment].each do |manifest_record|
# segment = cookbook segment
# remote_list = list of file hashes
@@ -233,7 +233,7 @@ class Chef
current_checksum = nil
if Chef::FileCache.has_key?(cache_filename)
- current_checksum = Chef::Cookbook.checksum_cookbook_file(Chef::FileCache.load(cache_filename, false))
+ current_checksum = Chef::CookbookVersion.checksum_cookbook_file(Chef::FileCache.load(cache_filename, false))
end
# If the checksums are different between on-disk (current) and on-server
diff --git a/chef/lib/chef/cookbook/cookbook_collection.rb b/chef/lib/chef/cookbook/cookbook_collection.rb
index 3839326dc2..3133b0cd14 100644
--- a/chef/lib/chef/cookbook/cookbook_collection.rb
+++ b/chef/lib/chef/cookbook/cookbook_collection.rb
@@ -30,13 +30,13 @@ require 'extlib'
class Chef
class CookbookCollection < Mash
- # The input is a mapping of cookbook name to Cookbook object. We simply
- # extract them
- def initialize(cookbooks={})
+ # The input is a mapping of cookbook name to CookbookVersion objects. We
+ # simply extract them
+ def initialize(cookbook_versions={})
super() do |hash, key|
raise Chef::Exceptions::CookbookNotFound, "Cookbook #{key} not found"
end
- cookbooks.each{ |cookbook_name, cookbook| self[cookbook_name] = cookbook }
+ cookbook_versions.each{ |cookbook_name, cookbook_version| self[cookbook_name] = cookbook_version }
end
end
diff --git a/chef/lib/chef/cookbook/metadata/version.rb b/chef/lib/chef/cookbook/metadata/version.rb
index 84611ba66b..beed34e173 100644
--- a/chef/lib/chef/cookbook/metadata/version.rb
+++ b/chef/lib/chef/cookbook/metadata/version.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'chef/cookbook'
+require 'chef/cookbook_version'
require 'chef/cookbook/metadata'
class Chef::Cookbook::Metadata
diff --git a/chef/lib/chef/cookbook_loader.rb b/chef/lib/chef/cookbook_loader.rb
index 59235fc4a3..f8f95a25ef 100644
--- a/chef/lib/chef/cookbook_loader.rb
+++ b/chef/lib/chef/cookbook_loader.rb
@@ -19,7 +19,7 @@
# limitations under the License.
require 'chef/config'
-require 'chef/cookbook'
+require 'chef/cookbook_version'
require 'chef/cookbook/metadata'
class Chef
@@ -109,7 +109,7 @@ class Chef
remove_ignored_files_from(cookbook_settings)
cookbook_settings.each_key do |cookbook|
- @cookbooks_by_name[cookbook] = Chef::Cookbook.new(cookbook)
+ @cookbooks_by_name[cookbook] = Chef::CookbookVersion.new(cookbook)
@cookbooks_by_name[cookbook].attribute_filenames = cookbook_settings[cookbook][:attribute_filenames].values
@cookbooks_by_name[cookbook].definition_filenames = cookbook_settings[cookbook][:definition_filenames].values
@cookbooks_by_name[cookbook].recipe_filenames = cookbook_settings[cookbook][:recipe_filenames].values
diff --git a/chef/lib/chef/cookbook.rb b/chef/lib/chef/cookbook_version.rb
index 89c46f4e0c..261bf8c3bb 100644
--- a/chef/lib/chef/cookbook.rb
+++ b/chef/lib/chef/cookbook_version.rb
@@ -27,7 +27,7 @@ require 'chef/cookbook/file_vendor'
# TODO: timh/cw: 5-24-2010: mutators for files (e.g., recipe_filenames=,
# recipe_filenames.insert) should dirty the manifest so it gets regenerated.
class Chef
- class Cookbook
+ class CookbookVersion
include Chef::IndexQueue::Indexable
attr_accessor :definition_filenames, :template_filenames, :file_filenames,
@@ -56,7 +56,7 @@ class Chef
"all" => {
"map" => <<-EOJS
function(doc) {
- if (doc.chef_type == "cookbook") {
+ if (doc.chef_type == "cookbook_version") {
emit(doc.name, doc);
}
}
@@ -65,7 +65,7 @@ class Chef
"all_id" => {
"map" => <<-EOJS
function(doc) {
- if (doc.chef_type == "cookbook") {
+ if (doc.chef_type == "cookbook_version") {
emit(doc.name, doc.name);
}
}
@@ -74,7 +74,7 @@ class Chef
"all_with_version" => {
"map" => <<-EOJS
function(doc) {
- if (doc.chef_type == "cookbook") {
+ if (doc.chef_type == "cookbook_version") {
emit(doc.cookbook_name, doc.version);
}
}
@@ -83,7 +83,7 @@ class Chef
"all_latest_version" => {
"map" => %q@
function(doc) {
- if (doc.chef_type == "cookbook") {
+ if (doc.chef_type == "cookbook_version") {
emit(doc.cookbook_name, doc.version);
}
}
@@ -135,10 +135,10 @@ class Chef
nil
end
- # Creates a new Chef::Cookbook object.
+ # Creates a new Chef::CookbookVersion object.
#
# === Returns
- # object<Chef::Cookbook>:: Duh. :)
+ # object<Chef::CookbookVersion>:: Duh. :)
def initialize(name, couchdb=nil)
@name = name
@attribute_filenames = Array.new
@@ -552,26 +552,26 @@ class Chef
def to_json(*a)
result = manifest.dup
result['json_class'] = self.class.name
- result['chef_type'] = 'cookbook'
+ result['chef_type'] = 'cookbook_version'
result["_rev"] = couchdb_rev if couchdb_rev
result.to_json(*a)
end
def self.json_create(o)
- cookbook = new(o["cookbook_name"])
+ cookbook_version = new(o["cookbook_name"])
if o.has_key?('_rev')
- cookbook.couchdb_rev = o["_rev"] if o.has_key?("_rev")
+ cookbook_version.couchdb_rev = o["_rev"] if o.has_key?("_rev")
o.delete("_rev")
end
if o.has_key?("_id")
- cookbook.couchdb_id = o["_id"] if o.has_key?("_id")
- cookbook.index_id = cookbook.couchdb_id
+ cookbook_version.couchdb_id = o["_id"] if o.has_key?("_id")
+ cookbook_version.index_id = cookbook_version.couchdb_id
o.delete("_id")
end
- cookbook.manifest = o
+ cookbook_version.manifest = o
# We want the Chef::Cookbook::Metadata object to always be inflated
- cookbook.metadata = Chef::Cookbook::Metadata.from_hash(o["metadata"])
- cookbook
+ cookbook_version.metadata = Chef::Cookbook::Metadata.from_hash(o["metadata"])
+ cookbook_version
end
def generate_manifest_with_urls(&url_generator)
@@ -614,9 +614,9 @@ class Chef
# Couchdb
##
- def self.cdb_by_name(cookbook_name=nil, couchdb=nil)
+ def self.cdb_by_name(cookbook_name, couchdb=nil)
cdb = couchdb || Chef::CouchDB.new
- options = cookbook_name ? { :startkey => cookbook_name, :endkey => cookbook_name } : {}
+ options = { :startkey => cookbook_name, :endkey => cookbook_name }
rs = cdb.get_view("cookbooks", "all_with_version", options)
rs["rows"].inject({}) { |memo, row| memo.has_key?(row["key"]) ? memo[row["key"]] << row["value"] : memo[row["key"]] = [ row["value"] ]; memo }
end
@@ -634,19 +634,19 @@ class Chef
def self.cdb_load(name, version='latest', couchdb=nil)
cdb = couchdb || Chef::CouchDB.new
if version == "latest" || version == "_latest"
- rs = cdb.get_view("cookbooks", "all_latest_version", :key => name, :descending => true, :group => true, :reduce => true)["rows"].first
- cdb.load("cookbook", "#{rs["key"]}-#{rs["value"]}")
+ rs = cdb.get_view("cookbook_versions", "all_latest_version", :key => name, :descending => true, :group => true, :reduce => true)["rows"].first
+ cdb.load("cookbook_version", "#{rs["key"]}-#{rs["value"]}")
else
- cdb.load("cookbook", "#{name}-#{version}")
+ cdb.load("cookbook_version", "#{name}-#{version}")
end
end
def cdb_destroy
- (couchdb || Chef::CouchDB.new).delete("cookbook", full_name, couchdb_rev)
+ (couchdb || Chef::CouchDB.new).delete("cookbook_version", full_name, couchdb_rev)
end
def cdb_save
- @couchdb_rev = couchdb.store("cookbook", full_name, self)["rev"]
+ @couchdb_rev = couchdb.store("cookbook_version", full_name, self)["rev"]
end
def couchdb_id=(value)
diff --git a/chef/lib/chef/knife/cookbook_bulk_delete.rb b/chef/lib/chef/knife/cookbook_bulk_delete.rb
index e87effe534..82547a447f 100644
--- a/chef/lib/chef/knife/cookbook_bulk_delete.rb
+++ b/chef/lib/chef/knife/cookbook_bulk_delete.rb
@@ -29,7 +29,7 @@ class Chef
Chef::Log.fatal("You must supply a regular expression to match the results against")
exit 42
else
- bulk_delete(Chef::Cookbook, "cookbook", "cookbook", rest.get_rest("cookbooks"), @name_args[0]) do |name, cookbook|
+ bulk_delete(Chef::CookbookVersion, "cookbook", "cookbook", rest.get_rest("cookbooks"), @name_args[0]) do |name, cookbook|
rest.delete_rest(cookbook)
end
end
diff --git a/chef/lib/chef/knife/cookbook_delete.rb b/chef/lib/chef/knife/cookbook_delete.rb
index 508eb7652f..e11a9347a4 100644
--- a/chef/lib/chef/knife/cookbook_delete.rb
+++ b/chef/lib/chef/knife/cookbook_delete.rb
@@ -25,7 +25,7 @@ class Chef
banner "Sub-Command: cookbook delete COOKBOOK VERSION (options)"
def run
- delete_object(Chef::Cookbook, "#{@name_args[0]} #{@name_args[1]}", "cookbook") do
+ delete_object(Chef::CookbookVersion, "#{@name_args[0]} #{@name_args[1]}", "cookbook") do
rest.delete_rest("cookbooks/#{@name_args[0]}/#{@name_args[1]}")
end
end
diff --git a/chef/lib/chef/knife/cookbook_download.rb b/chef/lib/chef/knife/cookbook_download.rb
index 06665dec1b..3ec6e24bde 100644
--- a/chef/lib/chef/knife/cookbook_download.rb
+++ b/chef/lib/chef/knife/cookbook_download.rb
@@ -68,7 +68,7 @@ class Chef
end
end
- Chef::Cookbook::COOKBOOK_SEGMENTS.each do |segment|
+ Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment|
next unless manifest.has_key?(segment)
Chef::Log.info("Downloading #{segment}")
manifest[segment].each do |segment_file|
diff --git a/chef/lib/chef/knife/cookbook_show.rb b/chef/lib/chef/knife/cookbook_show.rb
index ae7911826f..ec7969471a 100644
--- a/chef/lib/chef/knife/cookbook_show.rb
+++ b/chef/lib/chef/knife/cookbook_show.rb
@@ -58,7 +58,7 @@ class Chef
cookbook_name, cookbook_version, segment, filename = @name_args[0..3]
manifest = rest.get_rest("cookbooks/#{cookbook_name}/#{cookbook_version}")
- cookbook = Chef::Cookbook.new(cookbook_name)
+ cookbook = Chef::CookbookVersion.new(cookbook_name)
cookbook.manifest = manifest
manifest_entry = cookbook.preferred_manifest_record(node, segment, filename)
diff --git a/chef/lib/chef/knife/cookbook_upload.rb b/chef/lib/chef/knife/cookbook_upload.rb
index 348f8cbc2f..c595ba1e64 100644
--- a/chef/lib/chef/knife/cookbook_upload.rb
+++ b/chef/lib/chef/knife/cookbook_upload.rb
@@ -21,7 +21,7 @@ require 'chef/knife'
require 'chef/streaming_cookbook_uploader'
require 'chef/cache/checksum'
require 'chef/sandbox'
-require 'chef/cookbook'
+require 'chef/cookbook_version'
require 'chef/cookbook/file_system_file_vendor'
require 'opscode/rest'