aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/jshipit/DockerAPIHelper.java
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2023-05-26 00:03:58 +0200
committeraxtloss <axtlos@getcryst.al>2023-05-26 00:03:58 +0200
commit87cc052844e2cacca591edd68884f1e7f6c49a3a (patch)
tree2e39577998921746253a7ed1ea08ee99e6d4ecc9 /src/main/java/io/github/jshipit/DockerAPIHelper.java
parent3fdb1012609b71a41e551ea0aad3b8a27b134e21 (diff)
downloadjshipit-87cc052844e2cacca591edd68884f1e7f6c49a3a.tar.gz
jshipit-87cc052844e2cacca591edd68884f1e7f6c49a3a.tar.bz2
Add comments to functions
Diffstat (limited to 'src/main/java/io/github/jshipit/DockerAPIHelper.java')
-rwxr-xr-xsrc/main/java/io/github/jshipit/DockerAPIHelper.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/main/java/io/github/jshipit/DockerAPIHelper.java b/src/main/java/io/github/jshipit/DockerAPIHelper.java
index ae0e536..b7c472c 100755
--- a/src/main/java/io/github/jshipit/DockerAPIHelper.java
+++ b/src/main/java/io/github/jshipit/DockerAPIHelper.java
@@ -38,6 +38,9 @@ public class DockerAPIHelper {
}
}
+ /*
+ * Get the Authentication URL from the registry
+ */
public void getAuthenticationUrl() throws IOException {
URL url_obj = null;
try {
@@ -60,11 +63,16 @@ public class DockerAPIHelper {
this.authURL = authenticate.get(0).replace("Bearer realm=", "").replace("\"", "").split(",")[0];
this.authService = authenticate.get(0).replace("service=", "").replace("\"", "").split(",")[1];
} else {
- this.authURL = "https://auth.docker.io/token";
+ this.authURL = "https://auth.docker.io/token"; // Just default to docker if the registry does not support or need authentication
this.authService = "registry.docker.io";
}
}
+ /*
+ * Generate an API token from the authentication URL
+ *
+ * @return String API token
+ */
public String generateAPIToken() throws IOException, RuntimeException {
URL url_obj = null;
try {
@@ -96,6 +104,11 @@ public class DockerAPIHelper {
}
}
+ /*
+ * Fetch the manifest JSON from the registry
+ *
+ * @return JsonNode Manifest JSON
+ */
public JsonNode fetchManifestJson() throws IOException, RuntimeException {
URL url_obj = null;
try {
@@ -130,6 +143,14 @@ public class DockerAPIHelper {
}
}
+ /*
+ * Fetch a blob from a specific image
+ *
+ * @param digest Digest of the blob to fetch
+ * @param tmpdir Directory to store the blob
+ * @param extract Whether or not to extract the blob
+ * @param renameTo Rename the blob to this name
+ */
public void fetchBlob(String digest, String tmpdir, boolean extract, String renameTo) throws IOException, RuntimeException {
String url = "https://" + this.apiRepo + "/v2/" + this.repository + "/" + this.image + "/blobs/"+digest;
String[][] headers = {{"Authorization", "Bearer "+this.apiToken}, {"Accept", "application/vnd/docker.distribution.manifest.v2+json"}};
@@ -137,10 +158,6 @@ public class DockerAPIHelper {
downloader.start();
}
- public String getApiToken() {
- return apiToken;
- }
-
public String getImage() {
return image;
}