From 593d83fc255abba12240c9f9925fa536f029564a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 19:39:24 +0200 Subject: [PATCH] feat: --demo stars platform-prod for alice too, and api-key expires soon --- cmd/lazysecrets/main.go | 5 ++++- internal/provider/fake/fake.go | 13 +++++++++++++ internal/provider/fake/seed.go | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cmd/lazysecrets/main.go b/cmd/lazysecrets/main.go index d2b5398..736fb1f 100644 --- a/cmd/lazysecrets/main.go +++ b/cmd/lazysecrets/main.go @@ -322,8 +322,11 @@ Flags: // Two Azure accounts, like a personal and an admin login in az. alice, admin := "Azure:alice@example.com/demo", "Azure:admin.alice@example.com/demo" fake.Seed(st, alice, admin) + az := fake.Azure(400*time.Millisecond).As(alice, "Azure · alice") + // Due soon whenever the demo runs (the tests' dates are fixed). + az.Expire("kv-app-prod", "api-key", time.Now().AddDate(0, 0, 9).Truncate(24*time.Hour)) providers = []provider.Provider{ - fake.Azure(400*time.Millisecond).As(alice, "Azure · alice"), + az, fake.AzureOps(700*time.Millisecond).As(admin, "Azure · admin.alice"), fake.Databricks(600 * time.Millisecond), fake.Repos(), diff --git a/internal/provider/fake/fake.go b/internal/provider/fake/fake.go index 5fdd016..8a766d9 100644 --- a/internal/provider/fake/fake.go +++ b/internal/provider/fake/fake.go @@ -218,6 +218,19 @@ func (p *Provider) addContainer(src provider.Source, name, detail string, types return c } +// Expire sets when the object name in vault expires, for --demo: a date +// relative to today in the test data would change the tests' screenshots +// from day to day. +func (p *Provider) Expire(vault, name string, at time.Time) { + for _, objs := range p.objects { + for i := range objs { + if objs[i].Container.Name == vault && objs[i].Name == name { + objs[i].Expires = at + } + } + } +} + func (p *Provider) add(c provider.Container, t provider.ObjectType, o provider.Object, value string) provider.Object { o.Container = c o.Type = t diff --git a/internal/provider/fake/seed.go b/internal/provider/fake/seed.go index cd9e237..406d377 100644 --- a/internal/provider/fake/seed.go +++ b/internal/provider/fake/seed.go @@ -34,7 +34,9 @@ func Seed(st *store.Store, alice, admin string) { path: []string{"platform-prod", "kv-shared-prod"}, uses: 2, ago: 26 * time.Hour}, {link: dbx + "app/storage-key", account: "Databricks", source: "dbx-prod", path: []string{"prod", "app"}, star: true, uses: 3, ago: 5 * time.Hour}, - // A subscription, and a repo's file. + // A subscription, for both accounts, and a repo's file. + {link: azure + "subscriptions/sub-prod", account: alice, source: "sub-prod", + name: "platform-prod", star: true}, {link: azure + "subscriptions/sub-prod", account: admin, source: "sub-prod", name: "platform-prod", star: true}, {link: "lazysecrets://repo/github.com%2Facme%2Flazysecrets-demo/deploy%2Fprod%2Fsecrets.yaml", account: "Repos",