Commit graph

13 commits

Author SHA1 Message Date
Achilleas Koutsou
9e0af86775 ostree: rename errors and introduce ParameterComboError
Shorter and clearer error types.
- InvalidParameterError is now RefError.  It is returned when a ref (the
  new ref or the parent ref) is invalid.
- The ResolveRefError is not renamed.  It is returned when a ref can't
  be resolved (e.g., ref not found at URL).

New error type ParameterComboError.  It is returned when a parent ref is
specified but no URL, which is an invalid parameter combination.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
36d8cd1dd2 ostree: move test server to separate package
Make it reusable for other packages
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
135cd684fc ostree: new ostree parameter rules
All parameters can now be specified at the same time.
See https://github.com/osbuild/osbuild-composer/issues/2131 for a
description of how the parameters are meant to interact.

In brief, the only invalid parameter combination is specifying a Parent
without a URL.
All other error conditions are for malformed URLs, invalid characters in
a ref, or error responses from the server.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
c68850fa26 ostree: return cusotm errors from validation functions
Errors implement the error interface, so we can return them as generic
errors. Callers can test the type only if they want to determine the
failure type.

The error types that can be returned from each function are documented
in the docstring.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
30e127d1b6 ostree: custom errors for ostree parameter validation 2022-02-23 11:08:24 +01:00
Achilleas Koutsou
7f69d56fc9 ostree: simplify VerifyRef() function
Return value of condition immediately
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
102c322ec9 ostree: simplify ResolveParams arguments
No need to pass the entire image type. We just need the default ref.
This removes the distro package dependency from the ostree package,
which we will need so distro can use the ostree types and functions.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
b92754b135 ostree: rename request parameters type
It's in the ostree package, so it doesn't need to have OSTree in the
name.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
db345d75dd ostree: include ref in error message when invalid 2022-02-23 11:08:24 +01:00
Achilleas Koutsou
c60c54aa43 ostree: ostree parameter validation and resolve function
Validates the ostree parameters and resolves the parent ID.
2022-02-23 11:08:24 +01:00
Achilleas Koutsou
14a74cf173 ostree: add test for VerifyRef() 2021-06-18 14:02:09 +01:00
Achilleas Koutsou
49a8d98c28 Move ResolveRef test to new package 2021-06-18 14:02:09 +01:00
Achilleas Koutsou
b2f5e1cd72 cloudapi: support ostree options
Move OSTree option handling outside of the weldr API to make it usable
by other packages. New subpackage at internal/ostree.

Add support for ostree options ("Ref" and "URL") in the Cloud API.
Validate OSTree options and resolve the parent reference the same way as
in the Weldr API.

Unlike the Weldr API, the Cloud API doesn't support specifying the
Parent reference directly.

The exports list is included in the job information on the queue.
2021-06-18 14:02:09 +01:00