feat: FlowStack 发布系统首个可运行版本 (gin + React)
- Go gin 后端:流水线/节点/连线/运行/日志/GitOps/插件 REST API, SQLite(GORM) 自动建表 + seed,模拟执行引擎 + SSE 实时日志推送, 前端产物 go:embed 嵌入单二进制,一个端口同时服务 API 与页面 - React 19 前端:画布式流水线编辑器(React Flow + Tekton 任务库)、 GitOps 部署、批量发布、发布记录等 14 个模块页面, tRPC 全部替换为 REST(TanStack Query) - 首次启动生成随机密码管理员账号(日志 + data/initial-admin-password.txt) - run.sh 一键构建启动(默认端口 9527,支持 start/stop/restart/build/dev)
This commit is contained in:
commit
04d1342b27
115 files changed
+23268
No files matched your search
@@ -0,0 +1,135 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// User 系统用户
|
||||
type User struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Username string `gorm:"uniqueIndex" json:"username"`
|
||||
Password string `json:"-"` // argon2id 哈希,绝不返回给前端
|
||||
Nickname string `json:"nickname"`
|
||||
Role string `gorm:"default:user" json:"role"` // admin | user
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// Pipeline 流水线定义
|
||||
type Pipeline struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"index" json:"name"`
|
||||
Description string `json:"description"`
|
||||
Type string `gorm:"default:native" json:"type"` // native | jenkins | tekton
|
||||
SourceRepo string `json:"sourceRepo"`
|
||||
SourceBranch string `gorm:"default:main" json:"sourceBranch"`
|
||||
GitopsRepo string `json:"gitopsRepo"`
|
||||
GitopsPath string `json:"gitopsPath"`
|
||||
DeployType string `gorm:"default:host" json:"deployType"` // host | k8s | gitops
|
||||
Env string `gorm:"default:staging" json:"env"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// PipelineNode 画布节点(JSON 字段名与前端 React Flow 对齐)
|
||||
type PipelineNode struct {
|
||||
ID uint `gorm:"primaryKey" json:"dbId"`
|
||||
PipelineID uint `gorm:"index" json:"pipelineId"`
|
||||
NodeID string `gorm:"index" json:"nodeId"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
PositionX float64 `json:"positionX"`
|
||||
PositionY float64 `json:"positionY"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
Category string `json:"category"` // source|build|test|security|deploy|gitops|custom
|
||||
Config map[string]interface{} `gorm:"serializer:json" json:"config"`
|
||||
}
|
||||
|
||||
// PipelineEdge 画布连线
|
||||
type PipelineEdge struct {
|
||||
ID uint `gorm:"primaryKey" json:"dbId"`
|
||||
PipelineID uint `gorm:"index" json:"pipelineId"`
|
||||
EdgeID string `gorm:"index" json:"edgeId"`
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
Label string `json:"label"`
|
||||
Animated bool `json:"animated"`
|
||||
}
|
||||
|
||||
// PipelineRun 一次流水线运行
|
||||
type PipelineRun struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
RunID string `gorm:"uniqueIndex" json:"runId"` // pr-<timestamp>
|
||||
PipelineID uint `gorm:"index" json:"pipelineId"`
|
||||
PipelineName string `json:"pipelineName"`
|
||||
Branch string `gorm:"default:main" json:"branch"`
|
||||
Env string `gorm:"default:staging" json:"env"`
|
||||
DeployType string `gorm:"default:host" json:"deployType"`
|
||||
Type string `gorm:"default:native" json:"type"`
|
||||
TriggerBy string `gorm:"default:system" json:"triggerBy"`
|
||||
TriggerType string `gorm:"default:manual" json:"triggerType"` // manual|webhook|cron|batch
|
||||
Status string `gorm:"default:pending" json:"status"` // pending|running|success|failed|cancelled
|
||||
DurationMs int64 `json:"durationMs"`
|
||||
NodesSnapshot string `json:"nodesSnapshot"`
|
||||
EdgesSnapshot string `json:"edgesSnapshot"`
|
||||
StartedAt time.Time `json:"startedAt"`
|
||||
CompletedAt *time.Time `json:"completedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// RunStage 运行中的阶段(对应一个节点)
|
||||
type RunStage struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
RunID uint `gorm:"index" json:"runId"`
|
||||
NodeID string `json:"nodeId"`
|
||||
Name string `json:"name"`
|
||||
PodName string `json:"podName"`
|
||||
Status string `gorm:"default:pending" json:"status"` // pending|running|success|failed|skipped
|
||||
ExitCode *int `json:"exitCode"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
CompletedAt *time.Time `json:"completedAt"`
|
||||
}
|
||||
|
||||
// LogEntry 运行日志
|
||||
type LogEntry struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
RunID uint `gorm:"index" json:"runId"`
|
||||
StageID uint `json:"stageId"`
|
||||
Level string `gorm:"default:info" json:"level"` // debug|info|warn|error
|
||||
Message string `json:"message"`
|
||||
Source string `gorm:"default:runner" json:"source"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
// Application GitOps 应用
|
||||
type Application struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
Repo string `json:"repo"`
|
||||
Branch string `gorm:"default:main" json:"branch"`
|
||||
Path string `json:"path"`
|
||||
Cluster string `gorm:"default:default" json:"cluster"`
|
||||
Namespace string `gorm:"default:default" json:"namespace"`
|
||||
ManifestType string `gorm:"default:plain" json:"manifestType"` // helm|kustomize|plain
|
||||
SyncPolicy string `gorm:"default:manual" json:"syncPolicy"` // manual|automated
|
||||
AutoPrune bool `json:"autoPrune"`
|
||||
SelfHeal bool `json:"selfHeal"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// Plugin 插件
|
||||
type Plugin struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
PluginID string `gorm:"uniqueIndex" json:"pluginId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Version string `json:"version"`
|
||||
Author string `json:"author"`
|
||||
Category string `gorm:"default:general" json:"category"`
|
||||
EntryPath string `json:"entryPath"`
|
||||
Installed bool `gorm:"default:true" json:"installed"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
Config map[string]interface{} `gorm:"serializer:json" json:"config"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
Reference in new issue
Block a user