-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: rid of deprecated class #209
Merged
dimafeng
merged 1 commit into
testcontainers:master
from
andreezy777:update_kafka_container
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 10 additions & 32 deletions
42
modules/kafka/src/main/scala/com/dimafeng/testcontainers/KafkaContainer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,29 @@ | ||
package com.dimafeng.testcontainers | ||
|
||
import org.testcontainers.containers.{KafkaContainer => JavaKafkaContainer} | ||
import org.testcontainers.utility.DockerImageName | ||
|
||
class KafkaContainer(confluentPlatformVersion: Option[String] = None, | ||
externalZookeeper: Option[String] = None) extends SingleContainer[JavaKafkaContainer] { | ||
case class KafkaContainer(dockerImageName: DockerImageName = DockerImageName.parse(KafkaContainer.defaultDockerImageName) | ||
) extends SingleContainer[JavaKafkaContainer] { | ||
|
||
@deprecated("Please use reflective methods of the scala container or `configure` method") | ||
val kafkaContainer: JavaKafkaContainer = { | ||
if (confluentPlatformVersion.isEmpty) { | ||
new JavaKafkaContainer() | ||
} else { | ||
new JavaKafkaContainer(confluentPlatformVersion.get) | ||
} | ||
} | ||
|
||
if (externalZookeeper.isEmpty) { | ||
kafkaContainer.withEmbeddedZookeeper() | ||
} else { | ||
kafkaContainer.withExternalZookeeper(externalZookeeper.get) | ||
} | ||
|
||
override val container: JavaKafkaContainer = kafkaContainer | ||
override val container: JavaKafkaContainer = new JavaKafkaContainer(dockerImageName) | ||
|
||
def bootstrapServers: String = container.getBootstrapServers | ||
} | ||
|
||
object KafkaContainer { | ||
|
||
val defaultImage = "confluentinc/cp-kafka" | ||
val defaultTag = "5.2.1" | ||
val defaultDockerImageName = s"$defaultImage:$defaultTag" | ||
|
||
def apply(confluentPlatformVersion: String = null, | ||
externalZookeeper: String = null): KafkaContainer = { | ||
new KafkaContainer(Option(confluentPlatformVersion), Option(externalZookeeper)) | ||
} | ||
|
||
case class Def( | ||
confluentPlatformVersion: String = defaultTag, | ||
externalZookeeper: Option[String] = None | ||
) extends ContainerDef { | ||
case class Def(dockerImageName: DockerImageName = DockerImageName.parse(KafkaContainer.defaultDockerImageName) | ||
) extends ContainerDef { | ||
|
||
override type Container = KafkaContainer | ||
|
||
override def createContainer(): KafkaContainer = { | ||
new KafkaContainer( | ||
confluentPlatformVersion = Some(confluentPlatformVersion), | ||
externalZookeeper = externalZookeeper | ||
) | ||
new KafkaContainer(dockerImageName) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this argument been removed on purpose? It doesn't seem to be deprecated in the Java lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you about
externalZookeeper
?If yes. Then by default
externalZookeeperConnect = null
in Java lib, so then we do not need pass any value, cause by default we will useembeddedZookeeper
(because methodwithEmbeddedZookeeper
returnsexternalZookeeperConnect = null
).And if anyone wants to use externalZookeeper they should use
configure
method (as written above the valkafkaContainer
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for vague question, and yes, I was asking about
externalZookeeperConnect
.Thank you, it makes sense!