Sha256: e3de80fb787ec438d399d78d03e5bb9375c5013d369f5d9c6e5e1a035f6b9cd8

Contents?: true

Size: 999 Bytes

Versions: 49

Compression:

Stored size: 999 Bytes

Contents

require 'aws-sdk-ecr'
require 'ostruct'

module RakeDocker
  module Authentication
    class ECR
      def initialize &block
        @config = OpenStruct.new(
            region: nil,
            registry_id: nil)
        block.call(@config)

        @ecr_client = Aws::ECR::Client.new(region: @config.region)
      end

      def arity
        0
      end

      def call
        registry_id = @config.registry_id.respond_to?(:call) ?
            @config.registry_id.call :
            @config.registry_id

        token_response = @ecr_client.get_authorization_token(
            registry_ids: [registry_id])
        token_data = token_response.authorization_data[0]
        proxy_endpoint = token_data.proxy_endpoint
        email = 'none'
        username, password =
            Base64.decode64(token_data.authorization_token).split(':')

        {
            username: username, password: password, email: email,
            serveraddress: proxy_endpoint
        }
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
rake_docker-2.4.0.pre.13 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.12 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.11 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.10 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.9 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.8 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.7 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.6 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.5 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.4 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.3 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.2 lib/rake_docker/authentication/ecr.rb
rake_docker-2.4.0.pre.1 lib/rake_docker/authentication/ecr.rb
rake_docker-2.3.0 lib/rake_docker/authentication/ecr.rb
rake_docker-2.2.0.pre.1 lib/rake_docker/authentication/ecr.rb
rake_docker-2.1.0 lib/rake_docker/authentication/ecr.rb
rake_docker-2.0.0.pre.2 lib/rake_docker/authentication/ecr.rb
rake_docker-1.4.0.pre.1 lib/rake_docker/authentication/ecr.rb
rake_docker-1.3.0 lib/rake_docker/authentication/ecr.rb
rake_docker-1.2.0.pre.1 lib/rake_docker/authentication/ecr.rb