mirror of
https://github.com/containers/podman.git
synced 2025-07-31 12:22:29 +08:00
Support podman image trust command
Display the trust policy of the host system. The trust policy is stored in the /etc/containers/policy.json file and defines a scope of registries or repositories. Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
@ -2,6 +2,8 @@ package image
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
cp "github.com/containers/image/copy"
|
||||
@ -117,3 +119,23 @@ func GetAdditionalTags(images []string) ([]reference.NamedTagged, error) {
|
||||
}
|
||||
return allTags, nil
|
||||
}
|
||||
|
||||
// IsValidImageURI checks if image name has valid format
|
||||
func IsValidImageURI(imguri string) (bool, error) {
|
||||
uri := "http://" + imguri
|
||||
u, err := url.Parse(uri)
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "invalid image uri: %s", imguri)
|
||||
}
|
||||
reg := regexp.MustCompile(`^[a-zA-Z0-9-_\.]+\/?:?[0-9]*[a-z0-9-\/:]*$`)
|
||||
ret := reg.FindAllString(u.Host, -1)
|
||||
if len(ret) == 0 {
|
||||
return false, errors.Wrapf(err, "invalid image uri: %s", imguri)
|
||||
}
|
||||
reg = regexp.MustCompile(`^[a-z0-9-:\./]*$`)
|
||||
ret = reg.FindAllString(u.Fragment, -1)
|
||||
if len(ret) == 0 {
|
||||
return false, errors.Wrapf(err, "invalid image uri: %s", imguri)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user