SecretsManager: Introduce secrets database wrapper (#105472)

SecretsManager: Introduce secret database wrapper

Co-authored-by: PoorlyDefinedBehaviour <brunotj2015@hotmail.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
This commit is contained in:
Dana Axinte
2025-05-20 11:48:47 +01:00
committed by GitHub
co-authored by PoorlyDefinedBehaviour Leandro Deveikis Matheus Macabu
parent 32bd9e22ee
commit a7922912fe
4 changed files with 125 additions and 3 deletions
+3 -3
View File
@@ -343,7 +343,7 @@ func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64,
Folder: folder,
GUID: guid,
}); err != nil {
if isRowAlreadyExistsError(err) {
if IsRowAlreadyExistsError(err) {
return guid, resource.ErrResourceAlreadyExists
}
return guid, fmt.Errorf("insert into resource: %w", err)
@@ -387,8 +387,8 @@ func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64,
return rv, nil
}
// isRowAlreadyExistsError checks if the error is the result of the row inserted already existing.
func isRowAlreadyExistsError(err error) bool {
// IsRowAlreadyExistsError checks if the error is the result of the row inserted already existing.
func IsRowAlreadyExistsError(err error) bool {
var sqlite sqlite3.Error
if errors.As(err, &sqlite) {
return sqlite.ExtendedCode == sqlite3.ErrConstraintUnique