From 891b27649eba50cf127364335888b15bd2e0efba Mon Sep 17 00:00:00 2001 From: fiftin Date: Tue, 2 Jul 2024 22:26:59 +0500 Subject: [PATCH] feat(secrets): implement secret getting for boltdb --- db/bolt/access_key.go | 5 ++++- db/bolt/environment.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/db/bolt/access_key.go b/db/bolt/access_key.go index 948ec4d4..a211bbe9 100644 --- a/db/bolt/access_key.go +++ b/db/bolt/access_key.go @@ -20,7 +20,10 @@ func (d *BoltDb) GetAccessKeyRefs(projectID int, accessKeyID int) (db.ObjectRefe func (d *BoltDb) GetAccessKeys(projectID int, params db.RetrieveQueryParams) ([]db.AccessKey, error) { var keys []db.AccessKey - err := d.getObjects(projectID, db.AccessKeyProps, params, nil, &keys) + err := d.getObjects(projectID, db.AccessKeyProps, params, func(i interface{}) bool { + k := i.(db.AccessKey) + return k.EnvironmentID == nil + }, &keys) return keys, err } diff --git a/db/bolt/environment.go b/db/bolt/environment.go index 10fe015b..21ba0337 100644 --- a/db/bolt/environment.go +++ b/db/bolt/environment.go @@ -40,3 +40,12 @@ func (d *BoltDb) CreateEnvironment(env db.Environment) (db.Environment, error) { func (d *BoltDb) DeleteEnvironment(projectID int, environmentID int) error { return d.deleteObject(projectID, db.EnvironmentProps, intObjectID(environmentID), nil) } + +func (d *BoltDb) GetEnvironmentSecrets(projectID int, environmentID int) ([]db.AccessKey, error) { + var keys []db.AccessKey + err := d.getObjects(projectID, db.AccessKeyProps, db.RetrieveQueryParams{}, func(i interface{}) bool { + k := i.(db.AccessKey) + return k.EnvironmentID != nil && *k.EnvironmentID == environmentID + }, &keys) + return keys, err +}