interface.go

 1package identity
 2
 3import (
 4	bootstrap "github.com/MichaelMure/git-bug/entity/boostrap"
 5	"github.com/MichaelMure/git-bug/repository"
 6	"github.com/MichaelMure/git-bug/util/lamport"
 7	"github.com/MichaelMure/git-bug/util/timestamp"
 8)
 9
10type Interface interface {
11	bootstrap.Entity
12
13	// Name return the last version of the name
14	// Can be empty.
15	Name() string
16
17	// DisplayName return a non-empty string to display, representing the
18	// identity, based on the non-empty values.
19	DisplayName() string
20
21	// Email return the last version of the email
22	// Can be empty.
23	Email() string
24
25	// Login return the last version of the login
26	// Can be empty.
27	// Warning: this login can be defined when importing from a bridge but should *not* be
28	// used to identify an identity as multiple bridge with different login can map to the same
29	// identity. Use the metadata system for that usage instead.
30	Login() string
31
32	// AvatarUrl return the last version of the Avatar URL
33	// Can be empty.
34	AvatarUrl() string
35
36	// Keys return the last version of the valid keys
37	// Can be empty.
38	Keys() []*Key
39
40	// SigningKey return the key that should be used to sign new messages. If no key is available, return nil.
41	SigningKey(repo repository.RepoKeyring) (*Key, error)
42
43	// ValidKeysAtTime return the set of keys valid at a given lamport time for a given clock of another entity
44	// Can be empty.
45	ValidKeysAtTime(clockName string, time lamport.Time) []*Key
46
47	// LastModification return the timestamp at which the last version of the identity became valid.
48	LastModification() timestamp.Timestamp
49
50	// LastModificationLamports return the lamport times at which the last version of the identity became valid.
51	LastModificationLamports() map[string]lamport.Time
52
53	// IsProtected return true if the chain of git commits started to be signed.
54	// If that's the case, only signed commit with a valid key for this identity can be added.
55	IsProtected() bool
56
57	// Validate check if the Identity data is valid
58	Validate() error
59
60	// NeedCommit indicate that the in-memory state changed and need to be committed in the repository
61	NeedCommit() bool
62}