public T getRootNode() { return getRoot().node("", null); }
/** * @return a normalized URI, not necessarily the URI this node was created from. Does not contain userInfo to avoid accidentialls * printing it. Use getUriWithUserInfo instead if you know what you're doing. */ public URI getUri() { return URI.create(getRoot().getFilesystem().getScheme() + ":" + getRoot().getId() + encodePath(getPath())); }
public World getWorld() { return getRoot().getFilesystem().getWorld(); }
/** * Throws an exception if this is not a link. */ public T resolveLink() throws ReadLinkException { String path; path = readLink(); if (path.startsWith(Filesystem.SEPARATOR_STRING)) { return getRoot().node(path.substring(1), null); } else { return (T) getParent().join(path); } }
/** * @param image may be null * @return container ids */ public List<String> containerList(String image) throws IOException { String filters; Node node; JsonArray array; List<String> result; String id; node = root.join("containers/json"); filters = image == null? "" : "&filters=" + enc("{\"ancestor\" : [\"" + image + "\"] }"); node = node.getRoot().node(node.getPath(), "all=true" + filters); array = parser.parse(node.readString()).getAsJsonArray(); result = new ArrayList<>(array.size()); for (JsonElement element : array) { id = element.getAsJsonObject().get("Id").getAsString(); result.add(id); } return result; }
/** @return image ids */ public List<String> imageList(Map<String, String> labels) throws IOException { String filters; Node node; JsonArray array; List<String> result; String id; node = root.join("images/json"); filters = labels.isEmpty()? "" : "&filters=" + enc("{\"label\" : [" + labelsToJsonArray(labels) + "] }"); node = node.getRoot().node(node.getPath(), "all=true" + filters); array = parser.parse(node.readString()).getAsJsonArray(); result = new ArrayList<>(array.size()); for (JsonElement element : array) { id = element.getAsJsonObject().get("Id").getAsString(); id = Strings.removeLeft(id, "sha256:"); result.add(id); } return result; }
/** * Returns a String representation suitable for messages. * * CAUTION: don't use to convert to a string, use instead. */ @Override public String toString() { Node working; working = getWorld().getWorking(); if (working == null || !getRoot().equals(working.getRoot())) { return getUri().toString(); } else { if (hasAncestor(working)) { return getRelative(working); } else { return Filesystem.SEPARATOR_STRING + getPath(); } } }
public T join(List<String> paths) { Root<T> root; T result; root = getRoot(); result = root.node(root.getFilesystem().join(getPath(), paths), null); return result; }
public void header(Node left, Node right, String relative, StringBuilder result) throws IOException { if (!left.exists()) { right.checkFile(); header('A', relative, result); } else if (!right.exists()) { header('R', relative, result); } else if (left.diff(right)) { header('M', relative, result); } else if (left.getRoot().getFilesystem().getFeatures().modes && !left.getPermissions().equals(right.getPermissions())) { header('m', relative, result); } else { // nothing } }