This commit is contained in:
Adam Majer 2024-07-09 12:06:24 +02:00
parent 300c411942
commit 8d7da9b376
18 changed files with 40879 additions and 25932 deletions

View File

@ -6,14 +6,14 @@ api.json:
obs.api.json: obs.api.json:
curl -o obs.api.yaml https://api.opensuse.org/apidocs/OBS-v2.10.50.yaml curl -o obs.api.yaml https://api.opensuse.org/apidocs/OBS-v2.10.50.yaml
client.gen.go: obs.api.json
go generate
gitea-generated/client/gitea_api_client.go: api.json gitea-generated/client/gitea_api_client.go: api.json
[ -d gitea-generated ] || mkdir gitea-generated [ -d gitea-generated ] || mkdir gitea-generated
podman run --rm -v $$(pwd):/api ghcr.io/go-swagger/go-swagger generate client -f /api/api.json -t /api/gitea-generated podman run --rm -v $$(pwd):/api ghcr.io/go-swagger/go-swagger generate client -f /api/api.json -t /api/gitea-generated
generate.go: api: gitea-generated/client/gitea_api_client.go client.gen.go
go generate
api: gitea-generated/client/gitea_api_client.go
build: api build: api
go build go build

40550
bots-common/client.gen.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ require (
require ( require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/getkin/kin-openapi v0.124.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect github.com/go-openapi/analysis v0.23.0 // indirect
@ -20,17 +21,25 @@ require (
github.com/go-openapi/loads v0.22.0 // indirect github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect github.com/go-openapi/spec v0.21.0 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.21.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

View File

@ -3,6 +3,8 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:W
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M=
github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@ -32,6 +34,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY=
github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@ -42,10 +46,16 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 h1:rICjNsHbPP1LttefanBPnwsSwl09SqhCO7Ee623qR84=
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0/go.mod h1:4k+cJeSq5ntkwlcpQSxLxICCxQzCL772o30PxdibRt4=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
@ -64,12 +74,21 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -8,6 +8,7 @@ import (
const RequestType_Push = "push" const RequestType_Push = "push"
const RequestType_Repository = "repository" const RequestType_Repository = "repository"
const RequestType_PR = "pull_request"
type RequestProcessor func(*RequestHandler) error type RequestProcessor func(*RequestHandler) error
@ -44,14 +45,28 @@ func StartServer(listenDefs ListenDefinitions) {
reqType := hdr[0] reqType := hdr[0]
if handler, ok := listenDefs.Handlers[reqType]; ok { if handler, ok := listenDefs.Handlers[reqType]; ok {
switch reqType {
case RequestType_Repository:
h.parseRepositoryRequest(req.Body)
case RequestType_Push:
h.parsePushRequest(req.Body)
case RequestType_PR:
h.parsePullRequest(req.Body)
default:
h.LogError("Unhandled request type: %s", reqType)
res.WriteHeader(http.StatusInternalServerError)
return
}
if err := handler(h); err != nil { if err := handler(h); err != nil {
h.LogError("error in handler for %s: %v", reqType, err); h.LogError("error in handler for %s: %v", reqType, err)
res.WriteHeader(http.StatusInternalServerError) res.WriteHeader(http.StatusInternalServerError)
return return
} }
} else { } else {
h.LogError("Unsupported request type: %s", reqType) h.LogError("Unsupported request type: %s", reqType)
res.WriteHeader(http.StatusInternalServerError) res.WriteHeader(http.StatusInternalServerError)
return
} }
if h.HasError() { if h.HasError() {

View File

@ -4231,6 +4231,38 @@ paths:
summary: 'Project not found: <some project>.' summary: 'Project not found: <some project>.'
tags: tags:
- Build - Build
post:
deprecated: true
summary: Show the build dependencies of packages that are part of the project.
description: |
This endpoint is exactly the same as
`GET /build/{project_name}/{repository_name}/{architecture_name}/{package_name}/_builddepinfo`, please use that one.
security:
- basic_authentication: []
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: repository_name
schema:
type: string
required: true
description: Repository name
example: openSUSE_Tumbleweed
- in: path
name: architecture_name
schema:
type: string
required: true
description: Architecture name
example: x86_64
tags:
- Build
"/build/{project_name}/{repository_name}/{architecture_name}/_jobhistory": "/build/{project_name}/{repository_name}/{architecture_name}/_jobhistory":
get: get:
summary: Get the build log of all finished builds. summary: Get the build log of all finished builds.
@ -5654,6 +5686,45 @@ paths:
summary: 'Project not found: 1' summary: 'Project not found: 1'
tags: tags:
- Build - Build
post:
deprecated: true
summary: Return the build history for a specific artifact
description: |
This endpoint is exactly the same as
`GET /build/{project_name}/{repository_name}/{architecture_name}/{package_name}/_history`, please use that one.
security:
- basic_authentication: []
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: repository_name
schema:
type: string
required: true
description: Repository name
example: openSUSE_Tumbleweed
- in: path
name: architecture_name
schema:
type: string
required: true
description: Architecture name
example: x86_64
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags:
- Build
"/build/{project_name}/{repository_name}/{architecture_name}/{package_name}/_jobstatus": "/build/{project_name}/{repository_name}/{architecture_name}/{package_name}/_jobstatus":
get: get:
summary: Show the build status of a currently running build job. summary: Show the build status of a currently running build job.
@ -6487,6 +6558,45 @@ paths:
summary: 'Project not found: 1' summary: 'Project not found: 1'
tags: tags:
- Build - Build
post:
deprecated: true
summary: Return the building status for a specific artifact
description: |
This endpoint is exactly the same as
`GET /build/{project_name}/{repository_name}/{architecture_name}/{package_name}/_status`, please use that one.
security:
- basic_authentication: []
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: repository_name
schema:
type: string
required: true
description: Repository name
example: openSUSE_Tumbleweed
- in: path
name: architecture_name
schema:
type: string
required: true
description: Architecture name
example: x86_64
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags:
- Build
"/build/{project_name}/{repository_name}/{architecture_name}/{package_name}/{file_name}": "/build/{project_name}/{repository_name}/{architecture_name}/{package_name}/{file_name}":
get: get:
summary: Return a specific artifact file contents summary: Return a specific artifact file contents
@ -11816,13 +11926,13 @@ paths:
title: test 1 title: test 1
who: Administrator who: Administrator
state: new state: new
when: 2021-09-30 07:12:02.000000000 +00:00 when: 2021-09-30 09:12:02.000000000 +02:00
event_type: review_wanted event_type: review_wanted
- id: 25 - id: 25
title: test 2 title: test 2
who: User 2 who: User 2
event_type: comment_for_package event_type: comment_for_package
when: 2021-09-27 07:16:19.000000000 +00:00 when: 2021-09-27 09:16:19.000000000 +02:00
'401': '401':
description: | description: |
Unauthorized. Unauthorized.
@ -13219,7 +13329,7 @@ paths:
description: 'Token description. It helps to identify a token from the rest description: 'Token description. It helps to identify a token from the rest
of the tokens of a user. of the tokens of a user.
' '
example: Rebuild gchz example: Rebuild gchz
- in: query - in: query
name: project name: project
@ -17100,7 +17210,7 @@ paths:
description: 'Diff relative to a given superseded request. State the id of description: 'Diff relative to a given superseded request. State the id of
the corresponding superseded request. the corresponding superseded request.
' '
example: 10401 example: 10401
- in: query - in: query
name: view name: view
@ -17120,6 +17230,8 @@ paths:
description: Include parsed issues from referenced sources description: Include parsed issues from referenced sources
- in: query - in: query
name: withdescriptionissues name: withdescriptionissues
schema:
type: string
description: Include parsed issues from request description description: Include parsed issues from request description
responses: responses:
'200': '200':
@ -18581,7 +18693,7 @@ paths:
code: invalid_attribute code: invalid_attribute
summary: 'Attribute ''foo'' must be in the $NAMESPACE:$NAME style summary: 'Attribute ''foo'' must be in the $NAMESPACE:$NAME style
' '
'401': '401':
description: | description: |
Unauthorized. Unauthorized.
@ -18687,21 +18799,21 @@ paths:
type: string type: string
description: 'The name of a binary package whose owners you want to search. description: 'The name of a binary package whose owners you want to search.
' '
- in: query - in: query
name: user name: user
schema: schema:
type: string type: string
description: 'Search what this user is owner of. description: 'Search what this user is owner of.
' '
- in: query - in: query
name: group name: group
schema: schema:
type: string type: string
description: 'The title of a group. Search what this group is owner of. description: 'The title of a group. Search what this group is owner of.
' '
- in: query - in: query
name: limit name: limit
schema: schema:
@ -18902,7 +19014,7 @@ paths:
summary: 'The search needs at least a ''binary'', ''package'' summary: 'The search needs at least a ''binary'', ''package''
or ''user'' parameter or ''user'' parameter
' '
search root not set: search root not set:
summary: Search root is not set summary: Search root is not set
description: At least one of the projects in your instance should description: At least one of the projects in your instance should
@ -18911,7 +19023,7 @@ paths:
summary: 'The attribute OBS:OwnerRootProject is not set to define summary: 'The attribute OBS:OwnerRootProject is not set to define
default projects. default projects.
' '
'401': '401':
description: | description: |
Unauthorized. Unauthorized.
@ -20342,7 +20454,7 @@ paths:
description: 'Empty result, when there is no matches. For example: description: 'Empty result, when there is no matches. For example:
`?match=project=''home:bs-team:OBS''`. `?match=project=''home:bs-team:OBS''`.
' '
'400': '400':
description: Bad Request description: Bad Request
content: content:
@ -20512,7 +20624,7 @@ paths:
description: 'Empty result, when there is no matches. For example: description: 'Empty result, when there is no matches. For example:
`?match=project=''home:bs-team:OBS''`. `?match=project=''home:bs-team:OBS''`.
' '
'400': '400':
description: Bad Request description: Bad Request
content: content:
@ -24770,7 +24882,7 @@ paths:
summary: 'pattern validation error: 1:1: FATAL: Start tag expected, summary: 'pattern validation error: 1:1: FATAL: Start tag expected,
< not found < not found
' '
'401': '401':
description: | description: |
Unauthorized. Unauthorized.
@ -25365,7 +25477,7 @@ paths:
expires: 1887851113 expires: 1887851113
fingerprint: 22c0 7ba5 3417 8cd0 2efe 22aa b88b 2fd4 3dbd c284 fingerprint: 22c0 7ba5 3417 8cd0 2efe 22aa b88b 2fd4 3dbd c284
sslcert: sslcert:
serial: 18991220325 serial: 18068117070991220325
issuer: CN=openSUSE Secure Boot CA, C=DE, L=Nuremberg, O=openSUSE issuer: CN=openSUSE Secure Boot CA, C=DE, L=Nuremberg, O=openSUSE
Project, emailAddress=build@opensuse.org Project, emailAddress=build@opensuse.org
subject: CN=openSUSE Secure Boot Signkey, C=DE, L=Nuremberg, O=openSUSE subject: CN=openSUSE Secure Boot Signkey, C=DE, L=Nuremberg, O=openSUSE
@ -26601,7 +26713,7 @@ paths:
required: true required: true
description: Project name description: Project name
example: home:Admin example: home:Admin
- in: path - in: query
name: mode name: mode
schema: schema:
type: string type: string
@ -26609,7 +26721,6 @@ paths:
- skip_disabled - skip_disabled
- enable_all - enable_all
- add_disabled - add_disabled
required: false
description: The channel will be added to the package using this mode. description: The channel will be added to the package using this mode.
example: add_disabled example: add_disabled
responses: responses:
@ -29915,7 +30026,7 @@ paths:
description: 'Passing the number of the revision, this endpoint displays the description: 'Passing the number of the revision, this endpoint displays the
attributes'' XML as it was at that point. attributes'' XML as it was at that point.
' '
example: 3 example: 3
- name: view - name: view
in: query in: query
@ -29941,7 +30052,7 @@ paths:
description: 'Passing `with_project`, the response displays the attributes description: 'Passing `with_project`, the response displays the attributes
of the package''s project in addition to the package ones. of the package''s project in addition to the package ones.
' '
example: 1 example: 1
responses: responses:
'200': '200':
@ -30327,7 +30438,7 @@ paths:
description: 'Passing the number of the revision, this endpoint displays the description: 'Passing the number of the revision, this endpoint displays the
attributes'' XML as it was at that point. attributes'' XML as it was at that point.
' '
example: 3 example: 3
- name: view - name: view
in: query in: query
@ -30354,7 +30465,7 @@ paths:
attribute of the package''s project, if any, in addition to the package attribute of the package''s project, if any, in addition to the package
one. one.
' '
example: 1 example: 1
responses: responses:
'200': '200':
@ -31809,7 +31920,7 @@ paths:
type: string type: string
description: 'Set to 1 to allow overwriting of a pre-existing package. description: 'Set to 1 to allow overwriting of a pre-existing package.
' '
example: 1 example: 1
- in: query - in: query
name: rev name: rev
@ -32093,6 +32204,8 @@ paths:
to base the build environment collection. to base the build environment collection.
- in: query - in: query
name: comment name: comment
schema:
type: string
description: Comment for the new revision. description: Comment for the new revision.
responses: responses:
'200': '200':
@ -32878,6 +32991,8 @@ paths:
description: Set to '1' to avoid running the services after the copy. description: Set to '1' to avoid running the services after the copy.
- in: query - in: query
name: comment name: comment
schema:
type: string
description: Comment for the new revision. description: Comment for the new revision.
responses: responses:
'200': '200':
@ -32989,6 +33104,23 @@ paths:
Create a RPM Spec File Template for a specified package. This endpoint Create a RPM Spec File Template for a specified package. This endpoint
is broken and will be removed. is broken and will be removed.
See [https://github.com/openSUSE/open-build-service/issues/9707](https://github.com/openSUSE/open-build-service/issues/9707) See [https://github.com/openSUSE/open-build-service/issues/9707](https://github.com/openSUSE/open-build-service/issues/9707)
security:
- basic_authentication: []
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags: tags:
- Sources - Packages - Sources - Packages
"/source/{project_name}/{package_name}?cmd=deleteuploadrev": "/source/{project_name}/{package_name}?cmd=deleteuploadrev":
@ -33601,7 +33733,7 @@ paths:
type: string type: string
description: 'Set to 1 to allow overwriting of a pre-existing package. description: 'Set to 1 to allow overwriting of a pre-existing package.
' '
example: 1 example: 1
- name: add_repositories_rebuild - name: add_repositories_rebuild
in: query in: query
@ -34343,7 +34475,7 @@ paths:
description: 'Link revision in base package. Set to `base` to use the commit description: 'Link revision in base package. Set to `base` to use the commit
revision. revision.
' '
example: base example: base
- in: query - in: query
name: rev name: rev
@ -34775,6 +34907,23 @@ paths:
Triggers a rebuild of the package. This endpoint Triggers a rebuild of the package. This endpoint
is broken and will be removed. is broken and will be removed.
See [`POST /build/{project_name}?cmd=rebuild`](#/Build/post_build__project_name__cmd_rebuild). See [`POST /build/{project_name}?cmd=rebuild`](#/Build/post_build__project_name__cmd_rebuild).
security:
- basic_authentication: []
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags: tags:
- Sources - Packages - Sources - Packages
"/source/{project_name}/{package_name}?cmd=release": "/source/{project_name}/{package_name}?cmd=release":
@ -34826,7 +34975,7 @@ paths:
description: 'Limit the release to a certain repository, set on the project description: 'Limit the release to a certain repository, set on the project
repository definitions. repository definitions.
' '
example: openSUSE_Tumbleweed example: openSUSE_Tumbleweed
- in: query - in: query
name: setrelease name: setrelease
@ -34835,7 +34984,7 @@ paths:
description: 'If this parameter is present, the release will be tagged with description: 'If this parameter is present, the release will be tagged with
this parameter''s value. this parameter''s value.
' '
example: Build8.18 example: Build8.18
- in: query - in: query
name: arch name: arch
@ -39311,7 +39460,7 @@ paths:
obsolete requests as well as missing reviews, otherwise don''t pass this obsolete requests as well as missing reviews, otherwise don''t pass this
query parameter." query parameter."
' '
- name: status - name: status
in: query in: query
schema: schema:
@ -39321,7 +39470,7 @@ paths:
status xml (broken packages, missing reviews, checks, etc.), otherwise don''t status xml (broken packages, missing reviews, checks, etc.), otherwise don''t
pass this query parameter" pass this query parameter"
' '
- name: history - name: history
in: query in: query
schema: schema:
@ -39710,7 +39859,7 @@ paths:
obsolete requests as well as missing reviews, otherwise don''t pass this obsolete requests as well as missing reviews, otherwise don''t pass this
query parameter. query parameter.
' '
- name: status - name: status
in: query in: query
schema: schema:
@ -39721,7 +39870,7 @@ paths:
status xml (broken packages, missing reviews, checks, etc.), otherwise don''t status xml (broken packages, missing reviews, checks, etc.), otherwise don''t
pass this query parameter. pass this query parameter.
' '
- name: history - name: history
in: query in: query
schema: schema:
@ -40396,7 +40545,7 @@ paths:
summary: 'Request ID currently excluded from project project_name. summary: 'Request ID currently excluded from project project_name.
Use --remove-exclusion if you want to force this action. Use --remove-exclusion if you want to force this action.
' '
Unknown Request: Unknown Request:
value: value:
code: invalid_request code: invalid_request
@ -41188,6 +41337,14 @@ paths:
deprecated: true deprecated: true
summary: This endpoint is deprecated summary: This endpoint is deprecated
description: This endpoint is no longer supported or might not work as expected. description: This endpoint is no longer supported or might not work as expected.
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
tags: tags:
- Statistics - Statistics
"/statistics/activity/{project_name}/{package_name}": "/statistics/activity/{project_name}/{package_name}":
@ -41195,6 +41352,21 @@ paths:
deprecated: true deprecated: true
summary: This endpoint is deprecated summary: This endpoint is deprecated
description: This endpoint is no longer supported or might not work as expected. description: This endpoint is no longer supported or might not work as expected.
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags: tags:
- Statistics - Statistics
"/statistics/added_timestamp/{project_name}/{package_name}": "/statistics/added_timestamp/{project_name}/{package_name}":
@ -41202,6 +41374,21 @@ paths:
deprecated: true deprecated: true
summary: This endpoint is deprecated summary: This endpoint is deprecated
description: This endpoint is no longer supported or might not work as expected. description: This endpoint is no longer supported or might not work as expected.
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags: tags:
- Statistics - Statistics
"/statistics/global_counters": "/statistics/global_counters":
@ -41482,6 +41669,14 @@ paths:
deprecated: true deprecated: true
summary: This endpoint is deprecated summary: This endpoint is deprecated
description: This endpoint is no longer supported or might not work as expected. description: This endpoint is no longer supported or might not work as expected.
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
tags: tags:
- Statistics - Statistics
"/statistics/most_active_packages": "/statistics/most_active_packages":
@ -41737,6 +41932,21 @@ paths:
deprecated: true deprecated: true
summary: This endpoint is deprecated summary: This endpoint is deprecated
description: This endpoint is no longer supported or might not work as expected. description: This endpoint is no longer supported or might not work as expected.
parameters:
- in: path
name: project_name
schema:
type: string
required: true
description: Project name
example: home:Admin
- in: path
name: package_name
schema:
type: string
required: true
description: Package name
example: ctris
tags: tags:
- Statistics - Statistics
"/status/messages": "/status/messages":

View File

@ -1,10 +1,8 @@
package main package common
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"os"
"strings" "strings"
) )
@ -56,36 +54,10 @@ func (h *RequestHandler) parsePullRequest(data io.ReadCloser) *PullRequestAction
return nil return nil
} }
h.PrjGit = action.Repository.Ssh_Url[:repoIdx+1] + DefaultGitPrj + ".git" h.PrjGit = action.Repository.Ssh_Url[:repoIdx+1] + DefaultGitPrj + ".git"
h.data = &action h.Data = &action
// sanity checks on request // sanity checks on request
return &action return &action
} }
func (h *RequestHandler) processCreatePullRequestAction() {
action := h.Request.data.(PullRequestAction)
action.PullRequest
}
func (h *RequestHandler) processUpdatePullRequestAction() {
// 1. update gitprj
// 2. re-request reviews, if needed
}
func (h *RequestHandler) processPullRequestAction() {
if h.HasError() {
return
}
action := h.Request.data.(PullRequestAction)
switch action.Action {
case "opened":
h.processCreatePullRequestAction()
default:
h.Error = fmt.Errorf("Invalid PR action type: %s", action.Action)
h.LogError("%#v", h.Error)
return
}
}

View File

@ -21,7 +21,7 @@ type PushRequest struct {
Repository Repository Repository Repository
} }
func (h *RequestHandler) ParsePushRequest(data io.Reader) *PushRequest { func (h *RequestHandler) parsePushRequest(data io.Reader) *PushRequest {
if h.HasError() { if h.HasError() {
return nil return nil
} }

View File

@ -36,7 +36,7 @@ func TestPushRequestParsing(t *testing.T) {
var h RequestHandler var h RequestHandler
h.Logger = CreateTestLogger(t) h.Logger = CreateTestLogger(t)
json := h.ParsePushRequest(strings.NewReader(examplePushJSON)) json := h.parsePushRequest(strings.NewReader(examplePushJSON))
if h.HasError() { if h.HasError() {
t.Fatalf("Can't parse struct: %s", h.Error.Error()) t.Fatalf("Can't parse struct: %s", h.Error.Error())
} }

View File

@ -42,7 +42,7 @@ type RepositoryAction struct {
} }
// TODO: sanity check values!!!! // TODO: sanity check values!!!!
func (h *RequestHandler) ParseRepositoryRequest(dataReader io.Reader) *RepositoryAction { func (h *RequestHandler) parseRepositoryRequest(dataReader io.Reader) *RepositoryAction {
if h.HasError() { if h.HasError() {
return nil return nil
} }

View File

@ -21,7 +21,7 @@ func TestRepositoryRequestParsing(t *testing.T) {
var h RequestHandler var h RequestHandler
h.Logger = CreateStdoutLogger(&strStr, &errStr) h.Logger = CreateStdoutLogger(&strStr, &errStr)
json := h.ParseRepositoryRequest(strings.NewReader(repoCreateJSON)) json := h.parseRepositoryRequest(strings.NewReader(repoCreateJSON))
if h.HasError() { if h.HasError() {
t.Fatalf("Can't parse struct: %s", h.Error) t.Fatalf("Can't parse struct: %s", h.Error)
} }

View File

@ -1,14 +0,0 @@
all: build
api.json:
curl -o api.json https://src.opensuse.org/swagger.v1.json
generated/client/gitea_api_client.go: api.json
[ -d generated ] || mkdir generated
podman run --rm -v $$(pwd):/api ghcr.io/go-swagger/go-swagger generate client -f /api/api.json -t /api/generated
api: generated/client/gitea_api_client.go
build: api
go build

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
#!/bin/sh
while true; do
clear
go test
inotifywait -q -e modify -e create -e delete -r .
done

View File

@ -1,3 +0,0 @@
package main;

View File

@ -1,13 +1,6 @@
package main package main
import ( import (
"errors"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"src.opensuse.org/autogits/common" "src.opensuse.org/autogits/common"
) )
@ -16,80 +9,28 @@ const (
ListenAddr = "[::1]" ListenAddr = "[::1]"
GitAuthor = "GiteaBot - AutoStaging" GitAuthor = "GiteaBot - AutoStaging"
PrReview = "pr-review"
) )
func createListenServer() { func processPullRequest(h *common.RequestHandler) error {
http.HandleFunc("/pr-review", func(res http.ResponseWriter, req *http.Request) { req := h.Data.(common.PullRequestAction)
h := createRequestHandler("pr-review")
// defer h.Close()
if len(req.Header.Get("Content-Type")) == 0 || // requests against project are not handled here
req.Header["Content-Type"][0] != "application/json" || if req.Repository.Name == common.DefaultGitPrj {
req.Method != "POST" { return nil
h.writeError()
res.WriteHeader(http.StatusInternalServerError)
return
}
hdr := req.Header[GiteaRequestHeader]
if len(hdr) != 1 {
h.LogError("Unsupported number of %s headers: %d: %#v\n", GiteaRequestHeader, len(hdr), hdr)
h.writeError()
res.WriteHeader(http.StatusInternalServerError)
return
}
reqType := hdr[0]
switch reqType {
case "pull_request":
h.parsePullRequest(req.Body)
h.processPullRequestAction()
default:
h.LogError("Unsupported request type: %s", reqType)
res.WriteHeader(http.StatusInternalServerError)
}
if h.HasError() {
h.writeError()
res.WriteHeader(http.StatusInternalServerError)
return
}
res.Header().Add("Content-Type", "application/json")
res.WriteHeader(http.StatusOK)
})
log.Fatal(http.ListenAndServe(ListenAddr+":"+fmt.Sprint(ListenPort), nil))
}
func parseObsSecretToken() error {
return nil
}
func parseGiteaSecretToken() error {
GiteaToken = os.Getenv(GiteaTokenEnv)
if len(GiteaToken) < 10 {
return errors.New(GiteaTokenEnv + " not provided")
}
err := os.Setenv(GiteaTokenEnv, "")
if err != nil {
return fmt.Errorf("%s: %v", "Cannot reset "+GiteaTokenEnv, err)
} }
return nil return nil
} }
func main() { func main() {
if err := parseGiteaSecretToken(); err != nil { var defs common.ListenDefinitions
fmt.Print(err)
return
}
if err := parseObsSecretToken(); err != nil { defs.Url = PrReview
fmt.Print(err) defs.GitAuthor = GitAuthor
return defs.Handlers[common.RequestType_PR] = processPullRequest
}
createListenServer() common.RequireGiteaSecretToken()
common.RequireObsSecretToken()
common.StartServer(defs)
} }

View File

@ -1,11 +0,0 @@
package main
const ReadmeBoilerplate = `
README
======
This empty project was created by AutoDevel bot.
AutoDevel creates projects that can be built
in Open Build Service.
`

View File

@ -1,5 +0,0 @@
all: build
build:
go build