From e87a629e3845574196a8350cd53dad4000b082b6 Mon Sep 17 00:00:00 2001 From: Gal Yardeni <55253849+gal-yardeni@users.noreply.github.com> Date: Wed, 7 Oct 2020 17:09:14 -0700 Subject: [PATCH] feat(dockerBranch): add branch info for docker images (#887) --- .../com/netflix/spinnaker/igor/docker/DockerMonitor.groovy | 2 ++ .../spinnaker/igor/docker/service/TaggedImageList.groovy | 1 + .../netflix/spinnaker/igor/docker/DockerMonitorSpec.groovy | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/DockerMonitor.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/DockerMonitor.groovy index 68d38aa2c..dc6b61be5 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/DockerMonitor.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/DockerMonitor.groovy @@ -204,6 +204,8 @@ class DockerMonitor extends CommonPollingMonitor .ifPresent({ commitId -> metadata.put("commitId", commitId.toString()) }) Optional.ofNullable(image.date) .ifPresent({ date -> metadata.put("date", date.toString()) }) + Optional.ofNullable(image.branch) + .ifPresent({ branch -> metadata.put("branch", branch.toString()) }) Artifact artifact = Artifact.builder() diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/service/TaggedImageList.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/service/TaggedImageList.groovy index 37bf49493..60fd98fd4 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/service/TaggedImageList.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/service/TaggedImageList.groovy @@ -28,4 +28,5 @@ class TaggedImage { String buildNumber String commitId String date + String branch } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/docker/DockerMonitorSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/docker/DockerMonitorSpec.groovy index d224b1441..a0c3d8aea 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/docker/DockerMonitorSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/docker/DockerMonitorSpec.groovy @@ -104,7 +104,9 @@ class DockerMonitorSpec extends Specification { repository: "repository", digest: "digest", buildNumber: "111", - commitId: "ab12c3" + commitId: "ab12c3", + date: "1598707355157", + branch: "master" ) when: @@ -127,6 +129,8 @@ class DockerMonitorSpec extends Specification { assert artifacts[0].metadata.tag == "tag" assert artifacts[0].metadata.buildNumber == "111" assert artifacts[0].metadata.commitId == "ab12c3" + assert artifacts[0].metadata.date == "1598707355157" + assert artifacts[0].metadata.branch == "master" return true }) }