-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifests_test.go
51 lines (41 loc) · 1.16 KB
/
manifests_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package registry
import (
"fmt"
"github.com/docker/distribution/manifest/schema2"
)
var (
gettingTheManifestOfForPlatformWithOsAndArchResult schema2.Manifest
)
func gettingTheManifestOfForPlatformWithOsAndArch(imageName, os, arch string) error {
domain, path, tag, _, err := ParseImageName(imageName)
if err != nil {
return err
}
reg := New(Options{
Client: DefaultClient(),
Domain: domain,
Protocol: "http",
})
repository := reg.Repository(path)
image, err := repository.Images().GetByTag(tag)
if err != nil {
return err
}
for _, p := range image.Platforms {
if p.Architecture == arch && p.OS == os {
m, err := repository.Manifests().Get(p.Digest)
if err != nil {
return err
}
gettingTheManifestOfForPlatformWithOsAndArchResult = m
return nil
}
}
return fmt.Errorf("platform with os '%s' and arch '%s' not found", os, arch)
}
func theManifestHasTheMediaType(mediaType string) error {
if gettingTheManifestOfForPlatformWithOsAndArchResult.MediaType != mediaType {
return fmt.Errorf("expected media type '%s' != actual media type '%s'", mediaType, gettingTheManifestOfForPlatformWithOsAndArchResult.MediaType)
}
return nil
}