model

package
v5.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

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

Different ways to handle failure states.

View Source
const (
	IDNotSet = -1
)

Variables

View Source
var (
	ErrAccessTokenNameInvalid   = errors.New("invalid access token name")
	ErrAccessTokenNameTooLong   = errors.New("access token name too long")
	ErrAccessTokenScopesInvalid = errors.New("invalid access token scopes")
	ErrAccessTokenScopesEmpty   = errors.New("at least one scope is required")
	ErrAccessTokenExpired       = errors.New("access token expired")
	ErrAccessTokenAdminScope    = errors.New("admin scopes not allowed for non-admin users")
)
View Source
var (
	ErrIntegrationNameInvalid   = errors.New("invalid integration name")
	ErrIntegrationTypeInvalid   = errors.New("invalid integration type")
	ErrIntegrationConfigInvalid = errors.New("invalid integration configuration")
	ErrIntegrationAccessDenied  = errors.New("access denied to integration")
	ErrIntegrationNotFound      = errors.New("integration not found")
	ErrIntegrationInactive      = errors.New("integration is not active")
)

Integration errors.

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 ErrInvalidStatusValue = errors.New("invalid status value")
View Source
var ErrInvalidWebhookEvent = errors.New("invalid webhook event")
View Source
var ValidIntegrationTypes = []IntegrationType{
	IntegrationTypeVault,
}

ValidIntegrationTypes lists all supported integration types.

Functions

func ApplyPagination

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

func GenerateNewAgentToken

func GenerateNewAgentToken() string

func GenerateNewAutoscalerToken

func GenerateNewAutoscalerToken() string

GenerateNewAutoscalerToken generates a new random token for autoscaler authentication.

func GeneratePersistentID

func GeneratePersistentID(token, name, platform, backend string) string

GeneratePersistentID creates a stable identity hash for an agent. For individual token agents, the token alone provides uniqueness. For master token agents, the name (hostname) differentiates agents sharing the same token. This hash persists across agent restarts and ID changes, allowing metrics aggregation.

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.

Types

type AccessToken

type AccessToken struct {
	ID        int64    `json:"id"         xorm:"pk autoincr 'id'"`
	UserID    int64    `json:"user_id"    xorm:"NOT NULL INDEX 'user_id'"`
	OrgID     int64    `json:"org_id"     xorm:"NOT NULL DEFAULT 0 INDEX 'org_id'"`  // 0 = user-level
	RepoID    int64    `json:"repo_id"    xorm:"NOT NULL DEFAULT 0 INDEX 'repo_id'"` // 0 = not repo-scoped
	Name      string   `json:"name"       xorm:"NOT NULL 'name'"`
	TokenHash string   `json:"-"          xorm:"UNIQUE VARCHAR(64) 'token_hash'"`
	Scopes    []string `json:"scopes"     xorm:"json 'scopes'"`
	ExpiresAt int64    `json:"expires_at" xorm:"'expires_at'"` // unix timestamp, 0 = never
	LastUsed  int64    `json:"last_used"  xorm:"'last_used'"`
	CreatedAt int64    `json:"created_at" xorm:"'created_at' created"`
	UpdatedAt int64    `json:"updated_at" xorm:"'updated_at' updated"`

} //	@name	AccessToken

AccessToken represents a user-created API access token.

func (*AccessToken) Copy

func (at *AccessToken) Copy() *AccessToken

Copy returns a copy of the access token without sensitive data.

func (*AccessToken) GetScopes

func (at *AccessToken) GetScopes() []AccessTokenScope

GetScopes returns the scopes as AccessTokenScope slice.

func (*AccessToken) HasScope

func (at *AccessToken) HasScope(required AccessTokenScope) bool

HasScope returns true if the token has the specified scope.

func (*AccessToken) IsExpired

func (at *AccessToken) IsExpired() bool

IsExpired returns true if the token has expired.

func (*AccessToken) IsOrgScoped

func (at *AccessToken) IsOrgScoped() bool

IsOrgScoped returns true if the token is scoped to a specific organization.

func (*AccessToken) IsRepoScoped

func (at *AccessToken) IsRepoScoped() bool

IsRepoScoped returns true if the token is scoped to a specific repository.

func (*AccessToken) IsUserLevel

func (at *AccessToken) IsUserLevel() bool

IsUserLevel returns true if the token is not scoped to an org or repo.

func (AccessToken) TableName

func (AccessToken) TableName() string

TableName returns database table name for xorm.

func (*AccessToken) Validate

func (at *AccessToken) Validate(isAdmin bool) error

Validate validates the access token fields.

type AccessTokenScope

type AccessTokenScope string

AccessTokenScope represents permission scopes for access tokens.

const (
	// User scopes - available to all users.
	ScopeRepoRead  AccessTokenScope = "repo:read"
	ScopeRepoWrite AccessTokenScope = "repo:write"
	ScopeRepoAdmin AccessTokenScope = "repo:admin"
	ScopeUserRead  AccessTokenScope = "user:read"
	ScopeUserWrite AccessTokenScope = "user:write"

	// Admin-only scopes.
	ScopeAdminRead  AccessTokenScope = "admin:read"
	ScopeAdminWrite AccessTokenScope = "admin:write"
)

func AllAdminScopes

func AllAdminScopes() []AccessTokenScope

AllAdminScopes returns all scopes available only to admins.

func AllScopes

func AllScopes() []AccessTokenScope

AllScopes returns all available scopes.

func AllUserScopes

func AllUserScopes() []AccessTokenScope

AllUserScopes returns all scopes available to regular users.

func (AccessTokenScope) IsAdminScope

func (s AccessTokenScope) IsAdminScope() bool

IsAdminScope returns true if the scope requires admin privileges.

func (AccessTokenScope) IsValid

func (s AccessTokenScope) IsValid() bool

IsValid returns true if the scope is a valid defined scope.

type AccessTokenStore

type AccessTokenStore interface {
	AccessTokenCreate(*AccessToken) error
	AccessTokenFind(int64) (*AccessToken, error)
	AccessTokenFindByHash(string) (*AccessToken, error)
	AccessTokenList(userID int64, p *ListOptions) ([]*AccessToken, error)
	AccessTokenDelete(*AccessToken) error
	AccessTokenUpdateLastUsed(int64, int64) error
}

AccessTokenStore defines the interface for access token persistence.

type AdminMetrics

type AdminMetrics = Metrics

