Allow image Created date to be configurable

A `createdDate` option on the Maven `spring-boot:build-image` goal
and the Gradle `bootBuildImage` task can be used to set the `Created`
metadata field on a generated OCI image to a specified date or to
the current date.

Closes gh-28798
This commit is contained in:
Scott Frederick
2023-04-05 13:05:48 -05:00
parent cacc563fc0
commit 5817c8441d
68 changed files with 542 additions and 71 deletions

View File

@@ -185,6 +185,14 @@ class ImageTests {
assertThat(request.getLaunchCache()).isEqualTo(Cache.volume("launch-cache-vol"));
}
@Test
void getBuildRequestWhenHasCreatedDateUsesCreatedDate() {
Image image = new Image();
image.createdDate = "2020-07-01T12:34:56Z";
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
assertThat(request.getCreatedDate()).isEqualTo("2020-07-01T12:34:56Z");
}
private Artifact createArtifact() {
return new DefaultArtifact("com.example", "my-app", VersionRange.createFromVersion("0.0.1-SNAPSHOT"), "compile",
"jar", null, new DefaultArtifactHandler());