Class: Dockly::Docker::ECR
- Inherits:
-
Object
- Object
- Dockly::Docker::ECR
- Includes:
- Util::DSL, Util::Logger::Mixin
- Defined in:
- lib/dockly/docker/ecr.rb
Instance Method Summary collapse
- #auth_data ⇒ Object
- #authenticate! ⇒ Object
- #authentication_required? ⇒ Boolean
- #client ⇒ Object
- #default_server_address? ⇒ Boolean
- #login_from_aws ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#auth_data ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/dockly/docker/ecr.rb', line 39 def auth_data @auth_data ||= client . . .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 ||= login_from_aws[0] @password ||= login_from_aws[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
24 25 26 |
# File 'lib/dockly/docker/ecr.rb', line 24 def authentication_required? true end |
#client ⇒ Object
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
28 29 30 |
# File 'lib/dockly/docker/ecr.rb', line 28 def default_server_address? false end |
#login_from_aws ⇒ Object
32 33 34 35 36 37 |
# File 'lib/dockly/docker/ecr.rb', line 32 def login_from_aws @login_from_aws ||= Base64 .decode64(auth_data.) .split(':') end |
#to_h ⇒ Object
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 |