Sha256: bf5fd0cbcd63575efe4958ddf95c503c856c3bc80b95f5d708c3756fbc1e96c1

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

require 'rake_factory'
require 'docker'

module RakeDocker
  module Tasks
    class Tag < RakeFactory::Task
      default_name :tag
      default_description(RakeFactory::DynamicValue.new do |t|
        "Tag #{t.image_name} image for repository"
      end)

      parameter :image_name, required: true
      parameter :repository_name, required: true
      parameter :repository_url, required: true

      parameter :tags, required: true

      action do |t|
        images = Docker::Image.all(filter: t.repository_name)
        if images.empty?
          raise ImageNotFound,
                "No image found with name: '#{t.image_name}'"
        end

        image = images.first

        t.tags.each do |tag|
          image.tag(repo: t.repository_url,
                    tag:,
                    force: true)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rake_docker-2.22.0.pre.3 lib/rake_docker/tasks/tag.rb
rake_docker-2.22.0.pre.2 lib/rake_docker/tasks/tag.rb
rake_docker-2.22.0.pre.1 lib/rake_docker/tasks/tag.rb
rake_docker-2.21.0 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.8 lib/rake_docker/tasks/tag.rb