mirror of
https://github.com/khuedoan/homelab.git
synced 2025-07-06 08:22:10 +07:00
feat(gitea): POC config as code (WIP)
This commit is contained in:
24
platform/gitea/files/config/config.yaml
Normal file
24
platform/gitea/files/config/config.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
users:
|
||||
- name: renovate
|
||||
tokenSecretRef: renovate-secret # ???
|
||||
organizations:
|
||||
- name: ops
|
||||
description: Operations
|
||||
teams:
|
||||
- name: Owners
|
||||
members:
|
||||
- renovate
|
||||
repositories:
|
||||
- path: ops/homelab
|
||||
private: false
|
||||
migrate:
|
||||
source: https://github.com/khuedoan/homelab
|
||||
mirror: false
|
||||
webhooks:
|
||||
- http://gitea-webhook.tekton-pipelines:3000
|
||||
- path: khuedoan/blog
|
||||
webhooks:
|
||||
- http://gitea-webhook.tekton-pipelines:3000
|
||||
- path: khuedoan/backstage
|
||||
webhooks:
|
||||
- http://gitea-webhook.tekton-pipelines:3000
|
8
platform/gitea/files/config/go.mod
Normal file
8
platform/gitea/files/config/go.mod
Normal file
@ -0,0 +1,8 @@
|
||||
module git.khuedoan.com/khuedoan/homelab/gitea/config
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.15.1 // indirect
|
||||
github.com/hashicorp/go-version v1.2.1 // indirect
|
||||
)
|
28
platform/gitea/files/config/go.sum
Normal file
28
platform/gitea/files/config/go.sum
Normal file
@ -0,0 +1,28 @@
|
||||
code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
|
||||
code.gitea.io/sdk/gitea v0.15.1 h1:WJreC7YYuxbn0UDaPuWIe/mtiNKTvLN8MLkaw71yx/M=
|
||||
code.gitea.io/sdk/gitea v0.15.1/go.mod h1:klY2LVI3s3NChzIk/MzMn7G1FHrfU7qd63iSMVoHRBA=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
|
||||
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
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=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
69
platform/gitea/files/config/main.go
Normal file
69
platform/gitea/files/config/main.go
Normal file
@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Name string
|
||||
TokenSecretRef string
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
Name string
|
||||
Members []string
|
||||
}
|
||||
|
||||
type Repository struct {
|
||||
Path string
|
||||
Migrate struct {
|
||||
Source string
|
||||
Mirror bool
|
||||
}
|
||||
Webhooks []string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Users []User
|
||||
Organizations []Organization
|
||||
Repositories []Repository
|
||||
}
|
||||
|
||||
func main() {
|
||||
// TODO
|
||||
url := "https://git.khuedoan.com"
|
||||
// url := "http://gitea-http:3000"
|
||||
password := "thisisjustfortestingdude"
|
||||
|
||||
options := (gitea.SetBasicAuth("gitea_admin", password))
|
||||
client, err := gitea.NewClient(url, options)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, _, err = client.CreateOrg(gitea.CreateOrgOption{
|
||||
Name: "testing",
|
||||
Description: "this is org description",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Create organization %s: %s", "testing", err)
|
||||
}
|
||||
|
||||
_, _, err = client.MigrateRepo(gitea.MigrateRepoOption{
|
||||
RepoName: "homelab",
|
||||
RepoOwner: "ops",
|
||||
CloneAddr: "https://github.com/khuedoan/homelab",
|
||||
Service: gitea.GitServicePlain,
|
||||
Mirror: true,
|
||||
Private: false,
|
||||
MirrorInterval: "10m",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Migrate %s/%s: %s", "ops", "homelab", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user