AdminMetrics is deprecated, use Metrics instead. Keeping for backward compatibility during migration.

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"          xorm:"name"`
	OwnerID                int64             `json:"owner_id"      xorm:"'owner_id'"`
	Token                  string            `json:"token"                     xorm:"token"`
	PersistentID           string            `json:"persistent_id"             xorm:"VARCHAR(64) INDEX 'persistent_id'"`
	LastContact            int64             `json:"last_contact"              xorm:"last_contact"`
	WorkflowPollingHealthy bool              `json:"workflow_polling_healthy"  xorm:"workflow_polling_healthy"`
	LastWork               int64             `json:"last_work"                 xorm:"last_work"` // last time the agent did something, this value is used to determine if the agent is still doing work used by the autoscaler
	Platform               string            `json:"platform"                  xorm:"VARCHAR(100) 'platform'"`
	Backend                string            `json:"backend"       xorm:"VARCHAR(100) 'backend'"`
	Hostname               string            `json:"hostname"      xorm:"VARCHAR(255) 'hostname'"`
	Capacity               int32             `json:"capacity"      xorm:"capacity"`
	Version                string            `json:"version"       xorm:"'version'"`
	BuildDate              string            `json:"build_date"    xorm:"'build_date'"`
	NoSchedule             bool              `json:"no_schedule"   xorm:"no_schedule"`
	Priority               int32             `json:"priority"      xorm:"DEFAULT 0 'priority'"`
	CustomLabels           map[string]string `json:"custom_labels"    xorm:"JSON 'custom_labels'"`
	LimitMem               int64             `json:"limit_mem"        xorm:"'limit_mem'"`
	LimitCPUQuota          int64             `json:"limit_cpu_quota"  xorm:"'limit_cpu_quota'"`
	// OrgID is counted as unset if set to -1, this is done to ensure a new(Agent) still enforce the OrgID check by default
	OrgID int64 `json:"org_id"        xorm:"INDEX 'org_id'"`

} //	@name	Agent

func (*Agent) CanAccessRepo

func (a *Agent) CanAccessRepo(repo *Repo) bool

func (*Agent) GetServerLabels

func (a *Agent) GetServerLabels() (map[string]string, error)

func (*Agent) IsSystemAgent

func (a *Agent) IsSystemAgent() bool

func (Agent) TableName

func (Agent) TableName() string

TableName return database table name for xorm.

type AgentListOptions

type AgentListOptions struct {
	ListOptions
	Search   string // Search in name, platform, backend, custom labels
	Platform string // Filter by platform
	Backend  string // Filter by backend
	OrgID    *int64 // Filter by org_id (nil = all, -1 = global agents only)
	Sort     string // Sort field: id, name, platform, backend, last_contact
	Order    string // Sort order: asc or desc
}

AgentListOptions defines filtering options for listing agents.

type AgentMetric

type AgentMetric struct {
	AgentID           int64   `json:"agent_id"`
	AgentPersistentID string  `json:"agent_persistent_id,omitempty"`
	AgentName         string  `json:"agent_name"`
	WorkflowCount     int64   `json:"workflow_count"`
	AvgBuildTime      float64 `json:"avg_build_time"` // in seconds
	Platform          string  `json:"platform"`
	Backend           string  `json:"backend"`
}

AgentMetric represents metrics for a specific agent.

type AgentMetricData

type AgentMetricData struct {
	AgentPersistentID string
	AgentName         string
	Platform          string
	Count             int64
}

AgentMetricData holds aggregated workflow data for an agent persistent ID. Used by store methods to return agent metrics grouped by persistent ID.

type AgentWithStats

type AgentWithStats struct {
	Agent
	RunningWorkflows int `json:"running_workflows"`
}

AgentWithStats is used for API responses to include runtime stats.

type ApprovalMode

type ApprovalMode string
const (
	RequireApprovalNone         ApprovalMode = "none"          // require approval for no events
	RequireApprovalForks        ApprovalMode = "forks"         // require approval for PRs from forks (default)
	RequireApprovalPullRequests ApprovalMode = "pull_requests" // require approval for all PRs
	RequireApprovalAllEvents    ApprovalMode = "all_events"    // require approval for all external events
)

func (ApprovalMode) Valid

func (mode ApprovalMode) Valid() bool

type Autoscaler

type Autoscaler 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"                  xorm:"UNIQUE NOT NULL 'name'"`
	Token             string            `json:"-"                     xorm:"token"` // Authentication token (excluded from JSON)
	OwnerID           int64             `json:"owner_id"              xorm:"'owner_id'"`
	LastContact       int64             `json:"last_contact"          xorm:"last_contact"`
	MinAgents         int32             `json:"min_agents"            xorm:"'min_agents'"`
	MaxAgents         int32             `json:"max_agents"            xorm:"'max_agents'"`
	WorkflowsPerAgent int32             `json:"workflows_per_agent"   xorm:"'workflows_per_agent'"`
	Provider          string            `json:"provider"              xorm:"VARCHAR(50) 'provider'"`
	InstanceType      string            `json:"instance_type"         xorm:"VARCHAR(100) 'instance_type'"`
	Region            string            `json:"region"                xorm:"VARCHAR(100) 'region'"`
	AgentLabels       map[string]string `json:"agent_labels"          xorm:"JSON 'agent_labels'"`
	LimitCPUQuota     string            `json:"limit_cpu_quota"       xorm:"VARCHAR(50) 'limit_cpu_quota'"`
	LimitMem          string            `json:"limit_mem"             xorm:"VARCHAR(50) 'limit_mem'"`
	Enabled           bool              `json:"enabled"               xorm:"DEFAULT true 'enabled'"`
	Version           string            `json:"version"               xorm:"'version'"`
	ActiveAgents      int32             `json:"active_agents"         xorm:"'active_agents'"`
	PendingAgents     int32             `json:"pending_agents"        xorm:"'pending_agents'"`
	OrgID             int64             `json:"org_id"                xorm:"INDEX 'org_id'"`

} //	@name	Autoscaler

Autoscaler represents an autoscaler instance that provisions agents on demand.

func (*Autoscaler) CanProvision

func (a *Autoscaler) CanProvision(requiredLabels map[string]string) bool

CanProvision checks if the autoscaler can provision an agent with the given labels. This performs label matching similar to agent label matching logic.

func (*Autoscaler) IsHealthy

func (a *Autoscaler) IsHealthy() bool

IsHealthy returns true if the autoscaler has sent a heartbeat recently (within 120 seconds).

func (*Autoscaler) IsSystemAutoscaler

func (a *Autoscaler) IsSystemAutoscaler() bool

IsSystemAutoscaler returns true if the autoscaler is a system-level (global) autoscaler.

func (Autoscaler) TableName

func (Autoscaler) TableName() string

TableName returns the database table name for xorm.

type AutoscalerListOptions

type AutoscalerListOptions struct {
	ListOptions
	Search   string // Search in name, provider
	Provider string // Filter by provider
	Enabled  *bool  // Filter by enabled status (nil = all)
	OrgID    *int64 // Filter by org_id (nil = all, -1 = global autoscalers only)
	Sort     string // Sort field: id, name, provider, last_contact
	Order    string // Sort order: asc or desc
}

AutoscalerListOptions defines filtering options for listing autoscalers.

type AutoscalerWithToken

type AutoscalerWithToken struct {
	*Autoscaler
	Token string `json:"token"`

} //	@name	AutoscalerWithToken

