mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
perf(doctor): run checks concurrently and share docker lookups (#32)
This commit is contained in:
1 parent
3c4118ff1a
commit
dd38f6dc27
20 files changed
+623
-51
No files matched your search
@@ -85,6 +85,18 @@ public class DockerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/** The value of label {@code key} on a local image, empty when the label or image is missing. */
|
||||
public Optional<String> imageLabel(String image, String key) throws DockerException {
|
||||
try {
|
||||
String out = run("docker", "inspect", "--format",
|
||||
"{{index .Config.Labels \"" + key + "\"}}", image);
|
||||
String value = out.trim();
|
||||
return value.isEmpty() || "<no value>".equals(value) ? Optional.empty() : Optional.of(value);
|
||||
} catch (DockerException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public void pull(String image, String policy) throws DockerException {
|
||||
if ("never".equalsIgnoreCase(policy)) return;
|
||||
if ("missing".equalsIgnoreCase(policy) && isImagePresent(image)) return;
|
||||
|
||||
Reference in new issue
Block a user