Description
Extend the ResourceDefinitionModel struct by adding a new standalone method called BadgerDBDelete. To avoid breaking changes across external system logic, do not refactor or replace the legacy etcd-based Delete implementation. This new capability will introduce standalone support to remove an existing resource definition payload directly from BadgerDB.
Requirements
- File Location:
internal/models/resource_definitions.go
- Method Signature Strategy: Introduce a new method named
BadgerDBDelete(name string) error on the ResourceDefinitionModel struct.
- Transactionality: Execute the entire removal check and delete block inside a BadgerDB Update (write) transaction to ensure proper synchronization.
- Key Generation: Generate the targeted key using the existing
key(name) helper (i.e., /resource_definitions/{name}).
- Existence Verification & Error Handling: * Prior to running the deletion call, explicitly verify whether the key exists inside BadgerDB by trying to retrieve it or using transaction methods.
- If the key is not found, return a descriptive custom "not found" validation error matching the error context returned by the etcd-based predecessor.
- Testing: Write a dedicated validation test suite inside
internal/models/resource_definitions_test.go to prove standalone item removal mechanics.
Success Criteria
Description
Extend the
ResourceDefinitionModelstruct by adding a new standalone method calledBadgerDBDelete. To avoid breaking changes across external system logic, do not refactor or replace the legacy etcd-basedDeleteimplementation. This new capability will introduce standalone support to remove an existing resource definition payload directly from BadgerDB.Requirements
internal/models/resource_definitions.goBadgerDBDelete(name string) erroron theResourceDefinitionModelstruct.key(name)helper (i.e.,/resource_definitions/{name}).internal/models/resource_definitions_test.goto prove standalone item removal mechanics.Success Criteria
BadgerDBDeletemethod is successfully added to the data layer model alongside legacy paths without modifying existing API signatures.Updateblock.BadgerDBDeleteto strip the key from the dataset.