-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.go
43 lines (36 loc) · 970 Bytes
/
backend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package saltyhash
import (
"context"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/helper/locksutil"
"github.com/hashicorp/vault/sdk/logical"
)
type backend struct {
*framework.Backend
// Locks to make changes to role entries. These will be initialized to a
// predefined number of locks when the backend is created, and will be
// indexed based on salted role names.
roleLocks []*locksutil.LockEntry
}
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend(ctx, conf)
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
func Backend(_ context.Context, _ *logical.BackendConfig) *backend {
b := &backend{
roleLocks: locksutil.CreateLocks(),
}
b.Backend = &framework.Backend{
BackendType: logical.TypeLogical,
Paths: []*framework.Path{
b.pathHash(),
b.pathHashBatch(),
b.pathListRoles(),
b.pathRoles(),
},
}
return b
}