Sha256: aabc70f670da4d1c2ef0ae37bdce4e2dfe7a10e438927227ff8229aa237e0c21
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
module Foreplay class Engine class Secrets class Location include Foreplay attr_reader :secret_location, :environment def initialize(s, e) @secret_location = s @environment = e end def secrets return @secrets if @secrets @secrets = all_secrets[environment] case @secrets when Hash log "Loaded #{secrets.keys.length} secrets" @secrets when String log "Unexpected secrets found: #{@secrets}" @secrets = {} else log 'No secrets found' url ? log("Looked in #{url}") : log('No url found') log("Secrets #{all_secrets.key?(environment) ? 'has a' : 'has no'} key #{environment}") if all_secrets @secrets = {} end end def all_secrets return @all_secrets if @all_secrets @all_secrets = url ? YAML.load(raw_secrets) : {} rescue Psych::SyntaxError => e log "Exception caught when loading secrets from this location: #{url}" log "#{e.class}: #{e.message}".red @all_secrets = {} end def raw_secrets return @raw_secrets if @raw_secrets @raw_secrets = `#{command}` log command log @raw_secrets @raw_secrets end def command @command ||= "curl -k -L#{header_string} #{url}".fake_erb end def header_string @header_string ||= headers.map { |k, v| " -H \"#{k}: #{v}\"" }.join if headers.is_a? Hash end def headers @headers ||= secret_location['headers'] end def url @url ||= @secret_location['url'] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreplay-0.13.4 | lib/foreplay/engine/secrets/location.rb |