Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read registries.conf from XDG_CONFIG_HOME if set #2450

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions pkg/sysregistriesv2/system_registries_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ type Endpoint struct {
}

// userRegistriesFile is the path to the per user registry configuration file.
var userRegistriesFile = filepath.FromSlash(".config/containers/registries.conf")
var userRegistriesFile = filepath.FromSlash("containers/registries.conf")

// userRegistriesDir is the path to the per user registry configuration file.
var userRegistriesDir = filepath.FromSlash(".config/containers/registries.conf.d")
var userRegistriesDir = filepath.FromSlash("containers/registries.conf.d")

// rewriteReference will substitute the provided reference `prefix` to the
// endpoints `location` from the `ref` and creates a new named reference from it.
Expand Down Expand Up @@ -564,8 +564,14 @@ func newConfigWrapper(ctx *types.SystemContext) configWrapper {
// it exists only to allow testing it with an artificial home directory.
func newConfigWrapperWithHomeDir(ctx *types.SystemContext, homeDir string) configWrapper {
var wrapper configWrapper
userRegistriesFilePath := filepath.Join(homeDir, userRegistriesFile)
userRegistriesDirPath := filepath.Join(homeDir, userRegistriesDir)
var configHome string
var envVarFound bool

if configHome, envVarFound = os.LookupEnv("XDG_CONFIG_HOME"); !envVarFound {
configHome = filepath.Join(homeDir, ".config")
}
userRegistriesFilePath := filepath.Join(configHome, userRegistriesFile)
userRegistriesDirPath := filepath.Join(configHome, userRegistriesDir)

// decide configPath using per-user path or system file
if ctx != nil && ctx.SystemRegistriesConfPath != "" {
Expand Down