Sha256: 255a2bed665460136e60ec91ebf2fa2ee411025fe1299551e52eacc996881c5b
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require "json" module BBC module Cosmos module Config class Cosmos attr_reader :aws_config def initialize(aws_config) @aws_config = aws_config end def stack_name @aws_config.tags["aws:cloudformation:stack-name"] end def app_name @aws_config.tags["AppName"] end def component_name @aws_config.tags["BBCComponent"].downcase end def component_config load_config_from_s3? ? @aws_config.s3_config(config) : config[:configuration] end def config @config ||= ::JSON.parse(app_config_string, :symbolize_names => true) end def environment BBC::Cosmos.production? ? config[:environment] : ENV.fetch("APP_ENV", "development") end def version BBC::Cosmos.production? ? config[:release] : "#{environment}-version" end private def load_config_from_s3? config[:configuration].include?(:config_path) && \ BBC::Cosmos.production? end def app_config_string File.open(config_location).read end def config_location BBC::Cosmos.production? ? cosmos_config_location : ENV["DEV_APP_CONF"] end def cosmos_config_location "/etc/#{component_name}/component_configuration.json" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bbc-cosmos-config-0.3.6 | lib/bbc/cosmos/config/cosmos.rb |