Documentation
¶
Index ¶
- Constants
- func AIChat(ctx context.Context, c *app.RequestContext)
- func AIGetConfig(ctx context.Context, c *app.RequestContext)
- func AIListModels(ctx context.Context, c *app.RequestContext)
- func AIStatus(ctx context.Context, c *app.RequestContext)
- func AITestConfig(ctx context.Context, c *app.RequestContext)
- func AIUpdateConfig(ctx context.Context, c *app.RequestContext)
- func AdminGuard() app.HandlerFunc
- func ApplyTemplate(ctx context.Context, c *app.RequestContext)
- func ApproveForcePush(ctx context.Context, c *app.RequestContext)
- func AuditReport(ctx context.Context, c *app.RequestContext)
- func AutoDiscover(ctx context.Context, c *app.RequestContext)
- func BackupGists(ctx context.Context, c *app.RequestContext)
- func BatchRepos(ctx context.Context, c *app.RequestContext)
- func BatchRetryFailed(ctx context.Context, c *app.RequestContext)
- func BuildBackupManifest(ctx context.Context, c *app.RequestContext)
- func CanWriteRole(r Role) bool
- func CleanupBackups(ctx context.Context, c *app.RequestContext)
- func CloseWebhookRateLimiter()
- func CreatePlatform(ctx context.Context, c *app.RequestContext)
- func CreateTemplate(ctx context.Context, c *app.RequestContext)
- func DeleteHistory(ctx context.Context, c *app.RequestContext)
- func DeletePlatform(ctx context.Context, c *app.RequestContext)
- func DeletePlatformWebhook(ctx context.Context, c *app.RequestContext)
- func DeleteTemplate(ctx context.Context, c *app.RequestContext)
- func DetectDrift(ctx context.Context, c *app.RequestContext)
- func DiagnoseRun(ctx context.Context, c *app.RequestContext)
- func DrillHistory(ctx context.Context, c *app.RequestContext)
- func ExportDrillHistory(ctx context.Context, c *app.RequestContext)
- func ExportGitHubMigration(ctx context.Context, c *app.RequestContext)
- func ExportIssues(ctx context.Context, c *app.RequestContext)
- func GenerateDeployKey(ctx context.Context, c *app.RequestContext)
- func GetAPIKey() string
- func GetAPIKeyRole() string
- func GetAuthUser(c appRequestContext) string
- func GetPlatform(ctx context.Context, c *app.RequestContext)
- func GetRBAC(_ context.Context, c *app.RequestContext)
- func GetSyncService() *corebridge.Service
- func GitServeBasePath() string
- func GitServeEnabled() bool
- func GitServePublic() bool
- func HealthCheck(ctx context.Context, c *app.RequestContext)
- func HealthScore(ctx context.Context, c *app.RequestContext)
- func HistoryChannelApply(ctx context.Context, c *app.RequestContext)
- func HistoryChannelAudit(ctx context.Context, c *app.RequestContext)
- func HistoryChannelCreate(ctx context.Context, c *app.RequestContext)
- func HistoryChannelDelete(ctx context.Context, c *app.RequestContext)
- func HistoryChannelGet(ctx context.Context, c *app.RequestContext)
- func HistoryChannelList(ctx context.Context, c *app.RequestContext)
- func HistoryChannelPlan(ctx context.Context, c *app.RequestContext)
- func HistoryChannelPreview(ctx context.Context, c *app.RequestContext)
- func HistoryChannelPreviewMarkdown(ctx context.Context, c *app.RequestContext)
- func HistoryChannelPush(ctx context.Context, c *app.RequestContext)
- func HistoryChannelResolve(ctx context.Context, c *app.RequestContext)
- func HistoryChannelUpdate(ctx context.Context, c *app.RequestContext)
- func HistoryOverrideDelete(ctx context.Context, c *app.RequestContext)
- func HistoryOverrideList(ctx context.Context, c *app.RequestContext)
- func HistoryOverrideSet(ctx context.Context, c *app.RequestContext)
- func HistoryRunGet(ctx context.Context, c *app.RequestContext)
- func HistoryRunList(ctx context.Context, c *app.RequestContext)
- func HistoryRunRollback(ctx context.Context, c *app.RequestContext)
- func HistorySync(ctx context.Context, c *app.RequestContext)
- func HistoryTargetCreate(ctx context.Context, c *app.RequestContext)
- func HistoryTargetDelete(ctx context.Context, c *app.RequestContext)
- func HistoryTargetList(ctx context.Context, c *app.RequestContext)
- func HistoryTargetRotate(ctx context.Context, c *app.RequestContext)
- func HistoryTargetUpdate(ctx context.Context, c *app.RequestContext)
- func ImportPublicOrg(ctx context.Context, c *app.RequestContext)
- func ImportStarred(ctx context.Context, c *app.RequestContext)
- func ListBundles(ctx context.Context, c *app.RequestContext)
- func ListEvents(ctx context.Context, c *app.RequestContext)
- func ListForcePushApprovals(_ context.Context, c *app.RequestContext)
- func ListMetadataBackups(ctx context.Context, c *app.RequestContext)
- func ListOperationLogs(ctx context.Context, c *app.RequestContext)
- func ListPlatformRepos(ctx context.Context, c *app.RequestContext)
- func ListPlatformWebhooks(ctx context.Context, c *app.RequestContext)
- func ListPlatforms(ctx context.Context, c *app.RequestContext)
- func ListTemplates(ctx context.Context, c *app.RequestContext)
- func MetadataBackup(ctx context.Context, c *app.RequestContext)
- func MetadataRestore(ctx context.Context, c *app.RequestContext)
- func MetricsMiddleware() app.HandlerFunc
- func MirrorChannelCreate(ctx context.Context, c *app.RequestContext)
- func MirrorChannelDelete(ctx context.Context, c *app.RequestContext)
- func MirrorChannelGet(ctx context.Context, c *app.RequestContext)
- func MirrorChannelList(ctx context.Context, c *app.RequestContext)
- func MirrorPreview(ctx context.Context, c *app.RequestContext)
- func MirrorRunCreate(ctx context.Context, c *app.RequestContext)
- func MirrorRunGet(ctx context.Context, c *app.RequestContext)
- func MirrorRunList(ctx context.Context, c *app.RequestContext)
- func MirrorTargetDelete(ctx context.Context, c *app.RequestContext)
- func MirrorTargetTest(ctx context.Context, c *app.RequestContext)
- func MirrorTargetUpdate(ctx context.Context, c *app.RequestContext)
- func MirrorVerify(ctx context.Context, c *app.RequestContext)
- func MirrorVersions(ctx context.Context, c *app.RequestContext)
- func OIDCAuthMiddleware() app.HandlerFunc
- func OpsTodo(ctx context.Context, c *app.RequestContext)
- func OpsTrends(ctx context.Context, c *app.RequestContext)
- func OrgMirror(ctx context.Context, c *app.RequestContext)
- func PreviewTemplate(ctx context.Context, c *app.RequestContext)
- func ProviderHooks() *sdkprov.Hooks
- func PushBackup(ctx context.Context, c *app.RequestContext)
- func RPOReport(ctx context.Context, c *app.RequestContext)
- func RateLimitMiddleware() app.HandlerFunc
- func RebuildRepo(ctx context.Context, c *app.RequestContext)
- func ReceiveWebhook(ctx context.Context, c *app.RequestContext)
- func RegisterPlatformWebhook(ctx context.Context, c *app.RequestContext)
- func RepoBranches(ctx context.Context, c *app.RequestContext)
- func RepoCreate(ctx context.Context, c *app.RequestContext)
- func RepoDelete(ctx context.Context, c *app.RequestContext)
- func RepoFiles(ctx context.Context, c *app.RequestContext)
- func RepoGet(ctx context.Context, c *app.RequestContext)
- func RepoInventory(ctx context.Context, c *app.RequestContext)
- func RepoList(ctx context.Context, c *app.RequestContext)
- func RepoTest(ctx context.Context, c *app.RequestContext)
- func RepoUpdate(ctx context.Context, c *app.RequestContext)
- func RequestForcePushApproval(ctx context.Context, c *app.RequestContext)
- func ResolveOrgTarget(ctx context.Context, c *app.RequestContext)
- func RestoreBundle(ctx context.Context, c *app.RequestContext)
- func RetryEvent(ctx context.Context, c *app.RequestContext)
- func RetryRun(ctx context.Context, c *app.RequestContext)
- func RevokeForcePush(ctx context.Context, c *app.RequestContext)
- func RuleCreate(ctx context.Context, c *app.RequestContext)
- func RuleDelete(ctx context.Context, c *app.RequestContext)
- func RuleGet(ctx context.Context, c *app.RequestContext)
- func RuleList(ctx context.Context, c *app.RequestContext)
- func RuleUpdate(ctx context.Context, c *app.RequestContext)
- func RunDRDrill(ctx context.Context, c *app.RequestContext)
- func SetAIRebuildRunner(fn func(*agent.Settings) error)
- func SetAISettingsStore(get func() *agent.SettingsStore)
- func SetAPIKey(key string)
- func SetAPIKeyRole(role string)
- func SetAgentRunner(fn func() *agent.Runner)
- func SetAuthRole(c *app.RequestContext, r Role)
- func SetAuthUser(c appRequestContext, user string)
- func SetDefaultPlatform(ctx context.Context, c *app.RequestContext)
- func SetGitServe(enabled bool, basePath string, publicRead bool)
- func SetOIDCConfig(cfg *OIDCConfig)
- func SetSyncServiceGetter(fn func() *corebridge.Service)
- func SyncOverview(ctx context.Context, c *app.RequestContext)
- func SyncPlatformFiltered(ctx context.Context, c *app.RequestContext)
- func SyncPlatformRepos(ctx context.Context, c *app.RequestContext)
- func SystemStatus(ctx context.Context, c *app.RequestContext)
- func TaskCreate(ctx context.Context, c *app.RequestContext)
- func TaskDelete(ctx context.Context, c *app.RequestContext)
- func TaskGet(ctx context.Context, c *app.RequestContext)
- func TaskHistory(ctx context.Context, c *app.RequestContext)
- func TaskList(ctx context.Context, c *app.RequestContext)
- func TaskPreview(ctx context.Context, c *app.RequestContext)
- func TaskRun(ctx context.Context, c *app.RequestContext)
- func TaskUpdate(ctx context.Context, c *app.RequestContext)
- func TestPlatformConnection(ctx context.Context, c *app.RequestContext)
- func UpdatePlatform(ctx context.Context, c *app.RequestContext)
- func VerifyAuditChain(ctx context.Context, c *app.RequestContext)
- func VerifyBackupManifest(ctx context.Context, c *app.RequestContext)
- func VerifyBundle(ctx context.Context, c *app.RequestContext)
- func VerifyDrillChain(ctx context.Context, c *app.RequestContext)
- func WriteGuard() app.HandlerFunc
- type AuditReportReq
- type ImportPublicOrgReq
- type OIDCConfig
- type Role
Constants ¶
const ( RoleAdmin = authz.RoleAdmin RoleOperator = authz.RoleOperator RoleReadonly = authz.RoleReadonly )
Variables ¶
This section is empty.
Functions ¶
func AIChat ¶
func AIChat(ctx context.Context, c *app.RequestContext)
AIChat POST /api/v1/ai/chat —— SSE 流式响应。 事件:start(含 session_id)→ delta* / tool_start / tool_end / tool_confirm → done|error。
func AIGetConfig ¶ added in v1.17.0
func AIGetConfig(ctx context.Context, c *app.RequestContext)
AIGetConfig GET /api/v1/ai/config —— 读取 AI 配置(密钥脱敏)。
func AIListModels ¶ added in v1.18.0
func AIListModels(ctx context.Context, c *app.RequestContext)
AIListModels POST /api/v1/ai/models —— 列出 OpenAI 兼容端点可用模型。 Body: base_url(必填), api_key(可选,缺省用已保存密钥)。
**必须是 POST**:api_key 放 query 会进浏览器历史 / Referer / 反向代理 access log ⇒ 密钥泄漏(之前就是 GET+query)。
func AIStatus ¶
func AIStatus(ctx context.Context, c *app.RequestContext)
AIStatus GET /api/v1/ai/status —— 前端探测 AI 是否可用。
func AITestConfig ¶ added in v1.17.0
func AITestConfig(ctx context.Context, c *app.RequestContext)
AITestConfig POST /api/v1/ai/config/test —— 探测 OpenAI 兼容端点(不落盘)。
func AIUpdateConfig ¶ added in v1.17.0
func AIUpdateConfig(ctx context.Context, c *app.RequestContext)
AIUpdateConfig POST /api/v1/ai/config —— 更新配置并热生效。
func ApplyTemplate ¶ added in v1.17.0
func ApplyTemplate(ctx context.Context, c *app.RequestContext)
ApplyTemplate 批量套用策略模板(借鉴 Renovate packageRules 应用)。 只更新已存在任务的 cron/分支/启用位;不隐式创建任务,避免误建。
func ApproveForcePush ¶ added in v1.19.3
func ApproveForcePush(ctx context.Context, c *app.RequestContext)
ApproveForcePush POST /api/v1/ops/force-push-approvals/approve Admin 一次性放行指定审批。
func AuditReport ¶ added in v1.17.0
func AuditReport(ctx context.Context, c *app.RequestContext)
AuditReport 导出操作日志,便于合规留档(策略变更/重试记录都在审计里)。
func AutoDiscover ¶ added in v1.18.0
func AutoDiscover(ctx context.Context, c *app.RequestContext)
AutoDiscover POST /api/v1/ops/auto-discover 扫描平台仓库找本地未登记项;import_new=true 时自动导入。
func BackupGists ¶ added in v1.18.0
func BackupGists(ctx context.Context, c *app.RequestContext)
BackupGists POST /api/v1/ops/gists-backup 备份平台 token 可见的 gists 到冷备目录(仅 GitHub)。
func BatchRepos ¶
func BatchRepos(ctx context.Context, c *app.RequestContext)
BatchRepos 批量操作仓库(目前仅支持 delete)。
func BatchRetryFailed ¶ added in v1.17.0
func BatchRetryFailed(ctx context.Context, c *app.RequestContext)
BatchRetryFailed 扫描最近失败执行并批量重跑(返回将要/已重试列表)。
func BuildBackupManifest ¶ added in v1.18.0
func BuildBackupManifest(ctx context.Context, c *app.RequestContext)
BuildBackupManifest POST /api/v1/ops/backup-manifest
func CanWriteRole ¶ added in v1.25.0
CanWriteRole 判断角色能否执行写操作(admin/operator)。
给**绕过路由层**的调用方用(MCP 端点与 AI 助手直接调 core service, 不过路由的 WriteGuard)—— 那条路上没有中间件兜底,只能就地判。
func CleanupBackups ¶ added in v1.18.0
func CleanupBackups(ctx context.Context, c *app.RequestContext)
CleanupBackups POST /api/v1/ops/backup-cleanup 按 retention 天数清理;legal_hold 时拒绝。
func CloseWebhookRateLimiter ¶ added in v1.23.0
func CloseWebhookRateLimiter()
CloseWebhookRateLimiter 关闭 webhook 限流器的后台回收 goroutine。 服务退出路径应在 HTTP 排空后调用它(与 core.Service.Stop 同一批次)。
func CreatePlatform ¶
func CreatePlatform(ctx context.Context, c *app.RequestContext)
CreatePlatform 创建平台
func CreateTemplate ¶ added in v1.17.0
func CreateTemplate(ctx context.Context, c *app.RequestContext)
CreateTemplate POST /api/v1/ops/templates
func DeleteHistory ¶
func DeleteHistory(ctx context.Context, c *app.RequestContext)
DeleteHistory 删除单条同步执行历史(失败记录清理用)。
func DeletePlatform ¶
func DeletePlatform(ctx context.Context, c *app.RequestContext)
DeletePlatform 删除平台
func DeletePlatformWebhook ¶
func DeletePlatformWebhook(ctx context.Context, c *app.RequestContext)
DeletePlatformWebhook 删除平台侧的 Webhook。 @router /api/v1/webhook/platform/delete [POST]
func DeleteTemplate ¶ added in v1.17.0
func DeleteTemplate(ctx context.Context, c *app.RequestContext)
DeleteTemplate POST /api/v1/ops/templates/delete?id=
func DetectDrift ¶ added in v1.18.0
func DetectDrift(ctx context.Context, c *app.RequestContext)
DetectDrift POST /api/v1/ops/drift 比对本地 workdir 与目标远端分支 tip,发现静默漂移。
func DiagnoseRun ¶ added in v1.17.0
func DiagnoseRun(ctx context.Context, c *app.RequestContext)
DiagnoseRun GET /api/v1/ops/diagnose?run_id= 对失败 run 做结构化诊断:错误分类 → 可能原因 → 建议动作。 借鉴 AI 助手的解释能力,但无需模型即可给出规则化结论。
func DrillHistory ¶ added in v1.18.0
func DrillHistory(ctx context.Context, c *app.RequestContext)
DrillHistory GET /api/v1/ops/dr-drill/history?limit=
func ExportDrillHistory ¶ added in v1.19.0
func ExportDrillHistory(ctx context.Context, c *app.RequestContext)
ExportDrillHistory GET /api/v1/ops/dr-drill/export?format=json|csv&limit=
func ExportGitHubMigration ¶ added in v1.17.0
func ExportGitHubMigration(ctx context.Context, c *app.RequestContext)
ExportGitHubMigration POST /api/v1/ops/migration 调 GitHub Migration API 导出用户/组织全量 tar.gz(仓库+issues+PR+releases)。 与逐项 issues-export 互补:这是平台原生「一键全量归档」。
func ExportIssues ¶ added in v1.17.0
func ExportIssues(ctx context.Context, c *app.RequestContext)
ExportIssues GET /api/v1/ops/issues-export 借鉴 gickup 的 issues 备份:导出仓库 issue 列表,可选带评论。
func GenerateDeployKey ¶ added in v1.17.0
func GenerateDeployKey(ctx context.Context, c *app.RequestContext)
GenerateDeployKey POST /api/v1/ops/deploy-key 生成 Ed25519 密钥对:私钥交给镜像任务,公钥粘贴到目标平台 deploy key。 私钥只在响应中返回一次,不落库(调用方自行存入密钥管理)。
func GetAPIKeyRole ¶ added in v1.18.0
func GetAPIKeyRole() string
GetAPIKeyRole 返回 API Key 角色;未设置时读环境变量,默认 admin(兼容旧行为)。
func GetRBAC ¶ added in v1.18.0
func GetRBAC(_ context.Context, c *app.RequestContext)
GetRBAC GET /api/v1/ops/rbac 返回当前调用方角色(供前端隐藏无权按钮)。
func GetSyncService ¶
func GetSyncService() *corebridge.Service
func GitServeBasePath ¶ added in v1.19.1
func GitServeBasePath() string
GitServeBasePath 返回 bare 仓库根目录。
func HealthCheck ¶
func HealthCheck(ctx context.Context, c *app.RequestContext)
HealthCheck returns the health status of the service and its dependencies. 公开端点:不应因内部状态 panic(GetSyncService 可能返回 nil,如启动时序问题)。
func HealthScore ¶ added in v1.17.0
func HealthScore(ctx context.Context, c *app.RequestContext)
HealthScore 按维度规则给任务打分(借鉴 OpenSSF Scorecards)。 维度:reliability(35) / freshness(20) / schedule(15) / safety(15) / completeness(15)
func HistoryChannelApply ¶ added in v1.24.0
func HistoryChannelApply(ctx context.Context, c *app.RequestContext)
HistoryChannelApply 按通道把计划落到目标树,产出执行记录(本地,不推送)。
func HistoryChannelAudit ¶ added in v1.24.0
func HistoryChannelAudit(ctx context.Context, c *app.RequestContext)
HistoryChannelAudit 校验通道内执行记录的哈希链。
func HistoryChannelCreate ¶ added in v1.24.0
func HistoryChannelCreate(ctx context.Context, c *app.RequestContext)
HistoryChannelCreate 新建历史同步通道。
func HistoryChannelDelete ¶ added in v1.24.0
func HistoryChannelDelete(ctx context.Context, c *app.RequestContext)
HistoryChannelDelete 删除通道(连同其推送目标)。
func HistoryChannelGet ¶ added in v1.24.0
func HistoryChannelGet(ctx context.Context, c *app.RequestContext)
HistoryChannelGet 通道详情(含推送目标)。
func HistoryChannelList ¶ added in v1.24.0
func HistoryChannelList(ctx context.Context, c *app.RequestContext)
HistoryChannelList 列出历史同步通道。
func HistoryChannelPlan ¶ added in v1.24.0
func HistoryChannelPlan(ctx context.Context, c *app.RequestContext)
HistoryChannelPlan 按通道生成同步计划(纯读)。
func HistoryChannelPreview ¶ added in v1.24.0
func HistoryChannelPreview(ctx context.Context, c *app.RequestContext)
HistoryChannelPreview 执行预检:把这次同步的全部影响面摊开,但不推送。
纯读:不推送、不改原始目标仓。物化与门禁都在临时工作副本上进行, 与真正执行走的是同一套代码路径 —— 预检结论必须与执行结论一致。
func HistoryChannelPreviewMarkdown ¶ added in v1.24.0
func HistoryChannelPreviewMarkdown(ctx context.Context, c *app.RequestContext)
HistoryChannelPreviewMarkdown 预检报告的 Markdown 视图(给人读)。
func HistoryChannelPush ¶ added in v1.24.0
func HistoryChannelPush(ctx context.Context, c *app.RequestContext)
HistoryChannelPush 按通道推送最近一次执行记录的产物(危险)。
func HistoryChannelResolve ¶ added in v1.24.0
func HistoryChannelResolve(ctx context.Context, c *app.RequestContext)
HistoryChannelResolve 按通道生成计划并计算 hold 的自动解法(含冲突卷宗)。
func HistoryChannelUpdate ¶ added in v1.24.0
func HistoryChannelUpdate(ctx context.Context, c *app.RequestContext)
HistoryChannelUpdate 更新通道。
func HistoryOverrideDelete ¶ added in v1.24.0
func HistoryOverrideDelete(ctx context.Context, c *app.RequestContext)
HistoryOverrideDelete 删除一条裁决(回到自动判定)。
func HistoryOverrideList ¶ added in v1.24.0
func HistoryOverrideList(ctx context.Context, c *app.RequestContext)
HistoryOverrideList 列出通道的裁决。
func HistoryOverrideSet ¶ added in v1.24.0
func HistoryOverrideSet(ctx context.Context, c *app.RequestContext)
HistoryOverrideSet 写入(或覆盖)一条裁决。
func HistoryRunGet ¶ added in v1.24.0
func HistoryRunGet(ctx context.Context, c *app.RequestContext)
HistoryRunGet 执行记录详情(审计材料:计划统计/commit 映射/检测报告/ref 对照)。
func HistoryRunList ¶ added in v1.24.0
func HistoryRunList(ctx context.Context, c *app.RequestContext)
HistoryRunList 列出通道的执行记录。
func HistoryRunRollback ¶ added in v1.24.0
func HistoryRunRollback(ctx context.Context, c *app.RequestContext)
HistoryRunRollback 把目标树回滚到指定 ref(危险)。
func HistorySync ¶ added in v1.24.0
func HistorySync(ctx context.Context, c *app.RequestContext)
HistorySync 一次跑完「预检 → 移植 → 推送」。
有阻塞项(门禁不过 / 有待裁决冲突 / 需强推)时**停下并报告**,不往下走。
func HistoryTargetCreate ¶ added in v1.24.0
func HistoryTargetCreate(ctx context.Context, c *app.RequestContext)
HistoryTargetCreate 新建推送目标(凭据加密落库,响应不回显)。
func HistoryTargetDelete ¶ added in v1.24.0
func HistoryTargetDelete(ctx context.Context, c *app.RequestContext)
HistoryTargetDelete 删除推送目标。
func HistoryTargetList ¶ added in v1.24.0
func HistoryTargetList(ctx context.Context, c *app.RequestContext)
HistoryTargetList 列出通道的推送目标(顺序 = 推送优先级)。
func HistoryTargetRotate ¶ added in v1.24.0
func HistoryTargetRotate(ctx context.Context, c *app.RequestContext)
HistoryTargetRotate 轮换推送目标的凭据(只换密钥,不动 URL)。
func HistoryTargetUpdate ¶ added in v1.24.0
func HistoryTargetUpdate(ctx context.Context, c *app.RequestContext)
HistoryTargetUpdate 更新推送目标。
func ImportPublicOrg ¶ added in v1.19.3
func ImportPublicOrg(ctx context.Context, c *app.RequestContext)
ImportPublicOrg POST /api/v1/ops/import-public-org 列出组织公开仓并可选建同步任务(默认只导入仓库记录)。 编排在 core Service.ImportPublicOrg;壳做绑定、平台校验、审计与响应包装。
func ImportStarred ¶ added in v1.19.3
func ImportStarred(ctx context.Context, c *app.RequestContext)
ImportStarred POST /api/v1/ops/import-starred 拉取平台 starred 仓库并可选导入。
func ListBundles ¶ added in v1.17.0
func ListBundles(ctx context.Context, c *app.RequestContext)
ListBundles GET /api/v1/ops/bundles
func ListEvents ¶
func ListEvents(ctx context.Context, c *app.RequestContext)
func ListForcePushApprovals ¶ added in v1.19.3
func ListForcePushApprovals(_ context.Context, c *app.RequestContext)
ListForcePushApprovals GET /api/v1/ops/force-push-approvals
func ListMetadataBackups ¶ added in v1.18.0
func ListMetadataBackups(ctx context.Context, c *app.RequestContext)
ListMetadataBackups GET /api/v1/ops/metadata-backups?repo_key=
func ListOperationLogs ¶
func ListOperationLogs(ctx context.Context, c *app.RequestContext)
ListOperationLogs GET /api/v1/logs/operations 返回 {list, pagination, stats}(stats.total 为全量总数,pagination.total 为过滤后的结果数)。
func ListPlatformRepos ¶
func ListPlatformRepos(ctx context.Context, c *app.RequestContext)
ListPlatformRepos 列出平台上的仓库(从远程 API 获取)
func ListPlatformWebhooks ¶
func ListPlatformWebhooks(ctx context.Context, c *app.RequestContext)
ListPlatformWebhooks 列出平台侧已注册的 Webhook。 @router /api/v1/webhook/platform/list [GET]
func ListPlatforms ¶
func ListPlatforms(ctx context.Context, c *app.RequestContext)
ListPlatforms 列出所有平台
func ListTemplates ¶ added in v1.17.0
func ListTemplates(ctx context.Context, c *app.RequestContext)
ListTemplates GET /api/v1/ops/templates
func MetadataBackup ¶ added in v1.18.0
func MetadataBackup(ctx context.Context, c *app.RequestContext)
MetadataBackup POST /api/v1/ops/metadata-backup 抓取 issues/PR/labels/milestones/releases 元数据快照, 可选下载 source archive / GitHub Release 附件 / Gists。 请求体绑定 biz/model/ops(IDL 生成,snake_case 标签)。 采集引擎在 core(Service.BackupMetadata,经 ProviderForPlatform 取数); 本层只做 Bind → core → DTO 转换 → 审计。
func MetadataRestore ¶ added in v1.19.1
func MetadataRestore(ctx context.Context, c *app.RequestContext)
MetadataRestore POST /api/v1/ops/metadata-restore 将 metadata-backup 快照回灌到目标仓:labels → milestones → issues → PRs(以 issue 形态) → releases。 dry_run 缺省 true(安全默认);overwrite=false 时同名跳过。 回灌引擎在 core(Service.RestoreMetadata);本层只做 Bind → core → DTO 转换 → 审计。
func MetricsMiddleware ¶ added in v1.17.0
func MetricsMiddleware() app.HandlerFunc
MetricsMiddleware 记录 HTTP 请求量(方法/路径/状态码)。
func MirrorChannelCreate ¶
func MirrorChannelCreate(ctx context.Context, c *app.RequestContext)
func MirrorChannelDelete ¶
func MirrorChannelDelete(ctx context.Context, c *app.RequestContext)
func MirrorChannelGet ¶
func MirrorChannelGet(ctx context.Context, c *app.RequestContext)
func MirrorChannelList ¶
func MirrorChannelList(ctx context.Context, c *app.RequestContext)
func MirrorPreview ¶
func MirrorPreview(ctx context.Context, c *app.RequestContext)
func MirrorRunCreate ¶
func MirrorRunCreate(ctx context.Context, c *app.RequestContext)
func MirrorRunGet ¶
func MirrorRunGet(ctx context.Context, c *app.RequestContext)
func MirrorRunList ¶
func MirrorRunList(ctx context.Context, c *app.RequestContext)
func MirrorTargetDelete ¶
func MirrorTargetDelete(ctx context.Context, c *app.RequestContext)
func MirrorTargetTest ¶
func MirrorTargetTest(ctx context.Context, c *app.RequestContext)
func MirrorTargetUpdate ¶
func MirrorTargetUpdate(ctx context.Context, c *app.RequestContext)
func MirrorVerify ¶
func MirrorVerify(ctx context.Context, c *app.RequestContext)
func MirrorVersions ¶
func MirrorVersions(ctx context.Context, c *app.RequestContext)
func OIDCAuthMiddleware ¶ added in v1.18.0
func OIDCAuthMiddleware() app.HandlerFunc
OIDCAuthMiddleware 校验 Authorization: Bearer <jwt>(HS256)。 未启用时返回 nil,调用方应回退默认 API Key 鉴权。
func OpsTodo ¶ added in v1.19.0
func OpsTodo(ctx context.Context, c *app.RequestContext)
OpsTodo GET /api/v1/ops/todo 聚合健康 attention + 孤儿仓库 + RPO 超标,按优先级输出可执行队列。 聚合规则在 core Service.OpsTodo;壳只做计数与响应包装。
func OpsTrends ¶ added in v1.20.0
func OpsTrends(ctx context.Context, c *app.RequestContext)
OpsTrends GET /api/v1/ops/trends?days=30 同步成功率/耗时时间序列(供前端小图)。聚合在 core Service.OpsTrends。
func OrgMirror ¶ added in v1.19.3
func OrgMirror(ctx context.Context, c *app.RequestContext)
OrgMirror POST /api/v1/ops/org-mirror 按策略(preserve|single|flat|mixed)把源组织仓库映射到目标命名空间,并可选建同步任务。
func PreviewTemplate ¶ added in v1.17.0
func PreviewTemplate(ctx context.Context, c *app.RequestContext)
PreviewTemplate 套用前预览命中结果(借鉴 Renovate dry-run)。
func ProviderHooks ¶ added in v1.21.0
ProviderHooks 返回 core provider 生命周期钩子(平台 API 限流指标)。 经 corebridge.WithProviderHooks 传入 NewService,钩子随 provider 构造固化, 不再依赖"先于 core 初始化调用"的时序约定。
平台 transport 已接管 429/5xx 及 403+X-RateLimit-Remaining=0 的退避重试; 这里只负责观测:每次响应命中限流特征即记一次 gitferry_api_ratelimit_total(含重试的每次尝试,与原 githubapi.Throttler "每次退避打点"近似)。
func PushBackup ¶ added in v1.20.0
func PushBackup(ctx context.Context, c *app.RequestContext)
PushBackup POST /api/v1/ops/push-backup 把任务 workdir 中的 mirror 推到额外备份远端(github/gitlab 任意 git remote)。 不改写 module 身份,纯备份副本;force 按 --force 与任务策略由调用方控制。
func RPOReport ¶ added in v1.18.0
func RPOReport(ctx context.Context, c *app.RequestContext)
RPOReport GET /api/v1/ops/rpo?max_seconds=
func RateLimitMiddleware ¶
func RateLimitMiddleware() app.HandlerFunc
RateLimitMiddleware 按客户端 IP 限流;超限返回 429。
func RebuildRepo ¶ added in v1.17.0
func RebuildRepo(ctx context.Context, c *app.RequestContext)
RebuildRepo POST /api/v1/ops/rebuild 触发一次「冷启动全量拉取」:由 core 在**拿到该任务的执行权之后**清空工作目录, 强制从源重新克隆。
**这里不再自己删目录**:workdir 按 taskKey 共享,受理阶段就删会和正在跑的 同步抢同一个目录(把跑着的工作树删掉),而且任务在跑时受理会失败, 结果是"目录被删了、重建没排上"。清目录的语义归 core (git-ferry-core service/rebuild.go),这里是唯一的 rebuild 语义入口。
func ReceiveWebhook ¶
func ReceiveWebhook(ctx context.Context, c *app.RequestContext)
func RegisterPlatformWebhook ¶
func RegisterPlatformWebhook(ctx context.Context, c *app.RequestContext)
RegisterPlatformWebhook 在平台侧为仓库注册 Webhook。 @router /api/v1/webhook/platform/register [POST]
func RepoBranches ¶
func RepoBranches(ctx context.Context, c *app.RequestContext)
func RepoCreate ¶
func RepoCreate(ctx context.Context, c *app.RequestContext)
func RepoDelete ¶
func RepoDelete(ctx context.Context, c *app.RequestContext)
func RepoFiles ¶ added in v1.20.0
func RepoFiles(ctx context.Context, c *app.RequestContext)
RepoFiles GET /api/v1/ops/repo-files?task_key=&path= 只读浏览任务 workdir 中的文件/目录(救援用)。path 相对 workdir,禁止 ..。
func RepoInventory ¶ added in v1.17.0
func RepoInventory(ctx context.Context, c *app.RequestContext)
RepoInventory GET /api/v1/ops/inventory 消灭孤儿仓库:哪些仓库没同步任务、哪些一直失败、哪些很久没跑。 盘点规则在 core Service.RepoInventory。
func RepoUpdate ¶
func RepoUpdate(ctx context.Context, c *app.RequestContext)
func RequestForcePushApproval ¶ added in v1.19.3
func RequestForcePushApproval(ctx context.Context, c *app.RequestContext)
RequestForcePushApproval POST /api/v1/ops/force-push-approvals 产生一条 pending 审批(同步引擎/前端在 block 策略触发时调用)。
func ResolveOrgTarget ¶ added in v1.19.3
func ResolveOrgTarget(ctx context.Context, c *app.RequestContext)
ResolveOrgTarget POST /api/v1/ops/resolve-org-target 按 org_mapping 策略计算目标仓库 key(纯预览,不落库)。
func RestoreBundle ¶ added in v1.17.0
func RestoreBundle(ctx context.Context, c *app.RequestContext)
RestoreBundle POST /api/v1/ops/bundles/restore
func RetryEvent ¶
func RetryEvent(ctx context.Context, c *app.RequestContext)
func RetryRun ¶ added in v1.17.0
func RetryRun(ctx context.Context, c *app.RequestContext)
RetryRun 手动重试一条失败执行:取 run 的 task_key 再触发一次同步。 只允许重试 failed 状态,避免把成功任务误触发。
func RevokeForcePush ¶ added in v1.27.0
func RevokeForcePush(ctx context.Context, c *app.RequestContext)
RevokeForcePush POST /api/v1/ops/force-push-approvals/revoke Admin 撤销一条放行(放行不再生效)。
没有撤销口子时,唯一能"取消"授权的办法是等它被用掉 —— 而那恰恰是最不该覆盖目标侧独有提交的时刻。
func RuleCreate ¶
func RuleCreate(ctx context.Context, c *app.RequestContext)
func RuleDelete ¶
func RuleDelete(ctx context.Context, c *app.RequestContext)
func RuleUpdate ¶
func RuleUpdate(ctx context.Context, c *app.RequestContext)
func RunDRDrill ¶ added in v1.18.0
func RunDRDrill(ctx context.Context, c *app.RequestContext)
RunDRDrill POST /api/v1/ops/dr-drill 从冷备 bundle 恢复到临时目录 → git fsck → refs 比对 → 出 RTO 报告。
func SetAIRebuildRunner ¶ added in v1.17.0
SetAIRebuildRunner 注入 Runner 重建函数。
func SetAISettingsStore ¶ added in v1.17.0
func SetAISettingsStore(get func() *agent.SettingsStore)
SetAISettingsStore 注入 AI 设置库。
func SetAPIKeyRole ¶ added in v1.18.0
func SetAPIKeyRole(role string)
SetAPIKeyRole 设置共享 API Key 的角色(admin/operator/readonly)。
func SetAgentRunner ¶
SetAgentRunner 注入 AI Runner(nil = AI 未启用)。
func SetAuthRole ¶ added in v1.18.0
func SetAuthRole(c *app.RequestContext, r Role)
SetAuthRole 写入角色(鉴权中间件调用)。
func SetAuthUser ¶
func SetAuthUser(c appRequestContext, user string)
SetAuthUser 由壳层鉴权中间件调用,写入已认证用户名(SSO/网关头/自定义 IdP)。
func SetDefaultPlatform ¶
func SetDefaultPlatform(ctx context.Context, c *app.RequestContext)
SetDefaultPlatform 设置默认平台
func SetGitServe ¶ added in v1.19.1
SetGitServe 启用/配置只读 Git Smart HTTP。
func SetOIDCConfig ¶ added in v1.18.0
func SetOIDCConfig(cfg *OIDCConfig)
SetOIDCConfig 注册 OIDC 配置(壳层启动时调用)。
func SetSyncServiceGetter ¶
func SetSyncServiceGetter(fn func() *corebridge.Service)
func SyncOverview ¶ added in v1.17.0
func SyncOverview(ctx context.Context, c *app.RequestContext)
SyncOverview 同步侧仪表盘指标。
func SyncPlatformFiltered ¶ added in v1.17.0
func SyncPlatformFiltered(ctx context.Context, c *app.RequestContext)
SyncPlatformFiltered POST /api/v1/ops/sync-platform 借鉴 gickup filter:导入时排除 archived/fork、按 star/语言/glob 裁剪。
func SyncPlatformRepos ¶
func SyncPlatformRepos(ctx context.Context, c *app.RequestContext)
SyncPlatformRepos 同步平台仓库到本地
func SystemStatus ¶
func SystemStatus(ctx context.Context, c *app.RequestContext)
SystemStatus 返回系统状态信息(管理面板用)。
func TaskCreate ¶
func TaskCreate(ctx context.Context, c *app.RequestContext)
func TaskDelete ¶
func TaskDelete(ctx context.Context, c *app.RequestContext)
func TaskHistory ¶
func TaskHistory(ctx context.Context, c *app.RequestContext)
func TaskPreview ¶
func TaskPreview(ctx context.Context, c *app.RequestContext)
func TaskUpdate ¶
func TaskUpdate(ctx context.Context, c *app.RequestContext)
func TestPlatformConnection ¶
func TestPlatformConnection(ctx context.Context, c *app.RequestContext)
TestPlatformConnection 测试平台连接
func UpdatePlatform ¶
func UpdatePlatform(ctx context.Context, c *app.RequestContext)
UpdatePlatform 更新平台
func VerifyAuditChain ¶ added in v1.18.0
func VerifyAuditChain(ctx context.Context, c *app.RequestContext)
VerifyAuditChain GET /api/v1/ops/audit-chain/verify 校验审计日志哈希链完整性(防篡改证明)。
func VerifyBackupManifest ¶ added in v1.18.0
func VerifyBackupManifest(ctx context.Context, c *app.RequestContext)
VerifyBackupManifest GET /api/v1/ops/backup-manifest/verify
func VerifyBundle ¶ added in v1.17.0
func VerifyBundle(ctx context.Context, c *app.RequestContext)
VerifyBundle GET /api/v1/ops/bundles/verify?name=
func VerifyDrillChain ¶ added in v1.18.0
func VerifyDrillChain(ctx context.Context, c *app.RequestContext)
VerifyDrillChain GET /api/v1/ops/dr-drill/chain/verify
func WriteGuard ¶ added in v1.18.0
func WriteGuard() app.HandlerFunc
WriteGuard 写操作 RBAC 中间件(挂到 POST/PUT/DELETE 路由)。
Types ¶
type AuditReportReq ¶ added in v1.17.0
type AuditReportReq struct {
StartDate string `json:"start_date" form:"start_date" query:"start_date"`
EndDate string `json:"end_date" form:"end_date" query:"end_date"`
Action string `json:"action" form:"action" query:"action"`
Format string `json:"format" form:"format" query:"format"` // json | csv
Limit int `json:"limit" form:"limit" query:"limit"`
}
AuditReportReq 报告请求。
type ImportPublicOrgReq ¶ added in v1.19.3
type ImportPublicOrgReq struct {
PlatformKey string `json:"platform_key"`
Org string `json:"org"`
CreateTasks bool `json:"create_tasks"`
TargetPlatform string `json:"target_platform"`
TargetOrg string `json:"target_org"`
ExcludeArchived *bool `json:"exclude_archived"`
ExcludeForks *bool `json:"exclude_forks"`
MinStars int32 `json:"min_stars"`
DryRun *bool `json:"dry_run"`
Max int32 `json:"max"`
}
ImportPublicOrgReq 导入公共 Org 公开仓(匿名/只读镜像)。
type OIDCConfig ¶ added in v1.18.0
type OIDCConfig struct {
Enabled bool `yaml:"enabled"`
// Secret HS256 共享密钥(必填;RS256 请走代理层)
Secret string `yaml:"secret"`
// Issuer 期望的 iss(空=不校验)
Issuer string `yaml:"issuer"`
// Audience 期望的 aud(空=不校验)
Audience string `yaml:"audience"`
// RoleClaim JWT 中角色声明键,默认 "role"
RoleClaim string `yaml:"role_claim"`
// UserClaim JWT 中用户名声明键,默认 "sub"
UserClaim string `yaml:"user_claim"`
// DefaultRole 无角色声明时的缺省角色,默认 readonly
DefaultRole string `yaml:"default_role"`
}
OIDCConfig OIDC/JWT Bearer 鉴权配置(公网壳可选)。 支持 HS256 共享密钥模式:与 IdP/网关约定 secret,校验 exp/iss/aud。 生产更推荐在反向代理层做 OIDC,再用 SetAuthMiddlewareProvider 注入身份头。
type Role ¶ added in v1.18.0
Role 访问角色(RBAC 最小集)。
别名到 authz 包:工具层要判角色,而工具包不能反向依赖 biz/handler (会成环)—— 角色类型与 ctx 传递都放在 internal/pkg/authz。
func GetAuthRole ¶ added in v1.18.0
func GetAuthRole(c *app.RequestContext) Role
GetAuthRole 读取角色;缺省 readonly(安全侧)。
Source Files
¶
- ai_config.go
- ai_service.go
- apikey.go
- audit.go
- audit_report.go
- backup_remote_service.go
- backup_service.go
- deploykey_service.go
- diagnose_service.go
- dr_service.go
- forcepush_approval.go
- gists_service.go
- gitserve_cfg.go
- governance_service.go
- health.go
- health_service.go
- histsync_service.go
- identity.go
- import_filter_service.go
- init.go
- issues_service.go
- lifecycle_service.go
- metadata_restore.go
- metadata_service.go
- metrics_mw.go
- migration_service.go
- mirror_service.go
- oidc_auth.go
- operation_log_service.go
- org_import_service.go
- org_mirror_service.go
- platform_service.go
- provider_access.go
- provider_hooks.go
- rbac.go
- rebuild_service.go
- repo_service.go
- retry_service.go
- sync_task_service.go
- system_service.go
- todo_service.go
- tpl_service.go
- trends_service.go
- webhook_receive.go
- webhook_service.go