Commit graph

416 commits

Author SHA1 Message Date
Sanne Raymaekers
0b11dc6b59 cloudapi/v2: mark md5 signature as required in package metadata
Technically osbuild/osbuild-composer#4564 broke the api spec by marking
a required field as non-required. Fix this by using allOf.
2025-03-21 10:06:42 +01:00
Sanne Raymaekers
ec93197b7a cloudapi/v2: add some unit tests for testing modules 2025-03-20 14:07:52 +01:00
Sanne Raymaekers
241aae6fd4 cloudapi: support dnf modules
Exposes enabled modules in the api.
2025-03-20 14:07:52 +01:00
Michael Vogt
4584d05eff cloudapi: silence logrus in tests
This commit discards the logrus output when the tests are run. That
might be a controversial change but the amount of redundant output
that drowns the actual failures makes it very hard to work with
these tests.
2025-03-10 20:20:00 +01:00
Brian C. Lane
5e3d6aff54 cloudapi: Add a test for metadata returning the compose request
Related: RHEL-60120
2025-03-05 12:36:36 +01:00
Brian C. Lane
d8e9a86921 cloudapi: save and return compose request details
The original compose request contains useful details that are not
preserved when it is converted to a manifest. Things like the
distribution, arch, image type, blueprint or customizations are useful
when examining builds later.

This saves the original request json using the job id and a new
directory (ComposeRequest) under the artifacts directory. The original
request, if present, is then added to the compose/<id>/metadata response
alongside the package list.

Related: RHEL-60120
2025-03-05 12:36:36 +01:00
Brian C. Lane
a394d1a498 cloudapi: Fix href for metadata responses
Related: RHEL-60120
2025-03-05 12:36:36 +01:00
Brian C. Lane
c0bf89b51f openapi: Add ComposeRequest as part of the ComposeMetadata response
This will allow clients to display more information about a compose,
including the image type created, arch and distro, and blueprint to
customizations used to create it.

Related: RHEL-60120
2025-03-05 12:36:36 +01:00
Brian C. Lane
96715c3106 cloudapi: Use constants for distro in compose_test.go
This will make it easier to update next time the distribution version
needs to be bumped.
2025-02-24 13:26:40 +01:00
Brian C. Lane
0256e09031 lint: Clean up golangci-lint v1.60 complaints
This cleans up the linting results by adding checks for
integer underflow/overflow in several places, suppressing the error in
places where it has been checked, or fixing the types when possible.
2025-02-24 04:20:42 -08:00
Michael Vogt
f237af9bda cloudapi: move fedora-39 test forward to fedora-42
This commit fixes the failing TestGetImageRequests_BlueprintDistro
test. It fails because fedora-39 is no longer part of the supported
distros and can no longer be build. Move to fedora-42 so that we
have a bit time before we need to update it again.

