summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_version.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-15 15:05:59 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-02-11 19:12:06 -0800
commit728717d1b5e489f82526b8390ab42846939392ee (patch)
tree770ffa29ce7464791352e2fd5864083b686f1226 /lib/chef/cookbook_version.rb
parent3743da85e48f2fc57e48ed62c014c1070bb69f38 (diff)
downloadchef-728717d1b5e489f82526b8390ab42846939392ee.tar.gz
allow dep injecting chef_server_rest into objects
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r--lib/chef/cookbook_version.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index c51d5798c5..b8f32a61bb 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -76,6 +76,8 @@ class Chef
attr_reader :recipe_filenames_by_name
attr_reader :attribute_filenames_by_short_filename
+ attr_accessor :chef_server_rest
+
# The first root path is the primary cookbook dir, from which metadata is loaded
def root_dir
root_paths[0]
@@ -98,7 +100,7 @@ class Chef
#
# === Returns
# object<Chef::CookbookVersion>:: Duh. :)
- def initialize(name, *root_paths)
+ def initialize(name, *root_paths, chef_server_rest: nil)
@name = name
@root_paths = root_paths
@frozen = false
@@ -119,6 +121,7 @@ class Chef
@status = :ready
@file_vendor = nil
@metadata = Chef::Cookbook::Metadata.new
+ @chef_server_rest = chef_server_rest
end
def version
@@ -512,12 +515,12 @@ class Chef
cookbook_manifest.force_save_url
end
- def self.chef_server_rest
- Chef::REST.new(Chef::Config[:chef_server_url])
+ def chef_server_rest
+ @chef_server_rest ||= self.chef_server_rest
end
- def chef_server_rest
- self.class.chef_server_rest
+ def self.chef_server_rest
+ Chef::REST.new(Chef::Config[:chef_server_url])
end
def destroy