Class: Bellboy::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/bellboy/installer.rb

Overview

Downloads data bags from the remote API for any Cookbook that contains a Bellboy manifest.

Class Method Summary collapse

Class Method Details

.install(berksfile, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bellboy/installer.rb', line 26

def install(berksfile, options = {})
  @bellboyfile = options[:bellboyfile]

  local_sources = Bellboy.berks_sources(berksfile)

  local_sources.each do |source|
    Bellboy.logger.debug "Source: #{source.cached_cookbook.path}"

    if File.exists?(File.join(source.cached_cookbook.path, @bellboyfile))
      site = berksfile.locations.select { |loc| loc[:type] == :databags }.first

      if site.nil?
        # Try the 'site' location
        site = berksfile.locations.select { |loc| loc[:type] == :site }.first

        fail Berkshelf::InvalidChefAPILocation if site.nil?

        location = "#{site[:value]}/databags"
      else
        location = site[:value]
      end

      download_databags(source, location)
    end

  end
end