summaryrefslogtreecommitdiff
path: root/pkg/registries
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-07-16 12:14:05 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2018-07-20 11:00:52 +0200
commitc737d01937fc3644bdabbe50df71a455aa3b1f8b (patch)
tree96d987aaf4b6520cf8d209a5ae1db50c92eced46 /pkg/registries
parent06a5cc41bfe816312b02fd96ecb175a7196b2b1d (diff)
downloadpodman-c737d01937fc3644bdabbe50df71a455aa3b1f8b.tar.gz
podman-c737d01937fc3644bdabbe50df71a455aa3b1f8b.tar.bz2
podman-c737d01937fc3644bdabbe50df71a455aa3b1f8b.zip
rootless: allow a per-user registries.conf file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/registries')
-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