...
1
2
3 package cache
4
5 import (
6 "fmt"
7
8 "github.com/docker/distribution"
9 )
10
11
12
13 type BlobDescriptorCacheProvider interface {
14 distribution.BlobDescriptorService
15
16 RepositoryScoped(repo string) (distribution.BlobDescriptorService, error)
17 }
18
19
20
21 func ValidateDescriptor(desc distribution.Descriptor) error {
22 if err := desc.Digest.Validate(); err != nil {
23 return err
24 }
25
26 if desc.Size < 0 {
27 return fmt.Errorf("cache: invalid length in descriptor: %v < 0", desc.Size)
28 }
29
30 if desc.MediaType == "" {
31 return fmt.Errorf("cache: empty mediatype on descriptor: %v", desc)
32 }
33
34 return nil
35 }
36
View as plain text