summaryrefslogtreecommitdiff
path: root/lib/chef/shell
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-07-29 17:14:24 -0700
committerdanielsdeleo <dan@getchef.com>2014-07-30 14:07:07 -0700
commit263f62774641bf32be6fd79d1d69022531fb3285 (patch)
tree4e7a541754dd2e81e64c8ca28f77360368062188 /lib/chef/shell
parentfc3b0eed9b8b33bcb51121deee09314f9eb86622 (diff)
downloadchef-263f62774641bf32be6fd79d1d69022531fb3285.tar.gz
Make FileVendor configuration specific to the two implementations
FileVendor previously was configured by storing a closure/anonymous function as a class instance variable. This had the following downsides: * The API was too general, which caused a lot of code repetition * The block was lazily evaluated, which hid errors and made testing more difficult * The closures captured references to classes with references to large data structures, which complicates GC. Since we've only ever had the same two implementations of FileVendor, we can encapsulate configuration of the FileVendor factory by wrapping each configuration option in a method. As a side benefit, arguments to these methods will be eagerly evaluated, which makes it easier to detect errors.
Diffstat (limited to 'lib/chef/shell')
-rw-r--r--lib/chef/shell/shell_session.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index a158020116..73e6c34ebb 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -169,7 +169,7 @@ module Shell
def rebuild_context
@run_status = Chef::RunStatus.new(@node, @events)
- Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, Chef::Config[:cookbook_path]) }
+ Chef::Cookbook::FileVendor.fetch_from_disk(Chef::Config[:cookbook_path])
cl = Chef::CookbookLoader.new(Chef::Config[:cookbook_path])
cl.load_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cl)
@@ -201,7 +201,7 @@ module Shell
def rebuild_context
@run_status = Chef::RunStatus.new(@node, @events)
- Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::RemoteFileVendor.new(manifest, Chef::REST.new(Chef::Config[:server_url])) }
+ Chef::Cookbook::FileVendor.fetch_from_remote(Chef::REST.new(Chef::Config[:chef_server_url]))
cookbook_hash = @client.sync_cookbooks
cookbook_collection = Chef::CookbookCollection.new(cookbook_hash)
@run_context = Chef::RunContext.new(node, cookbook_collection, @events)