feat: lazysecrets list's JSON says when an entry was last used, and how often
This commit is contained in:
3 files changed
+23
-11
No files matched your search
@@ -40,9 +40,11 @@ type Entry struct {
|
||||
// AccountLabel names the az account, when there are several.
|
||||
AccountLabel string `json:"accountLabel,omitempty"`
|
||||
// Starred is starred for this account; Recent is used lately (Recent,
|
||||
// R, in the TUI).
|
||||
Starred bool `json:"starred"`
|
||||
Recent bool `json:"recent"`
|
||||
// R, in the TUI): LastUsed is when, Uses how often.
|
||||
Starred bool `json:"starred"`
|
||||
Recent bool `json:"recent"`
|
||||
LastUsed time.Time `json:"lastUsed,omitzero"`
|
||||
Uses int `json:"uses,omitempty"`
|
||||
// Error says why a source's vaults or a vault's secrets couldn't be
|
||||
// listed. The entry is then that source or vault, again, or with an
|
||||
// account's sources unreadable, the account without a link.
|
||||
@@ -61,9 +63,10 @@ type Options struct {
|
||||
// Lists only needed for other kinds aren't loaded: sources and vaults
|
||||
// alone don't load any secrets. Lists that fail are always listed.
|
||||
Kinds []string
|
||||
// Mark tells whether the entry with link is starred for account, and
|
||||
// used lately; nil marks nothing.
|
||||
Mark func(link, account string) (starred, recent bool)
|
||||
// Mark tells whether the entry with link is starred for account,
|
||||
// and when it was last used and how often (zero: not lately); nil
|
||||
// marks nothing.
|
||||
Mark func(link, account string) (starred bool, lastUsed time.Time, uses int)
|
||||
Timeout func(provider.Kind) time.Duration
|
||||
Now func() time.Time
|
||||
}
|
||||
@@ -225,7 +228,8 @@ func (l *lister) put(p provider.Provider, e Entry) {
|
||||
}
|
||||
e.Account = p.ID()
|
||||
if l.o.Mark != nil && e.Link != "" {
|
||||
e.Starred, e.Recent = l.o.Mark(e.Link, e.Account)
|
||||
e.Starred, e.LastUsed, e.Uses = l.o.Mark(e.Link, e.Account)
|
||||
e.Recent = !e.LastUsed.IsZero()
|
||||
}
|
||||
id := p.ID() + "\x00" + e.Link + "\x00" + e.Error
|
||||
if l.stopped != nil || l.seen[id] {
|
||||
|
||||
Reference in new issue
Block a user