-
-
Notifications
You must be signed in to change notification settings - Fork 478
/
store.go
59 lines (52 loc) · 1.88 KB
/
store.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gopass
import (
"context"
"fmt"
)
// Byter is a minimal secrets write interface
type Byter interface {
Bytes() []byte
}
// Secret is a secret type.
type Secret interface {
Byter
Keys() []string
// Get returns a single value for that key, use Password() to get the password value.
Get(key string) (string, bool)
// Values returns all values for that key, use Password() to get the password value.
Values(key string) ([]string, bool)
// Set sets a single header value, use SetPassword() to set the password value.
Set(key string, value interface{}) error
// Add appends the value to that key, use SetPassword() to set the password value.
Add(key string, value interface{}) error
// Del removes a single header value
Del(key string) bool
// GetBody returns everything except the header. Use Bytes to get everything
Body() string
Password() string
SetPassword(string)
}
// Store is a secret store.
type Store interface {
fmt.Stringer
// List all secrets
List(context.Context) ([]string, error)
// Get an decrypted secret. Revision defaults to "latest".
Get(ctx context.Context, name, revision string) (Secret, error)
// Set (add) a new revision of an secret
Set(ctx context.Context, name string, sec Byter) error
// Revisions return a list of revisions for a secret
Revisions(ctx context.Context, name string) ([]string, error)
// Remove a single secret
Remove(ctx context.Context, name string) error
// RemoveAll secrets with a common prefix
RemoveAll(ctx context.Context, prefix string) error
// Rename a path (secret of prefix) without decrypting
Rename(ctx context.Context, src, dest string) error
// Sync with a remote (if configured)
// NOTE: We will always auto-sync when mutating the store. Use this to
// manually pull in changes.
Sync(ctx context.Context) error
// Clean up any resources. MUST be called before the process exists.
Close(ctx context.Context) error
}