Class: Dockly::Docker::ECR

Inherits:
Object
  • Object
show all
Includes:
Util::DSL, Util::Logger::Mixin
Defined in:
lib/dockly/docker/ecr.rb

Instance Method Summary collapse

Instance Method Details

#auth_dataObject



39
40
41
42
43
44
45
# File 'lib/dockly/docker/ecr.rb', line 39

def auth_data
  @auth_data ||=
    client
      .get_authorization_token
      .authorization_data
      .first
end

#authenticate!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dockly/docker/ecr.rb', line 9

def authenticate!
  @username ||= [0]
  @password ||= [1]

  ensure_present! :password, :server_address, :username

  debug "Attempting to authenticate at #{server_address}"

  ::Docker.authenticate!(self.to_h)

  info "Successfully authenticated at #{server_address}"
rescue ::Docker::Error::AuthenticationError
  raise "Could not authenticate at #{server_address}"
end

#authentication_required?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dockly/docker/ecr.rb', line 24

def authentication_required?
  true
end

#clientObject



47
48
49
# File 'lib/dockly/docker/ecr.rb', line 47

def client
  @client ||= Aws::ECR::Client.new(region: 'us-east-1')
end

#default_server_address?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/dockly/docker/ecr.rb', line 28

def default_server_address?
  false
end

#login_from_awsObject



32
33
34
35
36
37
# File 'lib/dockly/docker/ecr.rb', line 32

def 
  @login_from_aws ||=
    Base64
      .decode64(auth_data.authorization_token)
      .split(':')
end

#to_hObject



51
52
53
54
55
56
57
58
59
# File 'lib/dockly/docker/ecr.rb', line 51

def to_h
  ensure_present! :username, :password, :server_address

  {
    'serveraddress' => "https://#{server_address}",
    'username' => username,
    'password' => password
  }
end