Sha256: 6cabb749969a5f9ac0be6cfc4fe332436026a911fa2a566fec2ab8370ed82f39

Contents?: true

Size: 695 Bytes

Versions: 5

Compression:

Stored size: 695 Bytes

Contents

class Ufo::Env
  def self.setup!(project_root='.')
    # Ensures that  UFO_ENV is always set to a default value.
    # For Ufo::Env.setup! we do not need to check if we're in a ufo project
    # Because we could not be at first. For example when: ufo init is first called.
    # Other uses of Ufo::Settings assumes that we should be in a ufo project.
    settings = Ufo::Settings.new(project_root, false).data
    map = settings['aws_profile_ufo_env_map']

    if map
      ufo_env = map[ENV['AWS_PROFILE']] || map['default']
    end
    ufo_env ||= 'prod' # defaults to prod
    ufo_env = ENV['UFO_ENV'] if ENV['UFO_ENV'] # highest precedence

    Kernel.const_set(:UFO_ENV, ufo_env)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ufo-2.1.0 lib/ufo/env.rb
ufo-2.0.3 lib/ufo/env.rb
ufo-2.0.2 lib/ufo/env.rb
ufo-2.0.1 lib/ufo/env.rb
ufo-2.0.0 lib/ufo/env.rb