"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ContainerConfig.java" between
spring-boot-2.7.3.tar.gz and spring-boot-2.7.4.tar.gz

About: Spring Boot helps to create Spring-powered, production-grade applications and services.

ContainerConfig.java  (spring-boot-2.7.3):ContainerConfig.java  (spring-boot-2.7.4)
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skipping to change at line 51 skipping to change at line 51
* @author Phillip Webb * @author Phillip Webb
* @author Scott Frederick * @author Scott Frederick
* @author Jeroen Meijer * @author Jeroen Meijer
* @since 2.3.0 * @since 2.3.0
*/ */
public class ContainerConfig { public class ContainerConfig {
private final String json; private final String json;
ContainerConfig(String user, ImageReference image, String command, List<S tring> args, Map<String, String> labels, ContainerConfig(String user, ImageReference image, String command, List<S tring> args, Map<String, String> labels,
List<Binding> bindings, Map<String, String> env, String n List<Binding> bindings, Map<String, String> env, String n
etworkMode) throws IOException { etworkMode, List<String> securityOptions)
throws IOException {
Assert.notNull(image, "Image must not be null"); Assert.notNull(image, "Image must not be null");
Assert.hasText(command, "Command must not be empty"); Assert.hasText(command, "Command must not be empty");
ObjectMapper objectMapper = SharedObjectMapper.get(); ObjectMapper objectMapper = SharedObjectMapper.get();
ObjectNode node = objectMapper.createObjectNode(); ObjectNode node = objectMapper.createObjectNode();
if (StringUtils.hasText(user)) { if (StringUtils.hasText(user)) {
node.put("User", user); node.put("User", user);
} }
node.put("Image", image.toString()); node.put("Image", image.toString());
ArrayNode commandNode = node.putArray("Cmd"); ArrayNode commandNode = node.putArray("Cmd");
commandNode.add(command); commandNode.add(command);
skipping to change at line 73 skipping to change at line 74
ArrayNode envNode = node.putArray("Env"); ArrayNode envNode = node.putArray("Env");
env.forEach((name, value) -> envNode.add(name + "=" + value)); env.forEach((name, value) -> envNode.add(name + "=" + value));
ObjectNode labelsNode = node.putObject("Labels"); ObjectNode labelsNode = node.putObject("Labels");
labels.forEach(labelsNode::put); labels.forEach(labelsNode::put);
ObjectNode hostConfigNode = node.putObject("HostConfig"); ObjectNode hostConfigNode = node.putObject("HostConfig");
if (networkMode != null) { if (networkMode != null) {
hostConfigNode.put("NetworkMode", networkMode); hostConfigNode.put("NetworkMode", networkMode);
} }
ArrayNode bindsNode = hostConfigNode.putArray("Binds"); ArrayNode bindsNode = hostConfigNode.putArray("Binds");
bindings.forEach((binding) -> bindsNode.add(binding.toString())); bindings.forEach((binding) -> bindsNode.add(binding.toString()));
if (securityOptions != null && !securityOptions.isEmpty()) {
ArrayNode securityOptsNode = hostConfigNode.putArray("Sec
urityOpt");
securityOptions.forEach(securityOptsNode::add);
}
this.json = objectMapper.writeValueAsString(node); this.json = objectMapper.writeValueAsString(node);
} }
/** /**
* Write this container configuration to the specified {@link OutputStrea m}. * Write this container configuration to the specified {@link OutputStrea m}.
* @param outputStream the output stream * @param outputStream the output stream
* @throws IOException on IO error * @throws IOException on IO error
*/ */
public void writeTo(OutputStream outputStream) throws IOException { public void writeTo(OutputStream outputStream) throws IOException {
StreamUtils.copy(this.json, StandardCharsets.UTF_8, outputStream) ; StreamUtils.copy(this.json, StandardCharsets.UTF_8, outputStream) ;
skipping to change at line 123 skipping to change at line 128
private final List<String> args = new ArrayList<>(); private final List<String> args = new ArrayList<>();
private final Map<String, String> labels = new LinkedHashMap<>(); private final Map<String, String> labels = new LinkedHashMap<>();
private final List<Binding> bindings = new ArrayList<>(); private final List<Binding> bindings = new ArrayList<>();
private final Map<String, String> env = new LinkedHashMap<>(); private final Map<String, String> env = new LinkedHashMap<>();
private String networkMode; private String networkMode;
private final List<String> securityOptions = new ArrayList<>();
Update(ImageReference image) { Update(ImageReference image) {
this.image = image; this.image = image;
} }
private ContainerConfig run(Consumer<Update> update) { private ContainerConfig run(Consumer<Update> update) {
update.accept(this); update.accept(this);
try { try {
return new ContainerConfig(this.user, this.image, this.command, this.args, this.labels, this.bindings, return new ContainerConfig(this.user, this.image, this.command, this.args, this.labels, this.bindings,
this.env, this.networkMode); this.env, this.networkMode, this. securityOptions);
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
} }
/** /**
* Update the container config with a specific user. * Update the container config with a specific user.
* @param user the user to set * @param user the user to set
*/ */
skipping to change at line 200 skipping to change at line 207
/** /**
* Update the container config with the network that the build co ntainer will * Update the container config with the network that the build co ntainer will
* connect to. * connect to.
* @param networkMode the network * @param networkMode the network
*/ */
public void withNetworkMode(String networkMode) { public void withNetworkMode(String networkMode) {
this.networkMode = networkMode; this.networkMode = networkMode;
} }
/**
* Update the container config with a security option.
* @param option the security option
*/
public void withSecurityOption(String option) {
this.securityOptions.add(option);
}
} }
} }
 End of changes. 6 change blocks. 
4 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)