interface.go

 1package identity
 2
 3import (
 4	"github.com/MichaelMure/git-bug/entity"
 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	// Id return the Identity identifier
12	Id() entity.Id
13
14	// Name return the last version of the name
15	// Can be empty.
16	Name() string
17
18	// Email return the last version of the email
19	// Can be empty.
20	Email() string
21
22	// Login return the last version of the login
23	// Can be empty.
24	// Warning: this login can be defined when importing from a bridge but should *not* be
25	// used to identify an identity as multiple bridge with different login can map to the same
26	// identity. Use the metadata system for that usage instead.
27	Login() string
28
29	// AvatarUrl return the last version of the Avatar URL
30	// Can be empty.
31	AvatarUrl() string
32
33	// Keys return the last version of the valid keys
34	// Can be empty.
35	Keys() []*Key
36
37	// ValidKeysAtTime return the set of keys valid at a given lamport time
38	// Can be empty.
39	ValidKeysAtTime(time lamport.Time) []*Key
40
41	// DisplayName return a non-empty string to display, representing the
42	// identity, based on the non-empty values.
43	DisplayName() string
44
45	// Validate check if the Identity data is valid
46	Validate() error
47
48	// Write the identity into the Repository. In particular, this ensure that
49	// the Id is properly set.
50	Commit(repo repository.ClockedRepo) error
51
52	// If needed, write the identity into the Repository. In particular, this
53	// ensure that the Id is properly set.
54	CommitAsNeeded(repo repository.ClockedRepo) error
55
56	// IsProtected return true if the chain of git commits started to be signed.
57	// If that's the case, only signed commit with a valid key for this identity can be added.
58	IsProtected() bool
59
60	// LastModificationLamportTime return the Lamport time at which the last version of the identity became valid.
61	LastModificationLamport() lamport.Time
62
63	// LastModification return the timestamp at which the last version of the identity became valid.
64	LastModification() timestamp.Timestamp
65}