Skip to content

Add BadgerDBDeletePipeline method for PipelineModel #258

Description

@jim-junior

Description

Extend the PipelineModel struct by implementing a new standalone method called BadgerDBDeletePipeline. To preserve backward compatibility and prevent breaking changes across the orchestration layer, do not change or delete the legacy etcd-based DeletePipeline implementation. This new method will introduce standalone support to remove a stored pipeline record directly from BadgerDB.

Requirements

  • File Location: internal/models/pipeline.go
  • Method Signature Strategy: Introduce a new method named BadgerDBDeletePipeline(name string) error on the PipelineModel struct.
  • Transactionality: Execute both the existence verification and key deletion sequences within a single BadgerDB Update (write) transaction to guarantee state safety.
  • Existence Verification & Error Handling: * Prior to running the deletion call, explicitly verify whether the key exists inside BadgerDB.
    • If the key is not found (e.g., catching badger.ErrKeyNotFound), immediately return the descriptive validation error: fmt.Errorf("pipeline not found") to match the exact query parity expected by the model handlers.
  • Key Generation: Generate the target storage key using the standard format string: /pipelines/{name}.
  • Testing: Create a comprehensive unit test case inside internal/models/pipeline_test.go to validate standalone key deletion, state cleanup verification, and missing item validation handling.

Success Criteria

  • The BadgerDBDeletePipeline method is added cleanly alongside legacy methods without breaking public structural boundaries.
  • The existence check and key deletion operate atomically inside an exclusive write transaction block.
  • Attempting to delete a non-existent pipeline safely drops out with a clear pipeline not found validation error.
  • Test Case implementation: A comprehensive unit test is provided that:
    • Seeds an isolated, in-memory BadgerDB database instance with a marshaled JSON mock pipeline configuration.
    • Successfully calls BadgerDBDeletePipeline with the corresponding configuration name.
    • Confirms through a subsequent lookup transaction that the key has been completely deleted from the database.
    • Asserts that invoking the method on an invalid pipeline name accurately triggers the expected "not found" validation response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    goPull requests that update go code

    Type

    Fields

    No fields configured for Task.

    Projects

    Status
    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions