diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-07 14:02:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:02:22 -0500 |
commit | 51166d08983378f57d270fe8ac814372684cdd50 (patch) | |
tree | 5a4cc49a3174e8b11bbcede5a6b5b614815b8629 /pkg/trust/trust.go | |
parent | 3569e24df8c3f774def37d99b7e23158349e92cf (diff) | |
parent | cf8f2342a1cdbd821fec217af75c2438c00a9b4d (diff) | |
download | podman-51166d08983378f57d270fe8ac814372684cdd50.tar.gz podman-51166d08983378f57d270fe8ac814372684cdd50.tar.bz2 podman-51166d08983378f57d270fe8ac814372684cdd50.zip |
Merge pull request #7357 from QiWang19/rootless-sign
image sign using per user registries.d
Diffstat (limited to 'pkg/trust/trust.go')
-rw-r--r-- | pkg/trust/trust.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pkg/trust/trust.go b/pkg/trust/trust.go index a61e0ef10..a30611b74 100644 --- a/pkg/trust/trust.go +++ b/pkg/trust/trust.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/containers/image/v5/types" + "github.com/docker/docker/pkg/homedir" "github.com/ghodss/yaml" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -60,6 +61,12 @@ type ShowOutput struct { Sigstore string } +// systemRegistriesDirPath is the path to registries.d. +const systemRegistriesDirPath = "/etc/containers/registries.d" + +// userRegistriesDir is the path to the per user registries.d. +var userRegistriesDir = filepath.FromSlash(".config/containers/registries.d") + // DefaultPolicyPath returns a path to the default policy of the system. func DefaultPolicyPath(sys *types.SystemContext) string { systemDefaultPolicyPath := "/etc/containers/policy.json" @@ -76,15 +83,17 @@ func DefaultPolicyPath(sys *types.SystemContext) string { // RegistriesDirPath returns a path to registries.d func RegistriesDirPath(sys *types.SystemContext) string { - systemRegistriesDirPath := "/etc/containers/registries.d" - if sys != nil { - if sys.RegistriesDirPath != "" { - return sys.RegistriesDirPath - } - if sys.RootForImplicitAbsolutePaths != "" { - return filepath.Join(sys.RootForImplicitAbsolutePaths, systemRegistriesDirPath) - } + if sys != nil && sys.RegistriesDirPath != "" { + return sys.RegistriesDirPath + } + userRegistriesDirPath := filepath.Join(homedir.Get(), userRegistriesDir) + if _, err := os.Stat(userRegistriesDirPath); err == nil { + return userRegistriesDirPath } + if sys != nil && sys.RootForImplicitAbsolutePaths != "" { + return filepath.Join(sys.RootForImplicitAbsolutePaths, systemRegistriesDirPath) + } + return systemRegistriesDirPath } |