image: precompile regexp

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: 8f57e7d2ef82d39e2c914b799e98ed6243b9b1d0
Component: engine
This commit is contained in:
unclejack
2015-05-13 21:47:43 +03:00
parent c6760c3f88
commit 3fb26e927f
+2 -1
View File
@@ -19,6 +19,8 @@ import (
// For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk
const MaxImageDepth = 127
var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
type Image struct {
ID string `json:"id"`
Parent string `json:"parent,omitempty"`
@@ -266,7 +268,6 @@ func NewImgJSON(src []byte) (*Image, error) {
// Check wheather id is a valid image ID or not
func ValidateID(id string) error {
validHex := regexp.MustCompile(`^([a-f0-9]{64})$`)
if ok := validHex.MatchString(id); !ok {
return fmt.Errorf("image ID '%s' is invalid", id)
}