mirror of
https://github.com/containers/podman.git
synced 2025-06-28 14:29:04 +08:00
regression: tls verify should be set on registries.conf if insecure
In the case where podman needs to pull an image, if that registry that the image resides on is known to be insesure (as defined in /etc/containers/registries.conf), tls-verify should be altered on the fly. Signed-off-by: baude <bbaude@redhat.com> Closes: #626 Approved by: mheon
This commit is contained in:
37
pkg/registries/registries.go
Normal file
37
pkg/registries/registries.go
Normal file
@ -0,0 +1,37 @@
|
||||
package registries
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/containers/image/pkg/sysregistries"
|
||||
"github.com/containers/image/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetRegistries obtains the list of registries defined in the global registries file.
|
||||
func GetRegistries() ([]string, error) {
|
||||
registryConfigPath := ""
|
||||
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
|
||||
if len(envOverride) > 0 {
|
||||
registryConfigPath = envOverride
|
||||
}
|
||||
searchRegistries, err := sysregistries.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: registryConfigPath})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
|
||||
}
|
||||
return searchRegistries, nil
|
||||
}
|
||||
|
||||
// GetInsecureRegistries obtains the list of inseure registries from the global registration file.
|
||||
func GetInsecureRegistries() ([]string, error) {
|
||||
registryConfigPath := ""
|
||||
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
|
||||
if len(envOverride) > 0 {
|
||||
registryConfigPath = envOverride
|
||||
}
|
||||
registries, err := sysregistries.GetInsecureRegistries(&types.SystemContext{SystemRegistriesConfPath: registryConfigPath})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
|
||||
}
|
||||
return registries, nil
|
||||
}
|
Reference in New Issue
Block a user