pkg/utils: Add function to check if an image is referenced by its ID

https://github.com/containers/toolbox/pull/318
This commit is contained in:
Harry Míchal 2020-05-11 16:12:06 +02:00 committed by Debarshi Ray
parent d589b3a252
commit dd947016b3
1 changed files with 6 additions and 0 deletions

View File

@ -271,6 +271,12 @@ func GetMountOptions(target string) (string, error) {
return mountOptions, nil
}
// ImageReferenceCanBeID checks if 'image' might be the ID of an image
func ImageReferenceCanBeID(image string) (bool, error) {
matched, err := regexp.MatchString("^[a-f0-9]\\{6,64\\}$", image)
return matched, err
}
// ShortID shortens provided id to first 12 characters.
func ShortID(id string) string {
if len(id) > idTruncLength {