AutoscalerWithToken is used for API responses that include the token (only on creation).

type CacheEntry

type CacheEntry struct {
	Key       string `json:"key" xorm:"pk 'key'"`
	Data      []byte `json:"data" xorm:"LONGBLOB 'data'"`
	ExpiresAt int64  `json:"expires_at" xorm:"'expires_at'"`
	CreatedAt int64  `json:"created_at" xorm:"'created_at'"`
}

CacheEntry represents a distributed cache entry.

func (CacheEntry) TableName

func (CacheEntry) TableName() string

TableName returns the table name for cache entries.

type Commit

type Commit struct {
	SHA      string
	ForgeURL string
}

type Config

type Config struct {
	ID     int64  `json:"-"    xorm:"pk autoincr 'id'"`
	RepoID int64  `json:"-"    xorm:"UNIQUE(s) 'repo_id'"`
	Hash   string `json:"hash" xorm:"UNIQUE(s) 'hash'"`
	Name   string `json:"name" xorm:"UNIQUE(s) 'name'"`
	Data   []byte `json:"data" xorm:"LONGBLOB 'data'"`

} //	@name	Config

Config represents a pipeline configuration.

func (Config) TableName

func (Config) TableName() string

type Cron

type Cron struct {
	ID        int64  `json:"id"         xorm:"pk autoincr 'id'"`
	Name      string `json:"name"       xorm:"name 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"  xorm:"next_exec"`
	Schedule  string `json:"schedule"   xorm:"schedule NOT NULL"` //	@weekly,	3min, ...
	Created   int64  `json:"created"    xorm:"created NOT NULL DEFAULT 0"`
	Branch    string `json:"branch"     xorm:"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 ensures cron has a valid name and schedule.

func (*Cron) WithRepo

func (c *Cron) WithRepo(repoName, repoOwner, repoDefaultBranch string) *CronWithRepo

WithRepo creates a CronWithRepo from a Cron with repo details.

type CronWithRepo

type CronWithRepo struct {
	*Cron
	RepoName          string `json:"repo_name"`
	RepoOwner         string `json:"repo_owner"`
	RepoDefaultBranch string `json:"repo_default_branch"`
}

CronWithRepo extends Cron with repository context for user views.

type DistributedLock

type DistributedLock struct {
	ID         int64  `json:"id"          xorm:"pk autoincr 'id'"`
	Name       string `json:"name"        xorm:"UNIQUE NOT NULL 'name'"`
	InstanceID string `json:"instance_id" xorm:"NOT NULL 'instance_id'"`
	AcquiredAt int64  `json:"acquired_at" xorm:"'acquired_at'"`
	ExpiresAt  int64  `json:"expires_at"  xorm:"'expires_at'"`

} //	@name	DistributedLock

DistributedLock represents a distributed lock for coordinating operations across multiple server instances in HA deployments.

func (DistributedLock) TableName

func (DistributedLock) TableName() string

TableName returns the table name for DistributedLock.

type DistributedMessage

type DistributedMessage struct {
	ID         string            `json:"id" xorm:"pk 'id'"`
	Data       []byte            `json:"data" xorm:"LONGBLOB 'data'"`
	Labels     map[string]string `json:"labels" xorm:"json 'labels'"`
	CreatedAt  int64             `json:"created_at" xorm:"'created_at'"`
	InstanceID string            `json:"instance_id" xorm:"'instance_id'"`

} //	@name	DistributedMessage

DistributedMessage represents a message stored in the database for distributed pub/sub.

func (DistributedMessage) TableName

func (DistributedMessage) TableName() string

TableName returns the table name for xorm.

type Entity

type Entity struct {
	ID         int64      `json:"id"`
	EntityType EntityType `json:"entity_type"`
	Name       string     `json:"name"`
	ForgeID    int64      `json:"forge_id,omitempty"`

	// User-specific fields (nil for orgs)
	Email       *string `json:"email,omitempty"`
	Avatar      *string `json:"avatar,omitempty"`
	Admin       *bool   `json:"admin,omitempty"`
	Description *string `json:"description,omitempty"`
	Timezone    *string `json:"timezone,omitempty"`

	// Org-specific fields (nil for users)
	IsUser  *bool `json:"is_user,omitempty"`
	Private *bool `json:"private,omitempty"`

} //	@name	Entity

Entity represents a unified view of users and organizations for admin management.

func OrgToEntity

func OrgToEntity(org *Org) *Entity

OrgToEntity converts an Org model to an Entity.

func UserToEntity

func UserToEntity(user *User) *Entity

UserToEntity converts a User model to an Entity.

type EntityType

type EntityType string

EntityType represents the type of entity (user or organization).

const (
	EntityTypeUser EntityType = "user"
	EntityTypeOrg  EntityType = "org"
)

type Environ

type Environ struct {
	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 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 ExternalSecretRef added in v5.1.0

type ExternalSecretRef struct {
	IntegrationID int64  `json:"integration_id" yaml:"integration_id"`
	Path          string `json:"path"           yaml:"path"`
	Key           string `json:"key"            yaml:"key"`
	Version       int    `json:"version"        yaml:"version,omitempty"`
}

ExternalSecretRef represents a reference to an external secret in YAML.

func (*ExternalSecretRef) CacheKey added in v5.1.0

func (r *ExternalSecretRef) CacheKey() string

CacheKey returns a unique key for caching this secret.

func (*ExternalSecretRef) Validate added in v5.1.0

func (r *ExternalSecretRef) Validate() error

Validate validates the external secret reference.

type Feed

type Feed struct {
	RepoID   int64  `json:"repo_id"                 xorm:"repo_id"`
	ID       int64  `json:"id,omitempty"            xorm:"pipeline_id"`
	Number   int64  `json:"number,omitempty"        xorm:"pipeline_number"`
	Event    string `json:"event,omitempty"         xorm:"pipeline_event"`
	Status   string `json:"status,omitempty"        xorm:"pipeline_status"`
	Created  int64  `json:"created,omitempty"       xorm:"pipeline_created"`
	Started  int64  `json:"started,omitempty"       xorm:"pipeline_started"`
	Finished int64  `json:"finished,omitempty"      xorm:"pipeline_finished"`
	Commit   string `json:"commit,omitempty"        xorm:"pipeline_commit"`
	Branch   string `json:"branch,omitempty"        xorm:"pipeline_branch"`
	Ref      string `json:"ref,omitempty"           xorm:"pipeline_ref"`
	Refspec  string `json:"refspec,omitempty"       xorm:"pipeline_refspec"`
	Title    string `json:"title,omitempty"         xorm:"pipeline_title"`
	Message  string `json:"message,omitempty"       xorm:"pipeline_message"`
	Author   string `json:"author,omitempty"        xorm:"pipeline_author"`
	Avatar   string `json:"author_avatar,omitempty" xorm:"pipeline_avatar"`
	Email    string `json:"author_email,omitempty"  xorm:"pipeline_email"`

} //	@name	Feed

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

type Forge

type Forge struct {
	ID                int64          `json:"id"                           xorm:"pk autoincr 'id'"`
	Type              ForgeType      `json:"type"                         xorm:"VARCHAR(250)"`
	URL               string         `json:"url"                          xorm:"VARCHAR(500) 'url'"`
	Client            string         `json:"client,omitempty"             xorm:"VARCHAR(250)"`
	ClientSecret      string         `json:"-"                            xorm:"VARCHAR(250)"` // do not expose client secret
	SkipVerify        bool           `json:"skip_verify,omitempty"        xorm:"bool"`
	OAuthHost         string         `json:"oauth_host,omitempty"         xorm:"VARCHAR(250) 'oauth_host'"` // public url for oauth if different from url
	AdditionalOptions map[string]any `json:"additional_options,omitempty" xorm:"json"`

} //	@name	Forge

func (*Forge) PublicCopy

func (f *Forge) PublicCopy() *Forge

PublicCopy returns a copy of the forge without sensitive information and technical details.

func (Forge) TableName

func (Forge) TableName() string

TableName returns the database table name for xorm.

type ForgeRemoteID

type ForgeRemoteID string

func (ForgeRemoteID) IsValid

func (r ForgeRemoteID) IsValid() bool

type ForgeType

type ForgeType string
const (
	ForgeTypeGithub              ForgeType = "github"
	ForgeTypeGitlab              ForgeType = "gitlab"
	ForgeTypeGitea               ForgeType = "gitea"
	ForgeTypeForgejo             ForgeType = "forgejo"
	ForgeTypeBitbucket           ForgeType = "bitbucket"
	ForgeTypeBitbucketDatacenter ForgeType = "bitbucket-dc"
	ForgeTypeAddon               ForgeType = "addon"
)

type Integration added in v5.1.0

type Integration struct {
	ID          int64           `json:"id"           xorm:"pk autoincr 'id'"`
	UserID      int64           `json:"user_id"      xorm:"NOT NULL INDEX 'user_id'"`
	Name        string          `json:"name"         xorm:"NOT NULL VARCHAR(255) 'name'"`
	Type        IntegrationType `json:"type"         xorm:"NOT NULL VARCHAR(50) 'type'"`
	Description string          `json:"description"  xorm:"TEXT 'description'"`

	// Configuration (provider-specific, encrypted in storage)
	Config string `json:"config,omitempty" xorm:"TEXT 'config'"`

	// Access Control - who can use this integration
	AllowedUserIDs []int64 `json:"allowed_user_ids" xorm:"json 'allowed_user_ids'"`
	AllowedOrgIDs  []int64 `json:"allowed_org_ids"  xorm:"json 'allowed_org_ids'"`
	AllowedRepoIDs []int64 `json:"allowed_repo_ids" xorm:"json 'allowed_repo_ids'"`

	// Status
	IsActive bool `json:"is_active" xorm:"DEFAULT true 'is_active'"`

	// Metadata
	CreatedAt int64 `json:"created_at" xorm:"created"`
	UpdatedAt int64 `json:"updated_at" xorm:"updated"`

} //	@name	Integration

Integration represents an external secret store integration.

func (*Integration) BeforeInsert added in v5.1.0

func (i *Integration) BeforeInsert()

BeforeInsert sets defaults before insertion.

func (*Integration) Copy added in v5.1.0

func (i *Integration) Copy() *Integration

Copy returns a copy of the integration without sensitive configuration.

func (*Integration) CopyWithRedactedConfig added in v5.1.0

func (i *Integration) CopyWithRedactedConfig() *Integration

CopyWithRedactedConfig returns a copy with configuration redacted for display.

func (*Integration) GetVaultConfig added in v5.1.0

func (i *Integration) GetVaultConfig() (*VaultConfig, error)

GetVaultConfig parses and returns the Vault configuration.

func (*Integration) HasAccess added in v5.1.0

func (i *Integration) HasAccess(userID int64, orgID int64, repoID int64) bool

HasAccess checks if the given user/org/repo has access to use this integration. Access is explicitly granted via allowlists - if no allowlists are configured, no one can use the integration (owner can still manage it, but not use it for secrets).

func (*Integration) SetVaultConfig added in v5.1.0

func (i *Integration) SetVaultConfig(config *VaultConfig) error

SetVaultConfig sets the Vault configuration.

func (Integration) TableName added in v5.1.0

func (Integration) TableName() string

TableName returns the database table name for xorm.

func (*Integration) Validate added in v5.1.0

func (i *Integration) Validate() error

Validate validates the integration fields.

type IntegrationStore added in v5.1.0

type IntegrationStore interface {
	IntegrationFind(int64) (*Integration, error)
	IntegrationFindByName(userID int64, name string) (*Integration, error)
	IntegrationList(userID int64, opts *ListOptions) ([]*Integration, error)
	IntegrationListAll() ([]*Integration, error)
	IntegrationListAccessible(userID int64, orgIDs []int64, repoIDs []int64, opts *ListOptions) ([]*Integration, error)
	IntegrationCreate(*Integration) error
	IntegrationUpdate(*Integration) error
	IntegrationDelete(*Integration) error
}

IntegrationStore persists integration information to storage.

type IntegrationType added in v5.1.0

type IntegrationType string

IntegrationType represents the type of external integration.

const (
	IntegrationTypeVault IntegrationType = "vault"
)

func (IntegrationType) IsValid added in v5.1.0

func (t IntegrationType) IsValid() bool

IsValid checks if the integration type is valid.

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"     xorm:"'time'"`
	Line    int          `json:"line"     xorm:"'line'"`
	Data    []byte       `json:"data"     xorm:"LONGBLOB"`
	Created int64        `json:"-"        xorm:"created"`
	Type    LogEntryType `json:"type"     xorm:"'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 MaintenanceConfig

type MaintenanceConfig struct {
	ID         int64  `json:"id"       xorm:"pk autoincr 'id'"`
	ActionType string `json:"action_type" xorm:"'action_type' unique"` // "vacuum" or "kubernetes_cleanup"
	Enabled    bool   `json:"enabled"  xorm:"'enabled'"`
	Schedule   string `json:"schedule" xorm:"'schedule'"` // Cron format: "0 5 * * *" for 5 AM daily
	DryRun     bool   `json:"dry_run" xorm:"'dry_run' default(false)"`
	// Action-specific statistics
	TotalRuns       int64     `json:"total_runs" xorm:"'total_runs' default(0)"`
	SuccessfulRuns  int64     `json:"successful_runs" xorm:"'successful_runs' default(0)"`
	LastRun         time.Time `json:"last_run" xorm:"'last_run'"`
	LastRunSuccess  bool      `json:"last_run_success" xorm:"'last_run_success' default(false)"`
	LastRunDuration int64     `json:"last_run_duration" xorm:"'last_run_duration' default(0)"` // Duration in milliseconds
	LastRunError    string    `json:"last_run_error" xorm:"'last_run_error'"`
	Created         int64     `json:"created"  xorm:"created"`
	Updated         int64     `json:"updated"  xorm:"updated"`
	// Runtime flags (not persisted)
	KubernetesCleanupAvailable bool `json:"kubernetes_cleanup_available" xorm:"-"` // Function is configured, not stored in DB
	// Environment variable override flags (not persisted)
	EnvVarsSet bool `json:"env_vars_set" xorm:"-"` // True if action-specific env vars are set (vacuum or k8s depending on action)

} //	@name	MaintenanceConfig

MaintenanceConfig represents the configuration for database maintenance operations.

func (MaintenanceConfig) TableName

func (MaintenanceConfig) TableName() string

type MaintenanceLog

type MaintenanceLog struct {
	ID       int64     `json:"id"       xorm:"pk autoincr 'id'"`
	RunTime  time.Time `json:"run_time" xorm:"'run_time'"`
	Success  bool      `json:"success"  xorm:"'success'"`
	Error    string    `json:"error"    xorm:"'error'"`
	Duration int64     `json:"duration" xorm:"'duration'"` // Duration in milliseconds
	Details  string    `json:"details"  xorm:"'details'"`  // JSON formatted details
	Created  int64     `json:"created"  xorm:"created"`

} //	@name	MaintenanceLog

MaintenanceLog represents a log entry for maintenance operations.

func (MaintenanceLog) TableName

func (MaintenanceLog) TableName() string

type MaintenanceOperationConfig

type MaintenanceOperationConfig struct {
	ID        int64     `json:"id"         xorm:"pk autoincr 'id'"`
	Operation string    `json:"operation"  xorm:"'operation' unique"`
	Enabled   bool      `json:"enabled"    xorm:"'enabled'"`
	Schedule  string    `json:"schedule"   xorm:"'schedule'"` // Cron format: "0 5 * * *" for 5 AM daily
	TotalRuns int64     `json:"total_runs" xorm:"'total_runs'"`
	LastRun   time.Time `json:"last_run"   xorm:"'last_run'"`
	Created   int64     `json:"created"    xorm:"created"`
	Updated   int64     `json:"updated"    xorm:"updated"`

} //	@name	MaintenanceOperationConfig

MaintenanceOperationConfig represents the configuration for individual maintenance operations.

func (MaintenanceOperationConfig) TableName

func (MaintenanceOperationConfig) TableName() string

type MaintenanceStats

type MaintenanceStats struct {
	ID              int64     `json:"id"              xorm:"pk autoincr 'id'"`
	LastRun         time.Time `json:"last_run"        xorm:"'last_run'"`
	LastRunSuccess  bool      `json:"last_run_success" xorm:"'last_run_success'"`
	LastRunError    string    `json:"last_run_error"  xorm:"'last_run_error'"`
	LastRunDuration int64     `json:"last_run_duration" xorm:"'last_run_duration'"` // Duration in milliseconds
	TotalRuns       int64     `json:"total_runs"      xorm:"'total_runs'"`
	SuccessfulRuns  int64     `json:"successful_runs" xorm:"'successful_runs'"`
	Created         int64     `json:"created"         xorm:"created"`
	Updated         int64     `json:"updated"         xorm:"updated"`

} //	@name	MaintenanceStats

MaintenanceStats represents statistics about maintenance operations.

func (MaintenanceStats) TableName

func (MaintenanceStats) TableName() string

type Metrics

type Metrics struct {
	TotalRepos       int64            `json:"total_repos"`
	TotalOrgs        int64            `json:"total_orgs"`
	TotalPipelines   int64            `json:"total_pipelines"`
	AvgBuildTime     float64          `json:"avg_build_time"` // in seconds
	AvgStepsPerFlow  float64          `json:"avg_steps_per_flow"`
	PipelinesByRepo  map[string]int64 `json:"pipelines_by_repo"`  // repo name -> count
	PipelinesByOrg   map[string]int64 `json:"pipelines_by_org"`   // org name -> count
	WorkflowsByAgent map[string]int64 `json:"workflows_by_agent"` // agent name -> count
	RepoDetails      []RepoMetric     `json:"repo_details"`
	OrgDetails       []OrgMetric      `json:"org_details"`
	AgentDetails     []AgentMetric    `json:"agent_details"`
	IsAdminScope     bool             `json:"is_admin_scope"` // true if showing all instance metrics
}

Metrics represents overall system metrics.

type MetricsTimeFilter

type MetricsTimeFilter struct {
	After  int64 `json:"after,omitempty"`  // Unix timestamp
	Before int64 `json:"before,omitempty"` // Unix timestamp
}

MetricsTimeFilter represents time-based filtering for metrics queries.

type Netrc

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

type Org

type Org struct {
	ID      int64  `json:"id,omitempty"       xorm:"pk autoincr 'id'"`
	ForgeID int64  `json:"forge_id,omitempty" xorm:"forge_id UNIQUE(s)"`
	Name    string `json:"name"               xorm:"'name' UNIQUE(s)"`
	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 OrgMetric

type OrgMetric struct {
	OrgID          int64   `json:"org_id"`
	OrgName        string  `json:"org_name"`
	PipelineCount  int64   `json:"pipeline_count"`
	RepoCount      int64   `json:"repo_count"`
	AvgBuildTime   float64 `json:"avg_build_time"`   // in seconds
	TotalBuildTime float64 `json:"total_build_time"` // in seconds
}

OrgMetric represents metrics for a specific organization.

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 'user_id'"`
	RepoID  int64 `json:"-"       xorm:"UNIQUE(s) INDEX NOT NULL 'repo_id'"`
	Repo    *Repo `json:"-"       xorm:"-"`
	Pull    bool  `json:"pull"    xorm:"pull"`
	Push    bool  `json:"push"    xorm:"push"`
	Admin   bool  `json:"admin"   xorm:"admin"`
	Synced  int64 `json:"synced"  xorm:"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 Pipeline

type Pipeline struct {
	ID                  int64                  `json:"id"                      xorm:"pk autoincr 'id'"`
	RepoID              int64                  `json:"-"                       xorm:"UNIQUE(s) INDEX 'repo_id'"`
	Number              int64                  `json:"number"                  xorm:"UNIQUE(s) 'number'"`
	Author              string                 `json:"author"                  xorm:"INDEX 'author'"`
	Parent              int64                  `json:"parent"                  xorm:"parent"`
	Event               WebhookEvent           `json:"event"                   xorm:"event"`
	Status              StatusValue            `json:"status"                  xorm:"INDEX 'status'"`
	Errors              []*types.PipelineError `json:"errors"                  xorm:"json 'errors'"`
	Created             int64                  `json:"created"                 xorm:"'created' NOT NULL DEFAULT 0 created"`
	Updated             int64                  `json:"updated"                 xorm:"'updated' NOT NULL DEFAULT 0 updated"`
	Started             int64                  `json:"started"                 xorm:"started"`
	Finished            int64                  `json:"finished"                xorm:"finished"`
	DeployTo            string                 `json:"deploy_to"               xorm:"deploy"`
	DeployTask          string                 `json:"deploy_task"             xorm:"deploy_task"`
	Commit              string                 `json:"commit"                  xorm:"commit"`
	Branch              string                 `json:"branch"                  xorm:"branch"`
	Ref                 string                 `json:"ref"                     xorm:"ref"`
	Refspec             string                 `json:"refspec"                 xorm:"refspec"`
	Title               string                 `json:"title"                   xorm:"title"`
	Message             string                 `json:"message"                 xorm:"TEXT 'message'"`
	Timestamp           int64                  `json:"timestamp"               xorm:"'timestamp'"`
	Sender              string                 `json:"sender"                  xorm:"sender"` // uses reported user for webhooks and name of cron for cron pipelines
	Avatar              string                 `json:"author_avatar"           xorm:"varchar(500) avatar"`
	Email               string                 `json:"author_email"            xorm:"varchar(500) email"`
	ForgeURL            string                 `json:"forge_url"               xorm:"forge_url"`
	Reviewer            string                 `json:"reviewed_by"             xorm:"reviewer"`
	Reviewed            int64                  `json:"reviewed"                xorm:"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'"`
	IsPrerelease        bool                   `json:"is_prerelease,omitempty" xorm:"is_prerelease"`
	FromFork            bool                   `json:"from_fork,omitempty"     xorm:"from_fork"`
	LogsDeleted         bool                   `json:"logs_deleted,omitempty"  xorm:"logs_deleted"`

} //	@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.

func (PipelineConfig) TableName

func (PipelineConfig) TableName() string

type PipelineFilter

type PipelineFilter struct {
	Before      int64
	After       int64
	Branch      string
	Events      []WebhookEvent
	RefContains string
	Status      StatusValue
	Search      string // Search query for number, message, branch, author
}

type PipelineOptions

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

} //	@name	PipelineOptions

type PullRequest

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

} //	@name	PullRequest

type QueueInfo

type QueueInfo struct {
	Pending       []QueueTask `json:"pending"`
	WaitingOnDeps []QueueTask `json:"waiting_on_deps"`
	Running       []QueueTask `json:"running"`
	Stats         struct {
		WorkerCount        int `json:"worker_count"`
		PendingCount       int `json:"pending_count"`
		WaitingOnDepsCount int `json:"waiting_on_deps_count"`
		RunningCount       int `json:"running_count"`
	} `json:"stats"`
	Paused bool `json:"paused"`

} //	@name	QueueInfo

QueueInfo represents the response structure for queue information API.

type QueueTask

type QueueTask struct {
	Task
	PipelineNumber  int64  `json:"pipeline_number"`
	AgentName       string `json:"agent_name"`
	PipelineCreated int64  `json:"pipeline_created"` // Unix timestamp when the pipeline was created
	PipelineStarted int64  `json:"pipeline_started"` // Unix timestamp when the pipeline started running (0 if not started)
}

QueueTask represents a task in the queue with additional API-specific fields.

type Redirection

type Redirection struct {
	ID       int64  `xorm:"pk autoincr '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 'id'"`
	OrgID     int64  `json:"org_id"     xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'org_id'"`
	RepoID    int64  `json:"repo_id"    xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'repo_id'"`
	Address   string `json:"address"    xorm:"NOT NULL UNIQUE(s) INDEX 'address'"`
	Username  string `json:"username"   xorm:"varchar(2000) 'username'"`
	Password  string `json:"password"   xorm:"TEXT 'password'"`
	ReadOnly  bool   `json:"readonly"   xorm:"-"`
	CreatedAt int64  `json:"created_at" xorm:"created"`
	UpdatedAt int64  `json:"updated_at" xorm:"updated"`

} //	@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) IsGlobal

