sqlite

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package sqlite provides the Sqlite data manipulation language (DML) for Vela.

Usage:

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

Index

Constants

View Source
const (
	// ListBuilds represents a query to
	// list all builds in the database.
	ListBuilds = `
SELECT *
FROM builds;
`

	// ListRepoBuilds represents a query to list
	// all builds for a repo_id in the database.
	ListRepoBuilds = `
SELECT *
FROM builds
WHERE repo_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListRepoBuildsByEvent represents a query to select
	// a build for a repo_id with a specific event type
	// in the database.
	ListRepoBuildsByEvent = `
SELECT *
FROM builds
WHERE repo_id = ?
AND event = ?
ORDER BY number DESC
LIMIT ?
OFFSET ?;
`

	// SelectRepoBuild represents a query to select
	// a build for a repo_id in the database.
	SelectRepoBuild = `
SELECT *
FROM builds
WHERE repo_id = ?
AND number = ?
LIMIT 1;
`

	// SelectLastRepoBuild represents a query to select
	// the last build for a repo_id in the database.
	SelectLastRepoBuild = `
SELECT *
FROM builds
WHERE repo_id = ?
ORDER BY number DESC
LIMIT 1;
`
	// SelectLastRepoBuildByBranch represents a query to
	// select the last build for a repo_id and branch name
	// in the database
	SelectLastRepoBuildByBranch = `
SELECT *
FROM builds
WHERE repo_id = ?
AND branch = ?
ORDER BY number DESC
LIMIT 1;
`

	// SelectBuildsCount represents a query to select
	// the count of builds in the database.
	SelectBuildsCount = `
SELECT count(*) as count
FROM builds;
`

	// SelectRepoBuildCount represents a query to select
	// the count of builds for a repo_id in the database.
	SelectRepoBuildCount = `
SELECT count(*) as count
FROM builds
WHERE repo_id = ?;
`

	// SelectRepoBuildCountByEvent represents a query to select
	// the count of builds for by repo and event type in the database.
	SelectRepoBuildCountByEvent = `
SELECT count(*) as count
FROM builds
WHERE repo_id = ?
AND event = ?;
`

	// SelectBuildsCountByStatus represents a query to select
	// the count of builds for a status in the database.
	SelectBuildsCountByStatus = `
SELECT count(*) as count
FROM builds
WHERE status = ?;
`

	// DeleteBuild represents a query to
	// remove a build from the database.
	DeleteBuild = `
DELETE
FROM builds
WHERE id = ?;
`
)
View Source
const (
	// ListHooks represents a query to
	// list all webhooks in the database.
	ListHooks = `
SELECT *
FROM hooks;
`

	// ListRepoHooks represents a query to list
	// all webhooks for a repo_id in the database.
	ListRepoHooks = `
SELECT *
FROM hooks
WHERE repo_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectRepoHookCount represents a query to select
	// the count of webhooks for a repo_id in the database.
	SelectRepoHookCount = `
SELECT count(*) as count
FROM hooks
WHERE repo_id = ?;
`

	// SelectRepoHook represents a query to select
	// a webhook for a repo_id in the database.
	SelectRepoHook = `
SELECT *
FROM hooks
WHERE repo_id = ?
AND number = ?
LIMIT 1;
`

	// SelectLastRepoHook represents a query to select
	// the last hook for a repo_id in the database.
	SelectLastRepoHook = `
SELECT *
FROM hooks
WHERE repo_id = ?
ORDER BY number DESC
LIMIT 1;
`

	// DeleteHook represents a query to
	// remove a webhook from the database.
	DeleteHook = `
DELETE
FROM hooks
WHERE id = ?;
`
)
View Source
const (
	// ListLogs represents a query to
	// list all logs in the database.
	ListLogs = `
SELECT *
FROM logs;
`

	// ListBuildLogs represents a query to list
	// all logs for a build_id in the database.
	ListBuildLogs = `
SELECT *
FROM logs
WHERE build_id = ?
ORDER BY step_id ASC;
`

	// SelectStepLog represents a query to select
	// a log for a step_id in the database.
	SelectStepLog = `
SELECT *
FROM logs
WHERE step_id = ?
LIMIT 1;
`

	// SelectServiceLog represents a query to select
	// a log for a service_id in the database.
	SelectServiceLog = `
SELECT *
FROM logs
WHERE service_id = ?
LIMIT 1;
`

	// DeleteLog represents a query to
	// remove a log from the database.
	DeleteLog = `
DELETE
FROM logs
WHERE id = ?;
`
)
View Source
const (
	// ListRepos represents a query to
	// list all repos in the database.
	ListRepos = `
SELECT *
FROM repos;
`

	// ListUserRepos represents a query to list
	// all repos for a user_id in the database.
	ListUserRepos = `
SELECT *
FROM repos
WHERE user_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListOrgRepos represents a query to list
	// all repos for an org in the database.
	ListOrgRepos = `
SELECT *
FROM repos
WHERE org = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectRepo represents a query to select a
	// repo for an org and name in the database.
	SelectRepo = `
SELECT *
FROM repos
WHERE org = ?
AND name = ?
LIMIT 1;
`

	// SelectUserReposCount represents a query to select
	// the count of repos for a user_id in the database.
	SelectUserReposCount = `
SELECT count(*) as count
FROM repos
WHERE user_id = ?;
`

	// SelectReposCount represents a query to select
	// the count of repos in the database.
	SelectReposCount = `
SELECT count(*) as count
FROM repos;
`

	// DeleteRepo represents a query to
	// remove a repo from the database.
	DeleteRepo = `
DELETE
FROM repos
WHERE id = ?;
`
)
View Source
const (
	// ListSecrets represents a query to
	// list all secrets in the database.
	ListSecrets = `
SELECT *
FROM secrets;
`

	// ListOrgSecrets represents a query to list all
	// secrets for a type and org in the database.
	ListOrgSecrets = `
SELECT *
FROM secrets
WHERE type = 'org'
AND org = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListRepoSecrets represents a query to list all
	// secrets for a type, org and repo in the database.
	ListRepoSecrets = `
SELECT *
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// ListSharedSecrets represents a query to list all
	// secrets for a type, org and team in the database.
	ListSharedSecrets = `
SELECT *
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectOrgSecretsCount represents a query to select the
	// count of org secrets for an org in the database.
	SelectOrgSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'org'
AND org = ?;
`

	// SelectRepoSecretsCount represents a query to select the
	// count of repo secrets for an org and repo in the database.
	SelectRepoSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?;
`

	// SelectSharedSecretsCount represents a query to select the
	// count of shared secrets for an org and repo in the database.
	SelectSharedSecretsCount = `
SELECT count(*) as count
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?;
`

	// SelectOrgSecret represents a query to select a
	// secret for an org and name in the database.
	SelectOrgSecret = `
SELECT *
FROM secrets
WHERE type = 'org'
AND org = ?
AND name = ?
LIMIT 1;
`

	// SelectRepoSecret represents a query to select a
	// secret for an org, repo and name in the database.
	SelectRepoSecret = `
SELECT *
FROM secrets
WHERE type = 'repo'
AND org = ?
AND repo = ?
AND name = ?
LIMIT 1;
`

	// SelectSharedSecret represents a query to select a
	// secret for an org, team and name in the database.
	SelectSharedSecret = `
SELECT *
FROM secrets
WHERE type = 'shared'
AND org = ?
AND team = ?
AND name = ?
LIMIT 1;
`

	// DeleteSecret represents a query to
	// remove a secret from the database.
	DeleteSecret = `
DELETE
FROM secrets
WHERE id = ?;
`
)
View Source
const (
	// ListServices represents a query to
	// list all services in the database.
	ListServices = `
SELECT *
FROM services;
`

	// ListBuildServices represents a query to list
	// all services for a build_id in the database.
	ListBuildServices = `
SELECT *
FROM services
WHERE build_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectBuildServicesCount represents a query to select
	// the count of services for a build_id in the database.
	SelectBuildServicesCount = `
SELECT count(*) as count
FROM services
WHERE build_id = ?
`

	// SelectServiceImagesCount represents a query to select
	// the count of an images appearances in the database.
	SelectServiceImagesCount = `
SELECT image, count(image) as count
FROM services
GROUP BY image
`

	// SelectBuildService represents a query to select a
	// service for a build_id and number in the database.
	SelectBuildService = `
SELECT *
FROM services
WHERE build_id = ?
AND number = ?
LIMIT 1;
`

	// DeleteService represents a query to
	// remove a service from the database.
	DeleteService = `
DELETE
FROM services
WHERE id = ?;
`
)
View Source
const (
	// ListSteps represents a query to
	// list all steps in the database.
	ListSteps = `
SELECT *
FROM steps;
`

	// ListBuildSteps represents a query to list
	// all steps for a build_id in the database.
	ListBuildSteps = `
SELECT *
FROM steps
WHERE build_id = ?
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectBuildStepsCount represents a query to select
	// the count of steps for a build_id in the database.
	SelectBuildStepsCount = `
SELECT count(*) as count
FROM steps
WHERE build_id = ?
`

	// SelectStepImagesCount represents a query to select
	// the count of an images appearances in the database.
	SelectStepImagesCount = `
SELECT image, count(image) as count
FROM steps
GROUP BY image;
`

	// SelectStepStatusesCount represents a query to select
	// the count of step status' appearances in the database.
	SelectStepStatusesCount = `
SELECT status, count(status) as count
FROM steps
GROUP BY status;
`

	// SelectBuildStep represents a query to select a
	// step for a build_id and number in the database.
	SelectBuildStep = `
SELECT *
FROM steps
WHERE build_id = ?
AND number = ?
LIMIT 1;
`

	// DeleteStep represents a query to
	// remove a step from the database.
	DeleteStep = `
DELETE
FROM steps
WHERE id = ?;
`
)
View Source
const (
	// ListUsers represents a query to
	// list all users in the database.
	ListUsers = `
SELECT *
FROM users;
`

	// ListLiteUsers represents a query to
	// list all lite users in the database.
	ListLiteUsers = `
SELECT id, name
FROM users
ORDER BY id DESC
LIMIT ?
OFFSET ?;
`

	// SelectUser represents a query to select
	// a user for an id in the database.
	SelectUser = `
SELECT *
FROM users
WHERE id = ?
LIMIT 1;
`

	// SelectUserName represents a query to select
	// a user for a name in the database.
	SelectUserName = `
SELECT *
FROM users
WHERE name = ?
LIMIT 1;
`

	// SelectUsersCount represents a query to select
	// the count of users in the database.
	SelectUsersCount = `
SELECT count(*) as count
FROM users;
`

	// DeleteUser represents a query to
	// remove a user from the database.
	DeleteUser = `
DELETE
FROM users
WHERE id = ?;
`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	BuildService   *Service
	HookService    *Service
	LogService     *Service
	RepoService    *Service
	SecretService  *Service
	ServiceService *Service
	StepService    *Service
	UserService    *Service
}

Map represents the Sqlite DML services in a struct for lookups.

func NewMap

func NewMap() *Map

NewMap returns the Sqlite Map for DML lookups.

type Service

type Service struct {
	List   map[string]string
	Select map[string]string
	Delete string
}

Service represents the Sqlite DML for a table in the database.

Jump to

Keyboard shortcuts

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