Class: ECSHelper::CommonHelper
- Inherits:
-
Object
- Object
- ECSHelper::CommonHelper
- Defined in:
- lib/ecs_helper/common_helper.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#env ⇒ Object
Returns the value of attribute env.
-
#helper ⇒ Object
Returns the value of attribute helper.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #account_id ⇒ Object
- #application ⇒ Object
- #auth_private_cmd ⇒ Object
- #environment ⇒ Object
-
#initialize(helper) ⇒ CommonHelper
constructor
A new instance of CommonHelper.
- #project ⇒ Object
- #region ⇒ Object
Constructor Details
#initialize(helper) ⇒ CommonHelper
Returns a new instance of CommonHelper.
13 14 15 |
# File 'lib/ecs_helper/common_helper.rb', line 13 def initialize(helper) @helper = helper end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
11 12 13 |
# File 'lib/ecs_helper/common_helper.rb', line 11 def branch @branch end |
#env ⇒ Object
Returns the value of attribute env.
11 12 13 |
# File 'lib/ecs_helper/common_helper.rb', line 11 def env @env end |
#helper ⇒ Object
Returns the value of attribute helper.
11 12 13 |
# File 'lib/ecs_helper/common_helper.rb', line 11 def helper @helper end |
#version ⇒ Object
Returns the value of attribute version.
11 12 13 |
# File 'lib/ecs_helper/common_helper.rb', line 11 def version @version end |
Instance Method Details
#account_id ⇒ Object
48 49 50 |
# File 'lib/ecs_helper/common_helper.rb', line 48 def account_id @account_id ||= ENV['AWS_ACCOUNT_ID'] || `aws sts get-caller-identity --query "Account" --output text`.strip end |
#application ⇒ Object
40 41 42 |
# File 'lib/ecs_helper/common_helper.rb', line 40 def application ENV['APPLICATION'] end |
#auth_private_cmd ⇒ Object
52 53 54 |
# File 'lib/ecs_helper/common_helper.rb', line 52 def auth_private_cmd @auth_private_cmd ||= Terrapin::CommandLine.new("docker login -u AWS -p $(aws ecr get-login-password --region=#{region}) #{account_id}.dkr.ecr.#{region}.amazonaws.com") end |
#environment ⇒ Object
32 33 34 |
# File 'lib/ecs_helper/common_helper.rb', line 32 def environment @env ||= helper.[:environment] || ENV['ENVIRONMENT'] || env_from_branch || raise(StandardError, 'Environment not detected') end |
#project ⇒ Object
36 37 38 |
# File 'lib/ecs_helper/common_helper.rb', line 36 def project ENV['PROJECT'] end |
#region ⇒ Object
44 45 46 |
# File 'lib/ecs_helper/common_helper.rb', line 44 def region @region ||= ENV['AWS_REGION'] end |