Well heres what a patch looks like (minus the tests)
diff --git a/chef/lib/chef/knife/cookbook_upload.rb
b/chef/lib/chef/knife/cookbook_upload.rb
index 52162fa..4ccab2b 100644
--- a/chef/lib/chef/knife/cookbook_upload.rb
+++ b/chef/lib/chef/knife/cookbook_upload.rb
@@ -20,6 +20,7 @@
require 'chef/knife'
require 'chef/cookbook_loader'
require 'chef/cookbook_uploader'
+require 'chef/cookbook/metadata'
class Chef
class Knife
@@ -28,6 +29,12 @@ class Chef
banner "knife cookbook upload [COOKBOOKS...] (options)"
-
option :deps,
-
:short => "-d",
-
:long => "--dependencies",
-
:boolean => true,
-
:description => "Upload dependencies automatically"
-
option :cookbook_path,
:short => "-o PATH:PATH",
:long => "--cookbook-path PATH:PATH",
@@ -46,6 +53,15 @@ class Chef
config[:cookbook_path] = Chef::Config[:cookbook_path]
end
-
# Check to ensure we have a valid source of cookbooks before continuing
-
unless File.directory?(config[:cookbook_path].first)
-
Chef::Log.error( File.join(config[:cookbook_path].first, "
doesn't exist!. Make sure you have cookbook_path configured
correctly"))
-
exit 1
-
end
-
vendor_path = File.expand_path(File.join(config[:cookbook_path].first))
-
cookbook_path = File.join(vendor_path, name_args[0])
-
Chef::Cookbook::FileVendor.on_create { |manifest|
Chef::Cookbook::FileSystemFileVendor.new(manifest) }
cl = Chef::CookbookLoader.new
@@ -71,6 +87,18 @@ class Chef
end
end
end
+
-
if config[:deps]
-
md = Chef::Cookbook::Metadata.new
-
md.from_file(File.join(cookbook_path, "metadata.rb"))
-
md.dependencies.each do |cookbook, version_list|
-
# Doesn't do versions.. yet
-
nv = Chef::Knife::CookbookUpload.new
-
nv.config = config
-
nv.name_args = [ cookbook ]
-
nv.run
-
end
-
end
end
private
==============================================
On Sun, Nov 7, 2010 at 1:37 PM, Dreamcat4 dreamcat4@gmail.com wrote:
Hi,
I'm aware that many people just upload everything, all of their
cookbooks. However in my case theres simply far too many of them.
So...
Any reason we cant have a '-d' flag for uploading cookbooks?
It seems knife site vendor already knows how to iterate over the
cookbook dependencies. Im thinking perhaps that can be leveraged for
the cookbook uploading too.
For example
knife cookbook site vendor COOKBOOK -d
knife cookbook site vendor COOKBOOK --dependencies
Would become
knife cookbook upload vendor COOKBOOK -d
knife cookbook upload COOKBOOK --dependencies
I'd be happy to have a crack at it.
dreamcat4
dreamcat4@gmail.com