1
0
mirror of https://github.com/rancher/steve.git synced 2025-08-31 15:11:31 +00:00

Split RegisterAfterUpsert into RegisterAfterAdd and RegisterAfterUpdate (#644)

* Split RegisterAfterUpsert into two

We're going to need to be able to differentiate between Add and Update
for storing events in the _events table.

* Update mocks
This commit is contained in:
Tom Lebreux
2025-05-30 08:25:12 -04:00
committed by GitHub
parent cb0d9d6d54
commit 55a1b940a0
7 changed files with 125 additions and 64 deletions

View File

@@ -70,7 +70,8 @@ type Store interface {
GetByKey(key string) (item any, exists bool, err error)
GetName() string
RegisterAfterUpsert(f func(key string, obj any, tx transaction.Client) error)
RegisterAfterAdd(f func(key string, obj any, tx transaction.Client) error)
RegisterAfterUpdate(f func(key string, obj any, tx transaction.Client) error)
RegisterAfterDelete(f func(key string, tx transaction.Client) error)
GetShouldEncrypt() bool
GetType() reflect.Type
@@ -102,7 +103,8 @@ func NewIndexer(ctx context.Context, indexers cache.Indexers, s Store) (*Indexer
Store: s,
indexers: indexers,
}
i.RegisterAfterUpsert(i.AfterUpsert)
i.RegisterAfterAdd(i.AfterUpsert)
i.RegisterAfterUpdate(i.AfterUpsert)
i.deleteIndicesQuery = fmt.Sprintf(deleteIndicesFmt, db.Sanitize(s.GetName()))
i.addIndexQuery = fmt.Sprintf(addIndexFmt, db.Sanitize(s.GetName()))