18 Commits

Author SHA1 Message Date
Philip Meulengracht
81309e59a9 daemon,cmd/snap: support for user services in snap services (#13381)
* daemon,cmd/snap: support for user services in snap services

* NEWS: update news to reflect this functionality

* cmd/snap: add missing unit tests

* many: use interface instead for StatusDecorator to allow for unit testing

* daemon: fix a static check for a range loop where a variable could be omitted

* daemon,cmd/snap: support user-service status of the root user with a --user switch

* t/main/services-user: add a case for root user

* t/main/services-user: fix wrong filename

* cmd/snap: fix TestAppStatus unit test failing

* cmd/snap: extend help for "snap services" to describe the new --global and --user switches

remove errors on redundant switches, remove unneeded argument, move validation of arguments closer to entry of Execute

* cmd/snap: refer directly to fields in the help docs
2024-04-11 12:45:48 +02:00
Zeyad Gouda
41512c4860 many: add "refresh-inhibited" select query to /v2/snaps
This select query allows only showing snaps that whose refresh
is inhibited.

* daemon: only show monitored snaps in "refresh-inhibited" select
* many: update refresh-inhibit-proceed-time field to refresh-inhibit in snaps api
* many: address review comments
* o/snapstate: export IsSnapMonitored
* o/snapstate: add doc comment for IsSnapMonitored
* daemon: check snap proceed time
* daemon: adjust proceed-time check
* client: update SnapRefreshInhibit.ProceedTime doc comment

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2024-02-28 12:37:31 +01:00
Philip Meulengracht
f7fea7fef0 daemon: allow polkit "io.snapcraft.snapd.manage" for /v2/apps endpoint 2024-02-23 10:36:14 +01:00
Philip Meulengracht
13209f518b daemon,o/servicestate: support for scopes and users in API for services 2024-02-21 14:22:15 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Philip Meulengracht
5a8f6d77e8 daemon,overlord/servicestate: review feedback from 11960
Rename SnapAppsLogReader to LogReader, fail if one of the AppInfos is not a service.
2022-07-18 08:56:51 +02:00
Philip Meulengracht
8f37138f4e overlord,systemd: review feedback
New helper function in servicestate to get logs for snap apps, replace that with the functionality in api_apps.go, new unit tests, remove a wild log debug
2022-07-15 10:12:09 +02:00
Philip Meulengracht
ffb6ecc62d daemon: update version check and include extra unit tests 2022-07-13 11:00:29 +02:00
Philip Meulengracht
5a8516942a daemon,systemd: introduce support for namespaces in 'snap logs' 2022-07-13 09:50:19 +02:00
Samuele Pedroni
716b13b5f9 daemon: simplify SyncResponse
it doesn't take Meta anymore
2021-06-03 13:49:26 +02:00
Samuele Pedroni
466f6206e0 daemon: use rspe (response error) instead of very contracted ae (api error) 2021-06-01 14:22:26 +02:00
Samuele Pedroni
082ec321aa daemon: start using apiError instead of building resp(JSON) directly
adjust tests as necessary, in most cases the test are simpler as
e.g. they need less casting
2021-05-28 19:48:20 +02:00
Samuele Pedroni
25e9e2e1f9 daemon: start coalescing resp into respJSON and evaporating Meta
the cleanliness gained by having two structures with almost
the same fields is probably not enough to justify both of them,
especially because daemon is where we are supposed to build
responses, we might as well deal with the details

Meta was a quick hack, also it hasn't really grown since so we can
try to remove it now

AsyncResponse never takes anything over the result but the change id
2021-05-28 19:48:19 +02:00
Samuele Pedroni
bb7eaf9dfb Merge remote-tracking branch 'upstream/master' into daemon-access-check 2021-05-19 17:57:13 +02:00
Alberto Mardegan
cccdcf8639 daemon: fix linter errors 2021-05-05 14:28:53 +03:00
James Henstridge
885de6ed72 Merge remote-tracking branch 'upstream/master' into daemon-access-check 2021-01-04 15:28:41 +08:00
Samuele Pedroni
616739dd67 daemon: move some helpers to their use api_*.go files
now that we have smaller api_*.go files some single use helpers
can live directly in them

move helpers from snap.go used by api_apps.go and api_find.go
2020-12-07 23:05:06 +01:00
Samuele Pedroni
001facd215 daemon: split apps and logs endpoints to api_apps.go and tests 2020-11-30 21:45:48 +01:00