feat(secrets): implement secret getting for boltdb

This commit is contained in:
fiftin 2024-07-02 22:26:59 +05:00
parent 6010665fe3
commit 891b27649e
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
2 changed files with 13 additions and 1 deletions

View File

@ -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
}

View File

@ -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
}