Help us shape the future of Go! Take the 2026 Go Developer Survey

corebridge

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlatformTypeGitHub   = model.PlatformTypeGitHub
	PlatformTypeCustom   = model.PlatformTypeCustom
	PlatformStatusActive = model.PlatformStatusActive
	PlatformStatusError  = model.PlatformStatusError
)

平台常量 / 工具(平台管理 handler 使用)

View Source
const (
	ErrorClassNotFound    = coreservice.ErrorClassNotFound
	ErrorClassConflict    = coreservice.ErrorClassConflict
	ErrorClassValidation  = coreservice.ErrorClassValidation
	ErrorClassAuth        = coreservice.ErrorClassAuth
	ErrorClassRateLimited = coreservice.ErrorClassRateLimited
	ErrorClassUnavailable = coreservice.ErrorClassUnavailable
	ErrorClassInternal    = coreservice.ErrorClassInternal
)
View Source
const (
	OrgMapPreserve = coreservice.OrgMapPreserve
	OrgMapSingle   = coreservice.OrgMapSingle
	OrgMapFlat     = coreservice.OrgMapFlat
	OrgMapMixed    = coreservice.OrgMapMixed
)
View Source
const (
	MirrorModePublish = model.MirrorModePublish
	MirrorModeBackup  = model.MirrorModeBackup
	MirrorRunPending  = model.MirrorRunPending
	MirrorRunRunning  = model.MirrorRunRunning
	MirrorRunSuccess  = model.MirrorRunSuccess
	MirrorRunFailed   = model.MirrorRunFailed
	MirrorKindVerify  = model.MirrorKindVerify
	MirrorKindPublish = model.MirrorKindPublish
)

镜像常量

View Source
const RebuildTrigger = model.TriggerRebuild

RebuildTrigger 全量重建触发器:core 会在拿到执行权后清空工作目录, 强制从源重新克隆(见 git-ferry-core service/rebuild.go)。

View Source
const StatusSuccess = model.StatusSuccess
View Source
const TriggerManual = model.TriggerManual

触发来源常量(手动触发路径使用)

Variables

View Source
var (
	ErrRepoNotFound           = coreservice.ErrRepoNotFound
	ErrTaskNotFound           = coreservice.ErrTaskNotFound
	ErrRuleNotFound           = coreservice.ErrRuleNotFound
	ErrPlatformNotFound       = coreservice.ErrPlatformNotFound
	ErrTargetPlatformNotFound = coreservice.ErrTargetPlatformNotFound
	ErrMetadataValidation     = coreservice.ErrMetadataValidation
	// ErrBackupDisabled 冷备未启用(没配 sync.backup_dir)—— 壳层据此回可读提示。
	ErrBackupDisabled = coreservice.ErrBackupDisabled
)

Functions

func DefaultPagination

func DefaultPagination(offset, limit int) dao.Pagination

func GenerateDeployKey added in v1.21.0

func GenerateDeployKey(comment string) (*credential.DeployKey, error)

GenerateDeployKey 生成镜像部署用 Ed25519 密钥对(私钥仅返回一次,不落库)。

func GetAPIURL

func GetAPIURL(platformType, instanceURL string) string

func IsPersonalOwner added in v1.21.0

func IsPersonalOwner(owner, targetUser string, orgOwners map[string]bool) bool

func ResolveTokenFromEnv added in v1.17.0

func ResolveTokenFromEnv(platformKey, current string) string

ResolveTokenFromEnv 用环境变量覆盖平台访问令牌。

INTEGRATION: GIT_SYNC_TOKEN_<PLATFORM_KEY 大写并把 - 换成 _>
例:platform key=my-github → GIT_SYNC_TOKEN_MY_GITHUB

密钥来源优先级(借鉴 ghorg token_cmd / 1Password 集成):

  1. GIT_SYNC_TOKEN_CMD_<KEY> —— 执行命令,stdout 第一行作为 token 例:GIT_SYNC_TOKEN_CMD_MY_GITHUB='op read op://infra/gh/token'
  2. GIT_SYNC_TOKEN_<KEY> —— 直接注入
  3. 返回 current(配置/DB 中的值)

设计意图:密钥不进配置文件/DB 明文,由部署方以 env/secrets manager 注入。 命令超时 5s,失败则回退到 env/原值。

func ValidOrgMapStrategy added in v1.21.0

func ValidOrgMapStrategy(s string) bool

func ValidPlatformType added in v1.15.0

func ValidPlatformType(t string) bool

ValidPlatformType 检查平台类型是否合法(SDK 注册表 + 扩展白名单)。

Types

type AuditChainResult added in v1.19.0

type AuditChainResult = coreservice.AuditChainResult

type AutoDiscoverOptions added in v1.18.0

