Commit graph

424 commits

Author SHA1 Message Date
Simon de Vlieger
242564cc5c test: update type names to new names
The image type names for Fedora were changed in images 0.138.0, aliases
were left behind so the old names still exist.

Split out the testcases between rhel and fedora so we test for the new
names being returned.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-25 09:26:59 +02:00
rverdile
983ac27484 cloudapi/v2: add insights proxy to subscription image options 2025-04-22 18:00:58 +02:00
Achilleas Koutsou
cf956ff5a6 Delete internal/blueprint/ and import from osbuild/blueprint
Import osbuild/blueprint v1.6.0
2025-04-17 11:17:58 +02:00
Achilleas Koutsou
ad0cb80bed cloudapi/v2: minsize can be a string or integer
Define a reusable minsize property in the cloud API schema.
The minsize type is either a uint64 or a string with data units.

Internally, this creates a union (json.RawMessage) type called Minsize
and optional uses of the property are of type *Minsize.  We define an
internal decodeMinsize() function to convert *Minsize to uint64.  This
is similar to the decodeSize() function in the blueprint, but made
specifically to handle *Minsize.
2025-03-27 11:33:56 +01:00
Achilleas Koutsou
82ac185e7c cloudapi: Disk customization conversion
Convert from cloudapi Disk customizations to the blueprint types.
2025-03-27 11:33:56 +01:00
Achilleas Koutsou
1a65e573eb cloudapi: add new Disk customizations
Following up from #4535 which added support for advanced partitioning
customizations to the blueprint.
These are now added to the cloud api spec.
2025-03-27 11:33:56 +01:00
Sanne Raymaekers
7652af83d7 cloudapi/v2: adapt to new oapi-codegen
Fixed distribution list type, function signatures (later versions parse
uuids in the generated code), defaults actually being set and added
x-go-type where needed.
2025-03-26 11:13:14 +01:00
Sanne Raymaekers
b2700903ae go.mod: bump github.com/getkin/kin-openapi to v0.131.0
As deepmap/oapi-codegen didn't work with this newer version, upgrade to
oapi-codegen/oapi-codegen v2.

Mitigating CVE-2025-30153
2025-03-26 11:13:14 +01:00
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