Description
Extend the PipelineModel struct by implementing a new standalone method called BadgerDBCreatePipeline. To prevent breaking changes across the codebase, do not refactor or replace the existing etcd-based CreatePipeline implementation. This method introduces native support for serializing and persisting a new pipeline payload directly inside BadgerDB.
Requirements
- File Location:
internal/models/pipeline.go
- Method Signature Strategy: Introduce a new method named
BadgerDBCreatePipeline(pipeline *types.Pipeline) error on the PipelineModel struct.
- Transactionality: Execute both the duplication check and the write sequence within a single BadgerDB Update (write) transaction to guarantee execution safety.
- Uniqueness Constraint: * Before saving the bytes, inspect the database to check if the calculated lookup key already exists.
- If the key exists, return a descriptive custom error indicating that a pipeline with that name is already defined, preventing accidental overwrites.
- Serialization & Key Generation: * Generate the targeted storage key using the format:
/pipelines/{pipeline.Name}.
- Marshal the incoming
*types.Pipeline struct into JSON bytes using the standard json.Marshal library.
- Testing: Add a dedicated unit test suite inside
internal/models/pipeline_test.go to validate successful creation workflows, persistence checks, and key-conflict validation pathways using an in-memory database instance.
Success Criteria
Description
Extend the
PipelineModelstruct by implementing a new standalone method calledBadgerDBCreatePipeline. To prevent breaking changes across the codebase, do not refactor or replace the existing etcd-basedCreatePipelineimplementation. This method introduces native support for serializing and persisting a new pipeline payload directly inside BadgerDB.Requirements
internal/models/pipeline.goBadgerDBCreatePipeline(pipeline *types.Pipeline) erroron thePipelineModelstruct./pipelines/{pipeline.Name}.*types.Pipelinestruct into JSON bytes using the standardjson.Marshallibrary.internal/models/pipeline_test.goto validate successful creation workflows, persistence checks, and key-conflict validation pathways using an in-memory database instance.Success Criteria
BadgerDBCreatePipelinemethod is added cleanly alongside legacy methods without breaking public structure boundaries.BadgerDBCreatePipelinewith a valid mock pipeline object.