model

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailureIgnore = "ignore"
	FailureFail   = "fail"
)

Different ways to handle failure states

Variables

View Source
var (
	ErrSecretNameInvalid  = errors.New("Invalid Secret Name")
	ErrSecretImageInvalid = errors.New("Invalid Secret Image")
	ErrSecretValueInvalid = errors.New("Invalid Secret Value")
	ErrSecretEventInvalid = errors.New("Invalid Secret Event")
)
View Source
var ErrInvalidWebhookEvent = errors.New("invalid webhook event")

Functions

func ApplyPagination

func ApplyPagination[T any](d *ListOptions, slice []T) []T

func IsThereRunningStage

func IsThereRunningStage(workflows []*Workflow) bool

IsThereRunningStage determine if it contains workflows running or pending to run TODO: return false based on depends_on (https://github.com/woodpecker-ci/woodpecker/pull/730#discussion_r795681697)

func ParseRepo

func ParseRepo(str string) (user, repo string, err error)

ParseRepo parses the repository owner and name from a string.

func ValidateWebhookEvent

func ValidateWebhookEvent(s WebhookEvent) error

Types

type Agent

type Agent struct {
	ID          int64  `json:"id"            xorm:"pk autoincr 'id'"`
	Created     int64  `json:"created"       xorm:"created"`
	Updated     int64  `json:"updated"       xorm:"updated"`
	Name        string `json:"name"`
	OwnerID     int64  `json:"owner_id"      xorm:"'owner_id'"`
	Token       string `json:"token"`
	LastContact int64  `json:"last_contact"`
	Platform    string `json:"platform"      xorm:"VARCHAR(100)"`
	Backend     string `json:"backend"       xorm:"VARCHAR(100)"`
	Capacity    int32  `json:"capacity"`
	Version     string `json:"version"`
	NoSchedule  bool   `json:"no_schedule"`

} //	@name Agent

func (*Agent) IsSystemAgent

func (a *Agent) IsSystemAgent() bool

func (Agent) TableName

func (Agent) TableName() string

TableName return database table name for xorm

type Config

type Config struct {
	ID     int64  `json:"-"    xorm:"pk autoincr 'config_id'"`
	RepoID int64  `json:"-"    xorm:"UNIQUE(s) 'config_repo_id'"`
	Hash   string `json:"hash" xorm:"UNIQUE(s) 'config_hash'"`
	Name   string `json:"name" xorm:"config_name"`
	Data   []byte `json:"data" xorm:"config_data"`

} //	@name Config

Config represents a pipeline configuration.

type ConfigStore

type ConfigStore interface {
	ConfigsForPipeline(pipelineID int64) ([]*Config, error)
	ConfigFindIdentical(repoID int64, hash string) (*Config, error)
	ConfigFindApproved(*Config) (bool, error)
	ConfigCreate(*Config) error
	PipelineConfigCreate(*PipelineConfig) error
}

ConfigStore persists pipeline configuration to storage.

type Cron

type Cron struct {
	ID        int64  `json:"id"                  xorm:"pk autoincr"`
	Name      string `json:"name"                xorm:"UNIQUE(s) INDEX"`
	RepoID    int64  `json:"repo_id"             xorm:"repo_id UNIQUE(s) INDEX"`
	CreatorID int64  `json:"creator_id"          xorm:"creator_id INDEX"`
	NextExec  int64  `json:"next_exec"`
	Schedule  string `json:"schedule"            xorm:"NOT NULL"` //	@weekly,	3min, ...
	Created   int64  `json:"created_at"          xorm:"created NOT NULL DEFAULT 0"`
	Branch    string `json:"branch"`

} //	@name Cron

func (Cron) TableName

func (Cron) TableName() string

TableName returns the database table name for xorm

func (*Cron) Validate

func (c *Cron) Validate() error

Validate a cron

type EncryptionBuilder

type EncryptionBuilder interface {
	WithClient(client EncryptionClient) EncryptionBuilder
	Build() error
}

EncryptionBuilder is user API to obtain correctly configured encryption

type EncryptionClient

type EncryptionClient interface {
	// SetEncryptionService should be used only by EncryptionServiceBuilder
	SetEncryptionService(encryption EncryptionService) error
	// EnableEncryption should encrypt all service data
	EnableEncryption() error
	// MigrateEncryption should decrypt all existing data and encrypt it with new encryption service
	MigrateEncryption(newEncryption EncryptionService) error
}

type EncryptionService

type EncryptionService interface {
	Encrypt(plaintext, associatedData string) (string, error)
	Decrypt(ciphertext, associatedData string) (string, error)
	Disable() error
}

type EncryptionServiceBuilder

type EncryptionServiceBuilder interface {
	WithClients(clients []EncryptionClient) EncryptionServiceBuilder
	Build() (EncryptionService, error)
}

type Environ

type Environ struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

Environ represents an environment variable.

func (*Environ) Copy

func (e *Environ) Copy() *Environ

Copy makes a copy of the environment variable without the value.

func (*Environ) Validate

func (e *Environ) Validate() error

Validate validates the required fields and formats.

type EnvironService

type EnvironService interface {
	EnvironList(*Repo) ([]*Environ, error)
}

EnvironService defines a service for managing environment variables.

type EnvironStore

type EnvironStore interface {
	EnvironList(*Repo) ([]*Environ, error)
}

EnvironStore persists environment information to storage.

type Event

type Event struct {
	Repo     Repo     `json:"repo"`
	Pipeline Pipeline `json:"pipeline"`
}

Event represents a pipeline event.

type EventType

type EventType string

EventType defines the possible types of pipeline events.

type Feed

type Feed struct {
	RepoID   int64  `json:"repo_id"                 xorm:"feed_repo_id"`
	ID       int64  `json:"id,omitempty"            xorm:"feed_pipeline_id"`
	Number   int64  `json:"number,omitempty"        xorm:"feed_pipeline_number"`
	Event    string `json:"event,omitempty"         xorm:"feed_pipeline_event"`
	Status   string `json:"status,omitempty"        xorm:"feed_pipeline_status"`
	Created  int64  `json:"created_at,omitempty"    xorm:"feed_pipeline_created"`
	Started  int64  `json:"started_at,omitempty"    xorm:"feed_pipeline_started"`
	Finished int64  `json:"finished_at,omitempty"   xorm:"feed_pipeline_finished"`
	Commit   string `json:"commit,omitempty"        xorm:"feed_pipeline_commit"`
	Branch   string `json:"branch,omitempty"        xorm:"feed_pipeline_branch"`
	Ref      string `json:"ref,omitempty"           xorm:"feed_pipeline_ref"`
	Refspec  string `json:"refspec,omitempty"       xorm:"feed_pipeline_refspec"`
	Remote   string `json:"remote,omitempty"        xorm:"feed_pipeline_clone_url"`
	Title    string `json:"title,omitempty"         xorm:"feed_pipeline_title"`
	Message  string `json:"message,omitempty"       xorm:"feed_pipeline_message"`
	Author   string `json:"author,omitempty"        xorm:"feed_pipeline_author"`
	Avatar   string `json:"author_avatar,omitempty" xorm:"feed_pipeline_avatar"`
	Email    string `json:"author_email,omitempty"  xorm:"feed_pipeline_email"`

} //	@name Feed

Feed represents an item in the user's feed or timeline.

type ForgeRemoteID

type ForgeRemoteID string

func (ForgeRemoteID) IsValid

func (r ForgeRemoteID) IsValid() bool

type ListOptions

type ListOptions struct {
	All     bool
	Page    int
	PerPage int
}

type LogEntry

type LogEntry struct {
	ID      int64        `json:"id"       xorm:"pk autoincr 'id'"`
	StepID  int64        `json:"step_id"  xorm:"INDEX 'step_id'"`
	Time    int64        `json:"time"`
	Line    int          `json:"line"`
	Data    []byte       `json:"data"     xorm:"LONGBLOB"`
	Created int64        `json:"-"        xorm:"created"`
	Type    LogEntryType `json:"type"`

} //	@name LogEntry

func (LogEntry) TableName

func (LogEntry) TableName() string

type LogEntryType

type LogEntryType int // @name	LogEntryType

LogEntryType identifies the type of line in the logs.

const (
	LogEntryStdout LogEntryType = iota
	LogEntryStderr
	LogEntryExitCode
	LogEntryMetadata
	LogEntryProgress
)

type Netrc

type Netrc struct {
	Machine  string `json:"machine"`
	Login    string `json:"login"`
	Password string `json:"password"`
}

type Org

type Org struct {
	ID     int64  `json:"id,omitempty"   xorm:"pk autoincr 'id'"`
	Name   string `json:"name"           xorm:"UNIQUE 'name'"`
	IsUser bool   `json:"is_user"        xorm:"is_user"`
	// if name lookup has to check for membership or not
	Private bool `json:"-"              xorm:"private"`

} //	@name Org

Org represents an organization.

func (Org) TableName

func (Org) TableName() string

TableName return database table name for xorm

type OrgPerm

type OrgPerm struct {
	Member bool `json:"member"`
	Admin  bool `json:"admin"`

} //	@name OrgPerm

OrgPerm defines an organization permission for an individual user.

type Perm

type Perm struct {
	UserID  int64 `json:"-"       xorm:"UNIQUE(s) INDEX NOT NULL 'perm_user_id'"`
	RepoID  int64 `json:"-"       xorm:"UNIQUE(s) INDEX NOT NULL 'perm_repo_id'"`
	Repo    *Repo `json:"-"       xorm:"-"`
	Pull    bool  `json:"pull"    xorm:"perm_pull"`
	Push    bool  `json:"push"    xorm:"perm_push"`
	Admin   bool  `json:"admin"   xorm:"perm_admin"`
	Synced  int64 `json:"synced"  xorm:"perm_synced"`
	Created int64 `json:"created" xorm:"created"`
	Updated int64 `json:"updated" xorm:"updated"`

} //	@name Perm

Perm defines a repository permission for an individual user.

func (Perm) TableName

func (Perm) TableName() string

TableName return database table name for xorm

type PermStore

type PermStore interface {
	PermFind(user *User, repo *Repo) (*Perm, error)
	PermUpsert(perm *Perm) error
	PermDelete(perm *Perm) error
	PermFlush(user *User, before int64) error
}

PermStore persists repository permissions information to storage.

type Pipeline

type Pipeline struct {
	ID                  int64             `json:"id"                      xorm:"pk autoincr 'pipeline_id'"`
	RepoID              int64             `json:"-"                       xorm:"UNIQUE(s) INDEX 'pipeline_repo_id'"`
	Number              int64             `json:"number"                  xorm:"UNIQUE(s) 'pipeline_number'"`
	Author              string            `json:"author"                  xorm:"INDEX 'pipeline_author'"`
	ConfigID            int64             `json:"-"                       xorm:"pipeline_config_id"`
	Parent              int64             `json:"parent"                  xorm:"pipeline_parent"`
	Event               WebhookEvent      `json:"event"                   xorm:"pipeline_event"`
	Status              StatusValue       `json:"status"                  xorm:"INDEX 'pipeline_status'"`
	Error               string            `json:"error"                   xorm:"LONGTEXT 'pipeline_error'"`
	Enqueued            int64             `json:"enqueued_at"             xorm:"pipeline_enqueued"`
	Created             int64             `json:"created_at"              xorm:"pipeline_created"`
	Updated             int64             `json:"updated_at"              xorm:"updated NOT NULL DEFAULT 0 'updated'"`
	Started             int64             `json:"started_at"              xorm:"pipeline_started"`
	Finished            int64             `json:"finished_at"             xorm:"pipeline_finished"`
	Deploy              string            `json:"deploy_to"               xorm:"pipeline_deploy"`
	Commit              string            `json:"commit"                  xorm:"pipeline_commit"`
	Branch              string            `json:"branch"                  xorm:"pipeline_branch"`
	Ref                 string            `json:"ref"                     xorm:"pipeline_ref"`
	Refspec             string            `json:"refspec"                 xorm:"pipeline_refspec"`
	CloneURL            string            `json:"clone_url"               xorm:"pipeline_clone_url"`
	Title               string            `json:"title"                   xorm:"pipeline_title"`
	Message             string            `json:"message"                 xorm:"TEXT 'pipeline_message'"`
	Timestamp           int64             `json:"timestamp"               xorm:"pipeline_timestamp"`
	Sender              string            `json:"sender"                  xorm:"pipeline_sender"` // uses reported user for webhooks and name of cron for cron pipelines
	Avatar              string            `json:"author_avatar"           xorm:"pipeline_avatar"`
	Email               string            `json:"author_email"            xorm:"pipeline_email"`
	Link                string            `json:"link_url"                xorm:"pipeline_link"`
	Reviewer            string            `json:"reviewed_by"             xorm:"pipeline_reviewer"`
	Reviewed            int64             `json:"reviewed_at"             xorm:"pipeline_reviewed"`
	Workflows           []*Workflow       `json:"workflows,omitempty"     xorm:"-"`
	ChangedFiles        []string          `json:"changed_files,omitempty" xorm:"LONGTEXT 'changed_files'"`
	AdditionalVariables map[string]string `json:"variables,omitempty"     xorm:"json 'additional_variables'"`
	PullRequestLabels   []string          `json:"pr_labels,omitempty"     xorm:"json 'pr_labels'"`

} //	@name Pipeline

func (Pipeline) IsMultiPipeline

func (p Pipeline) IsMultiPipeline() bool

IsMultiPipeline checks if step list contain more than one parent step

func (Pipeline) TableName

func (Pipeline) TableName() string

TableName return database table name for xorm

type PipelineConfig

type PipelineConfig struct {
	ConfigID   int64 `json:"-"   xorm:"UNIQUE(s) NOT NULL 'config_id'"`
	PipelineID int64 `json:"-"   xorm:"UNIQUE(s) NOT NULL 'pipeline_id'"`
}

PipelineConfig is the n:n relation between Pipeline and Config

type PipelineOptions

type PipelineOptions struct {
	Branch    string            `json:"branch"`
	Variables map[string]string `json:"variables"`

} //	@name PipelineOptions

type PullRequest

type PullRequest struct {
	Index int64  `json:"index"`
	Title string `json:"title"`

} //	@name PullRequest

type ReadOnlyRegistryService

type ReadOnlyRegistryService interface {
	RegistryFind(*Repo, string) (*Registry, error)
	RegistryList(*Repo, *ListOptions) ([]*Registry, error)
}

ReadOnlyRegistryService defines a service for managing registries.

type Redirection

type Redirection struct {
	ID       int64  `xorm:"pk autoincr 'redirection_id'"`
	RepoID   int64  `xorm:"'repo_id'"`
	FullName string `xorm:"UNIQUE INDEX 'repo_full_name'"`
}

func (Redirection) TableName

func (r Redirection) TableName() string

type Registry

type Registry struct {
	ID       int64  `json:"id"       xorm:"pk autoincr 'registry_id'"`
	RepoID   int64  `json:"-"        xorm:"UNIQUE(s) INDEX 'registry_repo_id'"`
	Address  string `json:"address"  xorm:"UNIQUE(s) INDEX 'registry_addr'"`
	Username string `json:"username" xorm:"varchar(2000) 'registry_username'"`
	Password string `json:"password" xorm:"TEXT 'registry_password'"`
	Token    string `json:"token"    xorm:"TEXT 'registry_token'"`
	Email    string `json:"email"    xorm:"varchar(500) 'registry_email'"`

} //	@name Registry

Registry represents a docker registry with credentials.

func (*Registry) Copy

func (r *Registry) Copy() *Registry

Copy makes a copy of the registry without the password.

func (*Registry) Validate

func (r *Registry) Validate() error

Validate validates the registry information.

type RegistryService

type RegistryService interface {
	RegistryFind(*Repo, string) (*Registry, error)
	RegistryList(*Repo, *ListOptions) ([]*Registry, error)
	RegistryCreate(*Repo, *Registry) error
	RegistryUpdate(*Repo, *Registry) error
	RegistryDelete(*Repo, string) error
}

RegistryService defines a service for managing registries.

type RegistryStore

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
}

