2023-03-15 19:00:52 +03:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2024-01-02 21:36:20 +03:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-15 19:00:52 +03:00
|
|
|
|
2022-01-05 21:02:03 +03:00
|
|
|
//go:build !enterprise
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
2021-05-11 20:12:54 +03:00
|
|
|
"fmt"
|
|
|
|
|
2018-09-18 06:03:00 +03:00
|
|
|
"github.com/hashicorp/vault/helper/namespace"
|
2019-04-13 00:54:35 +03:00
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
2018-09-18 06:03:00 +03: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 20:12:54 +03:00
|
|
|
return nil, 0, fmt.Errorf("failed to scan for leases: %w", err)
|
2018-09-18 06:03:00 +03:00
|
|
|
}
|
|
|
|
existing[namespace.RootNamespace] = keys
|
|
|
|
leaseCount += len(keys)
|
|
|
|
return existing, leaseCount, nil
|
|
|
|
}
|