class Rebi::Config
Attributes
aws_key[W]
aws_profile[W]
aws_secret[W]
data[RW]
region[W]
Public Class Methods
new()
click to toggle source
# File lib/rebi/config.rb, line 6 def initialize reload! end
Public Instance Methods
app_description()
click to toggle source
# File lib/rebi/config.rb, line 53 def app_description data[:app_description] || "Created via rebi" end
app_name()
click to toggle source
# File lib/rebi/config.rb, line 45 def app_name data[:app_name] end
app_name=(name)
click to toggle source
# File lib/rebi/config.rb, line 49 def app_name=name data[:app_name] = name end
aws_key()
click to toggle source
# File lib/rebi/config.rb, line 23 def aws_key data[:aws_key] || ENV["AWS_ACCESS_KEY_ID"] end
aws_profile()
click to toggle source
# File lib/rebi/config.rb, line 19 def aws_profile @aws_profile || data[:profile] || ENV["AWS_PROFILE"] end
aws_secret()
click to toggle source
# File lib/rebi/config.rb, line 27 def aws_secret data[:aws_secret] || ENV["AWS_SECRET_ACCESS_KEY"] end
aws_session_token()
click to toggle source
# File lib/rebi/config.rb, line 31 def aws_session_token ENV["AWS_SESSION_TOKEN"] end
config_file()
click to toggle source
# File lib/rebi/config.rb, line 10 def config_file @config_file ||= "#{Rebi.root}/.rebi.yml" end
config_file=(path)
click to toggle source
# File lib/rebi/config.rb, line 14 def config_file=path @config_file = Pathname.new(path).realpath.to_s end
env_by_name(name)
click to toggle source
# File lib/rebi/config.rb, line 71 def env_by_name name data[:stages].each do |stg_name, stg_conf| stg = stage stg_name stg_conf.keys.each do |env_name| env_conf = Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {}) return env_conf if env_conf.name == name end end return nil end
environment(stg_name, env_name)
click to toggle source
# File lib/rebi/config.rb, line 65 def environment stg_name, env_name stg = stage stg_name raise(Rebi::Error::ConfigNotFound.new("Environment config: #{env_name}")) unless stg.key?(env_name) return Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {}) end
push_to_file()
click to toggle source
# File lib/rebi/config.rb, line 96 def push_to_file File.open(config_file, "wb") do |f| f.write JSON.parse(data.to_json).to_yaml end Rebi.log "Saved config to #{config_file}" Rebi.log "For more configs, please refer sample or github" end
region()
click to toggle source
# File lib/rebi/config.rb, line 35 def region data[:region] end
reload!()
click to toggle source
# File lib/rebi/config.rb, line 39 def reload! @data = nil set_aws_config return data end
stage(stage)
click to toggle source
# File lib/rebi/config.rb, line 57 def stage stage data[:stages] && data[:stages][stage] || raise(Rebi::Error::ConfigNotFound.new("Stage: #{stage}")) end
stages()
click to toggle source
# File lib/rebi/config.rb, line 82 def stages data[:stages].keys end
timeout()
click to toggle source
# File lib/rebi/config.rb, line 61 def timeout (data[:timeout] || 60*10).second end
Private Instance Methods
set_aws_config()
click to toggle source
# File lib/rebi/config.rb, line 106 def set_aws_config conf = {} if region conf.merge!({ region: region }) end if aws_profile conf.merge!({ profile: aws_profile }) elsif aws_secret && aws_key conf.merge!( credentials: Aws::Credentials::new(aws_key, aws_secret, aws_session_token) ) end Aws.config.update conf end