Method: Baha::Config#each_image

Defined in:
lib/baha/config.rb

#each_imageObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/baha/config.rb', line 75

def each_image
  return unless @config.has_key?('images')
  @config['images'].each do |image|
    if image.has_key?('include')
      path = Pathname.new(image['include'])
      file = resolve_file(path)
      if file
        yml = YAML.load_file(file)
        yield Baha::Image.new(self,yml)
      else
        LOG.error { "Unable to find image include: #{path}"}
        next
      end
    elsif image.has_key?('dockerfile')
      path = Pathname.new(image['dockerfile'])
      file = resolve_file(path)
      if file
        dockerfile = Baha::Dockerfile.parse(file)
        dockerfile['name'] = image['name']
        dockerfile['tag'] = image['tag']
        yield Baha::Image.new(self,dockerfile)
      else
        LOG.error { "Unable to find dockerfile: #{path}"}
        next
      end
    else
      yield Baha::Image.new(self,image)
    end
  end
end