* 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
* 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>
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>
* 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>
* 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>
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.
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.
* 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>
* 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>
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>
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>
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>
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>