Class: Afterlife::Deploy::KubernetesDeployment::AwsAuth

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#registryObject (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_tokenObject



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

#commandsObject



135
136
137
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 135

def commands
  []
end

#docker_loginObject



139
140
141
142
143
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 139

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

#regionObject



149
150
151
# File 'lib/afterlife/deploy/kubernetes_deployment.rb', line 149

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