RegistryStore persists registry information to storage.

type Repo

type Repo struct {
	ID     int64 `json:"id,omitempty"                    xorm:"pk autoincr 'repo_id'"`
	UserID int64 `json:"-"                               xorm:"repo_user_id"`
	// ForgeRemoteID is the unique identifier for the repository on the forge.
	ForgeRemoteID                ForgeRemoteID  `json:"forge_remote_id"                 xorm:"forge_remote_id"`
	OrgID                        int64          `json:"org_id"                          xorm:"repo_org_id"`
	Owner                        string         `json:"owner"                           xorm:"UNIQUE(name) 'repo_owner'"`
	Name                         string         `json:"name"                            xorm:"UNIQUE(name) 'repo_name'"`
	FullName                     string         `json:"full_name"                       xorm:"UNIQUE 'repo_full_name'"`
	Avatar                       string         `json:"avatar_url,omitempty"            xorm:"varchar(500) 'repo_avatar'"`
	Link                         string         `json:"link_url,omitempty"              xorm:"varchar(1000) 'repo_link'"`
	Clone                        string         `json:"clone_url,omitempty"             xorm:"varchar(1000) 'repo_clone'"`
	Branch                       string         `json:"default_branch,omitempty"        xorm:"varchar(500) 'repo_branch'"`
	SCMKind                      SCMKind        `json:"scm,omitempty"                   xorm:"varchar(50) 'repo_scm'"`
	Timeout                      int64          `json:"timeout,omitempty"               xorm:"repo_timeout"`
	Visibility                   RepoVisibility `json:"visibility"                      xorm:"varchar(10) 'repo_visibility'"`
	IsSCMPrivate                 bool           `json:"private"                         xorm:"repo_private"`
	IsTrusted                    bool           `json:"trusted"                         xorm:"repo_trusted"`
	IsGated                      bool           `json:"gated"                           xorm:"repo_gated"`
	IsActive                     bool           `json:"active"                          xorm:"repo_active"`
	AllowPull                    bool           `json:"allow_pr"                        xorm:"repo_allow_pr"`
	Config                       string         `json:"config_file"                     xorm:"varchar(500) 'repo_config_path'"`
	Hash                         string         `json:"-"                               xorm:"varchar(500) 'repo_hash'"`
	Perm                         *Perm          `json:"-"                               xorm:"-"`
	CancelPreviousPipelineEvents []WebhookEvent `json:"cancel_previous_pipeline_events" xorm:"json 'cancel_previous_pipeline_events'"`
	NetrcOnlyTrusted             bool           `json:"netrc_only_trusted"              xorm:"NOT NULL DEFAULT true 'netrc_only_trusted'"`

} //	@name Repo

