diff --git a/.gitignore b/.gitignore index fcb10da..147bf6c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ bin **/config/config-prod.yaml **/config/config-demo.yaml dist -host-sessions \ No newline at end of file +host-sessions +code \ No newline at end of file diff --git a/README.MD b/README.MD index 73f566a..e65615c 100644 --- a/README.MD +++ b/README.MD @@ -14,7 +14,7 @@ 功能展望: - [ ] 基于 Kubernetes 原生 Job 的持续集成(CI); - - [x] Kubernetes Config 管理; + - [x] 秘钥管理; - [x] 构建环境管理; - [ ] 流水线管理(编排); @@ -24,6 +24,7 @@ - 管理员:`admin`,密码:`devops.zze`; - 测试账号:`test`,密码:`devops.zze`; +> 数据库每小时自动重置。 效果图: diff --git a/api/ci_env/v1/ci_env.go b/api/ci_env/v1/ci_env.go index 33fa42e..067cc40 100644 --- a/api/ci_env/v1/ci_env.go +++ b/api/ci_env/v1/ci_env.go @@ -40,7 +40,6 @@ type DelRes struct{} type GetLstReq struct { g.Meta `method:"get" path:"/ci-env/list" summary:"获取所有 CI 环境列表" tags:"CI 环境"` - *api.PageLstReq } type GetLstRes struct { diff --git a/api/ci_pipeline/ci_pipeline.go b/api/ci_pipeline/ci_pipeline.go index c4edea5..fc27ab8 100644 --- a/api/ci_pipeline/ci_pipeline.go +++ b/api/ci_pipeline/ci_pipeline.go @@ -18,4 +18,5 @@ type ICiPipelineV1 interface { Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) GetLst(ctx context.Context, req *v1.GetLstReq) (res *v1.GetLstRes, err error) GetConfig(ctx context.Context, req *v1.GetConfigReq) (res *v1.GetConfigRes, err error) + Run(ctx context.Context, req *v1.RunReq) (res *v1.RunRes, err error) } diff --git a/api/ci_pipeline/v1/ci_pipeline.go b/api/ci_pipeline/v1/ci_pipeline.go index e06c09e..dbca537 100644 --- a/api/ci_pipeline/v1/ci_pipeline.go +++ b/api/ci_pipeline/v1/ci_pipeline.go @@ -65,3 +65,11 @@ type GetConfigRes struct { Config *gjson.Json `json:"config"` EnvMap map[int]string `json:"envMap"` } + +type RunReq struct { + g.Meta `method:"post" path:"/ci-pipeline/{id}/run" summary:"运行流水线" tags:"CI 流水线"` + Id int ` v:"min:1#id必须" path:"id"` +} + +type RunRes struct { +} diff --git a/api/kubernetes_config/v1/kubernetes_config.go b/api/kubernetes_config/v1/kubernetes_config.go deleted file mode 100644 index e459988..0000000 --- a/api/kubernetes_config/v1/kubernetes_config.go +++ /dev/null @@ -1,56 +0,0 @@ -package v1 - -import ( - "devops-super/api" - "devops-super/internal/model/entity" - "devops-super/internal/model/mid" - "github.com/gogf/gf/v2/frame/g" -) - -type GetPageLstReq struct { - g.Meta `method:"get" path:"/kubernetes-config/page-list" summary:"分页获取 Kubernetes 配置列表" tags:"Kubernetes 配置"` - *api.PageLstReq -} - -type GetPageLstRes struct { - *api.PageLstRes[*entity.KubernetesConfig] -} - -type AddReq struct { - g.Meta `method:"post" path:"/kubernetes-config" summary:"添加 Kubernetes 配置" tags:"Kubernetes 配置"` - *mid.KubernetesConfig -} - -type AddRes struct{} - -type UptReq struct { - g.Meta `method:"put" path:"/kubernetes-config/{id}" summary:"更新 Kubernetes 配置" tags:"Kubernetes 配置"` - Id int ` v:"min:1#id必须" path:"id"` - *mid.KubernetesConfig -} - -type UptRes struct{} - -type DelReq struct { - g.Meta `method:"delete" path:"/kubernetes-config/{id}" summary:"删除 Kubernetes 配置" tags:"Kubernetes 配置"` - Id int ` v:"min:1#id必须" path:"id"` -} - -type DelRes struct{} - -type GetLstReq struct { - g.Meta `method:"get" path:"/kubernetes-config/list" summary:"获取所有 Kubernetes 配置列表" tags:"Kubernetes 配置"` - *api.PageLstReq -} - -type GetLstRes struct { - List []*entity.KubernetesConfig `json:"list"` -} - -type GetPartialLstReq struct { - g.Meta `method:"get" path:"/kubernetes-config/partial-list" summary:"获取所有 Kubernetes 配置列表(部分字段)" tags:"主机组"` -} - -type GetPartialLstRes struct { - List []*mid.KubernetesConfigPartial `json:"list"` -} diff --git a/api/kubernetes_config/kubernetes_config.go b/api/secret/secret.go similarity index 75% rename from api/kubernetes_config/kubernetes_config.go rename to api/secret/secret.go index 5497449..30b4fb0 100644 --- a/api/kubernetes_config/kubernetes_config.go +++ b/api/secret/secret.go @@ -2,19 +2,18 @@ // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // ================================================================================= -package kubernetes_config +package secret import ( "context" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) -type IKubernetesConfigV1 interface { +type ISecretV1 interface { GetPageLst(ctx context.Context, req *v1.GetPageLstReq) (res *v1.GetPageLstRes, err error) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) Upt(ctx context.Context, req *v1.UptReq) (res *v1.UptRes, err error) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) GetLst(ctx context.Context, req *v1.GetLstReq) (res *v1.GetLstRes, err error) - GetPartialLst(ctx context.Context, req *v1.GetPartialLstReq) (res *v1.GetPartialLstRes, err error) } diff --git a/api/secret/v1/secret.go b/api/secret/v1/secret.go new file mode 100644 index 0000000..9895e9b --- /dev/null +++ b/api/secret/v1/secret.go @@ -0,0 +1,48 @@ +package v1 + +import ( + "devops-super/api" + "devops-super/internal/model/entity" + "devops-super/internal/model/mid" + "github.com/gogf/gf/v2/frame/g" +) + +type GetPageLstReq struct { + g.Meta `method:"get" path:"/secret/page-list" summary:"分页获取秘钥列表" tags:"秘钥"` + *api.PageLstReq +} + +type GetPageLstRes struct { + *api.PageLstRes[*entity.Secret] +} + +type AddReq struct { + g.Meta `method:"post" path:"/secret" summary:"添加秘钥" tags:"秘钥"` + *mid.Secret +} + +type AddRes struct{} + +type UptReq struct { + g.Meta `method:"put" path:"/secret/{id}" summary:"更新秘钥" tags:"秘钥"` + Id int ` v:"min:1#id必须" path:"id"` + *mid.Secret +} + +type UptRes struct{} + +type DelReq struct { + g.Meta `method:"delete" path:"/secret/{id}" summary:"删除秘钥" tags:"秘钥"` + Id int ` v:"min:1#id必须" path:"id"` +} + +type DelRes struct{} + +type GetLstReq struct { + g.Meta `method:"get" path:"/secret/list" summary:"获取所有秘钥列表" tags:"秘钥"` + Type int `p:"type"` +} + +type GetLstRes struct { + List []*entity.Secret `json:"list"` +} diff --git a/go.mod b/go.mod index cbacd88..5b3e8b1 100644 --- a/go.mod +++ b/go.mod @@ -4,45 +4,65 @@ go 1.18 require ( github.com/casbin/casbin/v2 v2.77.2 + github.com/go-git/go-git/v5 v5.9.0 github.com/gogf/gf-jwt/v2 v2.1.0 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.4 github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.4 github.com/gogf/gf/v2 v2.5.4 github.com/gorilla/websocket v1.5.0 github.com/pkg/sftp v1.13.6 - golang.org/x/crypto v0.11.0 + golang.org/x/crypto v0.13.0 ) require ( + dario.cat/mergo v1.0.0 // indirect github.com/BurntSushi/toml v1.2.0 // indirect github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.15.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/golang-jwt/jwt/v4 v4.3.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/grokify/html-strip-tags-go v0.0.1 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kr/fs v0.1.0 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/redis/go-redis/v9 v9.0.5 // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/sergi/go-diff v1.1.0 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect github.com/tidwall/gjson v1.14.4 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect go.opentelemetry.io/otel v1.14.0 // indirect go.opentelemetry.io/otel/sdk v1.14.0 // indirect go.opentelemetry.io/otel/trace v1.14.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.13.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4a208f9..9aa9190 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,22 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/casbin/casbin/v2 v2.77.2 h1:yQinn/w9x8AswiwqwtrXz93VU48R1aYTXdHEx4RI3jM= github.com/casbin/casbin/v2 v2.77.2/go.mod h1:mzGx0hYW9/ksOSpw3wNjk3NRAroq5VMFYUQ6G43iGPk= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -13,11 +25,18 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= @@ -26,6 +45,14 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= +github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= +github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -47,6 +74,8 @@ github.com/gogf/gf/v2 v2.5.4 h1:UBCSw8mInkHmEqL0E1LYc6QhSpaNFY/wHcFrTI/rzTk= github.com/gogf/gf/v2 v2.5.4/go.mod h1:7yf5qp0BznfsYx7Sw49m3mQvBsHpwAjJk3Q9ZnKoUEc= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -70,10 +99,21 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0= github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -95,6 +135,11 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo= github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -104,8 +149,16 @@ github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDO github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= +github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -117,6 +170,8 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -133,12 +188,18 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -151,18 +212,24 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -170,38 +237,51 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -214,10 +294,13 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/hack/config.yaml b/hack/config.yaml index 68be86f..f96e973 100644 --- a/hack/config.yaml +++ b/hack/config.yaml @@ -5,12 +5,13 @@ gfcli: docker: build: "-a amd64 -s linux -p temp -ew" tagPrefixes: - - registry-azj-registry.cn-shanghai.cr.aliyuncs.com/ops/ +# - registry-azj-registry.cn-shanghai.cr.aliyuncs.com/ops/ + - zze326/ gen: dao: - link: "mysql:devops_super:devops_super.zze@tcp(192.168.2.231:3306)/devops_super?loc=Local&parseTime=true" group: default - tables: "user, permission, role, dept, host, host_group, host_terminal_session, kubernetes_config, ci_env, ci_pipeline" + tables: "user, permission, role, dept, host, host_group, host_terminal_session, kubernetes_config, ci_env, ci_pipeline, secret" withTime: false gJsonSupport: true overwriteDao: true diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 750cede..7f48d88 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -8,10 +8,10 @@ import ( "devops-super/internal/controller/host" "devops-super/internal/controller/host_group" "devops-super/internal/controller/host_terminal_session" - "devops-super/internal/controller/kubernetes_config" "devops-super/internal/controller/permission" "devops-super/internal/controller/public" "devops-super/internal/controller/role" + "devops-super/internal/controller/secret" "devops-super/internal/controller/user" "devops-super/internal/service" @@ -47,7 +47,7 @@ var ( host_group.NewV1(), // 主机组 host.NewV1(), // 主机 host_terminal_session.NewV1(), // 主机会话 - kubernetes_config.NewV1(), // Kubernetes 配置 + secret.NewV1(), // 秘钥管理 // 持续集成 ci_env.NewV1(), // ci 环境 ci_pipeline.NewV1(), // ci 流水线 diff --git a/internal/consts/ci.go b/internal/consts/ci.go new file mode 100644 index 0000000..0b3ec66 --- /dev/null +++ b/internal/consts/ci.go @@ -0,0 +1,7 @@ +package consts + +// 流水线任务类型 +const ( + PIPELINE_TASK_TYPE_GIT_PULL = 1 // Git 拉取 + PIPELINE_TASK_TYPE_SHELL_EXEC = 2 // 执行 shell +) diff --git a/internal/consts/consts.go b/internal/consts/consts.go index ec6102b..8393f8d 100644 --- a/internal/consts/consts.go +++ b/internal/consts/consts.go @@ -12,3 +12,9 @@ const PERMISSION_SYSTEM_REQUIRED_NAME = "system-required" // 主机终端会话文件默认保存目录,可通过配置 host.terminal.sessionFileDir 修改 const HOST_TERMINAL_SESSION_SAVE_DIRECTORY = "host-sessions" + +// 秘钥类型 +const ( + SECRET_TYPE_GIT_BASIC_AUTH = 1 // GIT Basic 认证 + SECRET_TYPE_KUBERNETES_CONFIG = 2 // Kubernetes config +) diff --git a/internal/controller/ci_env/ci_env_v1_del.go b/internal/controller/ci_env/ci_env_v1_del.go index babf293..a6f64e5 100644 --- a/internal/controller/ci_env/ci_env_v1_del.go +++ b/internal/controller/ci_env/ci_env_v1_del.go @@ -2,10 +2,9 @@ package ci_env import ( "context" + "devops-super/api/ci_env/v1" "devops-super/internal/model/do" "devops-super/internal/service" - - "devops-super/api/ci_env/v1" ) func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) { diff --git a/internal/controller/ci_pipeline/ci_pipeline_v1_get_config.go b/internal/controller/ci_pipeline/ci_pipeline_v1_get_config.go index 4224a91..d8c24af 100644 --- a/internal/controller/ci_pipeline/ci_pipeline_v1_get_config.go +++ b/internal/controller/ci_pipeline/ci_pipeline_v1_get_config.go @@ -14,8 +14,10 @@ func (c *ControllerV1) GetConfig(ctx context.Context, req *v1.GetConfigReq) (res var ( ePipeline *entity.CiPipeline config mid.CiPipelineConfig + entityMap map[int]*entity.CiEnv ) res = new(v1.GetConfigRes) + res.EnvMap = make(map[int]string, 0) ePipeline, err = service.CiPipeline().Get(ctx, &do.CiPipeline{Id: req.Id}) if err != nil { return @@ -26,6 +28,10 @@ func (c *ControllerV1) GetConfig(ctx context.Context, req *v1.GetConfigReq) (res return } - res.EnvMap, err = service.CiEnv().GetIdNameMap(ctx, config.GetEnvIds()) + entityMap, err = service.CiEnv().GetEntityMap(ctx, config.GetEnvIds()) + for id, e := range entityMap { + res.EnvMap[id] = e.Name + } + return } diff --git a/internal/controller/ci_pipeline/ci_pipeline_v1_run.go b/internal/controller/ci_pipeline/ci_pipeline_v1_run.go new file mode 100644 index 0000000..e12a387 --- /dev/null +++ b/internal/controller/ci_pipeline/ci_pipeline_v1_run.go @@ -0,0 +1,12 @@ +package ci_pipeline + +import ( + "context" + "devops-super/api/ci_pipeline/v1" + "devops-super/internal/service" +) + +func (c *ControllerV1) Run(ctx context.Context, req *v1.RunReq) (res *v1.RunRes, err error) { + err = service.CiPipeline().Run(ctx, req.Id) + return +} diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_get_partial_lst.go b/internal/controller/kubernetes_config/kubernetes_config_v1_get_partial_lst.go deleted file mode 100644 index deb5339..0000000 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_get_partial_lst.go +++ /dev/null @@ -1,14 +0,0 @@ -package kubernetes_config - -import ( - "context" - "devops-super/internal/service" - - "devops-super/api/kubernetes_config/v1" -) - -func (c *ControllerV1) GetPartialLst(ctx context.Context, req *v1.GetPartialLstReq) (res *v1.GetPartialLstRes, err error) { - res = new(v1.GetPartialLstRes) - res.List, err = service.KubernetesConfig().GetPartialLst(ctx) - return -} diff --git a/internal/controller/kubernetes_config/kubernetes_config.go b/internal/controller/secret/secret.go similarity index 90% rename from internal/controller/kubernetes_config/kubernetes_config.go rename to internal/controller/secret/secret.go index 2337a55..4ad1a11 100644 --- a/internal/controller/kubernetes_config/kubernetes_config.go +++ b/internal/controller/secret/secret.go @@ -2,4 +2,4 @@ // This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. // ================================================================================= -package kubernetes_config +package secret diff --git a/internal/controller/kubernetes_config/kubernetes_config_new.go b/internal/controller/secret/secret_new.go similarity index 72% rename from internal/controller/kubernetes_config/kubernetes_config_new.go rename to internal/controller/secret/secret_new.go index 752800e..759a05e 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_new.go +++ b/internal/controller/secret/secret_new.go @@ -2,14 +2,14 @@ // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. // ================================================================================= -package kubernetes_config +package secret import ( - "devops-super/api/kubernetes_config" + "devops-super/api/secret" ) type ControllerV1 struct{} -func NewV1() kubernetes_config.IKubernetesConfigV1 { +func NewV1() secret.ISecretV1 { return &ControllerV1{} } diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_add.go b/internal/controller/secret/secret_v1_add.go similarity index 66% rename from internal/controller/kubernetes_config/kubernetes_config_v1_add.go rename to internal/controller/secret/secret_v1_add.go index 2eed894..af8b675 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_add.go +++ b/internal/controller/secret/secret_v1_add.go @@ -1,4 +1,4 @@ -package kubernetes_config +package secret import ( "context" @@ -6,14 +6,14 @@ import ( "devops-super/internal/service" "github.com/gogf/gf/v2/util/gconv" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) { - in := new(entity.KubernetesConfig) + in := new(entity.Secret) if err = gconv.Struct(req, in); err != nil { return } - err = service.KubernetesConfig().Add(ctx, in) + err = service.Secret().Add(ctx, in) return } diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_del.go b/internal/controller/secret/secret_v1_del.go similarity index 57% rename from internal/controller/kubernetes_config/kubernetes_config_v1_del.go rename to internal/controller/secret/secret_v1_del.go index e18dbfd..e61d13c 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_del.go +++ b/internal/controller/secret/secret_v1_del.go @@ -1,14 +1,14 @@ -package kubernetes_config +package secret import ( "context" "devops-super/internal/model/do" "devops-super/internal/service" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) func (c *ControllerV1) Del(ctx context.Context, req *v1.DelReq) (res *v1.DelRes, err error) { - err = service.KubernetesConfig().Del(ctx, &do.KubernetesConfig{Id: req.Id}) + err = service.Secret().Del(ctx, &do.Secret{Id: req.Id}) return } diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_get_lst.go b/internal/controller/secret/secret_v1_get_lst.go similarity index 50% rename from internal/controller/kubernetes_config/kubernetes_config_v1_get_lst.go rename to internal/controller/secret/secret_v1_get_lst.go index 9bc2b6f..b5e4a5a 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_get_lst.go +++ b/internal/controller/secret/secret_v1_get_lst.go @@ -1,14 +1,19 @@ -package kubernetes_config +package secret import ( "context" + "devops-super/internal/model/do" "devops-super/internal/service" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) func (c *ControllerV1) GetLst(ctx context.Context, req *v1.GetLstReq) (res *v1.GetLstRes, err error) { res = new(v1.GetLstRes) - res.List, err = service.KubernetesConfig().GetLst(ctx) + in := new(do.Secret) + if req.Type != 0 { + in.Type = req.Type + } + res.List, err = service.Secret().GetLst(ctx, in) return } diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_get_page_lst.go b/internal/controller/secret/secret_v1_get_page_lst.go similarity index 58% rename from internal/controller/kubernetes_config/kubernetes_config_v1_get_page_lst.go rename to internal/controller/secret/secret_v1_get_page_lst.go index 163f40d..2d5332f 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_get_page_lst.go +++ b/internal/controller/secret/secret_v1_get_page_lst.go @@ -1,14 +1,14 @@ -package kubernetes_config +package secret import ( "context" "devops-super/internal/service" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) func (c *ControllerV1) GetPageLst(ctx context.Context, req *v1.GetPageLstReq) (res *v1.GetPageLstRes, err error) { res = new(v1.GetPageLstRes) - res.PageLstRes, err = service.KubernetesConfig().GetPageLst(ctx, req.PageLstReq) + res.PageLstRes, err = service.Secret().GetPageLst(ctx, req.PageLstReq) return } diff --git a/internal/controller/kubernetes_config/kubernetes_config_v1_upt.go b/internal/controller/secret/secret_v1_upt.go similarity index 66% rename from internal/controller/kubernetes_config/kubernetes_config_v1_upt.go rename to internal/controller/secret/secret_v1_upt.go index 9412531..a0e56ae 100644 --- a/internal/controller/kubernetes_config/kubernetes_config_v1_upt.go +++ b/internal/controller/secret/secret_v1_upt.go @@ -1,4 +1,4 @@ -package kubernetes_config +package secret import ( "context" @@ -6,14 +6,14 @@ import ( "devops-super/internal/service" "github.com/gogf/gf/v2/util/gconv" - "devops-super/api/kubernetes_config/v1" + "devops-super/api/secret/v1" ) func (c *ControllerV1) Upt(ctx context.Context, req *v1.UptReq) (res *v1.UptRes, err error) { - in := new(do.KubernetesConfig) + in := new(do.Secret) if err = gconv.Struct(req, in); err != nil { return } - err = service.KubernetesConfig().Upt(ctx, in) + err = service.Secret().Upt(ctx, in) return } diff --git a/internal/dao/internal/secret.go b/internal/dao/internal/secret.go new file mode 100644 index 0000000..b05a212 --- /dev/null +++ b/internal/dao/internal/secret.go @@ -0,0 +1,81 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// SecretDao is the data access object for table secret. +type SecretDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns SecretColumns // columns contains all the column names of Table for convenient usage. +} + +// SecretColumns defines and stores column names for table secret. +type SecretColumns struct { + Id string // + Name string // 名称 + Type string // 类型:1-git认证,2-Kubernetes config + Content string // 认证配置内容 + UpdatedAt string // 更新时间 +} + +// secretColumns holds the columns for table secret. +var secretColumns = SecretColumns{ + Id: "id", + Name: "name", + Type: "type", + Content: "content", + UpdatedAt: "updated_at", +} + +// NewSecretDao creates and returns a new DAO object for table data access. +func NewSecretDao() *SecretDao { + return &SecretDao{ + group: "default", + table: "secret", + columns: secretColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *SecretDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *SecretDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *SecretDao) Columns() SecretColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *SecretDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *SecretDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *SecretDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/secret.go b/internal/dao/secret.go new file mode 100644 index 0000000..bc8d432 --- /dev/null +++ b/internal/dao/secret.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "devops-super/internal/dao/internal" +) + +// internalSecretDao is internal type for wrapping internal DAO implements. +type internalSecretDao = *internal.SecretDao + +// secretDao is the data access object for table secret. +// You can define custom methods on it to extend its functionality as you wish. +type secretDao struct { + internalSecretDao +} + +var ( + // Secret is globally public accessible object for table secret operations. + Secret = secretDao{ + internal.NewSecretDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/logic/ci_env/ci_env.go b/internal/logic/ci_env/ci_env.go index 5663fd9..9c7e46a 100644 --- a/internal/logic/ci_env/ci_env.go +++ b/internal/logic/ci_env/ci_env.go @@ -71,8 +71,8 @@ func (*sCiEnv) Get(ctx context.Context, in *do.CiEnv) (out *entity.CiEnv, err er return } -func (*sCiEnv) GetIdNameMap(ctx context.Context, ids []int) (out map[int]string, err error) { - out = make(map[int]string, 0) +func (*sCiEnv) GetEntityMap(ctx context.Context, ids []int) (out map[int]*entity.CiEnv, err error) { + out = make(map[int]*entity.CiEnv, 0) if len(ids) == 0 { return } @@ -82,7 +82,7 @@ func (*sCiEnv) GetIdNameMap(ctx context.Context, ids []int) (out map[int]string, } for _, e := range es { - out[e.Id] = e.Name + out[e.Id] = e } return } diff --git a/internal/logic/ci_pipeline/ci_pipeline.go b/internal/logic/ci_pipeline/ci_pipeline.go index f88ae84..0f1e5d6 100644 --- a/internal/logic/ci_pipeline/ci_pipeline.go +++ b/internal/logic/ci_pipeline/ci_pipeline.go @@ -3,10 +3,14 @@ package user import ( "context" "devops-super/api" + "devops-super/internal/consts" "devops-super/internal/dao" "devops-super/internal/model/do" "devops-super/internal/model/entity" + "devops-super/internal/model/mid" "devops-super/internal/service" + "fmt" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gutil" ) @@ -75,3 +79,60 @@ func (*sCiPipeline) Del(ctx context.Context, in *do.CiPipeline) (err error) { _, err = dao.CiPipeline.Ctx(ctx).Where(in).OmitNilWhere().Delete() return } + +func (s *sCiPipeline) Run(ctx context.Context, id int) (err error) { + var ( + ePipeline *entity.CiPipeline + config mid.CiPipelineConfig + envMap map[int]*entity.CiEnv + ) + ePipeline, err = s.Get(ctx, &do.CiPipeline{Id: id}) + if err != nil { + return + } + + if err = ePipeline.Config.Scan(&config); err != nil { + return + } + + if envMap, err = service.CiEnv().GetEntityMap(ctx, config.GetEnvIds()); err != nil { + return + } + + // 组装环境关联的镜像和秘钥名称 + for _, envItem := range config { + envItem.Image = envMap[envItem.Id].Image + envItem.SecretName = envMap[envItem.Id].SecretName + + for _, stageItem := range envItem.Stages { + for _, taskItem := range stageItem.Tasks { + // 如果设置了 git 认证秘钥,组装一下 + if secretId := taskItem.GitPullData.SecretId; secretId > 0 { + var ( + eSecret *entity.Secret + gitBasicAuth *mid.UsernamePasswordContent + ) + eSecret, err = service.Secret().Get(ctx, &do.Secret{Id: secretId}) + if err != nil { + return err + } + + if err = eSecret.Content.Scan(&gitBasicAuth); err != nil { + return + } + if eSecret.Type == consts.SECRET_TYPE_GIT_BASIC_AUTH { + taskItem.GitPullData.GitBasicAuth = gitBasicAuth + } + } + } + } + + jsonStr, err := gjson.EncodeString(envItem.Stages) + if err != nil { + return err + } + + fmt.Println(jsonStr) + } + return +} diff --git a/internal/logic/ci_pipeline/client/main.go b/internal/logic/ci_pipeline/client/main.go new file mode 100644 index 0000000..5bfc61e --- /dev/null +++ b/internal/logic/ci_pipeline/client/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "devops-super/internal/consts" + "devops-super/internal/logic/ci_pipeline/client/task" + "devops-super/internal/model/mid" + "fmt" + "github.com/gogf/gf/v2/encoding/gjson" + "log" + "os" +) + +var ( + stages []*mid.CiPipelineConfigEnvStageItem +) + +func initParams() { + stagesJson := os.Getenv("STAGES") + if err := gjson.DecodeTo([]byte(stagesJson), &stages); err != nil { + log.Fatal(err) + } +} + +func runStages() { + for _, stage := range stages { + fmt.Printf("【%s】开始\n", stage.Name) + for _, taskRun := range stage.Tasks { + switch taskRun.Type { + case consts.PIPELINE_TASK_TYPE_GIT_PULL: + if err := task.GitClone(taskRun.GitPullData); err != nil { + log.Fatalf("git clone failed: err: %v", err) + } + case consts.PIPELINE_TASK_TYPE_SHELL_EXEC: + if err := task.ShellExec(taskRun.ShellExecData); err != nil { + log.Fatalf("exec shell failed, err: %v", err) + } + } + } + fmt.Printf("【%s】结束\n", stage.Name) + } +} + +func main() { + initParams() + runStages() +} diff --git a/internal/logic/ci_pipeline/client/task/git_clone.go b/internal/logic/ci_pipeline/client/task/git_clone.go new file mode 100644 index 0000000..ae56f61 --- /dev/null +++ b/internal/logic/ci_pipeline/client/task/git_clone.go @@ -0,0 +1,44 @@ +package task + +import ( + "devops-super/internal/model/mid" + "fmt" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/transport/http" + "log" + "os" + "path" + "path/filepath" +) + +func GitClone(data *mid.GitPullData) error { + baseName := filepath.Base(data.GitUrl) + extension := filepath.Ext(baseName) + fileNameWithoutExtension := baseName[0 : len(baseName)-len(extension)] + r, err := git.PlainClone(path.Join(fileNameWithoutExtension), false, &git.CloneOptions{ + Auth: &http.BasicAuth{ + Username: data.GitBasicAuth.Username, + Password: data.GitBasicAuth.Password, + }, + URL: data.GitUrl, + Progress: os.Stdout, + SingleBranch: true, + ReferenceName: plumbing.ReferenceName(data.Branch), + }) + if err != nil { + return err + } + ref, err := r.Head() + if err != nil { + log.Printf("err: %v", err) + return nil + } + commit, err := r.CommitObject(ref.Hash()) + if err != nil { + log.Printf("err: %v", err) + return nil + } + fmt.Print(commit) + return nil +} diff --git a/internal/logic/ci_pipeline/client/task/shell_exec.go b/internal/logic/ci_pipeline/client/task/shell_exec.go new file mode 100644 index 0000000..5e96d4a --- /dev/null +++ b/internal/logic/ci_pipeline/client/task/shell_exec.go @@ -0,0 +1,20 @@ +package task + +import ( + "devops-super/internal/model/mid" + "github.com/gogf/gf/v2/util/gutil" + "os" + "os/exec" +) + +func ShellExec(data *mid.ShellExecData) (err error) { + cmd := exec.Command("sh", "-c", data.Content) + if !gutil.IsEmpty(data.WorkDir) { + cmd.Dir = data.WorkDir + } + + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stdout + err = cmd.Run() + return +} diff --git a/internal/logic/kubernetes_config/kubernetes_config.go b/internal/logic/kubernetes_config/kubernetes_config.go deleted file mode 100644 index 74da59e..0000000 --- a/internal/logic/kubernetes_config/kubernetes_config.go +++ /dev/null @@ -1,83 +0,0 @@ -package user - -import ( - "context" - "devops-super/api" - "devops-super/internal/dao" - "devops-super/internal/model/do" - "devops-super/internal/model/entity" - "devops-super/internal/model/mid" - "devops-super/internal/service" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/util/gutil" -) - -type sKubernetesConfig struct{} - -var cols = dao.KubernetesConfig.Columns() - -func init() { - service.RegisterKubernetesConfig(New()) -} - -func New() *sKubernetesConfig { - return &sKubernetesConfig{} -} - -func (*sKubernetesConfig) Add(ctx context.Context, in *entity.KubernetesConfig) (err error) { - r, err := dao.KubernetesConfig.Ctx(ctx).Where(cols.Name, in.Name).One() - if err != nil { - return err - } - if r != nil { - return gerror.New("已存在该名称的配置") - } - _, err = dao.KubernetesConfig.Ctx(ctx).Insert(in) - return -} - -func (*sKubernetesConfig) Upt(ctx context.Context, in *do.KubernetesConfig) (err error) { - if !gutil.IsEmpty(in.Name) { - r, err := dao.KubernetesConfig.Ctx(ctx).WhereNot(cols.Id, in.Id).Where(cols.Name, in.Name).One() - if err != nil { - return err - } - if r != nil { - return gerror.New("已存在该名称的配置") - } - } - _, err = dao.KubernetesConfig.Ctx(ctx).WherePri(in.Id).OmitNilData().Data(in).Update() - return -} - -func (*sKubernetesConfig) GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.KubernetesConfig], err error) { - out = &api.PageLstRes[*entity.KubernetesConfig]{} - m := dao.KubernetesConfig.Ctx(ctx).Safe(true) - if !gutil.IsEmpty(in.Search) { - m = m.WhereOr(m.Builder().WhereOrLike(cols.Name, in.SearchStr())) - } - - err = m.Offset(in.Offset()).Limit(in.Limit()). - ScanAndCount(&out.List, &out.Total, false) - return -} - -func (*sKubernetesConfig) GetLst(ctx context.Context) (out []*entity.KubernetesConfig, err error) { - err = dao.KubernetesConfig.Ctx(ctx).OrderDesc(cols.Id).Scan(&out) - return -} - -func (*sKubernetesConfig) GetPartialLst(ctx context.Context) (out []*mid.KubernetesConfigPartial, err error) { - err = dao.KubernetesConfig.Ctx(ctx).FieldsEx(cols.Config, cols.UpdatedAt).OrderDesc(cols.Id).Scan(&out) - return -} - -func (*sKubernetesConfig) Get(ctx context.Context, in *do.KubernetesConfig) (out *entity.KubernetesConfig, err error) { - err = dao.KubernetesConfig.Ctx(ctx).Where(in).OmitNilWhere().Limit(1).Scan(&out) - return -} - -func (*sKubernetesConfig) Del(ctx context.Context, in *do.KubernetesConfig) (err error) { - _, err = dao.KubernetesConfig.Ctx(ctx).Where(in).OmitNilWhere().Delete() - return -} diff --git a/internal/logic/logic.go b/internal/logic/logic.go index e64e09d..6aaa2ae 100644 --- a/internal/logic/logic.go +++ b/internal/logic/logic.go @@ -12,9 +12,9 @@ import ( _ "devops-super/internal/logic/host" _ "devops-super/internal/logic/host_group" _ "devops-super/internal/logic/host_terminal_session" - _ "devops-super/internal/logic/kubernetes_config" _ "devops-super/internal/logic/middleware" _ "devops-super/internal/logic/permission" _ "devops-super/internal/logic/role" + _ "devops-super/internal/logic/secret" _ "devops-super/internal/logic/user" ) diff --git a/internal/logic/secret/ci_env.go b/internal/logic/secret/ci_env.go new file mode 100644 index 0000000..96e1b64 --- /dev/null +++ b/internal/logic/secret/ci_env.go @@ -0,0 +1,81 @@ +package user + +import ( + "context" + "devops-super/api" + "devops-super/internal/dao" + "devops-super/internal/model/do" + "devops-super/internal/model/entity" + "devops-super/internal/service" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/util/gutil" +) + +type sSecret struct{} + +var cols = dao.Secret.Columns() + +func init() { + service.RegisterSecret(New()) +} + +func New() *sSecret { + return &sSecret{} +} + +func (*sSecret) Add(ctx context.Context, in *entity.Secret) (err error) { + r, err := dao.Secret.Ctx(ctx).Where(cols.Name, in.Name).One() + if err != nil { + return err + } + if r != nil { + return gerror.New("已存在该名称的秘钥") + } + _, err = dao.Secret.Ctx(ctx).Insert(in) + return +} + +func (*sSecret) Upt(ctx context.Context, in *do.Secret) (err error) { + if !gutil.IsEmpty(in.Name) { + r, err := dao.Secret.Ctx(ctx).WhereNot(cols.Id, in.Id).Where(cols.Name, in.Name).One() + if err != nil { + return err + } + if r != nil { + return gerror.New("已存在该名称的秘钥") + } + } + _, err = dao.Secret.Ctx(ctx).WherePri(in.Id).OmitNilData().Data(in).Update() + return +} + +func (*sSecret) GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.Secret], err error) { + out = &api.PageLstRes[*entity.Secret]{} + m := dao.Secret.Ctx(ctx).Safe(true) + if !gutil.IsEmpty(in.Search) { + m = m.WhereOr(m.Builder().WhereOrLike(cols.Name, in.SearchStr())) + } + + if typeV := in.Wheres.Get("type"); !typeV.IsNil() { + m = m.Where(cols.Type, typeV.Int()) + } + + err = m.Offset(in.Offset()).Limit(in.Limit()). + ScanAndCount(&out.List, &out.Total, false) + return +} + +func (*sSecret) GetLst(ctx context.Context, in *do.Secret) (out []*entity.Secret, err error) { + err = dao.Secret.Ctx(ctx).Fields(cols.Id, cols.Name).Where(in).OmitNilWhere().OrderDesc(cols.Id).Scan(&out) + return +} + +func (*sSecret) Get(ctx context.Context, in *do.Secret) (out *entity.Secret, err error) { + err = dao.Secret.Ctx(ctx).Where(in).OmitNilWhere().Limit(1).Scan(&out) + return +} + +func (*sSecret) Del(ctx context.Context, in *do.Secret) (err error) { + _, err = dao.Secret.Ctx(ctx).Where(in).OmitNilWhere().Delete() + return +} diff --git a/internal/model/do/secret.go b/internal/model/do/secret.go new file mode 100644 index 0000000..29885ea --- /dev/null +++ b/internal/model/do/secret.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// Secret is the golang structure of table secret for DAO operations like Where/Data. +type Secret struct { + g.Meta `orm:"table:secret, do:true"` + Id interface{} // + Name interface{} // 名称 + Type interface{} // 类型:1-git认证,2-Kubernetes config + Content *gjson.Json // 认证配置内容 + UpdatedAt *gtime.Time // 更新时间 +} diff --git a/internal/model/entity/secret.go b/internal/model/entity/secret.go new file mode 100644 index 0000000..135d2be --- /dev/null +++ b/internal/model/entity/secret.go @@ -0,0 +1,19 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/os/gtime" +) + +// Secret is the golang structure for table secret. +type Secret struct { + Id int `json:"id" description:""` // + Name string `json:"name" description:"名称"` // 名称 + Type int `json:"type" description:"类型:1-git认证,2-Kubernetes config"` // 类型:1-git认证,2-Kubernetes config + Content *gjson.Json `json:"content" description:"认证配置内容"` // 认证配置内容 + UpdatedAt *gtime.Time `json:"updatedAt" description:"更新时间"` // 更新时间 +} diff --git a/internal/model/mid/ci_env.go b/internal/model/mid/ci_env.go index 86bf538..292b63a 100644 --- a/internal/model/mid/ci_env.go +++ b/internal/model/mid/ci_env.go @@ -1,7 +1,7 @@ package mid type CiEnv struct { - Name string `v:"required|max-length:30" json:"name"` - Image string `v:"required" json:"image"` - Secret string `json:"secret"` + Name string `v:"required|max-length:30" json:"name"` + Image string `v:"required" json:"image"` + SecretName string `json:"secretName"` } diff --git a/internal/model/mid/ci_pipeline.go b/internal/model/mid/ci_pipeline.go index 3b981f8..37f91c9 100644 --- a/internal/model/mid/ci_pipeline.go +++ b/internal/model/mid/ci_pipeline.go @@ -17,10 +17,30 @@ func (c CiPipelineConfig) GetEnvIds() []int { } type CiPipelineConfigEnvItem struct { - Id int `json:"id"` - Stages []*CiPipelineConfigEnvStageItem `json:"stages"` + Id int `json:"id" yaml:"id"` + Image string `json:"image" yaml:"image"` + SecretName string `json:"secretName" yaml:"secretName"` + Stages []*CiPipelineConfigEnvStageItem `json:"stages" yaml:"stages"` } type CiPipelineConfigEnvStageItem struct { - Name string `json:"name"` + Name string `json:"name" yaml:"name"` + Tasks []*CiPipelineConfigEnvStageTaskItem `json:"tasks" yaml:"tasks"` +} +type CiPipelineConfigEnvStageTaskItem struct { + Type int `json:"type" yaml:"type"` + GitPullData *GitPullData `json:"gitPullData,omitempty"` + ShellExecData *ShellExecData `json:"shellExecData,omitempty"` +} + +type GitPullData struct { + GitUrl string `json:"gitUrl,omitempty"` + Branch string `json:"branch,omitempty"` + SecretId int `json:"secretId,omitempty"` + GitBasicAuth *UsernamePasswordContent `json:"GitBasicAuth,omitempty"` +} + +type ShellExecData struct { + WorkDir string `json:"workDir,omitempty"` + Content string `json:"content"` } diff --git a/internal/model/mid/secret.go b/internal/model/mid/secret.go new file mode 100644 index 0000000..61336ae --- /dev/null +++ b/internal/model/mid/secret.go @@ -0,0 +1,18 @@ +package mid + +import "github.com/gogf/gf/v2/encoding/gjson" + +type Secret struct { + Name string `v:"required|max-length:30" json:"name"` + Type int `v:"required" json:"type"` + Content *gjson.Json `v:"required" json:"content"` +} + +type UsernamePasswordContent struct { + Username string `json:"username"` + Password string `json:"password"` +} + +type TextContent struct { + Text string `json:"text"` +} diff --git a/internal/service/ci_env.go b/internal/service/ci_env.go index 7788707..f293604 100644 --- a/internal/service/ci_env.go +++ b/internal/service/ci_env.go @@ -19,7 +19,7 @@ type ( GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.CiEnv], err error) GetLst(ctx context.Context) (out []*entity.CiEnv, err error) Get(ctx context.Context, in *do.CiEnv) (out *entity.CiEnv, err error) - GetIdNameMap(ctx context.Context, ids []int) (out map[int]string, err error) + GetEntityMap(ctx context.Context, ids []int) (out map[int]*entity.CiEnv, err error) Del(ctx context.Context, in *do.CiEnv) (err error) } ) diff --git a/internal/service/ci_pipeline.go b/internal/service/ci_pipeline.go index 13dc369..3841922 100644 --- a/internal/service/ci_pipeline.go +++ b/internal/service/ci_pipeline.go @@ -20,6 +20,7 @@ type ( GetLst(ctx context.Context) (out []*entity.CiPipeline, err error) Get(ctx context.Context, in *do.CiPipeline) (out *entity.CiPipeline, err error) Del(ctx context.Context, in *do.CiPipeline) (err error) + Run(ctx context.Context, id int) (err error) } ) diff --git a/internal/service/kubernetes_config.go b/internal/service/kubernetes_config.go deleted file mode 100644 index c5894e6..0000000 --- a/internal/service/kubernetes_config.go +++ /dev/null @@ -1,41 +0,0 @@ -// ================================================================================ -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// You can delete these comments if you wish manually maintain this interface file. -// ================================================================================ - -package service - -import ( - "context" - "devops-super/api" - "devops-super/internal/model/do" - "devops-super/internal/model/entity" - "devops-super/internal/model/mid" -) - -type ( - IKubernetesConfig interface { - Add(ctx context.Context, in *entity.KubernetesConfig) (err error) - Upt(ctx context.Context, in *do.KubernetesConfig) (err error) - GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.KubernetesConfig], err error) - GetLst(ctx context.Context) (out []*entity.KubernetesConfig, err error) - GetPartialLst(ctx context.Context) (out []*mid.KubernetesConfigPartial, err error) - Get(ctx context.Context, in *do.KubernetesConfig) (out *entity.KubernetesConfig, err error) - Del(ctx context.Context, in *do.KubernetesConfig) (err error) - } -) - -var ( - localKubernetesConfig IKubernetesConfig -) - -func KubernetesConfig() IKubernetesConfig { - if localKubernetesConfig == nil { - panic("implement not found for interface IKubernetesConfig, forgot register?") - } - return localKubernetesConfig -} - -func RegisterKubernetesConfig(i IKubernetesConfig) { - localKubernetesConfig = i -} diff --git a/internal/service/secret.go b/internal/service/secret.go new file mode 100644 index 0000000..7dfe46f --- /dev/null +++ b/internal/service/secret.go @@ -0,0 +1,39 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + "devops-super/api" + "devops-super/internal/model/do" + "devops-super/internal/model/entity" +) + +type ( + ISecret interface { + Add(ctx context.Context, in *entity.Secret) (err error) + Upt(ctx context.Context, in *do.Secret) (err error) + GetPageLst(ctx context.Context, in *api.PageLstReq) (out *api.PageLstRes[*entity.Secret], err error) + GetLst(ctx context.Context, in *do.Secret) (out []*entity.Secret, err error) + Get(ctx context.Context, in *do.Secret) (out *entity.Secret, err error) + Del(ctx context.Context, in *do.Secret) (err error) + } +) + +var ( + localSecret ISecret +) + +func Secret() ISecret { + if localSecret == nil { + panic("implement not found for interface ISecret, forgot register?") + } + return localSecret +} + +func RegisterSecret(i ISecret) { + localSecret = i +} diff --git a/manifest/docker/Dockerfile b/manifest/docker/Dockerfile index d0e361b..8ae890e 100644 --- a/manifest/docker/Dockerfile +++ b/manifest/docker/Dockerfile @@ -14,4 +14,4 @@ RUN chmod +x $WORKDIR/main # START ############################################################################### WORKDIR $WORKDIR -CMD ./main --gf.gcfg.file=config-prod.yaml +CMD ./main --gf.gcfg.file=config-demo.yaml