Sha256: c3c40ca418b48c435983023a269c424bf028b6b6e6fa1bf091329667f6913277

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 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
      # require 'pry'; binding.pry
      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

    def reset
      @configuration = nil
    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.3 lib/fsecret_loader.rb