Class: Afterlife::Deploy::DockerDeployment::AwsAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/afterlife/deploy/docker_deployment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry) ⇒ AwsAuth

Returns a new instance of AwsAuth.



79
80
81
# File 'lib/afterlife/deploy/docker_deployment.rb', line 79

def initialize(registry)
  @registry = registry
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



77
78
79
# File 'lib/afterlife/deploy/docker_deployment.rb', line 77

def registry
  @registry
end

Instance Method Details

#aws_ecr_tokenObject



93
94
95
# File 'lib/afterlife/deploy/docker_deployment.rb', line 93

def aws_ecr_token
  @aws_ecr_token ||= Exec.result("aws ecr get-login-password --region #{region}")
end

#commandsObject



83
84
85
# File 'lib/afterlife/deploy/docker_deployment.rb', line 83

def commands
  []
end

#docker_loginObject



87
88
89
90
91
# File 'lib/afterlife/deploy/docker_deployment.rb', line 87

def 
  <<-BASH
    echo "#{aws_ecr_token}" | docker login --username AWS --password-stdin #{registry}
  BASH
end

#regionObject



97
98
99
# File 'lib/afterlife/deploy/docker_deployment.rb', line 97

def region
  @region ||= registry.gsub(/[^.]+\.dkr\.ecr\.([^.]+)\.amazonaws\.com/, '\1')
end