func (r Registry) IsGlobal() bool

Global registry.

func (Registry) IsOrganization

func (r Registry) IsOrganization() bool

Organization registry.

func (Registry) IsRepository

func (r Registry) IsRepository() bool

Repository registry.

func (Registry) TableName

func (r Registry) TableName() string

func (*Registry) Validate

func (r *Registry) Validate() error

Validate validates the registry information.

func (*Registry) WithOrg

func (r *Registry) WithOrg(orgName string, isPersonalOrg bool) *RegistryWithOrg

WithOrg creates a RegistryWithOrg from a Registry with the given org name.

type RegistryWithOrg

type RegistryWithOrg struct {
	*Registry
	OrgName   string `json:"org_name"`
	ScopeType string `json:"scope_type"` // "user", "org", or "global"

} //	@name	RegistryWithOrg

RegistryWithOrg extends Registry with organization context for user views.

type Repo

type Repo struct {
	ID      int64 `json:"id,omitempty"                    xorm:"pk autoincr 'id'"`
	UserID  int64 `json:"-"                               xorm:"INDEX 'user_id'"`
	ForgeID int64 `json:"forge_id,omitempty"              xorm:"forge_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:"INDEX 'org_id'"`
	Owner                        string               `json:"owner"                           xorm:"UNIQUE(name) 'owner'"`
	Name                         string               `json:"name"                            xorm:"UNIQUE(name) 'name'"`
	FullName                     string               `json:"full_name"                       xorm:"UNIQUE 'full_name'"`
	Avatar                       string               `json:"avatar_url,omitempty"            xorm:"varchar(500) 'avatar'"`
	ForgeURL                     string               `json:"forge_url,omitempty"             xorm:"varchar(1000) 'forge_url'"`
	Clone                        string               `json:"clone_url,omitempty"             xorm:"varchar(1000) 'clone'"`
	CloneSSH                     string               `json:"clone_url_ssh"                   xorm:"varchar(1000) 'clone_ssh'"`
	Branch                       string               `json:"default_branch,omitempty"        xorm:"varchar(500) 'branch'"`
	PREnabled                    bool                 `json:"pr_enabled"                      xorm:"DEFAULT TRUE 'pr_enabled'"`
	Timeout                      int64                `json:"timeout,omitempty"               xorm:"timeout"`
	Visibility                   RepoVisibility       `json:"visibility"                      xorm:"varchar(10) 'visibility'"`
	IsSCMPrivate                 bool                 `json:"private"                         xorm:"private"`
	Trusted                      TrustedConfiguration `json:"trusted"                         xorm:"json 'trusted'"`
	RequireApproval              ApprovalMode         `json:"require_approval"                xorm:"varchar(50) require_approval"`
	IsActive                     bool                 `json:"active"                          xorm:"active"`
	AllowPull                    bool                 `json:"allow_pr"                        xorm:"allow_pr"`
	AllowDeploy                  bool                 `json:"allow_deploy"                    xorm:"allow_deploy"`
	DeployTeam                   string               `json:"deploy_team"                     xorm:"varchar(250) 'deploy_team'"`
	Config                       string               `json:"config_file"                     xorm:"varchar(500) 'config_path'"`
	Hash                         string               `json:"-"                               xorm:"varchar(500) 'hash'"`
	Perm                         *Perm                `json:"-"                               xorm:"-"`
	CancelPreviousPipelineEvents []WebhookEvent       `json:"cancel_previous_pipeline_events" xorm:"json 'cancel_previous_pipeline_events'"`
	NetrcTrustedPlugins          []string             `json:"netrc_trusted"                   xorm:"json 'netrc_trusted'"`
	LogsPipelinesKeepMin         int64                `json:"logs_keep_min,omitempty"         xorm:"logs_keep_min"`
	LogsDurationKeep             string               `json:"logs_keep_duration"              xorm:"varchar(500) 'logs_keep_duration'"`

} //	@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 RepoLastPipeline