type AutoDiscoverOptions = coreservice.AutoDiscoverOptions

type AutoRetryPolicy added in v1.21.0

type AutoRetryPolicy = coreservice.AutoRetryPolicy

type BackupManifest added in v1.18.0

type BackupManifest = coreservice.BackupManifest

type BulkMirrorItem added in v1.21.0

type BulkMirrorItem = coreservice.BulkMirrorItem

type BulkMirrorRequest added in v1.21.0

type BulkMirrorRequest = coreservice.BulkMirrorRequest

type BulkMirrorResult added in v1.21.0

type BulkMirrorResult = coreservice.BulkMirrorResult

type CommitPlan added in v1.24.0

type CommitPlan = history.CommitPlan

CommitPlan 按源侧提交分组的回滚视图。

type Config

type Config = synccore.Config

func LoadConfig

func LoadConfig(path string) (*Config, error)

type ConflictDossier added in v1.24.0

type ConflictDossier = history.ConflictDossier

ConflictDossier 待人工/AI 裁决的冲突卷宗。

type CreateMirrorChannelInput

type CreateMirrorChannelInput = coreservice.CreateMirrorChannelInput

type CreateRepoRequest

type CreateRepoRequest = model.CreateRepoRequest

type CreateRuleRequest

type CreateRuleRequest = model.CreateRuleRequest

type CreateTaskRequest

type CreateTaskRequest = model.CreateTaskRequest

type CredentialStatus added in v1.24.0

type CredentialStatus = coreservice.CredentialStatus

CredentialStatus 凭据状态。

type DiscoveryReport added in v1.18.0

type DiscoveryReport = coreservice.DiscoveryReport

type DriftItem added in v1.18.0

type DriftItem = coreservice.DriftItem

type DriftReport added in v1.18.0

type DriftReport = coreservice.DriftReport

type DrillReport added in v1.18.0

type DrillReport = coreservice.DrillReport

type ErrorClass added in v1.21.0

type ErrorClass = coreservice.ErrorClass

错误到传输层的分类契约(壳 response.FromError 据此选状态码)。

func Classify added in v1.21.0

func Classify(err error) ErrorClass

type ExecuteMirrorRunInput

type ExecuteMirrorRunInput = coreservice.ExecuteMirrorRunInput

type FilePlan added in v1.24.0

type FilePlan = history.FilePlan

FilePlan 单个文件的处置计划。

type ForcePushPolicy added in v1.18.0

type ForcePushPolicy = coreservice.ForcePushPolicy

type GateReport added in v1.24.0

type GateReport = coreservice.GateReport

GateReport 发布前门禁结果。

type GitServeSettings added in v1.19.1

type GitServeSettings struct {
	Enabled bool `yaml:"enabled"`
	// BasePath bare 仓库根目录;默认 <backup_dir>/git-serve
	BasePath string `yaml:"base_path"`
	// PublicRead true=无需鉴权(仅内网);默认 false
	PublicRead bool `yaml:"public_read"`
}

GitServeSettings 对应 yaml git_serve 段。

type HistoryChainResult added in v1.24.0

type HistoryChainResult = coreservice.HistoryChainResult

HistoryChainResult 通道内执行记录链的校验结果。

type HistoryChannelDTO added in v1.24.0

type HistoryChannelDTO = coreservice.HistoryChannelDTO

HistoryChannelDTO 通道的响应视图。

type HistoryChannelInput added in v1.24.0

type HistoryChannelInput = coreservice.HistoryChannelInput

HistoryChannelInput 通道的创建/更新入参。

type HistoryCredentialInput added in v1.24.0

type HistoryCredentialInput = coreservice.HistoryCredentialInput

HistoryCredentialInput 凭据轮换入参。

type HistoryOverrideDTO added in v1.24.0

type HistoryOverrideDTO = coreservice.HistoryOverrideDTO

HistoryOverrideDTO 裁决响应视图。

type HistoryOverrideInput added in v1.24.0

type HistoryOverrideInput = coreservice.HistoryOverrideInput

HistoryOverrideInput 裁决入参。

type HistoryPlanDTO added in v1.24.0

type HistoryPlanDTO = coreservice.HistoryPlanDTO

HistoryPlanDTO 同步计划的精简视图。

type HistoryPushDTO added in v1.24.0

type HistoryPushDTO = coreservice.HistoryPushDTO

HistoryPushDTO 推送结果。

type HistoryPushOptions added in v1.25.0

type HistoryPushOptions = coreservice.HistoryPushOptions

HistoryPushOptions 推送选项。

type HistoryRollbackDTO added in v1.24.0

type HistoryRollbackDTO = coreservice.HistoryRollbackDTO

HistoryRollbackDTO 回滚结果。

