30 lines
616 B
Go
30 lines
616 B
Go
package bundle
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
|
|
publicbundle "gitea.maximumdirect.net/eric/distributor/pkg/bundle"
|
|
)
|
|
|
|
var digestPattern = regexp.MustCompile(`^sha256:[0-9a-f]{64}$`)
|
|
|
|
func ValidateDigest(value string) error {
|
|
if !digestPattern.MatchString(value) {
|
|
return fmt.Errorf("must be lowercase sha256:<64 hex>")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func FileDigest(data []byte) string {
|
|
return publicbundle.FileDigest(data)
|
|
}
|
|
|
|
func BundleDigest(files []ManifestFile) string {
|
|
return publicbundle.BundleDigest(files)
|
|
}
|
|
|
|
func CanonicalFilePayload(files []ManifestFile) string {
|
|
return publicbundle.CanonicalFilePayload(files)
|
|
}
|