ImageConfig Class — spring-boot Architecture
Architecture documentation for the ImageConfig class in ImageConfig.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageConfig.java lines 38–137
public class ImageConfig extends MappedObject {
private final Map<String, String> labels;
private final Map<String, @Nullable String> configEnv;
ImageConfig(JsonNode node) {
super(node, MethodHandles.lookup());
this.labels = extractLabels();
this.configEnv = parseConfigEnv();
}
@SuppressWarnings("unchecked")
private Map<String, String> extractLabels() {
Map<String, String> labels = valueAt("/Labels", Map.class);
if (labels == null) {
return Collections.emptyMap();
}
return labels;
}
private Map<String, @Nullable String> parseConfigEnv() {
String[] entries = valueAt("/Env", String[].class);
if (entries == null) {
return Collections.emptyMap();
}
Map<String, @Nullable String> env = new LinkedHashMap<>();
for (String entry : entries) {
int i = entry.indexOf('=');
String name = (i != -1) ? entry.substring(0, i) : entry;
String value = (i != -1) ? entry.substring(i + 1) : null;
env.put(name, value);
}
return Collections.unmodifiableMap(env);
}
JsonNode getNodeCopy() {
return super.getNode().deepCopy();
}
/**
* Return the image labels. If the image has no labels, an empty {@code Map} is
* returned.
* @return the image labels, never {@code null}
*/
public Map<String, String> getLabels() {
return this.labels;
}
/**
* Return the image environment variables. If the image has no environment variables,
* an empty {@code Map} is returned.
* @return the env, never {@code null}
*/
public Map<String, @Nullable String> getEnv() {
return this.configEnv;
}
/**
* Create an updated copy of this image config.
* @param update consumer to apply updates
* @return an updated image config
*/
public ImageConfig copy(Consumer<Update> update) {
return new Update(this).run(update);
}
/**
* Update class used to change data when creating a copy.
*/
public static final class Update {
private final ObjectNode copy;
private Update(ImageConfig source) {
this.copy = (ObjectNode) source.getNode().deepCopy();
}
private ImageConfig run(Consumer<Update> update) {
update.accept(this);
return new ImageConfig(this.copy);
}
/**
* Update the image config with an additional label.
* @param label the label name
* @param value the label value
*/
public void withLabel(String label, String value) {
JsonNode labels = this.copy.at("/Labels");
if (labels.isMissingNode()) {
labels = this.copy.putObject("Labels");
}
((ObjectNode) labels).put(label, value);
}
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free