type HistoryRunDTO added in v1.24.0

type HistoryRunDTO = coreservice.HistoryRunDTO

HistoryRunDTO 执行记录的响应视图。

type HistorySummary added in v1.24.0

type HistorySummary = history.Summary

HistorySummary 计划统计。

type HistorySyncOptions added in v1.24.0

type HistorySyncOptions = coreservice.HistorySyncOptions

HistorySyncOptions 一次同步的选项。

type HistorySyncReport added in v1.24.0

type HistorySyncReport = coreservice.HistorySyncReport

HistorySyncReport 一次同步的结果。

type HistoryTargetDTO added in v1.24.0

type HistoryTargetDTO = coreservice.HistoryTargetDTO

HistoryTargetDTO 推送目标的响应视图(不回显凭据)。

type HistoryTargetInput added in v1.24.0

type HistoryTargetInput = coreservice.HistoryTargetInput

HistoryTargetInput 推送目标的创建/更新入参。

type ManifestVerifyResult added in v1.18.0

type ManifestVerifyResult = coreservice.ManifestVerifyResult

type MetadataBackupInfo added in v1.21.0

type MetadataBackupInfo = coreservice.MetadataBackupInfo

type MetadataBackupOptions added in v1.21.0

type MetadataBackupOptions = coreservice.MetadataBackupOptions

type MetadataBackupResult added in v1.21.0

type MetadataBackupResult = coreservice.MetadataBackupResult

type MetadataSnapshot added in v1.21.0

type MetadataSnapshot = coreservice.MetadataSnapshot

type MirrorChannel

type MirrorChannel = model.MirrorChannel

type MirrorRun

type MirrorRun = model.MirrorRun

type MirrorScrubRuleInput added in v1.25.0

type MirrorScrubRuleInput = coreservice.MirrorScrubRuleInput

MirrorScrubRuleInput 痕迹清理规则的入参(镜像发布用)。

type MirrorStep

type MirrorStep = model.MirrorStep

type MirrorTarget

type MirrorTarget = model.MirrorTarget

type MirrorTargetInput

type MirrorTargetInput = coreservice.MirrorTargetInput

type MirrorVersion

type MirrorVersion = coreservice.MirrorVersion

type MirrorVersionTarget

type MirrorVersionTarget = coreservice.MirrorVersionTarget

type MirrorVersionsResult

type MirrorVersionsResult = coreservice.MirrorVersionsResult

type OIDCSettings added in v1.18.0

type OIDCSettings struct {
	Enabled     bool   `yaml:"enabled"`
	Secret      string `yaml:"secret"`
	Issuer      string `yaml:"issuer"`
	Audience    string `yaml:"audience"`
	RoleClaim   string `yaml:"role_claim"`
	UserClaim   string `yaml:"user_claim"`
	DefaultRole string `yaml:"default_role"`
}

OIDCSettings 对应 yaml auth.oidc 段。

type OperationLog

type OperationLog = model.OperationLog

type OperationLogFilter

type OperationLogFilter = dao.OperationLogFilter

type Option added in v1.21.0

type Option = coreservice.Option

func WithDB added in v1.21.0

func WithDB(db *gorm.DB) Option

func WithForcePushApprover added in v1.21.0

func WithForcePushApprover(a executor.ForcePushApprover) Option

func WithProviderHooks added in v1.21.0

func WithProviderHooks(h *sdkprov.Hooks) Option

type OrgMapOptions added in v1.21.0

type OrgMapOptions = coreservice.OrgMapOptions

type OrgMapResult added in v1.21.0

type OrgMapResult = coreservice.OrgMapResult

func ResolveOrgTarget added in v1.21.0

func ResolveOrgTarget(sourceOwner, sourceRepo string, o *OrgMapOptions) (OrgMapResult, error)

ResolveOrgTarget 目标 owner/repo 映射(OrgMapOptions 较大,按指针传)。

type OrgMapStrategy added in v1.21.0

type OrgMapStrategy = coreservice.OrgMapStrategy

func ParseOrgMapStrategy added in v1.21.0

func ParseOrgMapStrategy(s string) (OrgMapStrategy, error)

type OrgRepoItem added in v1.21.0

type OrgRepoItem = coreservice.OrgRepoItem

type Pagination

type Pagination = dao.Pagination

type PathRuleDTO added in v1.24.0

type PathRuleDTO = coreservice.PathRuleDTO

PathRuleDTO 路径规则。

type Platform

type Platform = model.Platform

type PreviewReport added in v1.24.0

type PreviewReport = coreservice.PreviewReport

PreviewReport 预检报告。

type PreviewSyncRequest

type PreviewSyncRequest = model.PreviewSyncRequest

type PreviewSyncResult

