7 Commits

Author SHA1 Message Date
alfonsosanchezbeato
0a375dc253 many: support sideloading components (#13454)
* 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
2024-01-11 07:49:05 +00:00
Zeyad Gouda
5d2877e3aa daemon: fix /v2/snaps "Internal Server Error" error when installing unknown snaps
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>
2023-07-18 16:29:45 +02:00
Miguel Pires
baa80219fe daemon: support wrapping ChangeConflictError
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-30 16:00:14 +01:00
Ian Johnson
0aab832d6b daemon, client: add QuotaChangeContlict + ErrorKindQuotaChangeConflict
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>
2021-07-05 13:30:29 -05:00
Samuele Pedroni
d63c5e798b daemon: move errors-related code from response.go into errors.go 2021-06-09 16:58:42 +02:00
Samuele Pedroni
9648f2910b daemon: small tweaks and typo fix
thanks @stolowski
2021-06-01 14:16:21 +02:00
Samuele Pedroni
793ce20605 daemon: introduce apiError StructuredResponse
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
2021-05-28 19:48:19 +02:00