* daemon: support sideloading of components
* o/snapstate: check info in snap and component is coherent
Make sure that when we install a component it has been defined by the
owner snap and that the type is coherent betwee snap and component
metadata.
* cmd/snap: allow installation of local components
* tests/main: add spread test for components
* daemon: add component name to API data
* fixup! o/snapstate: check info in snap and component is coherent
* fixup! cmd/snap: allow installation of local components
* fixup! daemon: support sideloading of components
* fixup! tests/main: add spread test for components
* daemon: add helper for ErrorKindSnapNotInstalled errors
* fixup! daemon: support sideloading of components
Internal Server Error response was returned when only one of many snaps is
not found. The problem was passing all snap names (including succesful ones)
to errToResponse instead of the unknown snap only.
In the following example only "spamandeggs" is not found, 404 status code is
expected, 500 is returned instead:
curl -sS --unix-socket /run/snapd.socket http://localhost/v2/snaps -X POST \
-d '{"action": "install", "snaps": ["spamandeggs", "hello"]}' -H "Content-Type: application/json" \
| jq
> {
> "type": "error",
> "status-code": 500,
> "status": "Internal Server Error",
> "result": {
> "message": "store.SnapNotFound with 2 snaps"
> }
> }
Fixes: https://bugs.launchpad.net/snapd/+bug/2024858
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
Use a more proper error kind for quota conflicts, supporting the error type
*servicestate.QuotaChangeConflictError inside errToResponse and indicating what
sort of change the conflict is being used for.
Also update the unit tests for the daemon error response to check for this.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
apiError is a StructuredResponse (and also an error), the plan is to
use it everywhere instead of building the complicated respJSON for
errors directly
it can also be used as a return type for functions that are meant
exactly to build errors