Documentation
¶
Overview ¶
Package tpl 提供同步策略模板库(借鉴 Renovate packageRules/presets)。 模板描述「一批仓库该怎么同步」,可反复套用到任务创建/批量更新。 存储用 data/templates.json:壳层零 DB 迁移,重启可恢复。
Index ¶
- Variables
- type Spec
- type Store
- func (s *Store) Delete(id string) error
- func (s *Store) Effective(id string) (*Template, error)
- func (s *Store) Get(id string) (*Template, error)
- func (s *Store) List() []Template
- func (s *Store) ListByTag(tag string) []Template
- func (s *Store) Resolve(id string) (Spec, []string, error)
- func (s *Store) Upsert(t *Template) (*Template, error)
- type Template
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCycle = errors.New("template extends cycle detected")
ErrCycle 继承链成环。
View Source
var ErrNotFound = errors.New("template not found")
Functions ¶
This section is empty.
Types ¶
type Spec ¶
type Spec struct {
Cron string `json:"cron,omitempty"`
SourceBranch string `json:"source_branch,omitempty"`
TargetBranch string `json:"target_branch,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
// RetryMax 失败自动重跑上限(0=沿用全局)
RetryMax int `json:"retry_max,omitempty"`
}
Spec 策略默认值。非零/非空字段才参与覆盖。
func ResolveSelf ¶
ResolveSelf 不依赖 Store 的纯解析(测试用)。
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 文件型模板库。
type Template ¶
type Template struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Description string `gorm:"size:512" json:"description,omitempty"`
// Extends 继承的基础模板 ID(Renovate preset 模式)。可链式,须无环。
Extends string `gorm:"size:64" json:"extends,omitempty"`
// Match 任务/仓库匹配条件(与 health.Filter 同语义)
Match map[string][]string `gorm:"serializer:json" json:"match,omitempty"`
// Spec 套用到任务的默认值(cron/分支/启用);继承时子覆盖父(非空字段)。
Spec Spec `gorm:"serializer:json" json:"spec"`
// Tags 便于检索
Tags []string `gorm:"serializer:json" json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Template 同步策略模板。 模板同时作为 core 的 ORM 模型(gorm 标签仅为序列化,json 契约不变)。
Click to show internal directories.
Click to hide internal directories.