Repo represents a repository.

func (*Repo) ResetVisibility

func (r *Repo) ResetVisibility()

func (Repo) TableName

func (Repo) TableName() string

TableName return database table name for xorm

func (*Repo) Update

func (r *Repo) Update(from *Repo)

Update updates the repository with values from the given Repo.

type RepoPatch

type RepoPatch struct {
	Config                       *string         `json:"config_file,omitempty"`
	IsTrusted                    *bool           `json:"trusted,omitempty"`
	IsGated                      *bool           `json:"gated,omitempty"`
	Timeout                      *int64          `json:"timeout,omitempty"`
	Visibility                   *string         `json:"visibility,omitempty"`
	AllowPull                    *bool           `json:"allow_pr,omitempty"`
	CancelPreviousPipelineEvents *[]WebhookEvent `json:"cancel_previous_pipeline_events"`
	NetrcOnlyTrusted             *bool           `json:"netrc_only_trusted"`

} //	@name RepoPatch

RepoPatch represents a repository patch object.

type RepoVisibility

type RepoVisibility string //	@name RepoVisibility

RepoVisibility represent to wat state a repo in woodpecker is visible to others

const (
	VisibilityPublic   RepoVisibility = "public"
	VisibilityPrivate  RepoVisibility = "private"
	VisibilityInternal RepoVisibility = "internal"
)

