summaryrefslogtreecommitdiff
path: root/pkg/registries/registries.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-07-20 12:29:04 -0400
committerGitHub <noreply@github.com>2018-07-20 12:29:04 -0400
commitd433e5612409f9e2207b11b017b1101631a7971b (patch)
tree7e198c5a0b9f07a1dc8537b5f172aee54563832a /pkg/registries/registries.go
parentba1871dac033783ab0329c9b3c9113a34a90992f (diff)
parentd4f14be3a7aa7b5b884906d764db3214e51b3e67 (diff)
downloadpodman-d433e5612409f9e2207b11b017b1101631a7971b.tar.gz
podman-d433e5612409f9e2207b11b017b1101631a7971b.tar.bz2
podman-d433e5612409f9e2207b11b017b1101631a7971b.zip
Merge pull request #1099 from giuseppe/per-user-conf-files
rootless: allow to override configuration files
Diffstat (limited to 'pkg/registries/registries.go')
-rw-r--r--pkg/registries/registries.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go
index 844d2c415..c84bb21f6 100644
--- a/pkg/registries/registries.go
+++ b/pkg/registries/registries.go
@@ -2,15 +2,27 @@ package registries
import (
"os"
+ "path/filepath"
"github.com/containers/image/pkg/sysregistries"
"github.com/containers/image/types"
"github.com/pkg/errors"
+ "github.com/projectatomic/libpod/pkg/rootless"
)
+// userRegistriesFile is the path to the per user registry configuration file.
+var userRegistriesFile = filepath.Join(os.Getenv("HOME"), ".config/containers/registries.conf")
+
// GetRegistries obtains the list of registries defined in the global registries file.
func GetRegistries() ([]string, error) {
registryConfigPath := ""
+
+ if rootless.IsRootless() {
+ if _, err := os.Stat(userRegistriesFile); err == nil {
+ registryConfigPath = userRegistriesFile
+ }
+ }
+
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
if len(envOverride) > 0 {
registryConfigPath = envOverride
@@ -25,6 +37,11 @@ func GetRegistries() ([]string, error) {
// GetInsecureRegistries obtains the list of insecure registries from the global registration file.
func GetInsecureRegistries() ([]string, error) {
registryConfigPath := ""
+
+ if _, err := os.Stat(userRegistriesFile); err == nil {
+ registryConfigPath = userRegistriesFile
+ }
+
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
if len(envOverride) > 0 {
registryConfigPath = envOverride