Class: Vault::Provision::Prototype
- Inherits:
-
Object
- Object
- Vault::Provision::Prototype
show all
- Defined in:
- lib/vault/provision/prototype.rb
Overview
prototype for the individual hierarchy paths
Direct Known Subclasses
Auth::Approle, Auth::Ldap::Config, Auth::Ldap::Groups, Aws::SecretBackend, Generic, Vault::Provision::Pki::Config::Crl, Vault::Provision::Pki::Config::Urls, Vault::Provision::Pki::Intermediate::Generate::Internal, Vault::Provision::Pki::Roles, Vault::Provision::Pki::Root::Generate::Internal, Secret, Sys::Audit, Sys::Auth, Sys::Mounts, Sys::Policy
Defined Under Namespace
Classes: InvalidProvisioningFileError
Instance Method Summary
collapse
Constructor Details
#initialize(boss) ⇒ Prototype
Returns a new instance of Prototype.
7
8
9
10
11
12
13
|
# 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
|
Instance Method Details
#mounts_by_type(type) ⇒ Object
28
29
30
31
|
# File 'lib/vault/provision/prototype.rb', line 28
def mounts_by_type type
mounts = @vault.sys.mounts
mounts.keys.select { |mp| mounts[mp].type == type }
end
|
#provision! ⇒ Object
46
47
48
|
# File 'lib/vault/provision/prototype.rb', line 46
def provision!
puts "#{self.class} says: Go climb a tree!"
end
|
#repo_files ⇒ Object
24
25
26
|
# File 'lib/vault/provision/prototype.rb', line 24
def repo_files
Find.find(repo_path).select { |rf| rf.end_with?('.json') }
end
|
#repo_files_by_mount_type(type) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/vault/provision/prototype.rb', line 33
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 ⇒ Object
20
21
22
|
# File 'lib/vault/provision/prototype.rb', line 20
def repo_path
"#{@instance_dir}/#{repo_prefix}"
end
|
#repo_prefix ⇒ Object
15
16
17
18
|
# 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) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/vault/provision/prototype.rb', line 50
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
|