2018-02-20 00:24:10 +02:00
|
|
|
// Copyright 2018 Drone.IO Inc.
|
2018-03-21 15:02:17 +02:00
|
|
|
//
|
2018-02-20 00:24:10 +02:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2018-03-21 15:02:17 +02:00
|
|
|
//
|
2018-02-20 00:24:10 +02:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2018-03-21 15:02:17 +02:00
|
|
|
//
|
2018-02-20 00:24:10 +02:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2015-10-22 01:14:02 +02:00
|
|
|
package store
|
|
|
|
|
2016-03-25 21:54:16 +02:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2021-10-12 09:25:13 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
2016-03-25 21:54:16 +02:00
|
|
|
)
|
|
|
|
|
2021-11-13 21:18:06 +02:00
|
|
|
// TODO: CreateX func should return new object to not indirect let storage change an existing object (alter ID etc...)
|
|
|
|
|
2015-10-22 01:14:02 +02:00
|
|
|
type Store interface {
|
2016-03-25 21:54:16 +02:00
|
|
|
// GetUser gets a user by unique ID.
|
|
|
|
GetUser(int64) (*model.User, error)
|
|
|
|
|
|
|
|
// GetUserLogin gets a user by unique Login name.
|
|
|
|
GetUserLogin(string) (*model.User, error)
|
|
|
|
|
|
|
|
// GetUserList gets a list of all users in the system.
|
2021-11-13 21:18:06 +02:00
|
|
|
// TODO: paginate
|
2016-03-25 21:54:16 +02:00
|
|
|
GetUserList() ([]*model.User, error)
|
|
|
|
|
|
|
|
// GetUserCount gets a count of all users in the system.
|
2021-11-13 21:18:06 +02:00
|
|
|
GetUserCount() (int64, error)
|
2016-03-25 21:54:16 +02:00
|
|
|
|
|
|
|
// CreateUser creates a new user account.
|
|
|
|
CreateUser(*model.User) error
|
|
|
|
|
|
|
|
// UpdateUser updates a user account.
|
|
|
|
UpdateUser(*model.User) error
|
|
|
|
|
|
|
|
// DeleteUser deletes a user account.
|
|
|
|
DeleteUser(*model.User) error
|
|
|
|
|
|
|
|
// GetRepo gets a repo by unique ID.
|
|
|
|
GetRepo(int64) (*model.Repo, error)
|
|
|
|
|
|
|
|
// GetRepoName gets a repo by its full name.
|
|
|
|
GetRepoName(string) (*model.Repo, error)
|
|
|
|
|
|
|
|
// GetRepoCount gets a count of all repositories in the system.
|
2021-11-13 21:18:06 +02:00
|
|
|
GetRepoCount() (int64, error)
|
2016-03-25 21:54:16 +02:00
|
|
|
|
|
|
|
// CreateRepo creates a new repository.
|
|
|
|
CreateRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// UpdateRepo updates a user repository.
|
|
|
|
UpdateRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// DeleteRepo deletes a user repository.
|
|
|
|
DeleteRepo(*model.Repo) error
|
|
|
|
|
|
|
|
// GetBuild gets a build by unique ID.
|
|
|
|
GetBuild(int64) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildNumber gets a build by number.
|
2021-11-13 21:18:06 +02:00
|
|
|
GetBuildNumber(*model.Repo, int64) (*model.Build, error)
|
2016-03-25 21:54:16 +02:00
|
|
|
|
|
|
|
// GetBuildRef gets a build by its ref.
|
|
|
|
GetBuildRef(*model.Repo, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildCommit gets a build by its commit sha.
|
|
|
|
GetBuildCommit(*model.Repo, string, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildLast gets the last build for the branch.
|
|
|
|
GetBuildLast(*model.Repo, string) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildLastBefore gets the last build before build number N.
|
|
|
|
GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error)
|
|
|
|
|
|
|
|
// GetBuildList gets a list of builds for the repository
|
2021-11-13 21:18:06 +02:00
|
|
|
// TODO: paginate
|
2018-02-02 21:03:40 +02:00
|
|
|
GetBuildList(*model.Repo, int) ([]*model.Build, error)
|
2016-03-25 21:54:16 +02:00
|
|
|
|
2016-05-11 07:19:45 +02:00
|
|
|
// GetBuildQueue gets a list of build in queue.
|
|
|
|
GetBuildQueue() ([]*model.Feed, error)
|
|
|
|
|
2017-07-25 21:32:22 +02:00
|
|
|
// GetBuildCount gets a count of all builds in the system.
|
2021-11-13 21:18:06 +02:00
|
|
|
GetBuildCount() (int64, error)
|
2017-07-25 21:32:22 +02:00
|
|
|
|
2016-03-25 21:54:16 +02:00
|
|
|
// CreateBuild creates a new build and jobs.
|
2017-04-02 16:13:26 +02:00
|
|
|
CreateBuild(*model.Build, ...*model.Proc) error
|
2016-03-25 21:54:16 +02:00
|
|
|
|
|
|
|
// UpdateBuild updates a build.
|
|
|
|
UpdateBuild(*model.Build) error
|
|
|
|
|
2017-04-02 16:13:26 +02:00
|
|
|
//
|
2017-04-11 19:06:45 +02:00
|
|
|
// new functions
|
2017-04-02 16:13:26 +02:00
|
|
|
//
|
2016-05-11 23:37:56 +02:00
|
|
|
|
2017-07-14 21:58:38 +02:00
|
|
|
UserFeed(*model.User) ([]*model.Feed, error)
|
|
|
|
|
2021-11-13 21:18:06 +02:00
|
|
|
// RepoList TODO: paginate
|
2021-10-26 21:29:30 +02:00
|
|
|
RepoList(user *model.User, owned bool) ([]*model.Repo, error)
|
2021-11-13 21:18:06 +02:00
|
|
|
RepoListLatest(*model.User) ([]*model.Feed, error)
|
2021-11-18 16:42:18 +02:00
|
|
|
// RepoBatch Sync batch of repos from SCM (with permissions) to store (create if not exist else update)
|
2017-07-14 21:58:38 +02:00
|
|
|
RepoBatch([]*model.Repo) error
|
|
|
|
|
|
|
|
PermFind(user *model.User, repo *model.Repo) (*model.Perm, error)
|
|
|
|
PermUpsert(perm *model.Perm) error
|
|
|
|
PermDelete(perm *model.Perm) error
|
2017-07-16 19:37:16 +02:00
|
|
|
PermFlush(user *model.User, before int64) error
|
2017-07-14 21:58:38 +02:00
|
|
|
|
2019-06-11 10:50:50 +02:00
|
|
|
ConfigsForBuild(buildID int64) ([]*model.Config, error)
|
2021-11-13 21:18:06 +02:00
|
|
|
ConfigFindIdentical(repoID int64, hash string) (*model.Config, error)
|
2017-05-05 20:05:42 +02:00
|
|
|
ConfigFindApproved(*model.Config) (bool, error)
|
|
|
|
ConfigCreate(*model.Config) error
|
2019-06-11 10:50:50 +02:00
|
|
|
BuildConfigCreate(*model.BuildConfig) error
|
2017-05-05 18:59:37 +02:00
|
|
|
|
2017-04-11 19:06:45 +02:00
|
|
|
SenderFind(*model.Repo, string) (*model.Sender, error)
|
2021-11-13 21:18:06 +02:00
|
|
|
// SenderList TODO: paginate
|
2017-04-11 19:06:45 +02:00
|
|
|
SenderList(*model.Repo) ([]*model.Sender, error)
|
|
|
|
SenderCreate(*model.Sender) error
|
|
|
|
SenderUpdate(*model.Sender) error
|
|
|
|
SenderDelete(*model.Sender) error
|
|
|
|
|
|
|
|
SecretFind(*model.Repo, string) (*model.Secret, error)
|
|
|
|
SecretList(*model.Repo) ([]*model.Secret, error)
|
|
|
|
SecretCreate(*model.Secret) error
|
|
|
|
SecretUpdate(*model.Secret) error
|
|
|
|
SecretDelete(*model.Secret) error
|
2016-05-11 23:37:56 +02:00
|
|
|
|
2017-04-06 14:51:01 +02:00
|
|
|
RegistryFind(*model.Repo, string) (*model.Registry, error)
|
|
|
|
RegistryList(*model.Repo) ([]*model.Registry, error)
|
|
|
|
RegistryCreate(*model.Registry) error
|
|
|
|
RegistryUpdate(*model.Registry) error
|
|
|
|
RegistryDelete(*model.Registry) error
|
2017-03-28 10:53:06 +02:00
|
|
|
|
2017-04-01 13:17:04 +02:00
|
|
|
ProcLoad(int64) (*model.Proc, error)
|
2017-03-28 10:53:06 +02:00
|
|
|
ProcFind(*model.Build, int) (*model.Proc, error)
|
|
|
|
ProcChild(*model.Build, int, string) (*model.Proc, error)
|
|
|
|
ProcList(*model.Build) ([]*model.Proc, error)
|
|
|
|
ProcCreate([]*model.Proc) error
|
|
|
|
ProcUpdate(*model.Proc) error
|
2017-04-04 12:50:15 +02:00
|
|
|
ProcClear(*model.Build) error
|
2017-03-28 10:53:06 +02:00
|
|
|
|
2017-04-03 11:34:37 +02:00
|
|
|
LogFind(*model.Proc) (io.ReadCloser, error)
|
2021-11-13 21:18:06 +02:00
|
|
|
// TODO: since we do ReadAll in any case a ioReader is not the best idear
|
|
|
|
// so either find a way to write log in chunks by xorm ...
|
2017-04-03 11:34:37 +02:00
|
|
|
LogSave(*model.Proc, io.Reader) error
|
|
|
|
|
2017-03-28 10:53:06 +02:00
|
|
|
FileList(*model.Build) ([]*model.File, error)
|
|
|
|
FileFind(*model.Proc, string) (*model.File, error)
|
|
|
|
FileRead(*model.Proc, string) (io.ReadCloser, error)
|
|
|
|
FileCreate(*model.File, io.Reader) error
|
2017-04-14 13:32:36 +02:00
|
|
|
|
2021-11-13 21:18:06 +02:00
|
|
|
// TaskList TODO: paginate & opt filter
|
2017-04-14 13:32:36 +02:00
|
|
|
TaskList() ([]*model.Task, error)
|
|
|
|
TaskInsert(*model.Task) error
|
|
|
|
TaskDelete(string) error
|
2017-10-05 23:17:27 +02:00
|
|
|
|
|
|
|
Ping() error
|
2021-11-13 21:18:06 +02:00
|
|
|
Close() error
|
|
|
|
Migrate() error
|
2016-03-25 21:54:16 +02:00
|
|
|
}
|