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:
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
[ -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
generate.go:
go generate
api: gitea-generated/client/gitea_api_client.go
api: gitea-generated/client/gitea_api_client.go client.gen.go
build: api
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 (
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/stdr v1.2.2 // 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/spec v0.21.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/mailru/easyjson v0.7.7 // 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/opentracing/opentracing-go v1.2.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric 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/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
)

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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
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.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
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/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
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/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
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/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/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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
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/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
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/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
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/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 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -8,6 +8,7 @@ import (
const RequestType_Push = "push"
const RequestType_Repository = "repository"
const RequestType_PR = "pull_request"
type RequestProcessor func(*RequestHandler) error
@ -44,14 +45,28 @@ func StartServer(listenDefs ListenDefinitions) {
reqType := hdr[0]
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 {
h.LogError("error in handler for %s: %v", reqType, err);
h.LogError("error in handler for %s: %v", reqType, err)
res.WriteHeader(http.StatusInternalServerError)
return
}
} else {
h.LogError("Unsupported request type: %s", reqType)
res.WriteHeader(http.StatusInternalServerError)
return
}
if h.HasError() {

View File

@ -4231,6 +4231,38 @@ paths:
summary: 'Project not found: <some project>.'
tags:
- 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":
get:
summary: Get the build log of all finished builds.
@ -5654,6 +5686,45 @@ paths:
summary: 'Project not found: 1'
tags:
- 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":
get:
summary: Show the build status of a currently running build job.
@ -6487,6 +6558,45 @@ paths:
summary: 'Project not found: 1'
tags:
- 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}":
get:
summary: Return a specific artifact file contents
@ -11816,13 +11926,13 @@ paths:
title: test 1
who: Administrator
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
- id: 25
title: test 2
who: User 2
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':
description: |
Unauthorized.
@ -13219,7 +13329,7 @@ paths:
description: 'Token description. It helps to identify a token from the rest
of the tokens of a user.
'
'
example: Rebuild gchz
- in: query
name: project
@ -17100,7 +17210,7 @@ paths:
description: 'Diff relative to a given superseded request. State the id of
the corresponding superseded request.
'
'
example: 10401
- in: query
name: view
@ -17120,6 +17230,8 @@ paths:
description: Include parsed issues from referenced sources
- in: query
name: withdescriptionissues
schema:
type: string
description: Include parsed issues from request description
responses:
'200':
@ -18410,7 +18522,7 @@ paths:
owner:
login: user_1
email: user_1@example.com
realname:
realname:
- name: 4883
created_at: 2018-12-11 03:22:54 UTC
updated_at: 2018-12-11 03:22:54 UTC
@ -18581,7 +18693,7 @@ paths:
code: invalid_attribute
summary: 'Attribute ''foo'' must be in the $NAMESPACE:$NAME style
'
'
'401':
description: |
Unauthorized.
@ -18687,21 +18799,21 @@ paths:
type: string
description: 'The name of a binary package whose owners you want to search.
'
'
- in: query
name: user
schema:
type: string
description: 'Search what this user is owner of.
'
'
- in: query
name: group
schema:
type: string
description: 'The title of a group. Search what this group is owner of.
'
'
- in: query
name: limit
schema:
@ -18902,7 +19014,7 @@ paths:
summary: 'The search needs at least a ''binary'', ''package''
or ''user'' parameter
'
'
search root not set:
summary: Search root is not set
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
default projects.
'
'
'401':
description: |
Unauthorized.
@ -19656,14 +19768,14 @@ paths:
matches: 2
project:
- name: home:Iggy
title:
description:
title:
description:
person:
userid: Iggy
role: maintainer
- name: home:Iggy:branches:home:Admin
title: East of Eden
description:
description:
'400':
description: Bad Request
content:
@ -20342,7 +20454,7 @@ paths:
description: 'Empty result, when there is no matches. For example:
`?match=project=''home:bs-team:OBS''`.
'
'
'400':
description: Bad Request
content:
@ -20512,7 +20624,7 @@ paths:
description: 'Empty result, when there is no matches. For example:
`?match=project=''home:bs-team:OBS''`.
'
'
'400':
description: Bad Request
content:
@ -21596,7 +21708,7 @@ paths:
when: '2022-08-22T09:37:09'
who: Requestor
by_group: group_1
comment:
comment:
history:
who: Admin
when: '2022-08-22T09:37:09'
@ -21632,7 +21744,7 @@ paths:
when: '2022-08-22T09:37:09'
who: Admin
by_group: group_1
comment:
comment:
history:
who: Admin
when: '2022-08-22T09:37:09'
@ -21673,7 +21785,7 @@ paths:
when: '2022-08-22T09:37:09'
who: Admin
by_group: group_1
comment:
comment:
history:
who: Admin
when: '2022-08-22T09:37:09'
@ -24736,8 +24848,8 @@ paths:
srcmd5: 6c73fc9ef8d43369f0778564617b4a93
time: 1682497725
user: Admin
comment:
requestid:
comment:
requestid:
'400':
description: 'Error: Bad request.'
content:
@ -24770,7 +24882,7 @@ paths:
summary: 'pattern validation error: 1:1: FATAL: Start tag expected,
< not found
'
'
'401':
description: |
Unauthorized.
@ -25365,7 +25477,7 @@ paths:
expires: 1887851113
fingerprint: 22c0 7ba5 3417 8cd0 2efe 22aa b88b 2fd4 3dbd c284
sslcert:
serial: 18991220325
serial: 18068117070991220325
issuer: CN=openSUSE Secure Boot CA, C=DE, L=Nuremberg, O=openSUSE
Project, emailAddress=build@opensuse.org
subject: CN=openSUSE Secure Boot Signkey, C=DE, L=Nuremberg, O=openSUSE
@ -26601,7 +26713,7 @@ paths:
required: true
description: Project name
example: home:Admin
- in: path
- in: query
name: mode
schema:
type: string
@ -26609,7 +26721,6 @@ paths:
- skip_disabled
- enable_all
- add_disabled
required: false
description: The channel will be added to the package using this mode.
example: add_disabled
responses:
@ -29915,7 +30026,7 @@ paths:
description: 'Passing the number of the revision, this endpoint displays the
attributes'' XML as it was at that point.
'
'
example: 3
- name: view
in: query
@ -29941,7 +30052,7 @@ paths:
description: 'Passing `with_project`, the response displays the attributes
of the package''s project in addition to the package ones.
'
'
example: 1
responses:
'200':
@ -30327,7 +30438,7 @@ paths:
description: 'Passing the number of the revision, this endpoint displays the
attributes'' XML as it was at that point.
'
'
example: 3
- name: view
in: query
@ -30354,7 +30465,7 @@ paths:
attribute of the package''s project, if any, in addition to the package
one.
'
'
example: 1
responses:
'200':
@ -31809,7 +31920,7 @@ paths:
type: string
description: 'Set to 1 to allow overwriting of a pre-existing package.
'
'
example: 1
- in: query
name: rev
@ -32093,6 +32204,8 @@ paths:
to base the build environment collection.
- in: query
name: comment
schema:
type: string
description: Comment for the new revision.
responses:
'200':
@ -32134,7 +32247,7 @@ paths:
time: 1678785078
user: Admin
comment: Copying the build environment from origin
requestid:
requestid:
'400':
description: |
Bad Request.
@ -32380,8 +32493,8 @@ paths:
version: 2.10~pre
time: 1665060711
user: Admin
comment:
requestid:
comment:
requestid:
'400':
description: Bad Request.
content:
@ -32638,8 +32751,8 @@ paths:
version: 2.10~pre
time: 1665060711
user: Admin
comment:
requestid:
comment:
requestid:
'400':
description: Bad Request.
content:
@ -32878,6 +32991,8 @@ paths:
description: Set to '1' to avoid running the services after the copy.
- in: query
name: comment
schema:
type: string
description: Comment for the new revision.
responses:
'200':
@ -32989,6 +33104,23 @@ paths:
Create a RPM Spec File Template for a specified package. This endpoint
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)
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:
- Sources - Packages
"/source/{project_name}/{package_name}?cmd=deleteuploadrev":
@ -33257,7 +33389,7 @@ paths:
- 0
description: Set to `1` to only show changed files, and not details inside
files.
example:
example:
- in: query
name: olinkrev
schema:
@ -33601,7 +33733,7 @@ paths:
type: string
description: 'Set to 1 to allow overwriting of a pre-existing package.
'
'
example: 1
- name: add_repositories_rebuild
in: query
@ -33747,7 +33879,7 @@ paths:
- getprojectservices
responses:
'200':
description:
description:
content:
application/xml; charset=utf-8:
schema:
@ -34343,7 +34475,7 @@ paths:
description: 'Link revision in base package. Set to `base` to use the commit
revision.
'
'
example: base
- in: query
name: rev
@ -34620,8 +34752,8 @@ paths:
version: 2.10~pre
time: 1665060711
user: Admin
comment:
requestid:
comment:
requestid:
'400':
description: |
Bad Request.
@ -34775,6 +34907,23 @@ paths:
Triggers a rebuild of the package. This endpoint
is broken and will be removed.
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:
- Sources - Packages
"/source/{project_name}/{package_name}?cmd=release":
@ -34826,7 +34975,7 @@ paths:
description: 'Limit the release to a certain repository, set on the project
repository definitions.
'
'
example: openSUSE_Tumbleweed
- in: query
name: setrelease
@ -34835,7 +34984,7 @@ paths:
description: 'If this parameter is present, the release will be tagged with
this parameter''s value.
'
'
example: Build8.18
- in: query
name: arch
@ -37739,8 +37888,8 @@ paths:
version: 1
time: 1678787266
user: Admin
comment:
requestid:
comment:
requestid:
'401':
description: |
Unauthorized.
@ -39311,7 +39460,7 @@ paths:
obsolete requests as well as missing reviews, otherwise don''t pass this
query parameter."
'
'
- name: status
in: query
schema:
@ -39321,7 +39470,7 @@ paths:
status xml (broken packages, missing reviews, checks, etc.), otherwise don''t
pass this query parameter"
'
'
- name: history
in: query
schema:
@ -39710,7 +39859,7 @@ paths:
obsolete requests as well as missing reviews, otherwise don''t pass this
query parameter.
'
'
- name: status
in: query
schema:
@ -39721,7 +39870,7 @@ paths:
status xml (broken packages, missing reviews, checks, etc.), otherwise don''t
pass this query parameter.
'
'
- name: history
in: query
schema:
@ -40396,7 +40545,7 @@ paths:
summary: 'Request ID currently excluded from project project_name.
Use --remove-exclusion if you want to force this action.
'
'
Unknown Request:
value:
code: invalid_request
@ -41188,6 +41337,14 @@ paths:
deprecated: true
summary: This endpoint is deprecated
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:
- Statistics
"/statistics/activity/{project_name}/{package_name}":
@ -41195,6 +41352,21 @@ paths:
deprecated: true
summary: This endpoint is deprecated
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:
- Statistics
"/statistics/added_timestamp/{project_name}/{package_name}":
@ -41202,6 +41374,21 @@ paths:
deprecated: true
summary: This endpoint is deprecated
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:
- Statistics
"/statistics/global_counters":
@ -41482,6 +41669,14 @@ paths:
deprecated: true
summary: This endpoint is deprecated
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:
- Statistics
"/statistics/most_active_packages":
@ -41737,6 +41932,21 @@ paths:
deprecated: true
summary: This endpoint is deprecated
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:
- Statistics
"/status/messages":
@ -47215,7 +47425,7 @@ paths:
- name: x86_64:1a1f67b948b6:2
no_workers:
summary: No Workers Satisfy the Constraints
value:
value:
'400':
description: Bad Request.
content:

View File

@ -1,10 +1,8 @@
package main
package common
import (
"encoding/json"
"fmt"
"io"
"os"
"strings"
)
@ -56,36 +54,10 @@ func (h *RequestHandler) parsePullRequest(data io.ReadCloser) *PullRequestAction
return nil
}
h.PrjGit = action.Repository.Ssh_Url[:repoIdx+1] + DefaultGitPrj + ".git"
h.data = &action
h.Data = &action
// sanity checks on request
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
}
func (h *RequestHandler) ParsePushRequest(data io.Reader) *PushRequest {
func (h *RequestHandler) parsePushRequest(data io.Reader) *PushRequest {
if h.HasError() {
return nil
}

View File

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

View File

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

View File

@ -21,7 +21,7 @@ func TestRepositoryRequestParsing(t *testing.T) {
var h RequestHandler
h.Logger = CreateStdoutLogger(&strStr, &errStr)
json := h.ParseRepositoryRequest(strings.NewReader(repoCreateJSON))
json := h.parseRepositoryRequest(strings.NewReader(repoCreateJSON))
if h.HasError() {
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
import (
"errors"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"src.opensuse.org/autogits/common"
)
@ -16,80 +9,28 @@ const (
ListenAddr = "[::1]"
GitAuthor = "GiteaBot - AutoStaging"
PrReview = "pr-review"
)
func createListenServer() {
http.HandleFunc("/pr-review", func(res http.ResponseWriter, req *http.Request) {
h := createRequestHandler("pr-review")
// defer h.Close()
if len(req.Header.Get("Content-Type")) == 0 ||
req.Header["Content-Type"][0] != "application/json" ||
req.Method != "POST" {
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)
func processPullRequest(h *common.RequestHandler) error {
req := h.Data.(common.PullRequestAction)
// requests against project are not handled here
if req.Repository.Name == common.DefaultGitPrj {
return nil
}
return nil
}
func main() {
if err := parseGiteaSecretToken(); err != nil {
fmt.Print(err)
return
}
var defs common.ListenDefinitions
if err := parseObsSecretToken(); err != nil {
fmt.Print(err)
return
}
defs.Url = PrReview
defs.GitAuthor = GitAuthor
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