20 Commits

Author SHA1 Message Date
Samuele Pedroni
eabc9c3a29 daemon,tests: support forgetting device serial via API (#11135)
this is done by posting {"action":"forget"} to /v2/model/serial

a flag no-registration-until-reboot is also supported
2021-12-02 16:35:25 +01:00
Samuele Pedroni
716b13b5f9 daemon: simplify SyncResponse
it doesn't take Meta anymore
2021-06-03 13:49:26 +02:00
Samuele Pedroni
edf0b3f422 daemon: use apiError in api_model.go 2021-06-01 18:48:44 +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
a710d6c266 daemon: tighten access to POST /v2/model to be root only 2021-05-26 16:21:41 +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
219ebb3a95 daemon: move some more api tests from daemon to daemon_test
this covers tests for api_model.go, api_systems.go, and recent
api_system_recovery_keys.go
2020-11-30 21:53:36 +01:00
James Henstridge
6dca0bae80 daemon: reorder access checkers after method functions, to match struct layout 2020-08-27 13:48:57 +08:00
James Henstridge
8dd53dfad6 Merge remote-tracking branch 'upstream/master' into daemon-access-check 2020-08-07 08:52:36 +08:00
James Henstridge
ea3c3c4b6a daemon: don't export access checkers, and rename RootOnlyAccess to rootAccess 2020-08-07 08:42:36 +08:00
James Henstridge
14b9e7ec62 daemon: have each command list a ReadAccess and/or WriteAccess policy directly.
This is simpler than determining how the current set of flags
interoperate, and more closely matches how API access is documented to
work.
2020-08-07 08:32:56 +08:00
Samuele Pedroni
3c944b608b daemon: switch to use client.ErrorKind and drop the local errorKind... 2020-08-02 16:22:51 +02:00
Ian Johnson
f75f7bd2c2 many: rename error kind for assertions not found to be consistent
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2019-08-22 17:27:56 -05:00
Ian Johnson
2ba10914a3 daemon/api_model.go: use status codes directly
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2019-08-13 19:14:09 -05:00
Ian Johnson
0077012eb6 client,daemon/model: refactor ErrNoState handling
* In the daemon, setup a proper ErrorKind for the assertion not being
  found and return an errorResult with Kind set appropriately and Value
  set to the assertion that wasn't found.
* In the client, add a new method for introspecting an error to see if
  it is an ErrorKindAssertionNotFound, which corresponds to ErrNoState.
* In the model command, use the new client method for checking for the
  special case of ErrNoState.
* Remove old exported error kind from client in favor of the
  introspection method.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2019-08-13 18:46:41 -05:00
Ian Johnson
9b87486de3 daemon: add /v2/model GET and /v2/model/serial GET endpoints
* Add a new /v2/model GET endpoint which returns the singular, current model
  assertion, even if a device has been remodeled and has multiple model
  assertions
* Add a new /v2/model/serial GET endpoint which returns the singular, current
  serial assertion, even if a device has been remodeled and has multiple serial
  assertions

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2019-08-09 16:25:19 -05:00
Michael Vogt
b33fa85372 devicestate: make Remodel() return a state.Change
The devicestate.Remodel() call returns a []*state.TaskSet right
now. This is the usual pattern we use but for Remodel() its
not the right one because Remodel() cannot be composed with
other changes (doing that would be dangerous because of the
e.g. the task serialization inside remodel). Having a change
also means we can add the new model directly to the change
which will be useful when remodeling to different kernels
or (boot) bases as the validation code will need access to
the new model.

So this PR implements the switch from []*state.TaskSet to
*change. Followups will use it to add the model to the change
and to remodel to a different kernel/base.
2019-04-25 09:30:56 +02:00
John R. Lenton
33a1e289bf cmd/snap, daemon: address review feedback
* split api changes into api_model
* move debug POST get-model to GET model
2019-03-14 09:43:12 +00:00