Method: Codebuild::Setting#cb_env

Defined in:
lib/codebuild/setting.rb

#cb_envObject

Resolves infinite problem since Codebuild.env can be determined from CB_ENV or settings.yml files. When ufo is determined from settings it should not called Codebuild.env since that in turn calls Settings.new.data which can then cause an infinite loop.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/codebuild/setting.rb', line 36

def cb_env
  path = "#{cb_root}/.codebuild/settings.yml"
  if File.exist?(path)
    settings = YAML.load_file(path)
    env = settings.find do |_env, section|
      section ||= {}
      ENV['AWS_PROFILE'] && ENV['AWS_PROFILE'] == section['aws_profile']
    end
  end

  cb_env = env.first if env
  cb_env = ENV['CB_ENV'] if ENV['CB_ENV'] # highest precedence
  cb_env || 'development'
end