Sha256: fd549e23ae64320c1826687b75f00f4ff5b2f198c4cfd4d19c4c0b6d8ba59349

Contents?: true

Size: 698 Bytes

Versions: 1

Compression:

Stored size: 698 Bytes

Contents

# frozen_string_literal: true

require 'aws-sdk-secretsmanager'
require 'json'
require 'fsecret_loader/version'
require 'fsecret_loader/configuration'

# FSecretLoader module
module FSecretLoader
  class << self
    def config
      yield configuration
    end

    def load
      return if configuration.secret_id.nil?

      secrets.each_pair do |key, value|
        ENV[key.to_s] = value.to_s
      end
    end

    def configuration
      @configuration ||= Configuration.new
    end

    private

    def secrets
      JSON.parse(
        configuration
          .secret_client
          .get_secret_value(secret_id: configuration.secret_id)
          .secret_string
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fsecret_loader-0.1.2 lib/fsecret_loader.rb