Class: Rebi::ConfigEnvironment
- Inherits:
-
Object
- Object
- Rebi::ConfigEnvironment
- Defined in:
- lib/rebi/config_environment.rb
Constant Summary collapse
- NAMESPACE =
{ app_env: "aws:elasticbeanstalk:application:environment", eb_env: "aws:elasticbeanstalk:environment", autoscaling_launch: "aws:autoscaling:launchconfiguration", autoscaling_asg: "aws:autoscaling:asg", elb_policies: "aws:elb:policies", elb_health: "aws:elb:healthcheck", elb_loadbalancer: "aws:elb:loadbalancer", healthreporting: "aws:elasticbeanstalk:healthreporting:system", eb_command: "aws:elasticbeanstalk:command", }
- UPDATEABLE_NS =
{ autoscaling_asg: [:MaxSize, :MinSize], autoscaling_launch: [:InstanceType, :EC2KeyName], eb_env: [:ServiceRole], }
- DEFAULT_IAM_INSTANCE_PROFILE =
"aws-elasticbeanstalk-ec2-role"
Instance Attribute Summary collapse
-
#cfg_file ⇒ Object
readonly
Returns the value of attribute cfg_file.
-
#cname_prefix ⇒ Object
readonly
Returns the value of attribute cname_prefix.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#ebextensions ⇒ Object
readonly
Returns the value of attribute ebextensions.
-
#env_file ⇒ Object
readonly
Returns the value of attribute env_file.
-
#env_name ⇒ Object
readonly
Returns the value of attribute env_name.
-
#environment_variables ⇒ Object
readonly
Returns the value of attribute environment_variables.
-
#instance_num ⇒ Object
readonly
Returns the value of attribute instance_num.
-
#instance_profile ⇒ Object
readonly
Returns the value of attribute instance_profile.
-
#instance_type ⇒ Object
readonly
Returns the value of attribute instance_type.
-
#key_name ⇒ Object
readonly
Returns the value of attribute key_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#option_settings ⇒ Object
readonly
Returns the value of attribute option_settings.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#raw_conf ⇒ Object
readonly
Returns the value of attribute raw_conf.
-
#solution_stack_name ⇒ Object
readonly
Returns the value of attribute solution_stack_name.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
Instance Method Summary collapse
- #app_name ⇒ Object
- #cfg ⇒ Object
- #default_instance_profile? ⇒ Boolean
- #dotenv ⇒ Object
- #get_opt(namespace, opt_name = nil) ⇒ Object
- #get_raw_opt(namespace, opt_name = nil) ⇒ Object
-
#initialize(stage, env_name, env_conf = {}) ⇒ ConfigEnvironment
constructor
A new instance of ConfigEnvironment.
- #ns(key = nil) ⇒ Object
- #opts_array(opts = option_settings) ⇒ Object
- #platform_arn ⇒ Object
- #raw_environment_variables ⇒ Object
- #worker? ⇒ Boolean
Constructor Details
#initialize(stage, env_name, env_conf = {}) ⇒ ConfigEnvironment
Returns a new instance of ConfigEnvironment.
45 46 47 48 49 |
# File 'lib/rebi/config_environment.rb', line 45 def initialize stage, env_name, env_conf={} @raw_conf = env_conf.with_indifferent_access @stage = stage.to_sym @env_name = env_name.to_sym end |
Instance Attribute Details
#cfg_file ⇒ Object (readonly)
Returns the value of attribute cfg_file.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def cfg_file @cfg_file end |
#cname_prefix ⇒ Object (readonly)
Returns the value of attribute cname_prefix.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def cname_prefix @cname_prefix end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def description @description end |
#ebextensions ⇒ Object (readonly)
Returns the value of attribute ebextensions.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def ebextensions @ebextensions end |
#env_file ⇒ Object (readonly)
Returns the value of attribute env_file.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def env_file @env_file end |
#env_name ⇒ Object (readonly)
Returns the value of attribute env_name.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def env_name @env_name end |
#environment_variables ⇒ Object (readonly)
Returns the value of attribute environment_variables.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def environment_variables @environment_variables end |
#instance_num ⇒ Object (readonly)
Returns the value of attribute instance_num.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def instance_num @instance_num end |
#instance_profile ⇒ Object (readonly)
Returns the value of attribute instance_profile.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def instance_profile @instance_profile end |
#instance_type ⇒ Object (readonly)
Returns the value of attribute instance_type.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def instance_type @instance_type end |
#key_name ⇒ Object (readonly)
Returns the value of attribute key_name.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def key_name @key_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def name @name end |
#option_settings ⇒ Object (readonly)
Returns the value of attribute option_settings.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def option_settings @option_settings end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def @options end |
#raw_conf ⇒ Object (readonly)
Returns the value of attribute raw_conf.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def raw_conf @raw_conf end |
#solution_stack_name ⇒ Object (readonly)
Returns the value of attribute solution_stack_name.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def solution_stack_name @solution_stack_name end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def stage @stage end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier.
6 7 8 |
# File 'lib/rebi/config_environment.rb', line 6 def tier @tier end |
Instance Method Details
#app_name ⇒ Object
55 56 57 |
# File 'lib/rebi/config_environment.rb', line 55 def app_name Rebi.config.app_name end |
#cfg ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/rebi/config_environment.rb', line 138 def cfg begin return nil if cfg_file.blank? return (@cfg ||= YAML.load(ERB.new(IO.read(cfg_file)).result).with_indifferent_access) rescue Errno::ENOENT raise Rebi::Error::ConfigInvalid.new("cfg_file: #{cfg_file}") end end |
#default_instance_profile? ⇒ Boolean
117 118 119 |
# File 'lib/rebi/config_environment.rb', line 117 def default_instance_profile? self.instance_profile == DEFAULT_IAM_INSTANCE_PROFILE end |
#dotenv ⇒ Object
169 170 171 |
# File 'lib/rebi/config_environment.rb', line 169 def dotenv env_file.present? ? Dotenv.load(env_file).with_indifferent_access : {} end |
#get_opt(namespace, opt_name = nil) ⇒ Object
177 178 179 |
# File 'lib/rebi/config_environment.rb', line 177 def get_opt namespace, opt_name=nil has_value_by_keys(option_settings, namespace, opt_name) end |
#get_raw_opt(namespace, opt_name = nil) ⇒ Object
181 182 183 |
# File 'lib/rebi/config_environment.rb', line 181 def get_raw_opt namespace, opt_name=nil has_value_by_keys(raw_conf[:option_settings], namespace, opt_name) end |
#ns(key = nil) ⇒ Object
221 222 223 |
# File 'lib/rebi/config_environment.rb', line 221 def ns key=nil key.present? ? NAMESPACE[key.to_sym] : NAMESPACE end |
#opts_array(opts = option_settings) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/rebi/config_environment.rb', line 185 def opts_array opts=option_settings res = [] opts.each do |namespace, v| namespace, resource_name = namespace.split(".").reverse v.each do |option_name, value| res << { resource_name: resource_name, namespace: namespace, option_name: option_name, value: value.to_s, }.with_indifferent_access end end return res end |
#platform_arn ⇒ Object
151 152 153 |
# File 'lib/rebi/config_environment.rb', line 151 def platform_arn cfg && cfg[:Platform] && cfg[:Platform][:PlatformArn] end |
#raw_environment_variables ⇒ Object
165 166 167 |
# File 'lib/rebi/config_environment.rb', line 165 def raw_environment_variables raw_conf[:environment_variables] || {} end |
#worker? ⇒ Boolean
94 95 96 |
# File 'lib/rebi/config_environment.rb', line 94 def worker? tier[:name] == "Worker" ? true : false end |