Class: Blubber::Tagger
- Inherits:
-
Object
- Object
- Blubber::Tagger
- Defined in:
- lib/blubber/tagger.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(layer:, image_id:, logger: nil) ⇒ Tagger
constructor
A new instance of Tagger.
- #project ⇒ Object
- #run ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(layer:, image_id:, logger: nil) ⇒ Tagger
Returns a new instance of Tagger.
13 14 15 16 17 |
# File 'lib/blubber/tagger.rb', line 13 def initialize(layer:, image_id:, logger: nil) @layer = layer @image_id = image_id @logger = logger end |
Class Method Details
.docker_registry ⇒ Object
9 10 11 |
# File 'lib/blubber/tagger.rb', line 9 def self.docker_registry ENV.fetch('DOCKER_REGISTRY') end |
Instance Method Details
#project ⇒ Object
25 26 27 28 29 30 |
# File 'lib/blubber/tagger.rb', line 25 def project [ Tagger.docker_registry, *layer.split('/').select { |p| p[/[a-z0-9]+/] } ].join('/') end |
#run ⇒ Object
19 20 21 22 23 |
# File 'lib/blubber/tagger.rb', line 19 def run logger.info ui.color("#{layer}: PUSHING", :yellow) push end |
#tags ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/blubber/tagger.rb', line 32 def ||= begin = [] << commit unless dirty? << branch_name.gsub(/[^\w.-]/, '_') unless branch_name.empty? << 'latest' if branch_name == 'master' end << File.read("#{layer}/Dockerfile").scan(/LABEL version=([\w][\w.-]*)/) .flatten.map { |t| "#{t}#{dirty? ? '-dirty' : ''}" } end end |