type ResourceLimit

type ResourceLimit struct {
	MemSwapLimit int64
	MemLimit     int64
	ShmSize      int64
	CPUQuota     int64
	CPUShares    int64
	CPUSet       string
}

ResourceLimit is the resource limit to set on pipeline steps

type SCMKind

type SCMKind string //	@name SCMKind

SCMKind represent different version control systems

const (
	RepoGit      SCMKind = "git"
	RepoHg       SCMKind = "hg"
	RepoFossil   SCMKind = "fossil"
	RepoPerforce SCMKind = "perforce"
)

type Secret

type Secret struct {
	ID          int64          `json:"id"              xorm:"pk autoincr 'secret_id'"`
	OrgID       int64          `json:"-"               xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'secret_org_id'"`
	RepoID      int64          `json:"-"               xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'secret_repo_id'"`
	Name        string         `json:"name"            xorm:"NOT NULL UNIQUE(s) INDEX 'secret_name'"`
	Value       string         `json:"value,omitempty" xorm:"TEXT 'secret_value'"`
	Images      []string       `json:"image"           xorm:"json 'secret_images'"`
	PluginsOnly bool           `json:"plugins_only"    xorm:"secret_plugins_only"`
	Events      []WebhookEvent `json:"event"           xorm:"json 'secret_events'"`
	SkipVerify  bool           `json:"-"               xorm:"secret_skip_verify"`
	Conceal     bool           `json:"-"               xorm:"secret_conceal"`

} //	@name Secret

Secret represents a secret variable, such as a password or token.

func (*Secret) BeforeInsert

func (s *Secret) BeforeInsert()

BeforeInsert will sort events before inserted into database

func (*Secret) Copy

func (s *Secret) Copy() *Secret

Copy makes a copy of the secret without the value.

func (Secret) Global

func (s Secret) Global() bool

Global secret.

func (*Secret) Match

func (s *Secret) Match(event WebhookEvent) bool

Match returns true if an image and event match the restricted list.

func (Secret) Organization

func (s Secret) Organization() bool

Organization secret.

func (Secret) TableName

func (Secret) TableName() string

TableName return database table name for xorm

func (*Secret) Validate

func (s *Secret) Validate() error

Validate validates the required fields and formats.

type SecretService

type SecretService interface {
	SecretListPipeline(*Repo, *Pipeline, *ListOptions) ([]*Secret, error)
	// Repository secrets
	SecretFind(*Repo, string) (*Secret, error)
	SecretList(*Repo, *ListOptions) ([]*Secret, error)
	SecretCreate(*Repo, *Secret) error
	SecretUpdate(*Repo, *Secret) error
	SecretDelete(*Repo, string) error
	// Organization secrets
	OrgSecretFind(int64, string) (*Secret, error)
	OrgSecretList(int64, *ListOptions) ([]*Secret, error)
	OrgSecretCreate(int64, *Secret) error
	OrgSecretUpdate(int64, *Secret) error
	OrgSecretDelete(int64, string) error
	// Global secrets
	GlobalSecretFind(string) (*Secret, error)
	GlobalSecretList(*ListOptions) ([]*Secret, error)
	GlobalSecretCreate(*Secret) error
	GlobalSecretUpdate(*Secret) error
	GlobalSecretDelete(string) error
}

SecretService defines a service for managing secrets.

type SecretStore

type SecretStore interface {
	SecretFind(*Repo, string) (*Secret, error)
	SecretList(*Repo, bool, *ListOptions) ([]*Secret, error)
	SecretCreate(*Secret) error
	SecretUpdate(*Secret) error
	SecretDelete(*Secret) error
	OrgSecretFind(int64, string) (*Secret, error)
	OrgSecretList(int64, *ListOptions) ([]*Secret, error)
	GlobalSecretFind(string) (*Secret, error)
	GlobalSecretList(*ListOptions) ([]*Secret, error)
	SecretListAll() ([]*Secret, error)
}

SecretStore persists secret information to storage.

type ServerConfig

type ServerConfig struct {
	Key   string `json:"key"   xorm:"pk"`
	Value string `json:"value" xorm:""`
}

ServerConfig represents a key-value pair for storing server configurations.

type ServerConfigStore

type ServerConfigStore interface {
	ServerConfigGet(key string) (string, error)
	ServerConfigSet(key int64, value string) error
}

ServerConfigStore persists key-value pairs for storing server configurations.

type Settings

type Settings struct {
	Open            bool            // Enables open registration
	Admins          map[string]bool // Administrative users
	Orgs            map[string]bool // Organization whitelist
	OwnersWhitelist map[string]bool // Owners whitelist
}

Settings defines system configuration parameters.

func (*Settings) IsAdmin

func (c *Settings) IsAdmin(user *User) bool

IsAdmin returns true if the user is a member of the administrator list.

