|
|
@ -31,6 +31,7 @@ import org.springframework.boot.buildpack.platform.json.MappedObject;
|
|
|
|
* Image configuration information.
|
|
|
|
* Image configuration information.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @since 2.3.0
|
|
|
|
* @since 2.3.0
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ImageConfig extends MappedObject {
|
|
|
|
public class ImageConfig extends MappedObject {
|
|
|
@ -39,16 +40,27 @@ public class ImageConfig extends MappedObject {
|
|
|
|
|
|
|
|
|
|
|
|
private final Map<String, String> configEnv;
|
|
|
|
private final Map<String, String> configEnv;
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
ImageConfig(JsonNode node) {
|
|
|
|
ImageConfig(JsonNode node) {
|
|
|
|
super(node, MethodHandles.lookup());
|
|
|
|
super(node, MethodHandles.lookup());
|
|
|
|
this.labels = valueAt("/Labels", Map.class);
|
|
|
|
this.labels = extractLabels();
|
|
|
|
this.configEnv = parseConfigEnv();
|
|
|
|
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, String> parseConfigEnv() {
|
|
|
|
private Map<String, String> parseConfigEnv() {
|
|
|
|
Map<String, String> env = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
String[] entries = valueAt("/Env", String[].class);
|
|
|
|
String[] entries = valueAt("/Env", String[].class);
|
|
|
|
|
|
|
|
if (entries == null) {
|
|
|
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, String> env = new LinkedHashMap<>();
|
|
|
|
for (String entry : entries) {
|
|
|
|
for (String entry : entries) {
|
|
|
|
int i = entry.indexOf('=');
|
|
|
|
int i = entry.indexOf('=');
|
|
|
|
String name = (i != -1) ? entry.substring(0, i) : entry;
|
|
|
|
String name = (i != -1) ? entry.substring(0, i) : entry;
|
|
|
@ -63,16 +75,18 @@ public class ImageConfig extends MappedObject {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return the image labels.
|
|
|
|
* Return the image labels. If the image has no labels, an empty {@code Map} is
|
|
|
|
* @return the image labels
|
|
|
|
* returned.
|
|
|
|
|
|
|
|
* @return the image labels, never {@code null}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Map<String, String> getLabels() {
|
|
|
|
public Map<String, String> getLabels() {
|
|
|
|
return this.labels;
|
|
|
|
return this.labels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return the image environment variables.
|
|
|
|
* Return the image environment variables. If the image has no environment variables,
|
|
|
|
* @return the env
|
|
|
|
* an empty {@code Map} is returned.
|
|
|
|
|
|
|
|
* @return the env, never {@code null}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Map<String, String> getEnv() {
|
|
|
|
public Map<String, String> getEnv() {
|
|
|
|
return this.configEnv;
|
|
|
|
return this.configEnv;
|
|
|
|