Commit Graph

20 Commits

Author SHA1 Message Date
Kir Kolyshkin dc1d9738aa types: use strings.ReplaceAll
This fixes the following linter warning:

> types/utils.go:17:9: QF1004: could use strings.ReplaceAll instead (staticcheck)
> 	path = strings.Replace(path, "$UID", strconv.Itoa(rootlessUID), -1)
> 	       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 14:29:57 -07:00
Kir Kolyshkin 62ab0d3c3b types: use time.Equal
This fixes the following linter warnings:

> types/options.go:397:45: QF1009: probably want to use time.Time.Equal instead (staticcheck)
> 	if prevReloadConfig.storeOptions != nil && prevReloadConfig.mod == mtime && prevReloadConfig.configFile == configFile {
> 	                                           ^
> types/utils.go:64:45: QF1009: probably want to use time.Time.Equal instead (staticcheck)
> 	if prevReloadConfig.storeOptions != nil && prevReloadConfig.mod == mtime && prevReloadConfig.configFile == configFile {
> 	                                           ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 14:29:57 -07:00
Jan Rodák b48c88b66f
Fix errcheck: error return value of `ReloadConfigurationFile` is not checked
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-07-09 17:26:30 +02:00
Giuseppe Scrivano de0900aab7
types: use fileutils.{Le,E}xist()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-08 16:07:27 +02:00
Giuseppe Scrivano b0885dfba9
store: drop rootless from arguments
drop the rootless argument from DefaultStoreOptions and
UpdateStoreOptions since this can be retrieved internally through the
unshare package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-16 21:13:28 +01:00
Giuseppe Scrivano c72a594c83
types: use functionalities from pkg/homedir
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-16 08:36:21 +01:00
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07:00
Giuseppe Scrivano f64e1bd14a
store: prefer /etc/containers/storage.conf
when running in rootful mode, if it is present, prefer the override path
/etc/containers/storage.conf instead of using the default storage.conf
provided by the package under the /usr/share/containers/ directory.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-01-17 11:02:23 +01:00
Miloslav Trmač f42467020f Misc. warning cleanups
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:53:06 +02:00
Miloslav Trmač 4b28197720 Use os.ReadFile instead of ioutil.ReadFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:30:43 +02:00
Sascha Grunert 3455d12729
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the
deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 13:22:46 +02:00
Paul Holzinger 07530efd08
storage.conf: respect CONTAINERS_STORAGE_CONF env
CONTAINERS_STORAGE_CONF env var should overwrite the default path even
for the first config load at init time.

Fixes containers/podman#14267

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-06-01 16:23:55 +02:00
Daniel J Walsh 534b0b3281
Standardize on capatalized logrus messages, and remove stutters
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-23 14:43:35 -04:00
Giuseppe Scrivano 2c2968534e
types: on error fallback to filepath.Clean()
Now expandEnvPath always fallbacks to filepath.Clean() when
filepath.EvalSymlinks() fails.

commit b4477c7a8b introduced the
regression.

This is useful in a user namespace when the permissions for the
storage path are not yet tweaked to allow access for all users.

Reported by: https://github.com/containers/buildah/pull/3450

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-16 13:28:16 +02:00
Daniel J Walsh b4477c7a8b
Follow symlinks if they exists
Fixes: https://github.com/containers/podman/issues/10187

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-04 07:13:58 -04:00
Daniel J Walsh 728a92897f
Revert #952, we don't want to use /run/user on non systemd systems
This feature was originally added for  #568, and I mistakenly removed
it.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-12 14:00:58 -04:00
Daniel J Walsh 06e2dce12b
Use /run/user/UID in rootless mode if writable
Other parts of the code are using this directory, so we end up
with us creating an empty directory.

I don't see a reason why we would just use this directory only if
the init program is systemd?

Fixes: https://github.com/containers/podman/issues/10782

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-25 08:53:40 -04:00
mla 74a61676d2 Added support for CONTAINERS_STORAGE_CONF override
Signed-off-by: Morten Larsen <mortenlarsens@gmail.com>
2021-06-09 10:17:09 +02:00
Daniel J Walsh 98384ff1ca
Expand Variables on rootlessStoragePath
The current code was hanging for me, this makes sure the path is
expanded properly when it is read.

Fixes: https://github.com/containers/podman/issues/10181

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-05 13:49:51 -04:00
Daniel J Walsh 120cc997d2
Move storageOpts structures into types subdir to shrink bindings.
Currently when we build podman bindings we are pulling in the entire
storage libraries, even though we only need a few structures and
functions.

Testing with the following program

```
package main

import (
	"fmt"
	"github.com/containers/storage/types"
)

func main() {
	fmt.Println(types.GetRootlessRuntimeDir(0))
}
```

Removing types above gives me compile size of the the program

du -s t.old t.new
9640	t.before
3232	t.after

Currently these functions are being vendored into
containers/common/pkg/config, which leads to large size in podman-remote
and podman bindings.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-26 05:34:09 -05:00