Skip to content

Commit ccd22f4

Browse files
committed
fix: fix the bug when imagetag is none
1 parent d466b57 commit ccd22f4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docker-controller-scala-core/src/main/scala/com/github/j5ik2o/dockerController/DockerController.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ private[dockerController] class DockerControllerImpl(
7474
outputFrameInterval: FiniteDuration = 500.millis
7575
)(
7676
val imageName: String,
77-
val tag: Option[String] = None
77+
_tag: Option[String] = None
7878
) extends DockerController {
7979

80+
val tag: Option[String] = _tag.orElse(Some("latest"))
81+
8082
protected val logger: Logger = LoggerFactory.getLogger(getClass)
8183

8284
private var _containerId: Option[String] = _
@@ -188,7 +190,7 @@ private[dockerController] class DockerControllerImpl(
188190

189191
override def pullImageIfNotExists(f: PullImageCmd => PullImageCmd): Unit = {
190192
logger.debug("pullImageIfNotExists --- start")
191-
if (!existsImage(p => p.getRepoTags.contains(repoTag))) {
193+
if (!existsImage(p => Option(p.getRepoTags).exists(_.contains(repoTag)))) {
192194
pullImage(f)
193195
}
194196
logger.debug("pullImageIfNotExists --- finish")

docker-controller-scala-dynamodb-local/src/test/scala/com/github/j5ik2o/dockerController/dynamodbLocal/DynamoDBLocalControllerSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DynamoDBLocalControllerSpec extends AnyFreeSpec with DockerControllerSpecS
1717
logger.debug(s"testTimeFactor = $testTimeFactor")
1818

1919
val hostPort: Int = temporaryServerPort()
20-
val controller: DynamoDBLocalController = new DynamoDBLocalController(dockerClient)(hostPort)
20+
val controller: DynamoDBLocalController = new DynamoDBLocalController(dockerClient, imageTag = None)(hostPort)
2121

2222
// val waitPredicate: WaitPredicate = WaitPredicates.forListeningHostTcpPort(dockerHost, hostPort)
2323
val waitPredicate: WaitPredicate = WaitPredicates.forLogMessageByRegex(

0 commit comments

Comments
 (0)