func (*Settings) IsMember

func (c *Settings) IsMember(teams []*Team) bool

IsMember returns true if the user is a member of the whitelisted teams.

type StatusValue

type StatusValue string //	@name StatusValue

StatusValue represent pipeline states woodpecker know

const (
	StatusSkipped  StatusValue = "skipped"
	StatusPending  StatusValue = "pending"
	StatusRunning  StatusValue = "running"
	StatusSuccess  StatusValue = "success"
	StatusFailure  StatusValue = "failure"
	StatusKilled   StatusValue = "killed"
	StatusError    StatusValue = "error"
	StatusBlocked  StatusValue = "blocked"
	StatusDeclined StatusValue = "declined"
)

func PipelineStatus

func PipelineStatus(workflows []*Workflow) StatusValue

PipelineStatus determine pipeline status based on corresponding workflow list

func WorkflowStatus

func WorkflowStatus(steps []*Step) StatusValue

WorkflowStatus determine workflow status based on corresponding step list

type Step

type Step struct {
	ID         int64       `json:"id"                   xorm:"pk autoincr 'step_id'"`
	UUID       string      `json:"uuid"                 xorm:"INDEX 'step_uuid'"`
	PipelineID int64       `json:"pipeline_id"          xorm:"UNIQUE(s) INDEX 'step_pipeline_id'"`
	PID        int         `json:"pid"                  xorm:"UNIQUE(s) 'step_pid'"`
	PPID       int         `json:"ppid"                 xorm:"step_ppid"`
	Name       string      `json:"name"                 xorm:"step_name"`
	State      StatusValue `json:"state"                xorm:"step_state"`
	Error      string      `json:"error,omitempty"      xorm:"TEXT 'step_error'"`
	Failure    string      `json:"-"                    xorm:"step_failure"`
	ExitCode   int         `json:"exit_code"            xorm:"step_exit_code"`
	Started    int64       `json:"start_time,omitempty" xorm:"step_started"`
	Stopped    int64       `json:"end_time,omitempty"   xorm:"step_stopped"`
	Type       StepType    `json:"type,omitempty"       xorm:"step_type"`

} //	@name Step

Step represents a process in the pipeline.

func (*Step) Failing

func (p *Step) Failing() bool

Failing returns true if the process state is failed, killed or error.

func (*Step) Running

func (p *Step) Running() bool

Running returns true if the process state is pending or running.

func (Step) TableName

func (Step) TableName() string

TableName return database table name for xorm

type StepStore

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
	StepClear(*Pipeline) error
}

StepStore persists process information to storage.

type StepType

type StepType string //	@name StepType

StepType identifies the type of step

const (
	StepTypeClone    StepType = "clone"
	StepTypeService  StepType = "service"
	StepTypePlugin   StepType = "plugin"
	StepTypeCommands StepType = "commands"
	StepTypeCache    StepType = "cache"
)

type Task

type Task struct {
	ID           string                 `json:"id"           xorm:"PK UNIQUE 'task_id'"`
	Data         []byte                 `json:"data"         xorm:"'task_data'"`
	Labels       map[string]string      `json:"labels"       xorm:"json 'task_labels'"`
	Dependencies []string               `json:"dependencies" xorm:"json 'task_dependencies'"`
	RunOn        []string               `json:"run_on"       xorm:"json 'task_run_on'"`
	DepStatus    map[string]StatusValue `json:"dep_status"   xorm:"json 'task_dep_status'"`
	AgentID      int64                  `json:"agent_id"     xorm:"'agent_id'"`

} //	@name Task

Task defines scheduled pipeline Task.

func (*Task) ShouldRun

func (t *Task) ShouldRun() bool

ShouldRun tells if a task should be run or skipped, based on dependencies

func (*Task) String

func (t *Task) String() string

func (Task) TableName

func (Task) TableName() string

TableName return database table name for xorm

type TaskStore

type TaskStore interface {
	TaskList() ([]*Task, error)
	TaskInsert(*Task) error
	TaskDelete(string) error
}

TaskStore defines storage for scheduled Tasks.

type Team

type Team struct {
	// Login is the username for this team.
	Login string `json:"login"`

	// the avatar url for this team.
	Avatar string `json:"avatar_url"`
}

