Commit graph

16 commits

Author SHA1 Message Date
Ondřej Budai
befeef34a5 koji: use nvra as the filename for images
We have the same thing for AWS. The AWS target also specifies under what name
should be the image available in EC2.

As requested by Brew maintainers Tomáš Kopeček and Lubomír Sedlář.
2020-10-27 19:01:30 +00:00
Lars Karlitski
b25a350502 osbuild-composer: merge cloud API into main binary
This removes the osbuild-composer-cloud package, binary, systemd units,
the (unused) test binary, and the (only-run-on-RHEL) test in aws.sh.

Instead, move the cloud API into the main package, using the same
socket as the koji API, osbuild-composer-api.socket. Expose it next to
the koji API on route `/api/composer/v1`.

This is a backwards incompatible change, but only of the -cloud parts,
which have been marked as subject to change.
2020-10-16 09:37:04 +02:00
Lars Karlitski
d7bff4bd3b kojiapi: add simple test for the /status API
Add a simple unit test for the koji API.

This adds a Handler() method to the koji.Server struct, which made
writing the test easier. This is a direction we want to go in anyway in
the future.
2020-10-13 18:52:44 +02:00
Ondřej Budai
9fc924fbf4 kojiapi: make repo gpgkey optional
The kojiapi actually shouldn't require it as we need to build images from
unsigned packages.

Fixes #985
2020-10-13 08:10:22 +02:00
Lars Karlitski
40d8440660 kojiapi: prefix all routes with /api/composer-koji/v1
The cloud API will be moved to `/api/composer/v1` in the future.

Mention this in the `servers` section of the openapi.yml (relative URLs
are allowed) too, even though our generator does not consider it.
2020-09-24 21:08:56 +01:00
Lars Karlitski
9008a1defc worker: require workers to pass their architecture
Jobs are scheduled with type "osbuild:{arch}", to ensure that workers
only get jobs with the right architecture assigned.
2020-09-23 14:28:52 +01:00
Ondřej Budai
c6b5dd8977 kojiapi: add /status route
It works the same way as in the worker API. It's very handy when we just want
to test whether the API is up and running.
2020-09-23 11:08:21 +01:00
Ondřej Budai
03768e5f18 api/worker, koji: fix race condition when using multiple listeners
When remote worker socket was enabled, this was happening:

e := echo.New()

go func() {
    e.Listener = listener1
    e.Start("")
}()

e.Listener = listener2
e.Start("")

Yeah, this is a race condition. None of the echo's Start methods cannot safely
handle multiple listeners.

This commit fixes this issue by using Echo only as a router for standard
http.Server which handles multiple listeners in a non-racy way.
2020-09-23 09:38:29 +02:00
Tom Gundersen
6bab73f378 kojiapi: move from chi to echo
Follow the worker API so we standardise on one library. This simplifies
the code quite a bit.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-21 11:18:45 +01:00
Tom Gundersen
504a5890d9 kojiapi: move api definition
Move the API definition into a sub-directory to follow the style
of the worker API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-21 11:18:45 +01:00
Tom Gundersen
c6cf9de85d koji: add config files to configure kerberos settings
Kerberos keytabs and principals are configured per koji server both in
composer and in the worker.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
e52830f530 upload/koji: don't pass task_id to cg_init_build
Contrary to our assumption, we cannot initialize the build with the
link to the task. We can only update the link once the build has
completed.

This seems like a bug in koji, but we keep it like this for now.
2020-09-16 00:15:02 +01:00
Tom Gundersen
f446613d4a upload/koji: use CGInitBuild and clarify metadata structs
Move to requiring CGInitBuild to be called before CGImport. In the
future we could make the former optional again, but for now we want to
allow the caller to have done CGInitBuild and for composer only to do
the CGImport using the passed in build_id and token.

Also rename and document some struct fields in the metadata struct to
make them more specific to our use-case and hopefully easier to read.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Ondřej Budai
e4b839b31f kojiapi: add koji target to composes
So far, composes created by kojiapi didn't have any targets. This commit
adds the koji target to them.

This is the last piece of the puzzle. From now on, osbuild-composer has
a koji API, which is actually able to upload images to Koji! Yay!
2020-09-16 00:15:02 +01:00
Tom Gundersen
67e4182ba4 kojiapi: add a server/client implementation of the OpenAPI spec
This just translates between the OpenAPI spec and our internal
API.

This still lacks tests, but a follow-up commit adds integration tests.

`internal/kojiapi/openapi.gen.go` was automatically generated from
`internal/kojiapi/openapi.yml`. To regenerate use `go generate ./...`.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
7109f49692 kojiapi: add OpenAPI spec
This adds the OpenAPI spec for the new composer-koji API. This API is meant
to expose expose just the functionality needed to generate images and push
them to koji.

Each compose may consist of several images, each image may have a
different architecture and image type, and the set of repositories with
their contents may be distinct. However, a compose is restricted to one
distro and one koji transaction.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00