class Dpl::Providers::Ecr
Attributes
Public Instance Methods
Source
# File lib/dpl/providers/ecr.rb, line 50 def deploy info :deploy, regions: regions.join(', '), targets: targets.join(', ') regions.product(targets).each do |region, target| push(region, target) end end
Source
# File lib/dpl/providers/ecr.rb, line 46 def validate # TODO: validate the image exists locally end
Private Instance Methods
Source
# File lib/dpl/providers/ecr.rb, line 70 def auth_region(region) token = auth_token(region) user, pass = parse_auth(token.authorization_token) url = token.proxy_endpoint shell :login, user:, pass:, url:, echo: false, silent: true info(:auth_region, url:) strip_protocol(url) end
Source
# File lib/dpl/providers/ecr.rb, line 66 def auth_regions @endpoints = regions.map { |region| [region, auth_region(region)] }.to_h end
Source
# File lib/dpl/providers/ecr.rb, line 79 def auth_token(region) ecr(region).get_authorization_token(registry_ids).authorization_data[0] end
Source
# File lib/dpl/providers/ecr.rb, line 97 def creds @creds ||= only(opts, :access_key_id, :secret_access_key) end
Source
# File lib/dpl/providers/ecr.rb, line 101 def ecr(region) Aws::ECR::Client.new(region:, **creds) end
Source
# File lib/dpl/providers/ecr.rb, line 105 def parse_auth(str) user, pass = Base64.decode64(str).split(':') [user, pass.chomp] end
Source
# File lib/dpl/providers/ecr.rb, line 114 def progress(events) events.split("\r\n").each do |event| event = JSON.parse(event) if e = event['error'] error e elsif %w[Preparing Pushing].include?(event['status']) nil elsif event['id'] info "#{event['status']} [#{event['id']}]" elsif event['status'] info event['status'] end end end
Source
# File lib/dpl/providers/ecr.rb, line 59 def push(region, target) url, repo, tag = endpoints[region], *target.split(':') shell :tag, url:, repo:, tag: tag || 'latest' shell(:push, url:, repo:) info :image_pushed, region:, target: end
Source
# File lib/dpl/providers/ecr.rb, line 87 def regions # not sure how this was meant to be normalized when being a YAML list region.split(',') end
Source
# File lib/dpl/providers/ecr.rb, line 83 def registry_ids account_id? ? { registry_ids: [account_id] } : {} end
Source
# File lib/dpl/providers/ecr.rb, line 110 def strip_protocol(url) url.sub(%r{^https?://}, '') end
Source
# File lib/dpl/providers/ecr.rb, line 92 def targets # not sure how this was meant to be normalized when being a YAML list target.split(',') end