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 ¶
View Source
var Flags = []cli.Flag{ &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_LOG_FORMAT", "DATABASE_LOG_FORMAT", "VELA_LOG_FORMAT"}, Name: "database.log.format", Usage: "format of logs to output", Value: "json", }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_LOG_LEVEL", "DATABASE_LOG_LEVEL", "VELA_LOG_LEVEL"}, Name: "database.log.level", Usage: "level of logs to output", Value: "info", }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_DRIVER", "DATABASE_DRIVER"}, Name: "database.driver", Usage: "driver to be used for the database system", Value: "sqlite3", }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_ADDR", "DATABASE_ADDR"}, Name: "database.addr", Usage: "fully qualified url (<scheme>://<host>) for the database", Value: "vela.sqlite", }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_OPEN", "DATABASE_CONNECTION_OPEN"}, Name: "database.connection.open", Usage: "maximum number of open connections to the database", Value: 0, }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_IDLE", "DATABASE_CONNECTION_IDLE"}, Name: "database.connection.idle", Usage: "maximum number of idle connections to the database", Value: 2, }, &cli.DurationFlag{ EnvVars: []string{"VELA_DATABASE_CONNECTION_LIFE", "DATABASE_CONNECTION_LIFE"}, Name: "database.connection.life", Usage: "duration of time a connection may be reused for the database", Value: 30 * time.Minute, }, &cli.IntFlag{ EnvVars: []string{"VELA_DATABASE_COMPRESSION_LEVEL", "DATABASE_COMPRESSION_LEVEL"}, Name: "database.compression.level", Usage: "level of compression for logs stored in the database", Value: constants.CompressionThree, }, &cli.StringFlag{ EnvVars: []string{"VELA_DATABASE_ENCRYPTION_KEY", "DATABASE_ENCRYPTION_KEY"}, Name: "database.encryption.key", Usage: "AES-256 key for encrypting and decrypting values in the database", }, }
Flags represents all supported command line interface (CLI) flags for the database.
Functions ¶
Types ¶
type Service ¶
type Service interface {
// Driver defines a function that outputs
// the configured database driver.
Driver() string
// 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)
// GetLastBuildByBranch defines a function that
// gets the last build ran by repo ID and branch.
GetLastBuildByBranch(*library.Repo, string) (*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, int64, error)
// GetOrgBuildList defines a function that
// gets a list of builds by org.
GetOrgBuildList(string, int, int) ([]*library.Build, int64, error)
// GetRepoBuildListByEvent defines a function that
// gets a list of builds by repo ID and event type.
GetRepoBuildListByEvent(*library.Repo, string, int, int) ([]*library.Build, int64, error)
// GetOrgBuildListByEvent defines a function that
// gets a list of builds by org and event type.
GetOrgBuildListByEvent(string, string, int, int) ([]*library.Build, int64, error)
// GetRepoBuildCount defines a function that
// gets the count of builds by repo ID.
GetRepoBuildCount(*library.Repo) (int64, error)
// GetOrgBuildCount defines a function that
// gets the count of builds by org.
GetOrgBuildCount(string) (int64, error)
// GetRepoBuildCountByEvent defines a function that
// gets the count of builds by repo ID and event type.
GetRepoBuildCountByEvent(*library.Repo, string) (int64, error)
// GetOrgBuildCountByEvent defines a function that
// gets the count of builds by org and event type.
GetOrgBuildCountByEvent(string, string) (int64, error)
// GetPendingAndRunningBuilds defines a function that
// gets the list of pending and running builds.
GetPendingAndRunningBuilds(string) ([]*library.BuildQueue, 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
// GetHook defines a function that
// gets a webhook by number and repo ID.
GetHook(int, *library.Repo) (*library.Hook, error)
// GetLastHook defines a function that
// gets the last hook by repo ID.
GetLastHook(*library.Repo) (*library.Hook, error)
// GetHookList defines a function that gets
// a list of all webhooks.
GetHookList() ([]*library.Hook, error)
// GetRepoHookList defines a function that
// gets a list of webhooks by repo ID.
GetRepoHookList(*library.Repo, int, int) ([]*library.Hook, error)
// GetRepoHookCount defines a function that
// gets the count of webhooks by repo ID.
GetRepoHookCount(*library.Repo) (int64, error)
// CreateHook defines a function that
// creates a new webhook.
CreateHook(*library.Hook) error
// UpdateHook defines a function that
// updates a webhook.
UpdateHook(*library.Hook) error
// DeleteHook defines a function that
// deletes a webhook by unique ID.
DeleteHook(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)
// GetOrgRepoList defines a function that
// gets a list of all repos by org.
GetOrgRepoList(string, int, int) ([]*library.Repo, error)
// GetRepoCount defines a function that
// gets 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)
// GetUserRepoCount defines a function that
// gets 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 the count of steps by build ID.
GetBuildStepCount(*library.Build) (int64, error)
// GetStepImageCount defines a function that
// gets a list of all step images and the
// count of their occurrence.
GetStepImageCount() (map[string]float64, error)
// GetStepStatusCount defines a function that
// gets a list of all step statuses and the
// count of their occurrence.
GetStepStatusCount() (map[string]float64, 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 the count of steps by build ID.
GetBuildServiceCount(*library.Build) (int64, error)
// GetServiceImageCount defines a function that
// gets a list of all service images and the
// count of their occurrence.
GetServiceImageCount() (map[string]float64, error)
// GetServiceStatusCount defines a function that
// gets a list of all service statuses and the
// count of their occurrence.
GetServiceStatusCount() (map[string]float64, 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 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
// GetWorker defines a function that
// gets a worker by hostname.
GetWorker(string) (*library.Worker, error)
// GetWorkerAddress defines a function that
// gets a worker by address.
GetWorkerByAddress(string) (*library.Worker, error)
// GetWorkerList defines a function that
// gets a list of all workers.
GetWorkerList() ([]*library.Worker, error)
// GetWorkerCount defines a function that
// gets the count of workers.
GetWorkerCount() (int64, error)
// CreateWorker defines a function that
// creates a new worker.
CreateWorker(*library.Worker) error
// UpdateWorker defines a function that
// updates a worker by unique ID.
UpdateWorker(*library.Worker) error
// DeleteWorker defines a function that
// deletes a worker by hostname.
DeleteWorker(int64) error
}
Service represents the interface for Vela integrating with the different supported Database backends.
func FromContext ¶
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.
type Setup ¶ added in v0.8.0
type Setup struct {
// specifies the driver to use for the database client
Driver string
// specifies the address to use for the database client
Address string
// specifies the level of compression to use for the database client
CompressionLevel int
// specifies the connection duration to use for the database client
ConnectionLife time.Duration
// specifies the maximum idle connections for the database client
ConnectionIdle int
// specifies the maximum open connections for the database client
ConnectionOpen int
// specifies the encryption key to use for the database client
EncryptionKey string
}
Setup represents the configuration necessary for creating a Vela service capable of integrating with a configured database system.
func (*Setup) Postgres ¶ added in v0.8.0
Postgres creates and returns a Vela service capable of integrating with a Postgres database system.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package postgres provides the ability for Vela to integrate with Postgres as a SQL backend.
|
Package postgres provides the ability for Vela to integrate with Postgres as a SQL backend. |
|
ddl
Package ddl provides the Postgres data definition language (DDL) for Vela.
|
Package ddl provides the Postgres data definition language (DDL) for Vela. |
|
dml
Package dml provides the Postgres data manipulation language (DML) for Vela.
|
Package dml provides the Postgres data manipulation language (DML) for Vela. |
|
Package sqlite provides the ability for Vela to integrate with Sqlite as a SQL backend.
|
Package sqlite provides the ability for Vela to integrate with Sqlite as a SQL backend. |
|
ddl
Package ddl provides the Sqlite data definition language (DDL) for Vela.
|
Package ddl provides the Sqlite data definition language (DDL) for Vela. |
|
dml
Package dml provides the Sqlite data manipulation language (DML) for Vela.
|
Package dml provides the Sqlite data manipulation language (DML) for Vela. |
Click to show internal directories.
Click to hide internal directories.