Skip to content

image/docker: use unified configfile for registries.d#753

Open
jankaluza wants to merge 12 commits intocontainers:mainfrom
jankaluza:registries.d-2
Open

image/docker: use unified configfile for registries.d#753
jankaluza wants to merge 12 commits intocontainers:mainfrom
jankaluza:registries.d-2

Conversation

@jankaluza
Copy link
Copy Markdown
Member

Switch registries.d loading to use configfile.Read(), enabling
unified drop-in search across /usr, /etc, and user config directories.
Files are merged with standard precedence, with higher-priority paths
masking lower ones.

Preserve explicit RegistriesDirPath override behavior.

Signed-off-by: Jan Kaluza jkaluza@redhat.com

jankaluza added 12 commits April 2, 2026 13:06
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
When no policy.json is found, `DefaultPolicy()`` previously returned a
generic error without indicating where the system looked for the file.

This commit introduces `configfile.ReadWithPaths()` to track all
attempted config file locations during iteration. It uses this
in DefaultPolicy() to include the searched paths in the error message
when no policy file is found.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit does the following:

- The `setup()` function now returns the SystemContext.
- The hardcoded check for "no policy file found" has moved to
  the test itself.
- Fixture is used for SignaturePolicyPath.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit introduces `File.ErrorIfNotFound`. If it is true, the Read
returns an error which contains all the paths it tried when searching
for a config file.

The ReadWithPaths is replaced by this new logic.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
Switch registries.d loading to use `configfile.Read()`, enabling
unified drop-in search across /usr, /etc, and user config directories.
Files are merged with standard precedence, with higher-priority paths
masking lower ones.

Preserve explicit RegistriesDirPath override behavior.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
@github-actions github-actions bot added storage Related to "storage" package common Related to "common" package image Related to "image" package labels Apr 9, 2026
@jankaluza
Copy link
Copy Markdown
Member Author

jankaluza commented Apr 9, 2026

This depends on #711. If someone wants to review this early, check only the last commit.

Copy link
Copy Markdown
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first look

mergedConfig.Docker[nsName] = nsConfig
nsMergedFrom[nsName] = configPath
// mergeRegistriesYAMLFragment parses configBytes as a single registries.d YAML fragment and merges it into merged.
func mergeRegistriesYAMLFragment(merged *registryConfiguration, configPath string, configBytes []byte, dockerDefaultMergedFrom *string, nsMergedFrom map[string]string) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Non-blocking: This works, but I think defining an object to hold the merging state, with new / mergeFragment / mergedConfig methods would be cleaner. But see elsewhere, do we need this split at all?)

if sys != nil && sys.RegistriesDirPath != "" {
return sys.RegistriesDirPath
logrus.Debugf(`Using registries.d directory %s`, sys.RegistriesDirPath)
return loadAndMergeConfig(sys.RegistriesDirPath)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance, this separate implementation is fairly unsatisfactory.

One approach might be to extend configfile yet again, to support “read exactly this directory and nothing else”. Another would be to have a directory enumerator that returns the same iterator as configfile.Read (whether that enumerator exists in this package or as a configfile.ReadInSingleDirectory). Then the iteration+merging loop would exist just once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering the iterator approach, but for me it was somehow over complicated, so I went with the current approach. Maybe new configfile function would make sense. I will try it.


By default, the registries configuration directory is `$HOME/.config/containers/registries.d` if it exists, otherwise `/etc/containers/registries.d` (unless overridden at compile-time);
applications may allow using a different directory instead.
By default, registries.d configuration is loaded from drop-in directories following the same search locations and precedence rules as other containers configuration files.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This almost begs to be a link to a common man page (I think there is a plan to have one)…

… and if we have that man page, do we need all of the details here? Or, if we won’t have that man page, does “the same as other files” help at all?


I’m worried that users won’t understand “containers configuration” to refer to only the go.podman.io/*-dependent software; users don’t care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package image Related to "image" package storage Related to "storage" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants