forked from segmentio/chamber
/
store.go
68 lines (57 loc) · 1.11 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
60
61
62
63
64
65
66
67
68
package store
import (
"errors"
"time"
)
type ChangeEventType int
const (
Created ChangeEventType = iota
Updated
)
func (c ChangeEventType) String() string {
switch c {
case Created:
return "Created"
case Updated:
return "Updated"
}
return "unknown"
}
var (
// ErrSecretNotFound is returned if the specified secret is not found in the
// parameter store
ErrSecretNotFound = errors.New("secret not found")
)
type SecretId struct {
Service string
Key string
}
type Secret struct {
Value *string
Meta SecretMetadata
}
// A secret without any metadata
type RawSecret struct {
Value string
Key string
}
type SecretMetadata struct {
Created time.Time
CreatedBy string
Version int
Key string
}
type ChangeEvent struct {
Type ChangeEventType
Time time.Time
User string
Version int
}
type Store interface {
Write(id SecretId, value string) error
Read(id SecretId, version int) (Secret, error)
List(service string, includeValues bool) ([]Secret, error)
ListRaw(service string) ([]RawSecret, error)
History(id SecretId) ([]ChangeEvent, error)
Delete(id SecretId) error
}