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
53
54
55
56
57
# File 'lib/bellboy/installer.rb', line 26

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

  # Make sure no one (E.g. rspec) did anything silly
  abort if @bellboyfile.nil?

  local_sources = Bellboy.berks_sources(berksfile)

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

    if File.exists?(File.join(source.path, @bellboyfile))
      site = berksfile.databags_source

      if site.nil?
        # Try the first source
        site = berksfile.sources.first

        fail Berkshelf::InvalidChefAPILocation if site.nil?

        location = "#{site.uri}/databags"
      else
        location = site.uri
      end

      Bellboy.logger.debug "Using #{site} for databags API location"

      download_databags(source, location)
    end

  end
end