20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/chef-berksfile-env.rb', line 20
def load_berksfile(path=nil)
raise "You must define the environment name before doing load_berksfile" if path.nil? && name.empty?
berksfile_path = path.nil? ? "environments/#{name}/Berksfile" : path
Chef::Log.debug("Using Berksfile path [#{berksfile_path}]")
begin
berksfile = ::Berkshelf::Berksfile.new find_berksfile(berksfile_path)
berksfile.list.each do |dependency|
cookbook dependency.name, "= #{dependency.locked_version.to_s}"
end
rescue ::Berkshelf::LockfileNotFound => e
raise "Your Berkshelf file [#{path}] has not been locked. Run 'berks install' to lock it"
end
end
|