blob: df1cea79d30acd25f43bd4001952166b7449eb3a (
plain) (
blame)
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
|
package io.github.jshipit;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) {
DockerAPIHelper api = new DockerAPIHelper("registry.docker.io", "https://auth.docker.io/token", "library", "archlinux", "latest");
JsonNode manifest = null;
System.out.println("API Token: " + api.getApiToken());
try {
manifest = api.fetchManifestJson();
} catch (IOException e) {
}
System.out.println("Manifest: " + manifest);
Path path = Path.of("./tmp_"+api.getImage()+"_"+api.getTag());
try {
Files.createDirectory(path);
} catch (IOException e) {
System.out.println("Failed to create directory: " + path);
return;
}
JsonNode layers = manifest.get("layers");
for (JsonNode layer : layers) {
System.out.println("Layer: " + layer);
try {
api.fetchBlob(layer.get("digest").asText(), path.toString());
} catch (IOException e) {
}
}
}
}
|