type PreviewSyncResult = model.PreviewSyncResult

type PublicOrgImportRequest added in v1.21.0

type PublicOrgImportRequest = coreservice.PublicOrgImportRequest

type PublicOrgImportResult added in v1.21.0

type PublicOrgImportResult = coreservice.PublicOrgImportResult

type RPOMetric added in v1.18.0

type RPOMetric = coreservice.RPOMetric

type RPOReport added in v1.18.0

type RPOReport = coreservice.RPOReport

type Repo

type Repo = model.Repo

type RepoFilter

type RepoFilter = dao.RepoFilter

type RepoImportFilter added in v1.17.0

type RepoImportFilter = coreservice.RepoImportFilter

type Resolution added in v1.24.0

type Resolution = history.Resolution

Resolution hold 文件的解法。

type RestoreKindStat added in v1.21.0

type RestoreKindStat = coreservice.RestoreKindStat

type RestoreRequest added in v1.21.0

type RestoreRequest = coreservice.RestoreRequest

type RestoreResult added in v1.21.0

type RestoreResult = coreservice.RestoreResult

type RetryDecision added in v1.21.0

type RetryDecision = coreservice.Decision

type RetryTracker added in v1.21.0

type RetryTracker = coreservice.RetryTracker

func NewRetryTracker added in v1.21.0

func NewRetryTracker(maxKeep int) *RetryTracker

type RunEvent added in v1.21.0

type RunEvent = coreservice.RunEvent

type RunWatchSettings added in v1.17.0

type RunWatchSettings struct {
	// Mode 事件源:event(默认,订阅 core 完成事件) | poll(轮询兜底)
	Mode            string `yaml:"mode"`
	IntervalSeconds int    `yaml:"interval_seconds"`
	HistoryLimit    int    `yaml:"history_limit"`
	Retry           struct {
		MaxAutoRetries  int `yaml:"max_auto_retries"`
		CooldownMinutes int `yaml:"cooldown_minutes"`
	} `yaml:"retry"`
}

RunWatchSettings 对应 yaml runwatch 段,main 启动时转成 runwatch.Config。

type ScrubHit added in v1.24.0

type ScrubHit = history.ScrubHit

ScrubHit 痕迹命中项。

type ScrubRuleDTO added in v1.24.0

type ScrubRuleDTO = coreservice.ScrubRuleDTO

ScrubRuleDTO 痕迹规则。

type Service

type Service = synccore.Service

func NewService

func NewService(cfg *Config, opts ...Option) (*Service, error)

type ShellConfig

type ShellConfig struct {
	*Config
	// APIKey 公网壳默认 X-API-Key;内网壳可忽略,改用网关/SSO。
	APIKey string
	// APIKeyRole 共享 API Key 的 RBAC 角色(admin/operator/readonly),默认 admin。
	APIKeyRole string
	// OIDC 可选 JWT Bearer 鉴权(HS256)。
	OIDC *OIDCSettings
	// Notify 多通道通知(ntfy/gotify/heartbeat)。
	Notify *notify.Config
	// RunWatch 运行观察与失败自动补偿设置。
	// 独立 struct 而非 runwatch.Config:corebridge 不依赖 runwatch,避免 import 环。
	RunWatch *RunWatchSettings
	// GitServe 只读 Git Smart HTTP(局域网/灾备 clone)。
	GitServe *GitServeSettings
}

ShellConfig 引擎配置 + 壳层登录/通知配置(不进 core)。

func LoadShellConfig

func LoadShellConfig(path string) (*ShellConfig, error)

LoadShellConfig 加载 core 配置,并叠加壳层 server.api_key / auth.oidc / notify / runwatch。

INTEGRATION: yaml server.api_key 或环境变量 GIT_SYNC_SERVER_API_KEY

type SyncRun

type SyncRun = model.SyncRun

type SyncRunStep

type SyncRunStep = model.SyncRunStep

type SyncTask

type SyncTask = model.SyncTask

type TagStatus

type TagStatus = model.TagStatus

type TargetImpact added in v1.24.0

type TargetImpact = coreservice.TargetImpact

TargetImpact 推送目标的影响面。

type UpdateRepoRequest

type UpdateRepoRequest = model.UpdateRepoRequest

type UpdateRuleRequest

type UpdateRuleRequest = model.UpdateRuleRequest

type UpdateTaskRequest

type UpdateTaskRequest = model.UpdateTaskRequest

type VerifyReport added in v1.21.0

type VerifyReport = coreservice.VerifyReport

type WebhookEvent

type WebhookEvent = model.WebhookEvent

type WebhookPayload

type WebhookPayload = synccore.WebhookPayload

type WebhookRule

type WebhookRule = model.WebhookRule

Jump to

Keyboard shortcuts

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