Class: Kitchen::Provisioner::Chef::Librarian

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/kitchen/provisioner/chef/librarian.rb

Overview

Chef cookbook resolver that uses Librarian-Chef and a Cheffile to calculate dependencies.

Author:

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(cheffile, path, logger = Kitchen.logger) ⇒ Librarian

Creates a new cookbook resolver.

Parameters:

  • cheffile (String)

    path to a Cheffile

  • path (String)

    path in which to vendor the resulting cookbooks

  • logger (Kitchen::Logger) (defaults to: Kitchen.logger)

    a logger to use for output, defaults to Kitchen.logger



43
44
45
46
47
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 43

def initialize(cheffile, path, logger = Kitchen.logger)
  @cheffile   = cheffile
  @path       = path
  @logger     = logger
end

Class Method Details

.load!(logger = Kitchen.logger) ⇒ Object

Loads the library code required to use the resolver.

Parameters:

  • logger (Kitchen::Logger) (defaults to: Kitchen.logger)

    a logger to use for output, defaults to Kitchen.logger



53
54
55
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 53

def self.load!(logger = Kitchen.logger)
  load_librarian!(logger)
end

Instance Method Details

#resolveObject

Performs the cookbook resolution and vendors the resulting cookbooks in the desired path.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 59

def resolve
  version = ::Librarian::Chef::VERSION
  info("Resolving cookbook dependencies with Librarian-Chef #{version}...")
  debug("Using Cheffile from #{cheffile}")

  env = ::Librarian::Chef::Environment.new(
    :project_path => File.dirname(cheffile))
  env.config_db.local["path"] = path
  ::Librarian::Action::Resolve.new(env).run
  ::Librarian::Action::Install.new(env).run
end