class BBC::Cosmos::Config::Cosmos

Attributes

aws_config[R]

Public Class Methods

new(aws_config) click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 9
def initialize(aws_config)
  @aws_config = aws_config
end

Public Instance Methods

app_name() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 17
def app_name
  @aws_config.tags["AppName"]
end
component_config() click to toggle source
# 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_name() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 21
def component_name
  @aws_config.tags["BBCComponent"].downcase
end
config() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 30
def config
  @config ||= ::JSON.parse(app_config_string, :symbolize_names => true)
end
environment() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 34
def environment
  BBC::Cosmos.production? ? config[:environment]
                          : ENV.fetch("APP_ENV", "development")
end
stack_name() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 13
def stack_name
  @aws_config.tags["aws:cloudformation:stack-name"]
end
version() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 39
def version
  BBC::Cosmos.production? ? config[:release] : "#{environment}-version"
end

Private Instance Methods

app_config_string() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 50
def app_config_string
  File.open(config_location).read
end
config_location() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 54
def config_location
  BBC::Cosmos.production? ? cosmos_config_location : ENV["DEV_APP_CONF"]
end
cosmos_config_location() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 58
def cosmos_config_location
  "/etc/#{component_name}/component_configuration.json"
end
load_config_from_s3?() click to toggle source
# File lib/bbc/cosmos/config/cosmos.rb, line 45
def load_config_from_s3?
  config[:configuration].include?(:config_path) && \
    BBC::Cosmos.production?
end