Class: BBC::Cosmos::Config::Cosmos

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/cosmos/config/cosmos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_config) ⇒ Cosmos

Returns a new instance of Cosmos.



9
10
11
# File 'lib/bbc/cosmos/config/cosmos.rb', line 9

def initialize(aws_config)
  @aws_config = aws_config
end

Instance Attribute Details

#aws_configObject (readonly)

Returns the value of attribute aws_config.



7
8
9
# File 'lib/bbc/cosmos/config/cosmos.rb', line 7

def aws_config
  @aws_config
end

Instance Method Details

#app_nameObject



17
18
19
# File 'lib/bbc/cosmos/config/cosmos.rb', line 17

def app_name
  @aws_config.tags["AppName"]
end

#component_configObject



25
26
27
# File 'lib/bbc/cosmos/config/cosmos.rb', line 25

def component_config
  load_config_from_s3? ? @aws_config.s3_config(config) : config[:configuration]
end

#component_nameObject



21
22
23
# File 'lib/bbc/cosmos/config/cosmos.rb', line 21

def component_name
  @aws_config.tags["BBCComponent"].downcase
end

#configObject



29
30
31
# File 'lib/bbc/cosmos/config/cosmos.rb', line 29

def config
  @config ||= JSON.parse(app_config_string, :symbolize_names => true)
end

#environmentObject



33
34
35
# File 'lib/bbc/cosmos/config/cosmos.rb', line 33

def environment
  BBC::Cosmos.production? ? config[:environment] : ENV.fetch('APP_ENV', 'development')
end

#stack_nameObject



13
14
15
# File 'lib/bbc/cosmos/config/cosmos.rb', line 13

def stack_name
  @aws_config.tags["aws:cloudformation:stack-name"]
end

#versionObject



37
38
39
# File 'lib/bbc/cosmos/config/cosmos.rb', line 37

def version
  BBC::Cosmos.production? ? config[:release] : "#{environment}-version"
end