2018-09-18 03:03:00 +00:00
|
|
|
// +build !enterprise
|
|
|
|
|
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
2021-05-11 17:12:54 +00:00
|
|
|
"fmt"
|
|
|
|
|
2018-09-18 03:03:00 +00:00
|
|
|
"github.com/hashicorp/vault/helper/namespace"
|
2019-04-12 21:54:35 +00:00
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
2018-09-18 03:03:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (m *ExpirationManager) leaseView(*namespace.Namespace) *BarrierView {
|
|
|
|
return m.idView
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ExpirationManager) tokenIndexView(*namespace.Namespace) *BarrierView {
|
|
|
|
return m.tokenView
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ExpirationManager) collectLeases() (map[*namespace.Namespace][]string, int, error) {
|
|
|
|
leaseCount := 0
|
|
|
|
existing := make(map[*namespace.Namespace][]string)
|
|
|
|
keys, err := logical.CollectKeys(m.quitContext, m.leaseView(namespace.RootNamespace))
|
|
|
|
if err != nil {
|
2021-05-11 17:12:54 +00:00
|
|
|
return nil, 0, fmt.Errorf("failed to scan for leases: %w", err)
|
2018-09-18 03:03:00 +00:00
|
|
|
}
|
|
|
|
existing[namespace.RootNamespace] = keys
|
|
|
|
leaseCount += len(keys)
|
|
|
|
return existing, leaseCount, nil
|
|
|
|
}
|