database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package database provides the ability for Vela to integrate with different supported SQL backends.

Usage:

import "github.com/go-vela/server/database"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c *cli.Context) (*client, error)

New returns a Database implementation that integrates with a supported database instance.

func NewTest

func NewTest() (*client, error)

NewTest returns a Database implementation that integrates with an in-memory Sqlite database instance.

It's possible to overide this with env variables, which gets used as a part of integration testing with the different supported backends.

This function is intended for running tests only.

func ToContext

func ToContext(c Setter, d Service)

ToContext adds the database Service to this context if it supports the Setter interface.

Types

type Service

type Service interface {

	// GetBuild defines a function that
	// gets a build by number and repo ID.
	GetBuild(int, *library.Repo) (*library.Build, error)
	// GetLastBuild defines a function that
	// gets the last build ran by repo ID.
	GetLastBuild(*library.Repo) (*library.Build, error)
	// GetBuildCount defines a function that
	// gets the count of builds.
	GetBuildCount() (int64, error)
	// GetBuildCountByStatus defines a function that
	// gets a the count of builds by status.
	GetBuildCountByStatus(string) (int64, error)
	// GetBuildList defines a function that gets
	// a list of all builds.
	GetBuildList() ([]*library.Build, error)
	// GetRepoBuildList defines a function that
	// gets a list of builds by repo ID.
	GetRepoBuildList(*library.Repo, int, int) ([]*library.Build, error)
	// GetRepoBuildCount defines a function that
	// gets a the count of builds for a specific repo ID.
	GetRepoBuildCount(*library.Repo) (int64, error)
	// CreateBuild defines a function that
	// creates a new build.
	CreateBuild(*library.Build) error
	// UpdateBuild defines a function that
	// updates a build.
	UpdateBuild(*library.Build) error
	// DeleteBuild defines a function that
	// deletes a build by unique ID.
	DeleteBuild(int64) error

	// GetStepLog defines a function that
	// gets a step log by unique ID.
	GetStepLog(int64) (*library.Log, error)
	// GetServiceLog defines a function that
	// gets a service log by unique ID.
	GetServiceLog(int64) (*library.Log, error)
	// GetBuildLogs defines a function that
	// gets a list of logs by build ID.
	GetBuildLogs(int64) ([]*library.Log, error)
	// CreateLog defines a function that
	// creates a new log.
	CreateLog(*library.Log) error
	// UpdateLog defines a function that
	// updates a log.
	UpdateLog(*library.Log) error
	// DeleteLog defines a function that
	// deletes a log by unique ID.
	DeleteLog(int64) error

	// GetRepo defines a function that
	// gets a repo by org and name.
	GetRepo(string, string) (*library.Repo, error)
	// GetRepoList defines a function that
	// gets a list of all repos.
	GetRepoList() ([]*library.Repo, error)
	// GetRepoCount defines a function that
	// gets a the count of repos.
	GetRepoCount() (int64, error)
	// GetUserRepoList defines a function
	// that gets a list of repos by user ID.
	GetUserRepoList(*library.User, int, int) ([]*library.Repo, error)
	// GetRepoCount defines a function that
	// gets a the count of repos for a user.
	GetUserRepoCount(*library.User) (int64, error)
	// CreateRepo defines a function that
	// creates a new repo.
	CreateRepo(*library.Repo) error
	// UpdateRepo defines a function that
	// updates a repo.
	UpdateRepo(*library.Repo) error
	// DeleteRepo defines a function that
	// deletes a repo by unique ID.
	DeleteRepo(int64) error

	// GetSecret defines a function that gets a secret
	// by type, org, name (repo or team) and secret name.
	GetSecret(string, string, string, string) (*library.Secret, error)
	// GetSecretList defines a function that
	// gets a list of all secrets.
	GetSecretList() ([]*library.Secret, error)
	// GetTypeSecretList defines a function that gets a list
	// of secrets by type, owner, and name (repo or team).
	GetTypeSecretList(string, string, string, int, int) ([]*library.Secret, error)
	// GetTypeSecretCount defines a function that gets a count
	// of secrets by type, owner, and name (repo or team).
	GetTypeSecretCount(string, string, string) (int64, error)
	// CreateSecret defines a function that
	// creates a new secret.
	CreateSecret(*library.Secret) error
	// UpdateSecret defines a function that
	// updates a secret.
	UpdateSecret(*library.Secret) error
	// DeleteSecret defines a function that
	// deletes a secret by unique ID.
	DeleteSecret(int64) error

	// GetStep defines a function that
	// gets a step by number and build ID.
	GetStep(int, *library.Build) (*library.Step, error)
	// GetStepList defines a function that
	// gets a list of all steps.
	GetStepList() ([]*library.Step, error)
	// GetBuildStepList defines a function that
	// gets a list of steps by build ID.
	GetBuildStepList(*library.Build, int, int) ([]*library.Step, error)
	// GetBuildStepCount defines a function that
	// gets a count of steps by build ID.
	GetBuildStepCount(*library.Build) (int64, error)
	// CreateStep defines a function that
	// creates a new step.
	CreateStep(*library.Step) error
	// UpdateStep defines a function that
	// updates a step.
	UpdateStep(*library.Step) error
	// DeleteStep defines a function that
	// deletes a step by unique ID.
	DeleteStep(int64) error

	// GetService defines a function that
	// gets a step by number and build ID.
	GetService(int, *library.Build) (*library.Service, error)
	// GetServiceList defines a function that
	// gets a list of all steps.
	GetServiceList() ([]*library.Service, error)
	// GetBuildServiceList defines a function
	// that gets a list of steps by build ID.
	GetBuildServiceList(*library.Build, int, int) ([]*library.Service, error)
	// GetBuildServiceCount defines a function
	// that gets a count of steps by build ID.
	GetBuildServiceCount(*library.Build) (int64, error)
	// CreateService defines a function that
	// creates a new step.
	CreateService(*library.Service) error
	// UpdateService defines a function that
	// updates a step.
	UpdateService(*library.Service) error
	// DeleteService defines a function that
	// deletes a step by unique ID.
	DeleteService(int64) error

	// GetUser defines a function that
	// gets a user by unique ID.
	GetUser(int64) (*library.User, error)
	// GetUserName defines a function that
	// gets a user by name.
	GetUserName(string) (*library.User, error)
	// GetUserList defines a function that
	// gets a list of all users.
	GetUserList() ([]*library.User, error)
	// GetUserCount defines a function that
	// gets a the count of users.
	GetUserCount() (int64, error)
	// GetUserLiteList defines a function
	// that gets a lite list of users.
	GetUserLiteList(int, int) ([]*library.User, error)
	// CreateUser defines a function that
	// creates a new user.
	CreateUser(*library.User) error
	// UpdateUser defines a function that
	// updates a user.
	UpdateUser(*library.User) error
	// DeleteUser defines a function that
	// deletes a user by unique ID.
	DeleteUser(int64) error
}

Service represents the interface for Vela integrating with the different supported Database backends.

func FromContext

func FromContext(c context.Context) Service

FromContext returns the database Service associated with this context.

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

Directories

Path Synopsis
ddl
Package ddl provides the data definition language (DDL) for Vela.
Package ddl provides the data definition language (DDL) for Vela.
postgres
Package postgres provides the Postgres data definition language (DDL) for Vela.
Package postgres provides the Postgres data definition language (DDL) for Vela.
sqlite
Package sqlite provides the Sqlite data definition language (DDL) for Vela.
Package sqlite provides the Sqlite data definition language (DDL) for Vela.
dml
Package dml provides the data manipulation language (DML) for Vela.
Package dml provides the data manipulation language (DML) for Vela.
postgres
Package postgres provides the Postgres data manipulation language (DML) for Vela.
Package postgres provides the Postgres data manipulation language (DML) for Vela.
sqlite
Package sqlite provides the Sqlite data manipulation language (DML) for Vela.
Package sqlite provides the Sqlite data manipulation language (DML) for Vela.

Jump to

Keyboard shortcuts

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