db

package
v0.28.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package db handles our database layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

type BoltDB struct {
	// contains filtered or unexported fields
}

BoltDB is a database using BoltDB

func New

func New(dataDir string) (*BoltDB, error)

New returns a valid locker. We need to be able to write to dataDir since bolt stores its data as a file

func NewWithDB

func NewWithDB(db *bolt.DB, bucket string, globalBucket string) (*BoltDB, error)

NewWithDB is used for testing.

func (*BoltDB) CheckCommandLock

func (b *BoltDB) CheckCommandLock(cmdName command.Name) (*command.Lock, error)

CheckCommandLock checks if CommandName lock was set. If the lock exists return the pointer to the lock object, otherwise return nil

func (*BoltDB) DeletePullStatus

func (b *BoltDB) DeletePullStatus(pull models.PullRequest) error

DeletePullStatus deletes the status for pull.

func (*BoltDB) GetLock

func (b *BoltDB) GetLock(p models.Project, workspace string) (*models.ProjectLock, error)

GetLock returns a pointer to the lock for that project and workspace. If there is no lock, it returns a nil pointer.

func (*BoltDB) GetPullStatus

func (b *BoltDB) GetPullStatus(pull models.PullRequest) (*models.PullStatus, error)

GetPullStatus returns the status for pull. If there is no status, returns a nil pointer.

func (*BoltDB) List

func (b *BoltDB) List() ([]models.ProjectLock, error)

List lists all current locks.

func (*BoltDB) LockCommand

func (b *BoltDB) LockCommand(cmdName command.Name, lockTime time.Time) (*command.Lock, error)

LockCommand attempts to create a new lock for a CommandName. If the lock doesn't exists, it will create a lock and return a pointer to it. If the lock already exists, it will return an "lock already exists" error

func (*BoltDB) TryLock

func (b *BoltDB) TryLock(newLock models.ProjectLock) (bool, models.ProjectLock, error)

TryLock attempts to create a new lock. If the lock is acquired, it will return true and the lock returned will be newLock. If the lock is not acquired, it will return false and the current lock that is preventing this lock from being acquired.

func (*BoltDB) Unlock

func (b *BoltDB) Unlock(p models.Project, workspace string) (*models.ProjectLock, error)

Unlock attempts to unlock the project and workspace. If there is no lock, then it will return a nil pointer. If there is a lock, then it will delete it, and then return a pointer to the deleted lock.

func (*BoltDB) UnlockByPull

func (b *BoltDB) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error)

UnlockByPull deletes all locks associated with that pull request and returns them.

func (*BoltDB) UnlockCommand

func (b *BoltDB) UnlockCommand(cmdName command.Name) error

UnlockCommand removes CommandName lock if present. If there are no lock it returns an error.

func (*BoltDB) UpdateProjectStatus

func (b *BoltDB) UpdateProjectStatus(pull models.PullRequest, workspace string, repoRelDir string, newStatus models.ProjectPlanStatus) error

UpdateProjectStatus updates project status.

func (*BoltDB) UpdatePullWithResults

func (b *BoltDB) UpdatePullWithResults(pull models.PullRequest, newResults []command.ProjectResult) (models.PullStatus, error)

UpdatePullWithResults updates pull's status with the latest project results. It returns the new PullStatus object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL