class Vault::Provision::Prototype
prototype for the individual hierarchy paths
Public Class Methods
new(boss)
click to toggle source
# File lib/vault/provision/prototype.rb, line 7 def initialize boss @vault = boss.vault @instance_dir = boss.instance_dir @intermediate_issuer = boss.intermediate_issuer @pki_allow_destructive = boss.pki_allow_destructive @aws_update_creds = boss.aws_update_creds end
Public Instance Methods
mounts_by_type(type)
click to toggle source
# File lib/vault/provision/prototype.rb, line 29 def mounts_by_type type mounts = @vault.sys.mounts mounts.keys.select { |mp| mounts[mp].type == type } end
provision!()
click to toggle source
# File lib/vault/provision/prototype.rb, line 47 def provision! puts "#{self.class} says: Go climb a tree!" end
repo_files()
click to toggle source
# File lib/vault/provision/prototype.rb, line 24 def repo_files return [] unless File.exist? repo_path Find.find(repo_path).select { |rf| rf.end_with?('.json') } end
repo_files_by_mount_type(type)
click to toggle source
# File lib/vault/provision/prototype.rb, line 34 def repo_files_by_mount_type type files = [] mounts_by_type(type).each do |mp| next unless Dir.exist? "#{@instance_dir}/#{mp}" Find.find("#{@instance_dir}/#{mp}").each do |rf| next unless rf.end_with? '.json' files << rf end end files end
repo_path()
click to toggle source
# File lib/vault/provision/prototype.rb, line 20 def repo_path "#{@instance_dir}/#{repo_prefix}" end
repo_prefix()
click to toggle source
# File lib/vault/provision/prototype.rb, line 15 def repo_prefix ActiveSupport::Inflector.underscore(self.class.to_s) .split('/')[2..-1].join('/') end
validate_file!(path)
click to toggle source
# File lib/vault/provision/prototype.rb, line 51 def validate_file! path file_string = File.read(path) begin case File.extname(path) when '.json' JSON.parse file_string when '.hcl' Rhcl.parse file_string else raise InvalidProvisioningFileError.new("unknown filetype #{File.extname(path)}") end true rescue Racc::ParseError, JSON::ParserError, InvalidProvisioningFileError => e raise InvalidProvisioningFileError.new("Unable to parse file #{path}:\nš±š±š±\n#{file_string}\nš±š±š±\n#{e.class} #{e.message}") end end