Class: ECSHelper::CommonHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_helper/common_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#branchObject

Returns the value of attribute branch.



11
12
13
# File 'lib/ecs_helper/common_helper.rb', line 11

def branch
  @branch
end

#envObject

Returns the value of attribute env.



11
12
13
# File 'lib/ecs_helper/common_helper.rb', line 11

def env
  @env
end

#helperObject

Returns the value of attribute helper.



11
12
13
# File 'lib/ecs_helper/common_helper.rb', line 11

def helper
  @helper
end

#versionObject

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_idObject



48
49
50
# File 'lib/ecs_helper/common_helper.rb', line 48

def 
  @account_id ||= ENV['AWS_ACCOUNT_ID'] || `aws sts get-caller-identity --query "Account" --output text`.strip
end

#applicationObject



40
41
42
# File 'lib/ecs_helper/common_helper.rb', line 40

def application
  ENV['APPLICATION']
end

#auth_private_cmdObject



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}) #{}.dkr.ecr.#{region}.amazonaws.com")
end

#environmentObject



32
33
34
# File 'lib/ecs_helper/common_helper.rb', line 32

def environment
  @env ||= helper.options[:environment] || ENV['ENVIRONMENT'] || env_from_branch || raise(StandardError, 'Environment not detected')
end

#projectObject



36
37
38
# File 'lib/ecs_helper/common_helper.rb', line 36

def project
  ENV['PROJECT']
end

#regionObject



44
45
46
# File 'lib/ecs_helper/common_helper.rb', line 44

def region
  @region ||= ENV['AWS_REGION']
end