Class: Blubber::Flow
- Inherits:
-
Object
- Object
- Blubber::Flow
- Defined in:
- lib/blubber/flow.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(layer:) ⇒ Flow
constructor
A new instance of Flow.
- #run ⇒ Object
Constructor Details
#initialize(layer:) ⇒ Flow
Returns a new instance of Flow.
49 50 51 |
# File 'lib/blubber/flow.rb', line 49 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 27 28 |
# File 'lib/blubber/flow.rb', line 9 def self.build(layers = nil) layers ||= changed_layers puts "Building layers: #{layers.join(', ')}" 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 |
.changed_layers ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/blubber/flow.rb', line 30 def self.changed_layers @changed_layers ||= begin if ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] != '' && ENV['BUILD_ALL'] != 'true' commit = ENV['GIT_COMMIT'] || `git rev-parse HEAD`.strip changes = `git diff --name-only #{ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT']}..#{commit}`.split("\n") paths = [] changes.each do |path| dirs = File.dirname(path).split(File::SEPARATOR) dirs.map.with_index { |_, i| dirs[0..i].join(File::SEPARATOR) }.reverse.each do |dir| paths << dir if File.exist?(File.join(dir, 'Dockerfile')) end end paths else Dir['**/*/Dockerfile'].map { |d| File.dirname(d) }.sort end end end |
Instance Method Details
#run ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/blubber/flow.rb', line 53 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.) end |