- From: Dreamcat4 <
>
- To:
- Subject: [chef] Re: knife upload cookbook dependencies?
- Date: Sun, 7 Nov 2010 20:02:49 +0000
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=Vj4I5/UibOpWAwOLf5CEuXLl3ZXLEIA3si9cdrMJqkioRcwYI+64WD+PS8C9o9y1It ZwEKsCy/C32CUED325pN1q0gtqmpnKAHiAUgVUFCEn3n7Wck5JjvTOdJtXrc7MY/W/28 gSLoQxo+GgMVmJnHsYhp1KGUQrTkZBVft1zSk=
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
<
>
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
>
>
Archive powered by MHonArc 2.6.16.