-
-
Notifications
You must be signed in to change notification settings - Fork 154
BE: SR: Add compatibility w/ GCP SR #1153
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
e9d5a7d
5392e77
0726114
aaa04b6
6ba0bc8
f2e8a53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ public class SchemaRegistrySerde implements BuiltInSerde { | |
|
||
private static final byte SR_PAYLOAD_MAGIC_BYTE = 0x0; | ||
private static final int SR_PAYLOAD_PREFIX_LENGTH = 5; | ||
private static final String CUSTOM_BEARER_AUTH_CREDENTIALS_SOURCE = "CUSTOM"; | ||
|
||
public static String name() { | ||
return "SchemaRegistry"; | ||
|
@@ -77,11 +78,15 @@ public void autoConfigure(PropertyResolver kafkaClusterProperties, | |
urls, | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.username", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.password", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistrySsl.keystoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistrySsl.keystorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null) | ||
), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryKeySchemaNameTemplate", String.class).orElse("%s-key"), | ||
kafkaClusterProperties.getProperty("schemaRegistrySchemaNameTemplate", String.class).orElse("%s-value"), | ||
kafkaClusterProperties.getProperty("schemaRegistryCheckSchemaExistenceForDeserialize", Boolean.class) | ||
|
@@ -103,11 +108,15 @@ public void configure(PropertyResolver serdeProperties, | |
urls, | ||
serdeProperties.getProperty("username", String.class).orElse(null), | ||
serdeProperties.getProperty("password", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
serdeProperties.getProperty("keystoreLocation", String.class).orElse(null), | ||
serdeProperties.getProperty("keystorePassword", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststoreLocation", String.class).orElse(null), | ||
kafkaClusterProperties.getProperty("ssl.truststorePassword", String.class).orElse(null) | ||
), | ||
kafkaClusterProperties.getProperty("schemaRegistryAuth.bearerAuthCustomProviderClass", String.class) | ||
.orElse(null), | ||
serdeProperties.getProperty("keySchemaNameTemplate", String.class).orElse("%s-key"), | ||
serdeProperties.getProperty("schemaNameTemplate", String.class).orElse("%s-value"), | ||
serdeProperties.getProperty("checkSchemaExistenceForDeserialize", Boolean.class) | ||
|
@@ -119,24 +128,27 @@ public void configure(PropertyResolver serdeProperties, | |
void configure( | ||
List<String> schemaRegistryUrls, | ||
SchemaRegistryClient schemaRegistryClient, | ||
String bearerAuthCustomProviderClass, | ||
String keySchemaNameTemplate, | ||
String valueSchemaNameTemplate, | ||
boolean checkTopicSchemaExistenceForDeserialize) { | ||
this.schemaRegistryUrls = schemaRegistryUrls; | ||
this.schemaRegistryClient = schemaRegistryClient; | ||
this.keySchemaNameTemplate = keySchemaNameTemplate; | ||
this.valueSchemaNameTemplate = valueSchemaNameTemplate; | ||
this.schemaRegistryFormatters = MessageFormatter.createMap(schemaRegistryClient); | ||
this.schemaRegistryFormatters = MessageFormatter.createMap(schemaRegistryClient, bearerAuthCustomProviderClass); | ||
this.checkSchemaExistenceForDeserialize = checkTopicSchemaExistenceForDeserialize; | ||
} | ||
|
||
private static SchemaRegistryClient createSchemaRegistryClient(List<String> urls, | ||
@Nullable String username, | ||
@Nullable String password, | ||
@Nullable String bearerAuthCustomProviderClass, | ||
@Nullable String keyStoreLocation, | ||
@Nullable String keyStorePassword, | ||
@Nullable String trustStoreLocation, | ||
@Nullable String trustStorePassword) { | ||
@Nullable String trustStorePassword | ||
) { | ||
Map<String, String> configs = new HashMap<>(); | ||
if (username != null && password != null) { | ||
configs.put(BASIC_AUTH_CREDENTIALS_SOURCE, "USER_INFO"); | ||
|
@@ -166,6 +178,11 @@ private static SchemaRegistryClient createSchemaRegistryClient(List<String> urls | |
keyStorePassword); | ||
} | ||
|
||
if (bearerAuthCustomProviderClass != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this called a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use this to reference this class. And I changed the bearer token implementation for the WebClient using this class too. Sorry 🙏 . |
||
configs.put(SchemaRegistryClientConfig.BEARER_AUTH_CREDENTIALS_SOURCE, CUSTOM_BEARER_AUTH_CREDENTIALS_SOURCE); | ||
configs.put(SchemaRegistryClientConfig.BEARER_AUTH_CUSTOM_PROVIDER_CLASS, bearerAuthCustomProviderClass); | ||
} | ||
|
||
return new CachedSchemaRegistryClient( | ||
urls, | ||
1_000, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,8 +381,13 @@ components: | |
properties: | ||
compatibilityLevel: | ||
$ref: '#/components/schemas/Compatibility' | ||
required: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why has compatibility become no longer required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to change it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I finally added a new compatibilityConfigGcp schema detached from the existent compatibilityConfig. And I had to modify code in SchemaRegistryService class. If this new modification is not ok then please let me know if you have any recommendation about how to address this as the only alternative I can think of is to add a new kafka-gcp-sr-api and a new GcpSchemaRegistryService class. |
||
- compatibilityLevel | ||
# GCP Managed Kafka Schema registries specific fields | ||
alias: | ||
type: string | ||
compatibility: | ||
$ref: '#/components/schemas/Compatibility' | ||
normalize: | ||
type: boolean | ||
|
||
CompatibilityLevelChange: | ||
type: object | ||
|
Uh oh!
There was an error while loading. Please reload this page.