Skip to content

Commit

Permalink
validate deprecated configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsomora committed Oct 27, 2023
1 parent bfc4a32 commit 2a7efed
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
19 changes: 18 additions & 1 deletion extensions/log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,21 @@ This group of the extension contains several interceptors implementation and uti

* [cdi](cdi) - Quarkus extension for CDI method logging(business method start/stop logging).
* [rs](rs) - Quarkus extension for HTTP request logging (client & server).
* [json](json) - Custom JSON log formatter that provides additional features
* [json](json) - Custom JSON log formatter that provides additional features


Migration configration from old tkit library

| old quarkus.tkit config | new tkit config |
|-----------------------------------------|-----------------|
| quarkus.tkit.log.console.json | tkit.log.json.enabled |
| quarkus.tkit.log.console.json.keys.type | tkit.log.json.keys.type |
| quarkus.tkit.log.console.json.keys.mdc | tkit.log.json.keys.mdc |
|quarkus.tkit.log.console.json.keys.ignore| tkit.log.json.keys.ignore|
|quarkus.tkit.log.console.json.keys.override| tkit.log.json.keys.override|
|quarkus.tkit.log.console.json.keys.env | tkit.log.json.keys.env|
|quarkus.tkit.log.console.json.keys.group| tkit.log.json.keys.group|
|quarkus.tkit.log.customdata.prefix | tkit.log.cdi.custom-data.prefix|
|quarkus.tkit.log.ignore.pattern | tkit.log.cdi.auto-discovery.ignore.pattern|
|quarkus.tkit.log.mdc.errorKey | tkit.log.cdi.mdc.errorKey|
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Singleton;

import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.jandex.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -29,6 +31,7 @@
import io.quarkus.arc.processor.BuildExtension;
import io.quarkus.deployment.annotations.*;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.ConfigPropertiesBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem;

Expand Down Expand Up @@ -222,6 +225,19 @@ private boolean matchesIgnorePattern(String name) {
});
}

@BuildStep
public ConfigPropertiesBuildItem validateDeprecatedConfiguration() {
Set<String> quarkusTkitConfigNames = StreamSupport
.stream(ConfigProvider.getConfig().getPropertyNames().spliterator(), false)
.filter(s -> s.startsWith("quarkus.tkit")).collect(Collectors.toSet());
if (!quarkusTkitConfigNames.isEmpty()) {
throw new IllegalArgumentException(
"Configuration with prefix quarkus.tkit are deprecated : " + quarkusTkitConfigNames
+ " . You can find new configuration mapping on https://github.com/1000kit/tkit-quarkus/tree/main/extensions/log");
}
return null;
}

private static LogService createLogService(AnnotationInstance annotationInstance) {

return new LogService() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.tkit.quarkus.log.cdi.test;

import io.quarkus.test.QuarkusUnitTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class LogProcessorTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource("deprecated.properties", "application.properties"))
.setExpectedException(IllegalArgumentException.class, true);

@Test
public void testPersistenceAndConfigTest() {
// should not be called, validation of deprecated configuration must fail
Assertions.fail();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quarkus.tkit.log.packages=de.telekom

0 comments on commit 2a7efed

Please sign in to comment.