forked from heroku/docker-registry-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
71 lines (52 loc) · 1.46 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"encoding/json"
"github.com/docker/distribution/manifest/schema1"
"github.com/fangtest/docker-registry-client/registry"
)
func main() {
url := "http://192.168.12.144:5000"
username := "" // anonymous
password := "" // anonymous
hub, err := registry.New(url, username, password)
if err != nil {
}
repositories, err := hub.Repositories()
if err != nil {
}
println(repositories)
tags, err := hub.Tags("app-center-ws")
if err != nil {
}
println(tags)
manifest, err := hub.Manifest("app-center-ws", "latest-origin-master-5a105bafbc-20233007153043-26")
if err != nil {
}
println(manifest)
time := buildCreateTime(manifest)
println(time)
manifestv2, sha256, err := hub.ManifestV2("app-center-ws", "latest-origin-master-5a105bafbc-20233007153043-26")
if err != nil {
}
println(manifestv2)
println(sha256)
digest, err := hub.ManifestDigest("app-center-ws", "latest-origin-master-5a105bafbc-20233007153043-26")
if err != nil {
}
println(digest)
metadata, err := hub.BlobMetadata("app-center-ws", "latest-origin-master-5a105bafbc-20233007153043-26")
if err != nil {
}
println(metadata.Size)
}
type ImageManifest struct {
Created string `json:"created"`
}
func buildCreateTime(manifest *schema1.SignedManifest) string {
compatibility := manifest.History[0].V1Compatibility
imageManifest := ImageManifest{}
if err := json.Unmarshal([]byte(compatibility), &imageManifest); err != nil {
return ""
}
return imageManifest.Created
}