Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2950ddf
wip: validate subject based on the namespace configuration
Athosone Jun 11, 2025
cd5608d
Polish code and rename classes (Schema>Subject)
Jun 14, 2025
5e68e44
Add constants + spotlessApply
Jun 16, 2025
6ad20d5
Remove methods that hamper introspection + do not test if strategy is…
Jun 18, 2025
f351874
Fix type of strategy config (ValidList -> ValidString)
Jun 18, 2025
7a8e352
Add comments and TODO
Jun 19, 2025
df8f01c
wip: fixing todos
Athosone Jun 19, 2025
e1cc21e
Fix SchemasServiceTest with new subject strategy handling
Jun 19, 2025
4096101
Fix enum error for SubjectNameStrategy
Jun 19, 2025
9c0c62e
change name of field 'name' in Enum (Enum has a default method name).
Jun 19, 2025
ad06e47
Simplify error message when subject name strategy is not respected
Jun 19, 2025
faadad2
Polish code + add test for topic record name strategy
Jun 19, 2025
64296e0
Update a method comment and apply spotlessApply
Jun 19, 2025
1f80892
Fix tests by adding topicValidator to all namespace specs
monitorpattern Jun 19, 2025
b787bbe
Remove deprecated method for invalid schema-resource name
monitorpattern Jun 19, 2025
6733c46
wip
Athosone Jun 19, 2025
e77edb3
Factorize code and homogeneize variable names
monitorpattern Jun 20, 2025
1d8fbc9
Polish the code + spotlessApply
monitorpattern Jun 24, 2025
6a2fe61
Compare subject name including namespace
Athosone Jun 28, 2025
93dee40
Polish the Readme
monitorpattern Jun 30, 2025
ad25d8c
Add an integration test for subject name strategy other than topic name
monitorpattern Jun 30, 2025
4bd6350
Apply spotlessApply task
Athosone Jul 9, 2025
49b4f2b
Fix comments
monitorpattern Jul 18, 2025
f2d1910
Fix topicvalidator comments
Athosone Jul 18, 2025
e93f2e5
Move SchemasSubjectNameValidator into SchemaService
monitorpattern Jul 24, 2025
1ea5eae
Apply spotlessApply
monitorpattern Jul 24, 2025
d437ee3
Refactor signatures of methods that involve schemas
monitorpattern Jul 24, 2025
1ad4d4c
fix: AllArgsConstructor
Athosone Jul 24, 2025
cd22bcf
fix: replace substring by replace :p
Athosone Jul 24, 2025
8d22cd6
fix: add description
Athosone Jul 24, 2025
0c25fc9
fix: refactor validate subject name strategy
Athosone Jul 24, 2025
53d7cb2
fix: remove extractRecordName
Athosone Jul 24, 2025
bcbc9a7
fix: handle key subject name strategies
Athosone Jul 24, 2025
df6747e
fix: fix javadoc
Athosone Jul 24, 2025
fee6a01
Rename tests wIcône xlsx MBO Team Mood.xlsx.r.t naming conventions
monitorpattern Jul 25, 2025
264df67
Rename tests wrt naming conventions WIP
monitorpattern Jul 25, 2025
469126e
fix: extract name, also renamed tests
Athosone Jul 25, 2025
1963921
fix: test from comment review
Athosone Jul 25, 2025
cee4ba8
fix: test with wrong input data
Athosone Jul 27, 2025
e501e71
fix: rolled back extract topic record name to handle union of reference
Athosone Jul 27, 2025
1521080
Some updates
loicgreffier Oct 20, 2025
fa857f3
Fixes before unit tests
loicgreffier Oct 20, 2025
8eaea88
update
loicgreffier Oct 24, 2025
13c0e32
update
loicgreffier Oct 24, 2025
8e58bb4
Run test on CCloud cluster
loicgreffier Oct 24, 2025
5cb1284
Update format
loicgreffier Oct 25, 2025
d3aa8b5
Add server validation for reference fields
loicgreffier Oct 26, 2025
1be2baf
spotless
loicgreffier Oct 26, 2025
b3a3b0f
Do not use the topic property anymore but namespace config instead
loicgreffier Nov 21, 2025
62160c0
Fix unit tests
loicgreffier Nov 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .docker/config/broker/create-user.sh
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions .docker/resources/admin/namespace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ metadata:
spec:
kafkaUser: "user1"
transactionsEnabled: true
subjectNameStrategies:
- "TopicNameStrategy"
- "RecordNameStrategy"
- "TopicRecordNameStrategy"
connectClusters:
- "local"
topicValidator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public enum Permission {
public static class AccessControlEntrySpec {
@NotNull protected AccessControlEntry.ResourceType resourceType;

@NotNull @NotBlank protected String resource;
@NotBlank protected String resource;

@NotNull protected ResourcePatternType resourcePatternType;

@NotNull protected Permission permission;

@NotBlank @NotNull protected String grantedTo;
@NotBlank protected String grantedTo;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/michelin/ns4kafka/model/Namespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static com.michelin.ns4kafka.util.enumation.Kind.NAMESPACE;

import com.michelin.ns4kafka.model.schema.SubjectNameStrategy;
import com.michelin.ns4kafka.validation.ConnectValidator;
import com.michelin.ns4kafka.validation.TopicValidator;
import io.micronaut.core.annotation.Introspected;
Expand Down Expand Up @@ -66,6 +67,9 @@ public static class NamespaceSpec {
@Builder.Default
private boolean transactionsEnabled = true;

@Builder.Default
private List<SubjectNameStrategy> subjectNameStrategies = SubjectNameStrategy.defaultStrategy();

@Builder.Default
private List<String> connectClusters = List.of();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/michelin/ns4kafka/model/RoleBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ public static class Role {
public static class Subject {
@NotNull private SubjectType subjectType;

@NotNull @NotBlank private String subjectName;
@NotBlank private String subjectName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public enum ResetOffsetsMethod {
@NoArgsConstructor
@AllArgsConstructor
public static class ConsumerGroupResetOffsetsSpec {
@NotNull @NotBlank private String topic;
@NotBlank private String topic;

@NotNull private ResetOffsetsMethod method;

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/michelin/ns4kafka/model/schema/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.michelin.ns4kafka.model.MetadataResource;
import io.micronaut.core.annotation.Introspected;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -88,7 +90,7 @@ public static class SchemaSpec {
@Builder.Default
private Compatibility compatibility = Compatibility.GLOBAL;

private List<Reference> references;
@Valid private List<Reference> references;

/** Schema reference. */
@Getter
Expand All @@ -98,9 +100,11 @@ public static class SchemaSpec {
@NoArgsConstructor
@AllArgsConstructor
public static class Reference {
private String name;
private String subject;
private Integer version;
@NotBlank private String name;

@NotBlank private String subject;

@NotNull private Integer version;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.michelin.ns4kafka.model.schema;

import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import java.util.List;
import lombok.AllArgsConstructor;

/** Schema subject naming strategies supported by Schema Registry. */
@AllArgsConstructor
public enum SubjectNameStrategy {
TOPIC_NAME("TopicNameStrategy"),
TOPIC_RECORD_NAME("TopicRecordNameStrategy"),
RECORD_NAME("RecordNameStrategy");

private final String value;

/**
* Convert the SubjectNameStrategy to its string representation.
*
* @return The string representation of the SubjectNameStrategy
*/
@JsonValue
@Override
public String toString() {
return value;
}

/**
* Get the default SubjectNameStrategy.
*
* @return The default SubjectNameStrategy
*/
public static List<SubjectNameStrategy> defaultStrategy() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would defaultStrategies be a better name?

return List.of(TOPIC_NAME);
}

/**
* Get SubjectNameStrategy from its string representation.
*
* @param stringValue The string representation of the SubjectNameStrategy
* @return The SubjectNameStrategy
*/
public static SubjectNameStrategy from(final String stringValue) {
return Arrays.stream(values())
.filter(s -> s.value.equals(stringValue))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Unknown strategy: " + stringValue));
}

/**
* Get the expected format for the subject name based on the strategy.
*
* @return The expected format for the subject name
*/
public String toExpectedFormat() {
return switch (this) {
case TOPIC_NAME -> "{topic}-{key|value}";
case TOPIC_RECORD_NAME -> "{topic}-{recordName}";
case RECORD_NAME -> "{recordName}";
};
}
}
Loading
Loading