Skip to content

Commit

Permalink
chore: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
secondsun committed Nov 23, 2021
1 parent a1f0237 commit 5726377
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
6 changes: 6 additions & 0 deletions extensions/apicurio-registry-avro/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-service-binding</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
Expand All @@ -44,6 +45,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Optional;
import java.util.logging.Logger;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;

Expand Down Expand Up @@ -47,12 +48,12 @@ public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> service

String prefix = channel;

String oAuthHost = binding.getProperties().get("oauthServerUrl");
if (oAuthHost == null) {
oAuthHost = binding.getProperties().get("oauthserverurl");
String oauthTokenUrl = binding.getProperties().get("oauthTokenUrl");
if (oauthTokenUrl == null) {
oauthTokenUrl = binding.getProperties().get("oauthtokenurl");
}
if (oAuthHost != null) {
properties.put(prefix + "apicurio.auth.service.url", oAuthHost);
if (oauthTokenUrl != null) {
properties.put(prefix + "apicurio.auth.service.token.endpoint", oauthTokenUrl);
}

String clientId = binding.getProperties().get("clientId");
Expand All @@ -70,15 +71,6 @@ public Optional<ServiceBindingConfigSource> convert(List<ServiceBinding> service
if (clientSecret != null) {
properties.put(prefix + "apicurio.auth.client.secret", clientSecret);
}

String realm = binding.getProperties().get("oauthRealm");
if (realm == null) {
realm = binding.getProperties().get("oauthRealm");
}
if (clientSecret != null) {
properties.put(prefix + "apicurio.auth.realm", realm);
}

if (registryUrl != null) {
properties.put(prefix + "apicurio.registry.url", registryUrl);
}
Expand All @@ -93,11 +85,17 @@ private List<String> extractChannels(Config configIn) {

for (String propertyName : configIn.getPropertyNames()) {
if (propertyName.startsWith(INCOMING_PREFIX)) {
var channelName = propertyName.replace(INCOMING_PREFIX, "").split("\\.")[0];
list.add(INCOMING_PREFIX + channelName + ".");
var channelAndProp = StringUtils.substringAfter(propertyName, INCOMING_PREFIX);
//remove property
var channelName = StringUtils.substringBefore(channelAndProp, ".");
if (!StringUtils.isBlank(channelName))
list.add(INCOMING_PREFIX + channelName + ".");
} else if (propertyName.startsWith(OUTGOING_PREFIX)) {
var channelName = propertyName.replace(OUTGOING_PREFIX, "").split("\\.")[0];
list.add(OUTGOING_PREFIX + channelName + ".");
var channelAndProp = StringUtils.substringAfter(propertyName, OUTGOING_PREFIX);
//remove property
var channelName = StringUtils.substringBefore(channelAndProp, ".");
if (!StringUtils.isBlank(channelName))
list.add(OUTGOING_PREFIX + channelName + ".");
}
}
return list;
Expand Down

0 comments on commit 5726377

Please sign in to comment.