Using os.Setenv in tests is problematic, because the change is
process-wise and other tests running in parallel might be affected.
Also, a somewhat complicated cleanup is needed.
Both issues are solved by using t.Setenv.
This commit also uses t.TempDir, t.Cleanup, and t.Helper when it makes
sense.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add a lock to EditConnectionConfig to make it race free for parallel
modification. It is possible that several podman system connection
commands are called simultaneously so we should read/file in a
consistent way to ensure no modifications are "silently dropped".
A test is added that reliably fails without the lock.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Factor out the connection file from readConnectionConf so we can then
use the path before opening the file which will be need for locking see
the following commit.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
As per Dan's feedback .conf sounds like a config file that can edited but
this file is really only managed by podman so just use the .json suffix
to make it more clear hopefully.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
podman systemd conenction and farm currently both write containers.conf
to store their settings. Each write removes comments from the user
config file and thus makes it not great to use.
The new approach is to have a seperate file connections.conf (json
format) to store both conenctions and farms for podman. We continue to
read containers.conf for the connections and farms as well and podman
can read both. This means we have a read only store in containers.conf
(manually added by users), they cannot be removed by the podman cli.
This is a breaking chnage and will require many chnages in podman to
migrate to the new APIs added in this commit.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>