pkg/stringid: remove unused ValidateID() function

This format-check was only used for v1 images.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-11-18 14:24:50 +01:00
parent 2004c507ab
commit 6f719acd23
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 1 additions and 25 deletions

View file

@ -4,7 +4,6 @@ package stringid // import "github.com/docker/docker/pkg/stringid"
import (
"crypto/rand"
"encoding/hex"
"errors"
"regexp"
"strconv"
"strings"
@ -15,10 +14,7 @@ const (
fullLen = 64
)
var (
validShortID = regexp.MustCompile("^[a-f0-9]{12}$")
validHex = regexp.MustCompile(`^[a-f0-9]{64}$`)
)
var validShortID = regexp.MustCompile("^[a-f0-9]{12}$")
// IsShortID determines if id has the correct format and length for a short ID.
// It checks the IDs length and if it consists of valid characters for IDs (a-f0-9).
@ -60,14 +56,3 @@ func GenerateRandomID() string {
return id
}
}
// ValidateID checks whether an ID string is a valid, full-length image ID.
func ValidateID(id string) error {
if len(id) != fullLen {
return errors.New("image ID '" + id + "' is invalid")
}
if !validHex.MatchString(id) {
return errors.New("image ID '" + id + "' is invalid")
}
return nil
}

View file

@ -78,12 +78,3 @@ func BenchmarkIsShortID(b *testing.B) {
}
}
}
func BenchmarkValidateID(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for _, id := range testIDs {
_ = ValidateID(id)
}
}
}