type RepoLastPipeline struct {
	*Repo
	LastPipeline *Pipeline `json:"last_pipeline,omitempty"`

} //	@name	RepoLastPipeline

RepoLastPipeline represents a repository with last pipeline execution information.

type RepoMetric

type RepoMetric struct {
	RepoID         int64   `json:"repo_id"`
	RepoName       string  `json:"repo_name"`
	RepoFullName   string  `json:"repo_full_name"`
	PipelineCount  int64   `json:"pipeline_count"`
	AvgBuildTime   float64 `json:"avg_build_time"`   // in seconds
	TotalBuildTime float64 `json:"total_build_time"` // in seconds
}

RepoMetric represents metrics for a specific repository.

type RepoPatch

type RepoPatch struct {
	Config                       *string                    `json:"config_file,omitempty"`
	RequireApproval              *string                    `json:"require_approval,omitempty"`
	Timeout                      *int64                     `json:"timeout,omitempty"`
	Visibility                   *string                    `json:"visibility,omitempty"`
	AllowPull                    *bool                      `json:"allow_pr,omitempty"`
	AllowDeploy                  *bool                      `json:"allow_deploy,omitempty"`
	DeployTeam                   *string                    `json:"deploy_team,omitempty"`
	CancelPreviousPipelineEvents *[]WebhookEvent            `json:"cancel_previous_pipeline_events"`
	LogsPipelinesKeepMin         int64                      `json:"logs_keep_min"`
	LogsDurationKeep             string                     `json:"logs_keep_duration"`
	NetrcTrusted                 *[]string                  `json:"netrc_trusted"`
	Trusted                      *TrustedConfigurationPatch `json:"trusted"`

} //	@name	RepoPatch

