Class: Afterlife::Deploy::KubernetesDeployment::AwsAuth
- Inherits:
-
Object
- Object
- Afterlife::Deploy::KubernetesDeployment::AwsAuth
- Defined in:
- lib/afterlife/deploy/kubernetes_deployment.rb
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #aws_ecr_token ⇒ Object
- #commands ⇒ Object
- #docker_login ⇒ Object
-
#initialize(registry) ⇒ AwsAuth
constructor
A new instance of AwsAuth.
- #region ⇒ Object
Constructor Details
#initialize(registry) ⇒ AwsAuth
Returns a new instance of AwsAuth.
131 132 133 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 131 def initialize(registry) @registry = registry end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
129 130 131 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 129 def registry @registry end |
Instance Method Details
#aws_ecr_token ⇒ Object
145 146 147 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 145 def aws_ecr_token @aws_ecr_token ||= Exec.result("aws ecr get-login-password --region #{region}") end |
#commands ⇒ Object
135 136 137 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 135 def commands [docker_login] end |
#docker_login ⇒ Object
139 140 141 142 143 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 139 def docker_login <<-BASH echo "#{aws_ecr_token}" | docker login --username AWS --password-stdin #{registry} BASH end |
#region ⇒ Object
149 150 151 |
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 149 def region @region ||= registry.gsub(/[^.]+\.dkr\.ecr\.([^.]+)\.amazonaws\.com/, '\1') end |