Sha256: 079c93867eee33cf2fc7e2b7aaf666341e7dd8a209801a0d44374aa5afac2e2b

Contents?: true

Size: 889 Bytes

Versions: 11

Compression:

Stored size: 889 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: tag,
                    force: true)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake_docker-2.20.0.pre.7 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.6 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.5 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.4 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.3 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.2 lib/rake_docker/tasks/tag.rb
rake_docker-2.20.0.pre.1 lib/rake_docker/tasks/tag.rb
rake_docker-2.19.0 lib/rake_docker/tasks/tag.rb
rake_docker-2.18.0.pre.6 lib/rake_docker/tasks/tag.rb
rake_docker-2.18.0.pre.5 lib/rake_docker/tasks/tag.rb
rake_docker-2.18.0.pre.4 lib/rake_docker/tasks/tag.rb