Team represents a team or organization in the forge.

type UpdatePipelineStore

type UpdatePipelineStore interface {
	UpdatePipeline(*Pipeline) error
}

type UpdateStepStore

type UpdateStepStore interface {
	StepUpdate(*Step) error
}

type UpdateWorkflowStore

type UpdateWorkflowStore interface {
	WorkflowUpdate(*Workflow) error
}

type User

type User struct {
	// the id for this user.
	//
	// required: true
	ID int64 `json:"id" xorm:"pk autoincr 'user_id'"`

	ForgeRemoteID ForgeRemoteID `json:"-" xorm:"forge_remote_id"`

	// Login is the username for this user.
	//
	// required: true
	Login string `json:"login"  xorm:"UNIQUE 'user_login'"`

	// Token is the oauth2 token.
	Token string `json:"-"  xorm:"TEXT 'user_token'"`

	// Secret is the oauth2 token secret.
	Secret string `json:"-" xorm:"TEXT 'user_secret'"`

	// Expiry is the token and secret expiration timestamp.
	Expiry int64 `json:"-" xorm:"user_expiry"`

	// Email is the email address for this user.
	//
	// required: true
	Email string `json:"email" xorm:" varchar(500) 'user_email'"`

	// the avatar url for this user.
	Avatar string `json:"avatar_url" xorm:" varchar(500) 'user_avatar'"`

	// Admin indicates the user is a system administrator.
	//
	// NOTE: If the username is part of the WOODPECKER_ADMIN
	// environment variable this value will be set to true on login.
	Admin bool `json:"admin,omitempty" xorm:"user_admin"`

	// Hash is a unique token used to sign tokens.
	Hash string `json:"-" xorm:"UNIQUE varchar(500) 'user_hash'"`

} //	@name User

User represents a registered user.

func (User) TableName

func (User) TableName() string

TableName return database table name for xorm

func (*User) Validate

func (u *User) Validate() error

Validate validates the required fields and formats.

type WebhookEvent

type WebhookEvent string //	@name WebhookEvent
const (
	EventPush   WebhookEvent = "push"
	EventPull   WebhookEvent = "pull_request"
	EventTag    WebhookEvent = "tag"
	EventDeploy WebhookEvent = "deployment"
	EventCron   WebhookEvent = "cron"
	EventManual WebhookEvent = "manual"
)

type WebhookEventList

type WebhookEventList []WebhookEvent

func (WebhookEventList) Len

func (wel WebhookEventList) Len() int

func (WebhookEventList) Less

func (wel WebhookEventList) Less(i, j int) bool

func (WebhookEventList) Swap

func (wel WebhookEventList) Swap(i, j int)

type Workflow

type Workflow struct {
	ID         int64             `json:"id"                   xorm:"pk autoincr 'workflow_id'"`
	PipelineID int64             `json:"pipeline_id"          xorm:"UNIQUE(s) INDEX 'workflow_pipeline_id'"`
	PID        int               `json:"pid"                  xorm:"UNIQUE(s) 'workflow_pid'"`
	Name       string            `json:"name"                 xorm:"workflow_name"`
	State      StatusValue       `json:"state"                xorm:"workflow_state"`
	Error      string            `json:"error,omitempty"      xorm:"TEXT 'workflow_error'"`
	Started    int64             `json:"start_time,omitempty" xorm:"workflow_started"`
	Stopped    int64             `json:"end_time,omitempty"   xorm:"workflow_stopped"`
	AgentID    int64             `json:"agent_id,omitempty"   xorm:"workflow_agent_id"`
	Platform   string            `json:"platform,omitempty"   xorm:"workflow_platform"`
	Environ    map[string]string `json:"environ,omitempty"    xorm:"json 'workflow_environ'"`
	Children   []*Step           `json:"children,omitempty"   xorm:"-"`
}

Workflow represents a workflow in the pipeline.

func (*Workflow) Failing

func (p *Workflow) Failing() bool

Failing returns true if the process state is failed, killed or error.

func (*Workflow) Running

func (p *Workflow) Running() bool

Running returns true if the process state is pending or running.

func (Workflow) TableName

func (Workflow) TableName() string

TableName return database table name for xorm

Jump to

Keyboard shortcuts

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