976 Commits

Author SHA1 Message Date
Andrew Phelps
3445443728 client, cmd/snap, daemon: api level changes for introducing offline flag to remodel (#13507)
* daemon: add offline field to remodeling JSON payload

* client, cmd/snap: add offline boolean option for remodeling to client and cli interface

* daemon: make snap files optional in the "multipart/form-data" remodel api

* tests/nested/manual/remodel-offline: add variants to test different combinations of installed/local snaps/assertions

* client: update comment on RemodelWithLocalSnaps to mention not contacting the store

* c/snap: remove unneeded var declaration

* tests/nested/manual/remodel-offline: clarify section that acks/adds the validation set assertion

* tests/nested/manual/remodel-offline: fix shellcheck warning on test's -a flag

* client: verify that normal (online) remodel does not set offline field in JSON payload
2024-02-12 09:03:18 +01:00
Samuele Pedroni
7c75f487d6 client,tests: do not try to change the gid when reading/removing auth.json (#13321)
* tests: cover auth.json NFS related fixes in nfs-support test

* client,tests: do not try to change the gid when reading/removing auth.json

the group is not relevant for this even under NFS, otoh
trying to switch it fails under running with sg

this makes sg lxd -c "snap..." work again

* skip nfs-support in ubuntu trusty

group 'systemd-journal' does not exist

---------

Co-authored-by: Sergio Cazzolato <sergio.cazzolato@canonical.com>
2023-11-29 10:06:20 +02:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Zeyad Yasser
b028176e30 many: implement snap install --prefer (#12993)
* many: implement snap install --prefer

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* many: add more tests and validation to --prefer install flag

* client/snap_op: add tests for prefer flag
* daemon/api_snaps: add input validation for prefer flag
	* prefer flag cannot be used with unaliased flag
	* prefer is supported only for install action
	* prefer is not supported int multi-snap operations
	* add tests
* o/snapstate: prevent implicilty setting unaliased flag when prefer flag is passed
	* add tests
* spread: update parallel-install-auto-aliases to cover edge cases for --prefer
	* check --prefer interaction with --unaliased implicit passing
	* resolve conflicts after merging master

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* spread: fix comment typo in main/parallel-install-auto-aliases

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* daemon: update flags conflict error message to be consistent

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* many: adjust help texts and move Prefer closer to Unaliased in structs

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* daemon/api_snaps_test: update TestPostSnapPreferWrongAction to match updated error message

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

---------

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2023-07-31 16:28:59 +02:00
Michael Vogt
c0e8ad56f3 client: fix specificErr handling in SnapshotExport() (#13001)
* client: fix specificErr handling in SnapshotExport()

The code was checking generating a `specificErr` but then checked
`if err != nil {` (and not check for specificErr) and also lacked
a unit test.

When adding the code test it became clear that the other issue
there is that the response body was never read so r.err() would
always return nil.

This commit fixes both issues.

* client: fix TestClientExportSnapshotSpecificErr naming

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-07-26 11:19:13 +02:00
Michael Vogt
57c8e27e91 client: extract realUidGid() helper (thanks to Oliver for the suggestion) 2023-07-20 13:52:49 +02:00
Philip Meulengracht
bd6fddcc3e client,osutil: support for accessing auth.json without root
Revive PR 4983 from @chipaca as the launchpad issue is still relevant, and we moved on to newer go versions a long time ago.
2023-07-20 13:52:49 +02:00
Alfonso Sánchez-Beato
8a9f3c889e many: move helper gadgettest function to gadget
Move SetEnclosingVolumeInStructs from gadgettest to gadget package so
it can be used from production code.
2023-07-05 07:56:23 +01:00
Alfonso Sánchez-Beato
7841d66e9f client: set enclosing volume when retrieving system details
As it is needed to answer correctly questions for partial gadgets.
2023-07-05 07:56:23 +01:00
Alfonso Sánchez-Beato
45b57be9fa client,cmd: support for offline remodeling
This adds options --snap and --assertion to the "snap remodel"
command, which can be used to pass local files to snapd so offline
remodelling is possible.
2023-06-22 12:44:28 +02:00
Alfonso Sánchez-Beato
1eb457a9e2 many: introduce min-size in gadget structures description
Introduce min-size so structures can specify it in the gadget. It will
be used in remodelling/gadget installation situation so we have wider
compatibility with older gadgets defining different sizes for the
partitions.

With this change we now cannot assume that we know the partitions
offsets in all cases and ranges will need to be taken into account.
2023-05-09 09:37:07 +02:00
Robert Ancell
8bde56574a store: return categories in find results (#12513)
* store: Return categories in find results

This allows clients to show the categories as snapcraft.io does.

Fixes https://bugs.launchpad.net/snapd/+bug/1838786

* Remove unnecessary CategoryInfos type

* Only show categories when using --verbose

* Add tests for snap info printing categories

* Update cmd/snap/cmd_info.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update cmd/snap/cmd_info.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* v1 store API doesn't return categories

* Drop category information from snap info

Other snap commands don't support categories yet, this change should be part of that.

* Add /v2/categories and support /v2/find?category=foo

* Add note that section is deprecated

* Update client/packages.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update daemon/api_categories.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update daemon/api_categories.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update daemon/api_categories.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update store/store.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update store/details_v2.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Update client/packages.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* Improve test error message

* Drop copy/pasted comments that doesn't seem relevant

* Remove unused import

* Reorder CategoryInfo struct

* Fix accepted content type for store v2/snaps/categories request

* Set APILevel for v2/snaps/categories request

* Update accept string used to get data for store test

* Make /v2/categories return objects not just strings

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-04-06 10:02:09 +02:00
Michael Vogt
ec484217a2 many: remove all device-setup fde-setup code (#12618)
* many: remove all `device-setup` fde-setup code

When we initially worked on the inline-cryto-engine (ICE) code we
had a design based on the fde-setup hook that would return a
`device-setup` feature as a hint that ICE should be used. It
turned out this design was impractical and we moved to a much
better approach that got merged in
https://github.com/snapcore/snapd/pull/12589
and relies on support for ICE in the kernel and cryptsetup.

With that new approach all the code that was supporting the
`device-setup` approach can be removed now.

* daemon: consider again the fde-setup hook case

* client: consider the ICE encryption type

* osu/disks,kernel: remove device-unlock support as well

---------

Co-authored-by: Samuele Pedroni <pedronis@lucediurna.net>
2023-04-05 18:03:03 +02:00
Ernest Lotter
1d1591f64b many: dynamic snapshot data exclusions (#12584) 2023-03-31 15:01:20 +02: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
Miguel Pires
402677df8a daemon: simplify time handling in REST API
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-12 14:29:33 +00:00
Philip Meulengracht
29cdd350ce client: review feedback
simplify doc strings
2023-01-10 09:19:26 +01:00
Philip Meulengracht
3c80844747 client,cmd/snap: refactor options to EnsureQuota. 2023-01-10 09:19:26 +01:00
Philip Meulengracht
895596b334 client: add services to the REST messages 2023-01-06 12:12:43 +01:00
Miguel Pires
ee783cc46c client: test SNAPD_CLIENT_DEBUG_HTTP env var
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-04 18:40:08 +01:00
Michael Vogt
f288974120 many: support logging HTTP requests in the client
Add a SNAP_CLIENT_DEBUG_HTTP bitfield environment variable that allows
logging requests, responses and bodies that the client receives from
the REST API. Bodies are never logged in local installs because, since
they contain packaged snaps, their size would make the log unreadable.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-04 18:40:08 +01:00
Miguel Pires
96491866f2 daemon: don't serialize empty time values in JSON
The hold and gating-hold values were always marshaled to JSON because
they were held in the Result struct as time.Time values and not
pointers.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-12-14 11:57:29 +00:00
Miguel Pires
742f1fe219 many: correct struct fields and output key
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-12-12 12:37:20 +01:00
Miguel Pires
5b9f33bd89 daemon: expose user and gating holds at /v2/snaps/{name}
Exposes the longest hold placed by a gating snap and the user hold,
keyed by "gating-hold" and "user-hold", respectively.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-12-12 12:37:20 +01:00
Michael Vogt
bb1f23a4bd client: remove misleading comments in ValidateApplyOptions
We noticed some copy/paste comments in client/validate.go in
ValidationSetResult. This commit removes them as they are
misleading.
2022-11-01 08:50:00 +01:00