class OpenStax::Aws::SecretsSpecification
Attributes
data[R]
Public Class Methods
from_content(content:, format: nil, top_key: nil, preparser: nil)
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 26 def self.from_content(content:, format: nil, top_key: nil, preparser: nil) new(content: content, format: format, top_key: top_key, preparser: preparser) end
from_file_name(file_name:, format:, top_key: nil, preparser: nil)
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 9 def self.from_file_name(file_name:, format:, top_key: nil, preparser: nil) file = File.open(file_name, "r") content = file.read file.close new(content: content, format: format, top_key: top_key, preparser: preparser) end
from_git(org_slash_repo:, sha:, path:, github_token: nil, format:, top_key: nil, preparser: nil)
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 16 def self.from_git(org_slash_repo:, sha:, path:, github_token: nil, format:, top_key: nil, preparser: nil) content = OpenStax::Aws::GitHelper.file_content_at_sha( org_slash_repo: org_slash_repo, sha: sha, path: path, github_token: github_token ) new(content: content, format: format, top_key: top_key, preparser: preparser) end
new(content:, format: nil, top_key: nil, preparser: nil)
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 30 def initialize(content:, format: nil, top_key: nil, preparser: nil) case content when Hash @data = content.dup when String raise "#{format} is not yet handled" if :yml != format case (preparser || 'none').to_sym when :erb content = parse_erb(content) end @data = YAML.load(content) else raise "Unknown secrets specification inline content type: #{content.class}" end @data = data.with_indifferent_access @data = data[top_key.to_s] if top_key end
Public Instance Methods
expanded_data()
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 51 def expanded_data flat_hash(@data).map{|k,v| [k.join('/'), v]}.to_h end
Protected Instance Methods
flat_hash(h,f=[],g={})
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 58 def flat_hash(h,f=[],g={}) return g.update({ f=>h }) unless h.is_a? Hash h.each { |k,r| flat_hash(r,f+[k],g) } g end
parse_erb(string)
click to toggle source
# File lib/openstax/aws/secrets_specification.rb, line 64 def parse_erb(string) (ERB.new string).result(binding) end