image/docker: use unified configfile search for cert directories#746
image/docker: use unified configfile search for cert directories#746jankaluza wants to merge 1 commit intocontainers:mainfrom
Conversation
Switch `dockerCertDir` to use the new `configfile.ContainersResourceDirs` for resolving certificate directories. Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
| for _, dir := range candidates { | ||
| info, err := os.Stat(dir) | ||
| if err != nil { | ||
| if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) { |
There was a problem hiding this comment.
why do we skip permission errors?
| // userConfigPathForResourceDirs is a test hook for ContainersResourceDirs. | ||
| userConfigPathForResourceDirs = UserConfigPath |
There was a problem hiding this comment.
it is not clear to me why do you need this? The other test does not need it? you can just sentenv the XDG_CONFIG_HOME dir?
| // | ||
| // The search covers, where configured (listed here from lowest to highest precedence. | ||
| // It can be extended with additional absolute directories via extraDirs (lowest precedence). | ||
| func ContainersResourceDirs(conf *Directory) ([]string, error) { |
There was a problem hiding this comment.
API wise I am not to sure we just want to return the list here?
certs.d just needs the first match starting with home, etc, /usr... so would it not be more logical to pass in the name we search as argument and the return a signle full path and exit early?
| func ContainersResourceDirs(conf *Directory) ([]string, error) { | ||
| candidates := make([]string, 0, 7+len(conf.ExtraDirs)) | ||
|
|
||
| userConfig, _ := userConfigPathForResourceDirs() |
There was a problem hiding this comment.
error should not be silently ignored
| path string | ||
| absolute bool | ||
| var perHostCertDirs = []string{ | ||
| etcDir + "/docker/certs.d", |
There was a problem hiding this comment.
@mtrmac Do we still want this path? API wise it seems rather ugly to define that search order with that additional path.
Switch
dockerCertDirto use the newconfigfile.ContainersResourceDirsfor resolving certificate directories.