mirror of https://github.com/containers/podman.git
Merge pull request #3064 from rhatdan/sysregistriesv2
change from sysregistries to sysregistriesv2
This commit is contained in:
commit
fde0dc2a55
|
@ -204,7 +204,7 @@ BuildRequires: golang(github.com/containers/image/docker/tarfile)
|
||||||
BuildRequires: golang(github.com/containers/image/image)
|
BuildRequires: golang(github.com/containers/image/image)
|
||||||
BuildRequires: golang(github.com/containers/image/oci/archive)
|
BuildRequires: golang(github.com/containers/image/oci/archive)
|
||||||
BuildRequires: golang(github.com/containers/image/pkg/strslice)
|
BuildRequires: golang(github.com/containers/image/pkg/strslice)
|
||||||
BuildRequires: golang(github.com/containers/image/pkg/sysregistries)
|
BuildRequires: golang(github.com/containers/image/pkg/sysregistriesv2)
|
||||||
BuildRequires: golang(github.com/containers/image/signature)
|
BuildRequires: golang(github.com/containers/image/signature)
|
||||||
BuildRequires: golang(github.com/containers/image/storage)
|
BuildRequires: golang(github.com/containers/image/storage)
|
||||||
BuildRequires: golang(github.com/containers/image/tarball)
|
BuildRequires: golang(github.com/containers/image/tarball)
|
||||||
|
@ -256,7 +256,7 @@ Requires: golang(github.com/containers/image/docker/tarfile)
|
||||||
Requires: golang(github.com/containers/image/image)
|
Requires: golang(github.com/containers/image/image)
|
||||||
Requires: golang(github.com/containers/image/oci/archive)
|
Requires: golang(github.com/containers/image/oci/archive)
|
||||||
Requires: golang(github.com/containers/image/pkg/strslice)
|
Requires: golang(github.com/containers/image/pkg/strslice)
|
||||||
Requires: golang(github.com/containers/image/pkg/sysregistries)
|
Requires: golang(github.com/containers/image/pkg/sysregistriesv2)
|
||||||
Requires: golang(github.com/containers/image/signature)
|
Requires: golang(github.com/containers/image/signature)
|
||||||
Requires: golang(github.com/containers/image/storage)
|
Requires: golang(github.com/containers/image/storage)
|
||||||
Requires: golang(github.com/containers/image/tarball)
|
Requires: golang(github.com/containers/image/tarball)
|
||||||
|
|
|
@ -52,14 +52,14 @@ host:
|
||||||
kernel: 4.18.7-200.fc28.x86_64
|
kernel: 4.18.7-200.fc28.x86_64
|
||||||
os: linux
|
os: linux
|
||||||
uptime: 218h 49m 33.66s (Approximately 9.08 days)
|
uptime: 218h 49m 33.66s (Approximately 9.08 days)
|
||||||
insecure registries:
|
|
||||||
registries: []
|
|
||||||
registries:
|
registries:
|
||||||
registries:
|
blocked: null
|
||||||
|
insecure: null
|
||||||
|
search:
|
||||||
- quay.io
|
- quay.io
|
||||||
- registry.fedoraproject.org
|
- registry.fedoraproject.org
|
||||||
- docker.io
|
- docker.io
|
||||||
- registry.access.redhat.com
|
- registry.redhat.io
|
||||||
store:
|
store:
|
||||||
ConfigFile: /etc/containers/storage.conf
|
ConfigFile: /etc/containers/storage.conf
|
||||||
ContainerStore:
|
ContainerStore:
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
dockerarchive "github.com/containers/image/docker/archive"
|
dockerarchive "github.com/containers/image/docker/archive"
|
||||||
"github.com/containers/image/docker/tarfile"
|
"github.com/containers/image/docker/tarfile"
|
||||||
ociarchive "github.com/containers/image/oci/archive"
|
ociarchive "github.com/containers/image/oci/archive"
|
||||||
"github.com/containers/image/pkg/sysregistries"
|
|
||||||
is "github.com/containers/image/storage"
|
is "github.com/containers/image/storage"
|
||||||
"github.com/containers/image/transports"
|
"github.com/containers/image/transports"
|
||||||
"github.com/containers/image/transports/alltransports"
|
"github.com/containers/image/transports/alltransports"
|
||||||
|
@ -284,9 +283,8 @@ func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goa
|
||||||
}
|
}
|
||||||
// If no image was found, we should handle. Lets be nicer to the user and see if we can figure out why.
|
// If no image was found, we should handle. Lets be nicer to the user and see if we can figure out why.
|
||||||
if len(images) == 0 {
|
if len(images) == 0 {
|
||||||
registryPath := sysregistries.RegistriesConfPath(&types.SystemContext{SystemRegistriesConfPath: systemRegistriesConfPath})
|
|
||||||
if goal.usedSearchRegistries && len(goal.searchedRegistries) == 0 {
|
if goal.usedSearchRegistries && len(goal.searchedRegistries) == 0 {
|
||||||
return nil, errors.Errorf("image name provided is a short name and no search registries are defined in %s.", registryPath)
|
return nil, errors.Errorf("image name provided is a short name and no search registries are defined in the registries config file.")
|
||||||
}
|
}
|
||||||
// If the image passed in was fully-qualified, we will have 1 refpair. Bc the image is fq'd, we dont need to yap about registries.
|
// If the image passed in was fully-qualified, we will have 1 refpair. Bc the image is fq'd, we dont need to yap about registries.
|
||||||
if !goal.usedSearchRegistries {
|
if !goal.usedSearchRegistries {
|
||||||
|
|
|
@ -1122,16 +1122,20 @@ func (r *Runtime) Info() ([]InfoData, error) {
|
||||||
return nil, errors.Wrapf(err, "error getting registries")
|
return nil, errors.Wrapf(err, "error getting registries")
|
||||||
}
|
}
|
||||||
registries := make(map[string]interface{})
|
registries := make(map[string]interface{})
|
||||||
registries["registries"] = reg
|
registries["search"] = reg
|
||||||
info = append(info, InfoData{Type: "registries", Data: registries})
|
|
||||||
|
|
||||||
i, err := sysreg.GetInsecureRegistries()
|
ireg, err := sysreg.GetInsecureRegistries()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error getting registries")
|
return nil, errors.Wrapf(err, "error getting registries")
|
||||||
}
|
}
|
||||||
insecureRegistries := make(map[string]interface{})
|
registries["insecure"] = ireg
|
||||||
insecureRegistries["registries"] = i
|
|
||||||
info = append(info, InfoData{Type: "insecure registries", Data: insecureRegistries})
|
breg, err := sysreg.GetBlockedRegistries()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error getting registries")
|
||||||
|
}
|
||||||
|
registries["blocked"] = breg
|
||||||
|
info = append(info, InfoData{Type: "registries", Data: registries})
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/image/pkg/sysregistries"
|
"github.com/containers/image/pkg/sysregistriesv2"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/containers/libpod/pkg/rootless"
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
@ -34,24 +34,59 @@ func SystemRegistriesConfPath() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRegistries obtains the list of registries defined in the global registries file.
|
func getRegistries() ([]sysregistriesv2.Registry, error) {
|
||||||
func GetRegistries() ([]string, error) {
|
registries, err := sysregistriesv2.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()})
|
||||||
searchRegistries, err := sysregistries.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()})
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
|
|
||||||
}
|
|
||||||
return searchRegistries, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetInsecureRegistries obtains the list of insecure registries from the global registration file.
|
|
||||||
func GetInsecureRegistries() ([]string, error) {
|
|
||||||
registries, err := sysregistries.GetInsecureRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
|
return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
|
||||||
}
|
}
|
||||||
return registries, nil
|
return registries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRegistries obtains the list of search registries defined in the global registries file.
|
||||||
|
func GetRegistries() ([]string, error) {
|
||||||
|
var searchRegistries []string
|
||||||
|
registries, err := getRegistries()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, reg := range registries {
|
||||||
|
if reg.Search {
|
||||||
|
searchRegistries = append(searchRegistries, reg.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return searchRegistries, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlockedRegistries obtains the list of blocked registries defined in the global registries file.
|
||||||
|
func GetBlockedRegistries() ([]string, error) {
|
||||||
|
var blockedRegistries []string
|
||||||
|
registries, err := getRegistries()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, reg := range registries {
|
||||||
|
if reg.Blocked {
|
||||||
|
blockedRegistries = append(blockedRegistries, reg.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return blockedRegistries, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInsecureRegistries obtains the list of insecure registries from the global registration file.
|
||||||
|
func GetInsecureRegistries() ([]string, error) {
|
||||||
|
var insecureRegistries []string
|
||||||
|
registries, err := getRegistries()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, reg := range registries {
|
||||||
|
if reg.Insecure {
|
||||||
|
insecureRegistries = append(insecureRegistries, reg.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return insecureRegistries, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetRegistry returns the registry name from a string if specified
|
// GetRegistry returns the registry name from a string if specified
|
||||||
func GetRegistry(image string) (string, error) {
|
func GetRegistry(image string) (string, error) {
|
||||||
// It is possible to only have the registry name in the format "myregistry/"
|
// It is possible to only have the registry name in the format "myregistry/"
|
||||||
|
|
Loading…
Reference in New Issue