RepoPatch represents a repository patch object.

type RepoVisibility

type RepoVisibility string //	@name	RepoVisibility

RepoVisibility represent to what state a repo in woodpecker is visible to others.

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

type Secret

type Secret struct {
	ID        int64          `json:"id"              xorm:"pk autoincr 'id'"`
	OrgID     int64          `json:"org_id"          xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'org_id'"`
	RepoID    int64          `json:"repo_id"         xorm:"NOT NULL DEFAULT 0 UNIQUE(s) INDEX 'repo_id'"`
	Name      string         `json:"name"            xorm:"NOT NULL UNIQUE(s) INDEX 'name'"`
	Value     string         `json:"value,omitempty" xorm:"TEXT 'value'"`
	Images    []string       `json:"images"          xorm:"json 'images'"`
	Events    []WebhookEvent `json:"events"          xorm:"json 'events'"`
	Source    string         `json:"source"          xorm:"varchar(50) DEFAULT 'internal' 'source'"`
	CreatedAt int64          `json:"created_at"      xorm:"created"`
	UpdatedAt int64          `json:"updated_at"      xorm:"updated"`

} //	@name	Secret

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

func (*Secret) BeforeInsert

func (s *Secret) BeforeInsert()

BeforeInsert will sort events and set defaults before inserted into database.

