Documentation
¶
Overview ¶
Package database is responsible for all database logic. It handles connecting to the database and performing queries.
Index ¶
- type Database
- func (db *Database) ChangeJobStatus(jobID uint, newStatus models.JobStatus) error
- func (db *Database) CreateAccessToken(userID uint, name, token string) (*models.AccessToken, error)
- func (db *Database) CreateArtifact(jobID uint, filename string) (*models.Artifact, error)
- func (db *Database) CreateFileUpload(filename, sha256Sum string, uploadedAt time.Time) (*models.FileUpload, error)
- func (db *Database) CreateJob(jobType models.JobType, uploadID, inputArtifactID uint) (*models.Job, error)
- func (db *Database) CreatePGPKey(userID uint, fingerprint, publicKey string) (*models.PGPKey, error)
- func (db *Database) CreateUpload(userID uint, source, version, maintainer, changedBy string, autopkgtest bool, ...) (*models.Upload, error)
- func (db *Database) CreateUser(id uint, username string) (*models.User, error)
- func (db *Database) GetAllAccessTokensByToken(token string) ([]*models.AccessToken, error)
- func (db *Database) GetAllAccessTokensByUserID(userID uint) ([]*models.AccessToken, error)
- func (db *Database) GetAllArtifactsByJobID(jobID uint) ([]*models.Artifact, error)
- func (db *Database) GetAllArtifactsByJobIDFilename(jobID uint, filename string) ([]*models.Artifact, error)
- func (db *Database) GetAllFileUploadsByUploadID(uploadID uint) ([]*models.FileUpload, error)
- func (db *Database) GetAllJobs() ([]*models.Job, error)
- func (db *Database) GetAllJobsByUploadID(uploadID uint) ([]*models.Job, error)
- func (db *Database) GetAllJobsByUploadIDStatuses(uploadID uint, statuses ...models.JobStatus) ([]*models.Job, error)
- func (db *Database) GetAllPGPKeys() ([]*models.PGPKey, error)
- func (db *Database) GetAllPGPKeysByFingerprint(fingerprint string) ([]*models.PGPKey, error)
- func (db *Database) GetAllPGPKeysByUserID(userID uint) ([]*models.PGPKey, error)
- func (db *Database) GetAllUploads() ([]*models.Upload, error)
- func (db *Database) GetAllUploadsByUserID(userID uint) ([]*models.Upload, error)
- func (db *Database) GetArtifact(id uint) (*models.Artifact, error)
- func (db *Database) GetFileUpload(id uint) (*models.FileUpload, error)
- func (db *Database) GetFileUploadByFileNameSHASumCompleted(filename, sha256Sum string, completed bool) (*models.FileUpload, error)
- func (db *Database) GetJob(id uint) (*models.Job, error)
- func (db *Database) GetNextJob() (*models.Job, error)
- func (db *Database) GetUpload(id uint) (*models.Upload, error)
- func (db *Database) GetUser(id uint) (*models.User, error)
- func (db *Database) RemoveAccessToken(id, userID uint) error
- func (db *Database) RemovePGPKey(id, userID uint) error
- func (db *Database) UpdateFileUpload(fileUpload *models.FileUpload) error
- func (db *Database) UpdateJob(job *models.Job) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an implementation of the app.Datastore interface
func NewDatabase ¶
NewDatabase creates a new database connection
func (*Database) ChangeJobStatus ¶ added in v0.10.1
ChangeJobStatus will change a job's status. This is not idempotent and will cause an error if the status was not modified.
func (*Database) CreateAccessToken ¶ added in v0.9.1
CreateAccessToken will create an access token
func (*Database) CreateArtifact ¶ added in v0.10.1
CreateArtifact will create a job artifact
func (*Database) CreateFileUpload ¶ added in v0.4.0
func (db *Database) CreateFileUpload(filename, sha256Sum string, uploadedAt time.Time) (*models.FileUpload, error)
CreateFileUpload will create a FileUpload
func (*Database) CreateJob ¶
func (db *Database) CreateJob(jobType models.JobType, uploadID, inputArtifactID uint) (*models.Job, error)
CreateJob will create a job
func (*Database) CreatePGPKey ¶ added in v0.9.1
func (db *Database) CreatePGPKey(userID uint, fingerprint, publicKey string) (*models.PGPKey, error)
CreatePGPKey will create PGP Key
func (*Database) CreateUpload ¶
func (db *Database) CreateUpload( userID uint, source, version, maintainer, changedBy string, autopkgtest bool, forward bool, ) (*models.Upload, error)
CreateUpload will create an upload
func (*Database) CreateUser ¶ added in v0.9.1
CreateUser will create a user
func (*Database) GetAllAccessTokensByToken ¶ added in v0.9.1
func (db *Database) GetAllAccessTokensByToken(token string) ([]*models.AccessToken, error)
GetAllAccessTokensByToken returns all AccessTokens that match the userID
func (*Database) GetAllAccessTokensByUserID ¶ added in v0.9.1
func (db *Database) GetAllAccessTokensByUserID(userID uint) ([]*models.AccessToken, error)
GetAllAccessTokensByUserID returns all AccessTokens that match the userID
func (*Database) GetAllArtifactsByJobID ¶ added in v0.10.1
GetAllArtifactsByJobID returns all job artifacts for a job
func (*Database) GetAllArtifactsByJobIDFilename ¶ added in v0.10.1
func (db *Database) GetAllArtifactsByJobIDFilename(jobID uint, filename string) ([]*models.Artifact, error)
GetAllArtifactsByJobIDFilename returns all job artifacts for a job with a matching file name
func (*Database) GetAllFileUploadsByUploadID ¶ added in v0.4.0
func (db *Database) GetAllFileUploadsByUploadID(uploadID uint) ([]*models.FileUpload, error)
GetAllFileUploadsByUploadID returns all file uploads for an Upload
func (*Database) GetAllJobs ¶
GetAllJobs returns all jobs
func (*Database) GetAllJobsByUploadID ¶ added in v0.9.1
GetAllJobsByUploadID returns all jobs for an upload
func (*Database) GetAllJobsByUploadIDStatuses ¶ added in v0.10.1
func (db *Database) GetAllJobsByUploadIDStatuses(uploadID uint, statuses ...models.JobStatus) ([]*models.Job, error)
GetAllJobsByUploadIDStatuses returns all jobs that match the given id and statuses
func (*Database) GetAllPGPKeys ¶ added in v0.9.1
GetAllPGPKeys returns all PGP Keys
func (*Database) GetAllPGPKeysByFingerprint ¶ added in v0.9.1
GetAllPGPKeysByFingerprint returns all keys that match the given fingerprint
func (*Database) GetAllPGPKeysByUserID ¶ added in v0.9.1
GetAllPGPKeysByUserID returns all PGPKeys that match the userID
func (*Database) GetAllUploads ¶
GetAllUploads returns all uploads
func (*Database) GetAllUploadsByUserID ¶ added in v0.9.1
GetAllUploadsByUserID returns all uploads for a user
func (*Database) GetArtifact ¶ added in v0.10.1
GetArtifact returns the Artifact with the given id
func (*Database) GetFileUpload ¶ added in v0.4.0
func (db *Database) GetFileUpload(id uint) (*models.FileUpload, error)
GetFileUpload returns the FileUpload with the given id
func (*Database) GetFileUploadByFileNameSHASumCompleted ¶ added in v0.4.0
func (db *Database) GetFileUploadByFileNameSHASumCompleted(filename, sha256Sum string, completed bool) (*models.FileUpload, error)
GetFileUploadByFileNameSHASumCompleted returns the first FileUpload that matches
func (*Database) GetNextJob ¶ added in v0.4.0
GetNextJob will return the next job to run
func (*Database) RemoveAccessToken ¶ added in v0.9.1
RemoveAccessToken removes all matching access tokens
func (*Database) RemovePGPKey ¶ added in v0.9.1
RemovePGPKey removes all matching pgp keys
func (*Database) UpdateFileUpload ¶ added in v0.4.0
func (db *Database) UpdateFileUpload(fileUpload *models.FileUpload) error
UpdateFileUpload will update a file upload