logical/postgresql: leasing

This commit is contained in:
Mitchell Hashimoto
2015-04-18 21:45:05 -07:00
parent 550db69c42
commit 22d959e313
5 changed files with 124 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ func Backend() *framework.Backend {
Paths: []*framework.Path{
pathConfigConnection(&b),
pathConfigLease(&b),
pathRoles(&b),
pathRoleCreate(&b),
},
@@ -95,6 +96,24 @@ func (b *backend) ResetDB() {
b.db = nil
}
// Lease returns the lease information
func (b *backend) Lease(s logical.Storage) (*configLease, error) {
entry, err := s.Get("config/lease")
if err != nil {
return nil, err
}
if entry == nil {
return nil, nil
}
var result configLease
if err := entry.DecodeJSON(&result); err != nil {
return nil, err
}
return &result, nil
}
const backendHelp = `
The PostgreSQL backend dynamically generates database users.