forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Service Binding configuration for Kafka
Fixes: quarkusio#15631
- Loading branch information
Showing
11 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
34 changes: 34 additions & 0 deletions
34
...a-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/KafkaBindingConverter.java
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.quarkus.kafka.client.runtime; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import io.quarkus.kubernetes.service.binding.runtime.ServiceBinding; | ||
import io.quarkus.kubernetes.service.binding.runtime.ServiceBindingConfigSource; | ||
import io.quarkus.kubernetes.service.binding.runtime.ServiceBindingConverter; | ||
|
||
public class KafkaBindingConverter implements ServiceBindingConverter { | ||
|
||
@Override | ||
public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> serviceBindings) { | ||
Optional<ServiceBinding> matchingByType = ServiceBinding.singleMatchingByType("kafka", serviceBindings); | ||
if (!matchingByType.isPresent()) { | ||
return Optional.empty(); | ||
} | ||
|
||
Map<String, String> properties = new HashMap<>(); | ||
ServiceBinding binding = matchingByType.get(); | ||
|
||
String bootstrapServers = binding.getProperties().get("bootstrapServers"); | ||
if (bootstrapServers == null) { | ||
bootstrapServers = binding.getProperties().get("bootstrap-servers"); | ||
} | ||
if (bootstrapServers != null) { | ||
properties.put("kafka.bootstrap.servers", bootstrapServers); | ||
} | ||
|
||
return Optional.of(new ServiceBindingConfigSource("kafka-k8s-service-binding-source", properties)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...s/META-INF/services/io.quarkus.kubernetes.service.binding.runtime.ServiceBindingConverter
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.kafka.client.runtime.KafkaBindingConverter |
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
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
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
1 change: 1 addition & 0 deletions
1
integration-tests/kafka-snappy/src/test/resources/k8s-sb/some-kafka/bootstrapServers
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost:19092 |
1 change: 1 addition & 0 deletions
1
integration-tests/kafka-snappy/src/test/resources/k8s-sb/some-kafka/provider
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
RH-SBO |
1 change: 1 addition & 0 deletions
1
integration-tests/kafka-snappy/src/test/resources/k8s-sb/some-kafka/type
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
kafka |