Instead of using os.MkdirTemp in tests, use t.TempDir.
In a few places where the parent directory is already create by t.TempDir,
replace os.MkdirTemp with os.Mkdir.
While at it, make sure to not a leak opened file descriptor returned by
os.CreateTemp.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Add `New()` function to create a Config and deprecate `NewConfig` which is
a) not extensible and b) broken in the sense that no external caller was
actually using the argument.
Many call sites use `Default()` which now has improved documentation and
allows for interacting with `New(). Most call sites just need to access
a pro-loaded config (via `Default()`). This config can overridden by
`New()` if the caller sets the specific option - a requirement for an
upcoming feature for Podman allowing to load user-specified configs via
CLI flags.
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
It's wasteful and `sut` was not a name I would now understand. Change
the tests that need a default config. The diff also shows that the
tests would benefit a lot from a rewrite into a table-driven form but I
do not want to shave the entire Yak.
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:
pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
return (perm & 0722) == 0700
^
Generated by gofumpt -w .
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>