mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-16 01:19:02 +01:00
Simplify store interfaces (#3437)
Use `store.Store` interface if possible.
This commit is contained in:
@@ -24,11 +24,6 @@ var (
|
||||
errEnvironValueInvalid = errors.New("invalid Environment Variable Value")
|
||||
)
|
||||
|
||||
// EnvironStore persists environment information to storage.
|
||||
type EnvironStore interface {
|
||||
EnvironList(*Repo) ([]*Environ, error)
|
||||
}
|
||||
|
||||
// Environ represents an environment variable.
|
||||
type Environ struct {
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -15,14 +15,6 @@
|
||||
|
||||
package model
|
||||
|
||||
// PermStore persists repository permissions information to storage.
|
||||
type PermStore interface {
|
||||
PermFind(user *User, repo *Repo) (*Perm, error)
|
||||
PermUpsert(perm *Perm) error
|
||||
PermDelete(perm *Perm) error
|
||||
PermFlush(user *User, before int64) error
|
||||
}
|
||||
|
||||
// Perm defines a repository permission for an individual user.
|
||||
type Perm struct {
|
||||
UserID int64 `json:"-" xorm:"UNIQUE(s) INDEX NOT NULL 'perm_user_id'"`
|
||||
|
||||
@@ -63,10 +63,6 @@ func (p Pipeline) IsMultiPipeline() bool {
|
||||
return len(p.Workflows) > 1
|
||||
}
|
||||
|
||||
type UpdatePipelineStore interface {
|
||||
UpdatePipeline(*Pipeline) error
|
||||
}
|
||||
|
||||
type PipelineOptions struct {
|
||||
Branch string `json:"branch"`
|
||||
Variables map[string]string `json:"variables"`
|
||||
|
||||
@@ -26,15 +26,6 @@ var (
|
||||
errRegistryPasswordInvalid = errors.New("invalid registry password")
|
||||
)
|
||||
|
||||
// RegistryStore persists registry information to storage.
|
||||
type RegistryStore interface {
|
||||
RegistryFind(*Repo, string) (*Registry, error)
|
||||
RegistryList(*Repo, *ListOptions) ([]*Registry, error)
|
||||
RegistryCreate(*Registry) error
|
||||
RegistryUpdate(*Registry) error
|
||||
RegistryDelete(repo *Repo, addr string) error
|
||||
}
|
||||
|
||||
// Registry represents a docker registry with credentials.
|
||||
type Registry struct {
|
||||
ID int64 `json:"id" xorm:"pk autoincr 'registry_id'"`
|
||||
|
||||
@@ -14,12 +14,6 @@
|
||||
|
||||
package model
|
||||
|
||||
// ServerConfigStore persists key-value pairs for storing server configurations.
|
||||
type ServerConfigStore interface {
|
||||
ServerConfigGet(key string) (string, error)
|
||||
ServerConfigSet(key int64, value string) error
|
||||
}
|
||||
|
||||
// ServerConfig represents a key-value pair for storing server configurations.
|
||||
type ServerConfig struct {
|
||||
Key string `json:"key" xorm:"pk"`
|
||||
|
||||
@@ -15,16 +15,6 @@
|
||||
|
||||
package model
|
||||
|
||||
// StepStore persists process information to storage.
|
||||
type StepStore interface {
|
||||
StepLoad(int64) (*Step, error)
|
||||
StepFind(*Pipeline, int) (*Step, error)
|
||||
StepChild(*Pipeline, int, string) (*Step, error)
|
||||
StepList(*Pipeline) ([]*Step, error)
|
||||
StepCreate([]*Step) error
|
||||
StepUpdate(*Step) error
|
||||
}
|
||||
|
||||
// Different ways to handle failure states
|
||||
const (
|
||||
FailureIgnore = "ignore"
|
||||
@@ -49,10 +39,6 @@ type Step struct {
|
||||
Type StepType `json:"type,omitempty" xorm:"step_type"`
|
||||
} // @name Step
|
||||
|
||||
type UpdateStepStore interface {
|
||||
StepUpdate(*Step) error
|
||||
}
|
||||
|
||||
// TableName return database table name for xorm
|
||||
func (Step) TableName() string {
|
||||
return "steps"
|
||||
|
||||
@@ -19,13 +19,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TaskStore defines storage for scheduled Tasks.
|
||||
type TaskStore interface {
|
||||
TaskList() ([]*Task, error)
|
||||
TaskInsert(*Task) error
|
||||
TaskDelete(string) error
|
||||
}
|
||||
|
||||
// Task defines scheduled pipeline Task.
|
||||
type Task struct {
|
||||
ID string `json:"id" xorm:"PK UNIQUE 'task_id'"`
|
||||
|
||||
@@ -32,10 +32,6 @@ type Workflow struct {
|
||||
Children []*Step `json:"children,omitempty" xorm:"-"`
|
||||
}
|
||||
|
||||
type UpdateWorkflowStore interface {
|
||||
WorkflowUpdate(*Workflow) error
|
||||
}
|
||||
|
||||
// TableName return database table name for xorm
|
||||
func (Workflow) TableName() string {
|
||||
return "workflows"
|
||||
|
||||
Reference in New Issue
Block a user