func (*Secret) Copy

func (s *Secret) Copy() *Secret

Copy makes a copy of the secret without the value.

func (*Secret) CopyWithAbbreviatedValue

func (s *Secret) CopyWithAbbreviatedValue() *Secret

CopyWithAbbreviatedValue makes a copy of the secret with an abbreviated value. The abbreviated value shows the first 6 and last 6 characters for verification.

func (Secret) IsGlobal

func (s Secret) IsGlobal() bool

Global secret.

func (Secret) IsOrganization

func (s Secret) IsOrganization() bool

Organization secret.

func (Secret) IsRepository

func (s Secret) IsRepository() bool

Repository 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.

func (*Secret) WithOrg

func (s *Secret) WithOrg(orgName string, isPersonalOrg bool) *SecretWithOrg

WithOrg creates a SecretWithOrg from a Secret with the given org name.

func (*Secret) WithRepo

func (s *Secret) WithRepo(repoName string) *SecretWithOrg

WithRepo creates a SecretWithOrg from a Secret with the given repo name.

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 SecretWithOrg

type SecretWithOrg struct {
	*Secret
	OrgName   string `json:"org_name"`
	RepoName  string `json:"repo_name,omitempty"`
	ScopeType string `json:"scope_type"` // "user", "org", "repo", or "global"

} //	@name	SecretWithOrg

SecretWithOrg extends Secret with organization and repository context for user views.

type ServerConfig

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

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

func (ServerConfig) TableName

func (ServerConfig) TableName() string

TableName return database table name for xorm.

type StatusValue

type StatusValue string //	@name	StatusValue

StatusValue represent pipeline states woodpecker know.

const (
	StatusSkipped  StatusValue = "skipped"  // skipped as another step failed
	StatusPending  StatusValue = "pending"  // pending to be executed
	StatusRunning  StatusValue = "running"  // currently running
	StatusSuccess  StatusValue = "success"  // successfully finished
	StatusFailure  StatusValue = "failure"  // failed to finish (exit code != 0)
	StatusKilled   StatusValue = "killed"   // killed by user
	StatusError    StatusValue = "error"    // error with the config / while parsing / some other system problem
	StatusBlocked  StatusValue = "blocked"  // waiting for approval
	StatusDeclined StatusValue = "declined" // blocked and declined
	StatusCreated  StatusValue = "created"  // created / internal use only
)

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.

func (StatusValue) Validate

func (s StatusValue) Validate() error

type Step

