Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,20 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
}

fun getImageId(buildInfos: List<BuildInfo>): ImageID? {
val firstAux = buildInfos.stream()
val reversedInfos = buildInfos.reversed()
val firstAux = reversedInfos.stream()
.filter { (_, _, _, _, _, _, _, aux): BuildInfo -> aux != null }
.findFirst()
if (firstAux.isPresent) {
return firstAux.get().aux
} else {
val idFromStream = buildInfos.stream()
val idFromStream = reversedInfos.stream()
.filter { (_, stream): BuildInfo -> stream?.contains("Successfully built ")!! }
.findFirst()
return if (idFromStream.isPresent) {
ImageID(idFromStream.get().stream!!.removePrefix("Successfully built ").replaceAfter('\n', "").trim())
} else {
val tagFromStream = buildInfos.stream()
val tagFromStream = reversedInfos.stream()
.filter { (_, stream): BuildInfo -> stream?.contains("Successfully tagged ")!! }
.findFirst()
tagFromStream.map { (_, stream): BuildInfo ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void setup() {
public void getImageIdFromAux() {
List<BuildInfo> infos = new ArrayList<>();
infos.add(new BuildInfo(null, null, null, null, null, null, null, new ImageID("sha256:expected-id")));
infos.add(new BuildInfo(null, "Successfully built the wind\ncaught it", null, null, null, null, null, null));
infos.add(new BuildInfo(null, "Successfully built f9d5f290d048\nfoo bar", null, null, null, null, null, null));
infos.add(new BuildInfo(null, "Successfully tagged image:tag\nbar baz", null, null, null, null, null, null));

Expand All @@ -35,6 +36,7 @@ public void getImageIdFromAux() {
@Test
public void getImageIdFromStreamWithBuildMessage() {
List<BuildInfo> infos = new ArrayList<>();
infos.add(new BuildInfo(null, "Successfully built the wind\ncaught it", null, null, null, null, null, null));
infos.add(new BuildInfo(null, "Successfully built f9d5f290d048\nfoo bar", null, null, null, null, null, null));
infos.add(new BuildInfo(null, "Successfully tagged image:tag\nbar baz", null, null, null, null, null, null));

Expand Down