feat: lazysecrets list prints notes, and --demo has a couple

This commit is contained in:
keb committed 2026-10-14 21:24:01 +02:00
1 parent 2c9c37f809
commit 824f7249c3
4 files changed
+31 -18

No files matched your search

+11 -6
View File
@@ -8,13 +8,14 @@ import (
"git.kebcloud.no/keb/lazysecrets/internal/store"
)
// Seed stars and uses a few of the demo's secrets, so --demo shows
// Favourites (F), Recent (R) and stars in lazysecrets list. alice and
// Seed stars, notes and uses a few of the demo's secrets, so --demo
// shows Favourites (F), Recent (R), notes, and stars in lazysecrets list. alice and
// admin are the two Azure accounts' provider IDs.
func Seed(st *store.Store, alice, admin string) {
type item struct {
link, account, source string
name string // else the link's last part
note string
path []string
star bool
uses int
@@ -23,11 +24,12 @@ func Seed(st *store.Store, alice, admin string) {
const azure, dbx = "lazysecrets://azure/", "lazysecrets://databricks/adb-1111111111111111.11.azuredatabricks.net/"
for _, it := range []item{
{link: azure + "kv-app-prod.vault.azure.net/secrets/db-password", account: alice, source: "sub-prod",
path: []string{"platform-prod", "kv-app-prod"}, star: true, uses: 12, ago: 20 * time.Minute},
path: []string{"platform-prod", "kv-app-prod"}, star: true, uses: 12, ago: 20 * time.Minute,
note: "rotated by the data team each quarter"},
{link: azure + "kv-app-prod.vault.azure.net/secrets/api-key", account: alice, source: "sub-prod",
path: []string{"platform-prod", "kv-app-prod"}, uses: 4, ago: 2 * time.Hour},
{link: azure + "kv-breakglass.vault.azure.net/secrets/emergency-admin", account: admin, source: "sub-prod",
path: []string{"platform-prod", "kv-breakglass"}, star: true},
path: []string{"platform-prod", "kv-breakglass"}, star: true, note: "incidents only: tell #ops when used"},
{link: azure + "kv-shared-prod.vault.azure.net/secrets/smtp-password", account: alice, source: "sub-prod",
path: []string{"platform-prod", "kv-shared-prod"}, uses: 2, ago: 26 * time.Hour},
{link: dbx + "app/storage-key", account: "Databricks", source: "dbx-prod",
@@ -43,10 +45,13 @@ func Seed(st *store.Store, alice, admin string) {
n.Name = cmp.Or(it.name, it.link[strings.LastIndex(it.link, "/")+1:])
n.Path, n.Source, n.Account = it.path, it.source, it.account
}
if it.star {
if it.star || it.note != "" {
_ = st.Update(it.link, func(n *store.Node) {
context(n)
n.ToggleStar(it.account)
if it.star {
n.ToggleStar(it.account)
}
n.Note = it.note
})
}
for range it.uses {