Class: Blubber::Flow

Inherits:
Object
  • Object
show all
Defined in:
lib/blubber/flow.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer:) ⇒ Flow

Returns a new instance of Flow.



28
29
30
# File 'lib/blubber/flow.rb', line 28

def initialize(layer:)
  @layer = layer
end

Class Method Details

.build(layers = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/blubber/flow.rb', line 9

def self.build(layers = nil)
  layers ||= Dir['**/*/Dockerfile'].map { |d| File.dirname(d) }

  images = layers.map { |layer| Flow.new(layer: layer).run }

  table = [HighLine.color('Layer', :bold), HighLine.color('Tag', :bold)]
  table += images.map do |image|
    if image[:success]
      image[:tags].map { |tag| [image[:project], tag] }
    else
      [image[:project], HighLine.color('FAILED', :red)]
    end
  end

  puts HighLine.new.list(table.flatten, :columns_across, 2)

  images.all? { |image| image[:success] }
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
# File 'lib/blubber/flow.rb', line 32

def run
  image = Builder.new(layer: layer, logger: logger).run

  tagger = Tagger.new(layer: layer, image_id: image[:id], logger: logger)
  tagger.run if image[:success]

  image.merge(project: tagger.project, tags: tagger.tags)
end