No behaviour change. - Deleted, unused or one-line wrappers: panes.RuneIndexes, Detail.Refresh (SetDescribed does it), SecretValue.Len, Query.Empty, Clipboard.Native, config.Load, get's value, Model.done, providerOf (cachefile.ProviderOf), contextWithTimeout, searchCoverage, startCrawl, showKeybindings, the expiry aliases and daysLeft. - cmp.Or instead of the two cmpOr copies; slices.Sorted(maps.Keys(…)), maps.Copy, wg.Go, utf8.RuneCountInString and new(true) instead of loops and helpers that do the same. - A container's pane title is set once, not twice; a redundant length check in share links and a no-op assignment in linkhandler.Launch are gone. - Tests call ansi.Strip and lastLines directly; gofmt -s on links.go. Reviewed-on: #76 Co-authored-by: Karl-Einar Bergstrøm <karl-einarb@outlook.com>
30 lines
849 B
Go
30 lines
849 B
Go
package app
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.kebcloud.no/keb/lazysecrets/internal/expiry"
|
|
"git.kebcloud.no/keb/lazysecrets/internal/provider"
|
|
)
|
|
|
|
// Secrets, keys and certificates with an expiry date are marked in the
|
|
// list once they have expired (✗ expired) or will within the configured
|
|
// warning period (⚠ 12d), and typing "expir" in the filter finds them.
|
|
|
|
// expiry tells whether o has expired or will within the warning period,
|
|
// and how long it has left.
|
|
func (m Model) expiry(o provider.Object) (expiry.State, time.Duration) {
|
|
return expiry.Of(o.Expires, m.now(), m.expiryWarning)
|
|
}
|
|
|
|
// expiryWord is matched by the filter: "expired" or "expiring".
|
|
func (m Model) expiryWord(o provider.Object) string {
|
|
switch state, _ := m.expiry(o); state {
|
|
case expiry.Expired:
|
|
return "expired"
|
|
case expiry.Soon:
|
|
return "expiring"
|
|
}
|
|
return ""
|
|
}
|