Class: Kitchen::Provisioner::Chef::Berkshelf
- Inherits:
-
Object
- Object
- Kitchen::Provisioner::Chef::Berkshelf
- Includes:
- Logging
- Defined in:
- lib/kitchen/provisioner/chef/berkshelf.rb
Overview
Chef cookbook resolver that uses Berkshelf and a Berksfile to calculate dependencies.
Class Method Summary collapse
-
.load!(logger: Kitchen.logger) ⇒ Object
Loads the library code required to use the resolver.
Instance Method Summary collapse
-
#initialize(berksfile, path, logger: Kitchen.logger, always_update: false) ⇒ Berkshelf
constructor
Creates a new cookbook resolver.
-
#resolve ⇒ Object
Performs the cookbook resolution and vendors the resulting cookbooks in the desired path.
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(berksfile, path, logger: Kitchen.logger, always_update: false) ⇒ Berkshelf
Creates a new cookbook resolver.
38 39 40 41 42 43 |
# File 'lib/kitchen/provisioner/chef/berkshelf.rb', line 38 def initialize(berksfile, path, logger: Kitchen.logger, always_update: false) @berksfile = berksfile @path = path @logger = logger @always_update = always_update end |
Class Method Details
Instance Method Details
#resolve ⇒ Object
Performs the cookbook resolution and vendors the resulting cookbooks in the desired path.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kitchen/provisioner/chef/berkshelf.rb', line 55 def resolve version = ::Berkshelf::VERSION info("Resolving cookbook dependencies with Berkshelf #{version}...") debug("Using Berksfile from #{berksfile}") ::Berkshelf.ui.mute do berksfile_obj = ::Berkshelf::Berksfile.from_file(berksfile) berksfile_obj.update if always_update && berksfile_obj.lockfile.present? # Berkshelf requires the directory to not exist FileUtils.rm_rf(path) berksfile_obj.vendor(path) end end |