Commit Graph

5 Commits

Author SHA1 Message Date
Kir Kolyshkin c2dee68766 Use t.Setenv in tests
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>
2025-04-14 11:16:55 -07:00
Paul Holzinger a94f7e6eb0 pkg/config: make EditConnectionConfig race free
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>
2024-03-04 16:30:29 +01:00
Paul Holzinger 969e9c04a0 pkg/config: readConnectionConf() take path as arg
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>
2024-03-04 15:57:24 +01:00
Paul Holzinger cd4fc1ddd2 pkg/config: rename podman-connections.conf to .json
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>
2024-02-06 17:20:00 +01:00
Paul Holzinger 330f41d7a2 pkg/config: add new connections.conf file
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>
2024-01-29 17:05:03 +01:00