It also updates TestGetImageRequests_NoRepositories to point to
fedora-42.
2025-02-19 19:19:42 +01:00
Michael Vogt
35167ce83f many: update for new reporegistry.New() api (c.f. pr#1179)
This commit updates osbuild-composer for the new API in images
for the `reporegistry.New()`. The main incompatible change is
that the `/repositories` part is not longer automatically added
inside the library so we need to add it on the call-site.

This needs https://github.com/osbuild/images/pull/1179
2025-02-19 19:19:42 +01:00
Michael Vogt
5906c554f6 cloudapi: update test to use repos from images
This commit updates the cloudapi test that uses the real repositories
to use the version of those from the "images" library. Composer
no longer carries the default repos.

Note that this can most likely be simplified once
https://github.com/osbuild/images/pull/1179
is merged.
2025-02-13 14:00:45 +01:00
Brian C. Lane
25e8bb1202 cloudapi: Fix artefact typo 2025-02-11 16:09:27 +01:00
Brian C. Lane
d47102716c v2_test: Add tests for Download
This enables the artifact directory during the tests, it mocks up a
download artifact, and tests that it can be downloaded. The file
contains JSON because the TestRoute helper expects that as the response.

Related: RHEL-60142
2025-02-11 16:09:27 +01:00
Brian C. Lane
a6f48bcd2f cloudapi: Add error information to ErrorUnknownUploadTarget
It can include useful extra details, whether or not the artifacts
directory is setup, whether the file is missing, etc.

Related: RHEL-60142
2025-02-11 16:09:27 +01:00
Brian C. Lane
d0be06278c cloudapi: Hook up the /composes/{id}/download handler
Resolves: RHEL-60142
2025-02-11 16:09:27 +01:00
Brian C. Lane
1d0d198e67 openapi: Add composes/{id}/download route
This will download the build artifact from a locally saved osbuild
compose. It will set the filename to the the UUID of the build with the
artifact filename appended. eg. 1dbcc86e-745b-4061-812f-e50f06fa7cbe-disk.qcow2

Related: RHEL-60142
2025-02-11 16:09:27 +01:00
Brian C. Lane
7622a69d60 v2_test: Add a test for GetDistributionsList
Related: RHEL-60133
2025-02-04 15:15:14 -08:00
Brian C. Lane
44ac65b70c cloudapi: Add /distributions to return distro:arch:image-type
This adds support for listing all of the supported distributions,
their arches, the image types, and their repository details.

This returns 3 nested json objects. The keys for the first layer are the
distribution names. The 2nd layer's keys are the architectures supported
by that distribution, and the 3rd layer's keys are the image types
supported by that distribution:architecture pair. The value of the 3rd
layer is the repository information.

Resolves: RHEL-60133
2025-02-04 15:15:14 -08:00
Brian C. Lane
325a018c75 cloudapi: Return the compose status of all root compose jobs
This returns the status using the same structure as it does for
requesting individual statuses for the jobs.

Related: RHEL-60120
2025-02-03 17:27:31 -08:00
Brian C. Lane
24b939d4c7 cloudapi: Move most of getComposeStatusImpl into a function
This will make it easier to use the status in responses.

Related: RHEL-60120
2025-02-03 17:27:31 -08:00
Brian C. Lane
b2d803306c cloudapi: Add /composes route to list root job UUIDs
This will be used to list the top level job UUIDs.

Related: RHEL-60120
2025-02-03 17:27:31 -08:00
Brian C. Lane
a613e8cb37 DepsolveJobResult: Remove unused Error and ErrorType
These fields are not set by the depsolve job, they are only set and used
in tests so remove them. Errors are reported in the result.JobError

Related: Related: RHEL-60125
2025-01-30 08:00:12 +01:00
Brian C. Lane
29f81a029a v2_test: Add a test for /search/packages
Add a new mockSearch job handler to return static results, add tests for
searching, for distro error, and for arch error.

Related: RHEL-60136
2025-01-30 08:00:12 +01:00
Brian C. Lane
17bebb547c v2 tests: Make it easier to add mock handlers to newV2Server
This refactors the server setup, splitting the depsolve and ostree
resolve goroutine creation into helper functions. It also removes the
use of channels, which was always set to "" (and in the case of the
multi-tenancy test an empty list, which acts the same).

Related: RHEL-60136
2025-01-30 08:00:12 +01:00
Brian C. Lane
532f1b0396 cloudapi: Hook up the /search/packages handler
This connects all the pieces needed to implement the search.

If you POST a request to /search/packages like this:

    {
      "packages": [
        "tmux"
      ],
      "distribution": "fedora-41",
      "architecture": "x86_64"
    }

It will return details about the tmux packages that looks like this:

{
  "packages": [
    {
      "arch": "x86_64",
      "buildtime": "2024-10-10T00:19:06Z",
      "description": "tmux is ...",
      "license": "ISC AND BSD-2-Clause AND BSD-3-Clause AND SSH-short AND LicenseRef-Fedora-Public-Domain",
      "name": "tmux",
      "release": "2.fc41",
      "summary": "A terminal multiplexer",
      "url": "https://tmux.github.io/",
      "version": "3.5a"
    }
  ]
}

Resolves: RHEL-60136
2025-01-30 08:00:12 +01:00
Brian C. Lane
234e8a09eb openapi: Add /search/packages route to the openapi schema
The request is similar to a depsolve request, it must include the
distribution and architecture. It can optionally include a list of
repositories to search, but if they are not included it searches the
default repos for the distro:arch

Related: RHEL-60136
2025-01-30 08:00:12 +01:00
Michael Vogt
a6ba0785b0 cloudapi: fix manifestSource.Serialize() 2025-01-29 18:03:11 +01:00
Sanne Raymaekers
4e803af8cd cloudapi: get rid of localSave check in local target
The local target shouldn't require any specific configuration and should
just be available always.
2025-01-24 15:26:15 +01:00
Sanne Raymaekers
7bfcac30dd cloudapi: support worker server target artifact retrieval
In order to get the artifact location from the cloudapi, add a helper
function in the worker server.
2025-01-24 15:26:15 +01:00
Brian C. Lane
df16f7fc63 v2_test: Add testing for cloudapi /depsolve/blueprint
Test the depsolve using a mocked response, test for mismatched
distributions, and for unsupported architectures.
2025-01-23 11:39:53 -08:00
Brian C. Lane
f377c5e3eb v2_test: Add a test-distro-1 repository
This also adds an actual repository json file for the test-disro.
Without this the repo.ListDistros() function doesn't return any actual
distros.

Related: RHEL-60125
2025-01-23 11:39:53 -08:00
Brian C. Lane
02d0b8ec01 cloudapi: Request depsolve from osbuild-worker
and return the response to the client. This uses the worker to depsolve
the requested packages. The result is returned to the client as a list
of packages using the same PackageMetadata schema as the ComposeStatus
response.  It will also time out after 5 minutes and return an error,
using the same timeout constant as depsolving during manifest
generation.

Related: RHEL-60125
2025-01-23 11:39:53 -08:00
Brian C. Lane
e06e62ca03 cloudapi: Add /depsolve/blueprint route
This will allow depsolving blueprints and returning package metadata for
the dependencies.

Related: RHEL-60125
2025-01-23 11:39:53 -08:00
Brian C. Lane
4f3c93ef1e cloudapi: Make sigmd5 in PackageMetadata optional
In order to reuse PackageMetadata with DepsolveResponse and not include
unused fields this changes the sigmd5 entry to an optional field. This
doesn't effect the use of PackageMetadata in the Compose response since
it is always set, and it allows it to be omitted in the response for
depsolving.

Also adds a basic test for stagesToPackageMetadata

Related: RHEL-60125
2025-01-23 11:39:53 -08:00
Brian C. Lane
08dc5f3041 cloudapi: Move GetCustomizationsFromBlueprintRequest
This function only depends on the Blueprint (cloudapi request type, not
the internal/blueprint) so move it to a function on that so that it can
be reused by other users of the cloudapi Blueprint.

Related: RHEL-60125
2025-01-23 11:39:53 -08:00
Sanne Raymaekers
425581fcc1 cloudapi/v2: support local upload target
The target validation rework broke the local upload target, which is
needed for cockpit-image-builder.
2025-01-22 13:54:40 +01:00
Michael Vogt
af0543d27c many: update images Manifest() API for PR#1107
This updates composer to use the updated API in images around the
seed handling for manifests, see images PR#1107 for details.

Note that this has no semantic changes yet. We could now simplfy
some things because images will auto-seed but that is for a followup.
2025-01-20 09:50:49 +01:00
Lukas Zapletal
d531f62488 blueprint: add cacert customization 2025-01-10 10:26:54 +01:00
Lukas Zapletal
4b55bc2825 cloudapi: carry ostree MTLS secret over 2024-12-03 13:59:45 +01:00
Sanne Raymaekers
8fd36225be cloudapi/v2: support HyperV generation in Azure upload options 2024-11-21 11:22:20 +01:00
Florian Schüller
992f876da0 cloudapi/v2/server: rephrase error message 2024-11-19 13:55:38 +01:00
Florian Schüller
02778b5361 cloudapi/v2/server: assure order of fail-calls
by avoiding map but rather using a slice the
order of SetFailed is maintained
2024-11-19 13:55:38 +01:00
Florian Schüller
2f4d7d3140 internal/cloudapi/v2/server: remove osbuild job explicitly set "failed"
osbuild job is a dependency of the resolve and manifest jobs so
leaving the state and it will fail as a depency is also fine
2024-11-19 13:55:38 +01:00
Florian Schüller
d3e3474fb7 internal/worker/server: return an error on depsolve timeout HMS-2989
Fixes the special case that if no worker is available and we
generate an internal timeout and cancel the depsolve including all
followup jobs, no error was propagated.
2024-11-19 13:55:38 +01:00
Lukas Zapletal
64f479092d osbuild-worker: use the new ostree resolver API 2024-11-07 16:17:56 +01:00
Tomáš Hozza
efc251fa02 CloudAPI: test /sboms endpoint for Koji composes
Extend the API unit test for Koji composes, to verify that the newly
added /sboms endpoint works correctly.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-09-20 17:02:09 +02:00
Tomáš Hozza
cf79bf677b CloudAPI: test /sboms endpoint for regular composes
Extend the unit test for regular (non-Koji) composes, to verify that
 the newly added /sboms endpoint works correctly.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-09-20 17:02:09 +02:00
Tomáš Hozza
6e8f0418a6 CloudAPI: add new /composes/{id}/sboms endpoint
Add a new /sboms API endpoint, for getting SBOM documents for a given
compose ID. The endpoint returns an array of SBOM documents for each
image built as part of the compose. For each image, there is an SBOM
document for each osbuild pipeline, which installs RPM packages. This is
usually one 'buildroot' and one 'image' pipeline.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-09-20 17:02:09 +02:00