Fix #533, add a reader for lease values (#529) and an acceptance test for mysql to prove it works

This commit is contained in:
Caleb Tennis
2015-08-13 15:32:40 -04:00
parent 6d05df1596
commit d009d79696
4 changed files with 103 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ func pathConfigLease(b *backend) *framework.Path {
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathLeaseRead,
logical.WriteOperation: b.pathLeaseWrite,
},
@@ -35,7 +36,7 @@ func pathConfigLease(b *backend) *framework.Path {
func (b *backend) pathLeaseWrite(
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
leaseRaw := d.Get("lease").(string)
leaseMaxRaw := d.Get("lease").(string)
leaseMaxRaw := d.Get("lease_max").(string)
lease, err := time.ParseDuration(leaseRaw)
if err != nil {
@@ -63,6 +64,25 @@ func (b *backend) pathLeaseWrite(
return nil, nil
}
func (b *backend) pathLeaseRead(
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
lease, err := b.Lease(req.Storage)
if err != nil {
return nil, err
}
if lease == nil {
return nil, nil
}
return &logical.Response{
Data: map[string]interface{}{
"lease": lease.Lease.String(),
"lease_max": lease.LeaseMax.String(),
},
}, nil
}
type configLease struct {
Lease time.Duration
LeaseMax time.Duration