-
Notifications
You must be signed in to change notification settings - Fork 1
/
backend.go
42 lines (35 loc) · 1.03 KB
/
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
package exoscale
import (
"context"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
"github.com/exoscale/vault-plugin-secrets-exoscale/version"
)
type exoscaleBackend struct {
exo *Exoscale
*framework.Backend
}
func Factory(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
backend := exoscaleBackend{exo: &Exoscale{}}
backend.Backend = &framework.Backend{
BackendType: logical.TypeLogical,
Help: "Dynamically create Exoscale IAM API Keys",
Paths: framework.PathAppend(
backend.pathRole(),
[]*framework.Path{
backend.pathConfigRoot(),
backend.pathConfigLease(),
backend.pathAPIKey(),
},
),
Secrets: []*framework.Secret{backend.secretAPIKey()},
RunningVersion: version.Version,
InitializeFunc: func(ctx context.Context, ir *logical.InitializationRequest) error {
return backend.exo.LoadConfigFromStorage(ctx, ir.Storage)
},
}
if err := backend.Setup(ctx, config); err != nil {
return nil, err
}
return &backend, nil
}