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>
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>
Newer version of go-dbus send `AUTH TEST` to the dbus test code
instead of the previous `AUTH TEST TEST`. This broke unit tests
in debian-sid and got distro patched in sid. The main snapd code
will need to get this change eventually too so integrate it now
and handle both the old and new godbus auth.
* Group 3rd party imports
* Remove unused vars
* Move var only used in tests into test
* Add 'nolint' to ignore warning on unused iotas (might've been
left to improve readability).
The condition/lock/shared buffer thingy was failing when running tests with
-count=100 due to proper lack of serialization. Refactor the code to use
channels, such that it is simpler to follow.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
The snap binary calls appropriate systemd instance to start a transient unit
that wraps the scope of the snap application. The code used to implement a busy
loop, checking whether the current process has been moved to new unit. However,
we should actually implement a complete job handlign sequence like systemd-run
does, that it wait for JobRemoved signal that matches our create transient unit
request.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This makes go doc not think that the GPL license is the documentation.
Thanks to Samuele for spotting.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
I wasn't aware of the various os.ModeFoo constant's and that they are
sufficient to probe for sockets. Thanks Maciek!
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
This commit is squashed history taken out of the refresh-app-awareness-v2
branch. It aggregated most of the new D-Bus helper logic in a pair of
packages. The dbusutil package contains non-silly logic to connect
to the session and system bus, as well as public mocking helpers.
The dbustest sub-package contains two helpers that provide dbus.Conn
for testing interaction and for testing bus access.
Note that I chose to leave behind one file in testutils, as it contains
existing test code used by user agent code. I can do that in another pass
to isolate it from this move.
This code is used in feature/refresh-app-awareness-v2, for both the
existing code in "snap run" and the new code in sandbox/cgroup package.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>