type Step struct {
	ID         int64       `json:"id"                   xorm:"pk autoincr 'id'"`
	UUID       string      `json:"uuid"                 xorm:"INDEX 'uuid'"`
	PipelineID int64       `json:"pipeline_id"          xorm:"UNIQUE(s) INDEX 'pipeline_id'"`
	PID        int         `json:"pid"                  xorm:"UNIQUE(s) 'pid'"`
	PPID       int         `json:"ppid"                 xorm:"ppid"`
	Name       string      `json:"name"                 xorm:"name"`
	State      StatusValue `json:"state"                xorm:"state"`
	Error      string      `json:"error,omitempty"      xorm:"TEXT 'error'"`
	Failure    string      `json:"-"                    xorm:"failure"`
	ExitCode   int         `json:"exit_code"            xorm:"exit_code"`
	Started    int64       `json:"started,omitempty"    xorm:"started"`
	Finished   int64       `json:"finished,omitempty"   xorm:"finished"`
	Type       StepType    `json:"type,omitempty"       xorm:"type"`
	DependsOn  []string    `json:"depends_on,omitempty" xorm:"json 'depends_on'"`

} //	@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 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 'id'"`
	PID          int                    `json:"pid"          xorm:"'pid'"`
	Name         string                 `json:"name"         xorm:"'name'"`
	Data         []byte                 `json:"-"            xorm:"LONGBLOB 'data'"`
	Labels       map[string]string      `json:"labels"       xorm:"json 'labels'"`
	Dependencies []string               `json:"dependencies" xorm:"json 'dependencies'"`
	RunOn        []string               `json:"run_on"       xorm:"json 'run_on'"`
	DepStatus    map[string]StatusValue `json:"dep_status"   xorm:"json 'dependencies_status'"`
	AgentID      int64                  `json:"agent_id"     xorm:"'agent_id'"`
	PipelineID   int64                  `json:"pipeline_id"  xorm:"'pipeline_id'"`
	RepoID       int64                  `json:"repo_id"      xorm:"'repo_id'"`

} //	@name	Task

Task defines scheduled pipeline Task.

func (*Task) ApplyLabelsFromRepo

func (t *Task) ApplyLabelsFromRepo(r *Repo) error

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 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 TrustedConfiguration

type TrustedConfiguration struct {
	Network  bool `json:"network"`
	Volumes  bool `json:"volumes"`
	Security bool `json:"security"`
}

type TrustedConfigurationPatch

type TrustedConfigurationPatch struct {
	Network  *bool `json:"network"`
	Volumes  *bool `json:"volumes"`
	Security *bool `json:"security"`
}

type User

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

	ForgeID int64 `json:"forge_id,omitempty" xorm:"forge_id"`

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

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

	// AccessToken is the oauth2 access token.
	AccessToken string `json:"-"  xorm:"TEXT 'access_token'"`

	// RefreshToken is the oauth2 refresh token.
	RefreshToken string `json:"-" xorm:"TEXT 'refresh_token'"`

	// Expiry is the AccessToken expiration timestamp (unix seconds).
	Expiry int64 `json:"-" xorm:"expiry"`

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

	// the avatar url for this user.
	Avatar string `json:"avatar_url" xorm:" varchar(500) '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:"admin"`

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

	// OrgID is the of the user as model.Org.
	OrgID int64 `json:"org_id" xorm:"org_id"`

	// Description is a short bio or description for this user.
	Description string `json:"description,omitempty" xorm:"TEXT 'description'"`

	// Timezone is the user's timezone (e.g., "America/New_York", "Europe/Berlin").
	Timezone string `json:"timezone,omitempty" xorm:"varchar(100) 'timezone'"`

} //	@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 VaultConfig added in v5.1.0

type VaultConfig struct {
	// Connection
	Address   string `json:"address"`             // Vault server URL (e.g., https://vault.example.com)
	Namespace string `json:"namespace,omitempty"` // Vault Enterprise namespace

	// AppRole Authentication
	RoleID   string `json:"role_id"`   // AppRole Role ID
	SecretID string `json:"secret_id"` // AppRole Secret ID (encrypted in storage)

	// Paths
	MountPath string `json:"mount_path"` // Secrets engine mount path (default: "secret")
	AuthPath  string `json:"auth_path"`  // Auth method path (default: "auth/approle")

	// TLS Configuration
	TLSConfig *VaultTLSConfig `json:"tls_config,omitempty"`
}

VaultConfig holds HashiCorp Vault/OpenBao specific configuration.

func (*VaultConfig) Redacted added in v5.1.0

func (c *VaultConfig) Redacted() *VaultConfig

Redacted returns a copy with sensitive fields redacted.

func (*VaultConfig) Validate added in v5.1.0

func (c *VaultConfig) Validate() error

Validate validates the Vault configuration.

func (*VaultConfig) WithDefaults added in v5.1.0

func (c *VaultConfig) WithDefaults() *VaultConfig

WithDefaults returns a copy with default values applied.

type VaultTLSConfig added in v5.1.0

type VaultTLSConfig struct {
	CACert        string `json:"ca_cert,omitempty"`         // CA certificate (PEM)
	ClientCert    string `json:"client_cert,omitempty"`     // Client certificate (PEM)
	ClientKey     string `json:"client_key,omitempty"`      // Client private key (PEM)
	TLSServerName string `json:"tls_server_name,omitempty"` // Server name for SNI
	Insecure      bool   `json:"insecure,omitempty"`        // Skip TLS verification (for dev only)
}

VaultTLSConfig holds TLS configuration for Vault connections.

type WebhookEvent

type WebhookEvent string //	@name	WebhookEvent
const (
	EventPush       WebhookEvent = "push"
	EventPull       WebhookEvent = "pull_request"
	EventPullClosed WebhookEvent = "pull_request_closed"
	EventPullMerged WebhookEvent = "pull_request_merged"
	EventPullEdited WebhookEvent = "pull_request_edited"
	EventTag        WebhookEvent = "tag"
	EventRelease    WebhookEvent = "release"
	EventDeploy     WebhookEvent = "deployment"
	EventCron       WebhookEvent = "cron"
	EventManual     WebhookEvent = "manual"
)

func (WebhookEvent) Validate

func (s WebhookEvent) Validate() error

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 'id'"`
	PipelineID        int64             `json:"pipeline_id"          xorm:"UNIQUE(s) INDEX 'pipeline_id'"`
	PID               int               `json:"pid"                  xorm:"UNIQUE(s) 'pid'"`
	Name              string            `json:"name"                 xorm:"name"`
	PipelineName      string            `json:"pipeline_name"        xorm:"pipeline_name"`
	State             StatusValue       `json:"state"                xorm:"state"`
	Error             string            `json:"error,omitempty"      xorm:"TEXT 'error'"`
	Started           int64             `json:"started,omitempty"    xorm:"started"`
	Finished          int64             `json:"finished,omitempty"   xorm:"finished"`
	AgentID           int64             `json:"agent_id,omitempty"            xorm:"agent_id"`
	AgentPersistentID string            `json:"agent_persistent_id,omitempty" xorm:"VARCHAR(64) INDEX 'agent_persistent_id'"`
	AgentName         string            `json:"agent_name,omitempty"          xorm:"VARCHAR(255) 'agent_name'"`
	Platform          string            `json:"platform,omitempty"            xorm:"platform"`
	Environ           map[string]string `json:"environ,omitempty"    xorm:"json 'environ'"`
	DependsOn         []string          `json:"depends_on,omitempty" xorm:"json 'depends_on'"`
	AxisID            int               `json:"-"                    xorm:"axis_id"`
	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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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