File: null.go

package info (click to toggle)
golang-github-cloudflare-redoctober 0.0~git20161017.0.78e9720-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 636 kB
  • sloc: sh: 65; makefile: 7
file content (63 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (3)
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
package persist

import (
	"errors"

	"github.com/cloudflare/redoctober/config"
	"github.com/cloudflare/redoctober/keycache"
	"github.com/cloudflare/redoctober/passvault"
)

// Null is a non-persisting store. It is used when persistence is not
// activated.
type Null struct {
	config *config.Delegations
}

func newNull(config *config.Delegations) (Store, error) {
	return &Null{config: config}, nil
}

func (n *Null) Blob() []byte {
	return nil
}

func (n *Null) Policy() string {
	return n.config.Policy
}

func (n *Null) Users() []string {
	return n.config.Users
}

func (n *Null) Store(bs []byte) error {
	return nil
}

func (n *Null) Load() error {
	return nil
}

func (n *Null) Persist() {
	return
}

func (n *Null) Status() *Status {
	return &Status{
		State:   Disabled,
		Summary: nil,
	}
}

func (n *Null) Delegate(record passvault.PasswordRecord, name, password string, users, labels []string, uses int, slot, durationString string) error {
	return errors.New("persist: null store does not support delegations")
}

func (n *Null) Cache() *keycache.Cache {
	cache := keycache.NewCache()
	return &cache
}

func (n *Null) Purge() error {
	return nil
}