2015-04-07 08:20:55 +00:00
|
|
|
package datastore
|
|
|
|
|
2015-04-13 06:08:55 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/drone/drone/common"
|
|
|
|
)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
var (
|
|
|
|
ErrConflict = "Key not unique"
|
|
|
|
ErrNotFound = "Key not found"
|
|
|
|
)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
type Datastore interface {
|
|
|
|
// User returns a user by user login.
|
|
|
|
User(string) (*common.User, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// UserCount returns a count of all registered users.
|
|
|
|
UserCount() (int, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// UserList returns a list of all registered users.
|
|
|
|
UserList() ([]*common.User, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetUser inserts or updates a user.
|
|
|
|
SetUser(*common.User) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetUserNotExists inserts a new user into the datastore.
|
|
|
|
// If the user login already exists ErrConflict is returned.
|
|
|
|
SetUserNotExists(*common.User) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// Del deletes the user.
|
|
|
|
DelUser(*common.User) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// Token returns the token for the given user and label.
|
|
|
|
Token(string, string) (*common.Token, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// TokenList returns a list of all tokens for the given
|
|
|
|
// user login.
|
|
|
|
TokenList(string) ([]*common.Token, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetToken inserts a new user token in the datastore.
|
|
|
|
SetToken(*common.Token) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// DelToken deletes the token.
|
|
|
|
DelToken(*common.Token) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// Subscribed returns true if the user is subscribed
|
|
|
|
// to the named repository.
|
|
|
|
Subscribed(string, string) (bool, error)
|
2015-04-08 22:43:59 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetSubscriber inserts a subscriber for the named
|
2015-04-14 04:39:05 +00:00
|
|
|
// repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
SetSubscriber(string, string) error
|
2015-04-08 22:43:59 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// DelSubscriber removes the subscriber by login for the
|
2015-04-14 04:39:05 +00:00
|
|
|
// named repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
DelSubscriber(string, string) error
|
|
|
|
|
|
|
|
// Repo returns the repository with the given name.
|
|
|
|
Repo(string) (*common.Repo, error)
|
2015-04-08 22:43:59 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// RepoList returns a list of repositories for the
|
|
|
|
// given user account.
|
|
|
|
RepoList(string) ([]*common.Repo, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// RepoParams returns the private environment parameters
|
2015-04-07 08:20:55 +00:00
|
|
|
// for the given repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
RepoParams(string) (map[string]string, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// RepoKeypair returns the private and public rsa keys
|
2015-04-07 08:20:55 +00:00
|
|
|
// for the given repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
RepoKeypair(string) (*common.Keypair, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetRepo inserts or updates a repository.
|
|
|
|
SetRepo(*common.Repo) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetRepo updates a repository. If the repository
|
|
|
|
// already exists ErrConflict is returned.
|
|
|
|
SetRepoNotExists(*common.User, *common.Repo) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetRepoParams inserts or updates the private
|
2015-04-07 08:20:55 +00:00
|
|
|
// environment parameters for the named repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
SetRepoParams(string, map[string]string) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetRepoKeypair inserts or updates the private and
|
2015-04-07 08:20:55 +00:00
|
|
|
// public keypair for the named repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
SetRepoKeypair(string, *common.Keypair) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// DelRepo deletes the repository.
|
|
|
|
DelRepo(*common.Repo) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// Build gets the specified build number for the
|
2015-04-07 08:20:55 +00:00
|
|
|
// named repository and build number
|
2015-04-15 05:04:38 +00:00
|
|
|
Build(string, int) (*common.Build, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// BuildList gets a list of recent builds for the
|
2015-04-07 08:20:55 +00:00
|
|
|
// named repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
BuildList(string) ([]*common.Build, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// BuildLast gets the last executed build for the
|
2015-04-07 08:20:55 +00:00
|
|
|
// named repository.
|
2015-04-15 05:04:38 +00:00
|
|
|
BuildLast(string) (*common.Build, error)
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-29 22:26:22 +00:00
|
|
|
// BuildAgent returns the agent that is being
|
|
|
|
// used to execute the build.
|
|
|
|
// BuildAgent(string, int) (*common.Agent, error)
|
|
|
|
|
2015-04-15 05:04:38 +00:00
|
|
|
// SetBuild inserts or updates a build for the named
|
|
|
|
// repository. The build number is incremented and
|
|
|
|
// assigned to the provided build.
|
|
|
|
SetBuild(string, *common.Build) error
|
2015-04-07 08:20:55 +00:00
|
|
|
|
2015-04-16 06:45:24 +00:00
|
|
|
// SetBuildState updates an existing build's start time,
|
|
|
|
// finish time, duration and state. No other fields are
|
|
|
|
// updated.
|
|
|
|
SetBuildState(string, *common.Build) error
|
|
|
|
|
|
|
|
// SetBuildStatus appends a new build status to an
|
|
|
|
// existing build record.
|
|
|
|
SetBuildStatus(string, int, *common.Status) error
|
|
|
|
|
|
|
|
// SetBuildTask updates an existing build task. The build
|
|
|
|
// and task must already exist. If the task does not exist
|
|
|
|
// an error is returned.
|
|
|
|
SetBuildTask(string, int, *common.Task) error
|
2015-04-29 18:19:39 +00:00
|
|
|
|
2015-04-29 22:26:22 +00:00
|
|
|
// SetBuildAgent insert or updates the agent that is
|
|
|
|
// running a build.
|
|
|
|
// SetBuildAgent(string, int, *common.Agent) error
|
|
|
|
|
|
|
|
// DelBuildAgent purges the referce to the agent
|
|
|
|
// that ran a build.
|
|
|
|
// DelBuildAgent(string, int, *common.Agent) error
|
|
|
|
|
2015-04-29 18:19:39 +00:00
|
|
|
// LogReader gets the task logs at index N for
|
|
|
|
// the named repository and build number.
|
|
|
|
LogReader(string, int, int) (io.Reader, error)
|
|
|
|
|
|
|
|
// SetLogs inserts or updates a task logs for the
|
|
|
|
// named repository and build number.
|
|
|
|
SetLogs(string, int, int, []byte) error
|
2015-04-07 08:20:55 +00:00
|
|
|
}
|