2475 Commits

Author SHA1 Message Date
Ian Johnson
6ac4b2198b daemon/api_quotas_test.go: fix errant merge commit oddities
These were added back via the merge to master and I missed it before pushing up
that commit.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-08 06:47:13 -05:00
Ian Johnson
a62abd6c97 Merge branch 'master' into feature/quota-groups-the-final-countdown-1
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-08 06:26:28 -05:00
Ian Johnson
b036199cd4 daemon/api_quotas.go: use client.QuotaValues for post struct too
Missed this in the previous commit. Thanks to Samuele for spotting this
irregularity.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-07 08:52:26 -05:00
Ian Johnson
d082924c0f client, cmd/snap, daemon: re-re-re-factor the API implementation
As per request, a thrice baked API implementation.
🍽️ Bon Appétit!

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-06 16:59:03 -05:00
Ian Johnson
f93a993c76 client, cmd/quota, daemon: change constraints + current maps to use ints
Instead of passing the values as strings, pass them as ints exactly with a map
of string -> interface{}. This induces a fair amount of overhead to parse
everywhere but still enables us to relatively easily add new keys/resource
types, assuming those types don't need special formatting like the memory does
with units.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-05 14:38:48 -05: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
Ian Johnson
5e530ba741 daemon/api_quotas.go: handle conflicts, returning conflict response
Also add unit tests for these scenarios.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-05 07:26:04 -05:00
Ian Johnson
37e7842338 client, cmd/snap, daemon: refactor REST API for quotas to match CLI org
The CLI has organization where the current and constraint keys are maps of the
unit of measure for the quota group to the value, so update the REST API to
match this.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-02 10:38:37 -05:00
Ian Johnson
a7a1061ca9 many: use changes + tasks for quota group operations
The exported methods from the servicestate package all return tasksets now,
which is expected to be put into changes that are executed by the overlord
loop. This involves changes in many parts that use quotas, such as the tests,
where a new mock function to create a quota group in state without running any
servicectl commands as well as changes to the client side.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-06-29 17:25:49 +02:00
Samuele Pedroni
9242fb8256 many: turn Contact into an accessor
as later it will be derived from links and also we will have
to deal with links from store response vs snap.yaml
2021-06-25 19:10:08 +02:00
Samuele Pedroni
aa7446be51 many: have configcore.Run/Early take a sysconfig.Device
adjust the affected code
2021-06-23 21:51:22 +02:00
Ian Johnson
4d2dc2462e daemon/api_quotas_test.go: fix test function mocking restoration
Also fix a test being in the wrong suite and needlessly creating a new daemon.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-06-21 07:56:11 -05:00
Ian Johnson
e7bf43ea16 o/servicestate/servicestatetest: add MockQuotaInState, use in external tests
This will be necessary to use when quota handlers no longer directly perform
the operation and instead return a task set.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-06-21 07:56:08 -05:00
Michael Vogt
ca648fee0f Merge remote-tracking branch 'upstream/master' into feature/quota-groups-remastered-deluxe-diamond-edition-2.5 2021-06-17 08:59:19 +02:00
Samuele Pedroni
82672cc4df many: fix imports order (according to gci)
Merge pull request #10411 from pedronis/gci-fix-last
2021-06-16 13:40:52 +02:00
Samuele Pedroni
c41d0dc93f daemon: add a Daemon argument to AccessChecker.CheckAccess
Merge pull request #10308 from jhenstridge/access-check-daemon-arg

We want to make the theme installation REST API available to selected snaps over the snapd-snap.socket socket. At present, the idea is to control which snaps have access to these calls through a marker interface. That means the access checker will need to be able to check whether a given snap has a connected plug of the marker interface. I've done this by passing the Daemon as an argument to theCheckAccess method.
2021-06-16 11:51:45 +02:00
Samuele Pedroni
54e84fb8db many: fix imports order (according to gci)
had to make the comment in wrappers/services_test.go a one-liner
otherwise half of it is lost

last set of files needing changing (as per current master)
2021-06-16 09:54:31 +02:00
Ian Johnson
894388b83c Merge branch 'master' into feature/quota-groups-remastered-deluxe-diamond-edition-2.5
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-06-14 11:08:45 -05:00
Samuele Pedroni
0085b4af03 daemon: switch /v2/accessories/themes to Store.SnapExists 2021-06-14 10:04:44 +02:00
James Henstridge
6158368b00 daemon: add a Daemon argument to AccessChecker.CheckAccess 2021-06-14 10:28:53 +08:00
Samuele Pedroni
f88d78dc52 daemon: make access_test.go a bit more precise
check for the status code for the relevant errors in errors_test.go
2021-06-11 17:11:14 +02:00
Samuele Pedroni
5b51edc4df Merge remote-tracking branch 'upstream/master' into daemon-access-check-response 2021-06-11 16:56:07 +02:00
Samuele Pedroni
e526bf7fda daemon: drop now unused test-only accessor
respJSON.ErrorResult is not used anymore as most tests get the
starting apiError directly instead
2021-06-10 13:15:35 +02:00
Samuele Pedroni
33245574ad daemon: drop apiBaseSuite.apiErrorReq as now errorReq is the same 2021-06-10 13:15:35 +02:00
Samuele Pedroni
c9d961a863 daemon: have apiBaseSuite.errorReq return *apiError directly
now that apiError is used everywhere to return errors

result naming and checks in tests are adjusted accordingly
2021-06-10 13:15:35 +02:00