mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Use line endings on all OSs when writing image config JSON
Previously \r\n was used on Windows and \n was used on other platforms. This resulted in different JSON content being written to the archive. As the config's entry name is the SHA-256 hash of its content, it also resulted in the entry name being different. This commit updates the JSON that's written into the archive to use \n line endings, irrespective of the OS on which the image is being built. See gh-19828
This commit is contained in:
parent
a0b4cdee44
commit
0a9fe65443
@ -136,7 +136,7 @@ public class ImageArchive implements TarArchive {
|
||||
private String writeConfig(Layout writer, List<LayerId> writtenLayers) throws IOException {
|
||||
try {
|
||||
ObjectNode config = createConfig(writtenLayers);
|
||||
String json = this.objectMapper.writeValueAsString(config);
|
||||
String json = this.objectMapper.writeValueAsString(config).replace("\r\n", "\n");
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
InspectedContent content = InspectedContent.of(Content.of(json), digest::update);
|
||||
String name = "/" + LayerId.ofSha256Digest(digest.digest()).getHash() + ".json";
|
||||
|
Loading…
Reference in New Issue
Block a user