class Cumulus::Configuration
Public: Contains the configuration values set in the configuration.json file. Provides a Singleton that can be accessed throughout the application.
Attributes
Public Class Methods
Public: Initialize the Configuration
Singleton. Must be called before any access to `Configuration.instance` is used.
conf_dir - The String path to the directory the configuration can be found in profile - The String profile name that will be used to make AWS API calls assume_role - The ARN of the role to assume when making AWS API calls autoscaling_force_size
- Determines whether autoscaling should use configured values for min/max/desired group size
# File lib/conf/Configuration.rb, line 144 def init(conf_dir, profile, assume_role, autoscaling_force_size) @@instance = new(conf_dir, profile, assume_role, autoscaling_force_size) end
Public: The Singleton instance of Configuration
.
Returns the Configuration
instance.
# File lib/conf/Configuration.rb, line 166 def instance @@instance end
Private Class Methods
Private: Initialize the Configuration
Singleton. Must be called before any access to `Configuration.instance` is used. Used by the tests to pass in json rather than a file
json - the Hash containing the json configuration conf_dir - The String path to the directory the configuration can be found in profile - The String profile name that will be used to make AWS API calls assume_role - The ARN of the role to assume when making AWS API calls autoscaling_force_size
- Determines whether autoscaling should use configured values for min/max/desired group size
# File lib/conf/Configuration.rb, line 159 def init_from_hash(json, conf_dir, profile, assume_role, autoscaling_force_size) @@instance = new(conf_dir, profile, assume_role, autoscaling_force_size, json) end
Internal: Constructor. Sets up the `instance` variable, which is the access point for the Singleton.
json - a Hash containing the json configuration. If nil, this value will be read in from the default location conf_dir - The String path to the directory the configuration can be found in profile - The String profile name that will be used to make AWS API calls assume_role - The ARN of the role to assume when making AWS API calls autoscaling_force_size
- Determines whether autoscaling should use configured values for min/max/desired group size
# File lib/conf/Configuration.rb, line 101 def initialize(conf_dir, profile, assume_role, autoscaling_force_size, json = nil) Config.conf_dir = conf_dir Config.json = json.nil? ? JSON.parse(File.read(absolute_path("configuration.json"))) : json @colors_enabled = conf "colors-enabled" @iam = IamConfig.new @autoscaling = AutoScalingConfig.new(autoscaling_force_size) @route53 = Route53Config.new @security = SecurityConfig.new @cloudfront = CloudFrontConfig.new @s3 = S3Config.new @elb = ELBConfig.new @vpc = VpcConfig.new @kinesis = KinesisConfig.new @sqs = SQSConfig.new @ec2 = EC2Config.new region = conf "region" credentials = if assume_role Aws::AssumeRoleCredentials.new( client: Aws::STS::Client.new(profile: profile, region: region), role_arn: assume_role, role_session_name: "#{region}-#{@profile}" ) end @client = { :region => region, :profile => profile, :credentials => credentials, :stub_responses => conf("stub_aws_responses", true) }.reject { |_, v| v.nil? } end