diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 6a8a651ff9..c7f7a105ec 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -90,7 +90,7 @@ jobs: docker images - name: Slack Notification (Always) - if: always() + if: github.event_name == 'push' && always() run: | MESSAGE="Registry 'build-verify' job completed with status: ${{ job.status }}" REPO="${{ github.repository }}" @@ -99,7 +99,7 @@ jobs: curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} - name: Slack Notification (Error) - if: failure() + if: github.event_name == 'push' && failure() run: | MESSAGE="Registry 'build-verify' job FAILED" REPO="${{ github.repository }}" @@ -181,7 +181,7 @@ jobs: run: docker buildx build --push -f ./Dockerfile -t quay.io/apicurio/apicurio-registry-ui:latest-snapshot -t docker.io/apicurio/apicurio-registry-ui:latest-snapshot --platform linux/amd64,linux/arm64,linux/s390x,linux/ppc64le . - name: Slack Notification (Always) - if: always() + if: github.event_name == 'push' && always() run: | MESSAGE="Registry 'build-verify-ui' job completed with status: ${{ job.status }}" REPO="${{ github.repository }}" @@ -190,7 +190,7 @@ jobs: curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} - name: Slack Notification (Error) - if: failure() + if: github.event_name == 'push' && failure() run: | MESSAGE="Registry 'build-verify-ui' job FAILED" REPO="${{ github.repository }}" @@ -287,7 +287,7 @@ jobs: run: docker images - name: Slack Notification (Always) - if: always() + if: github.event_name == 'push' && always() run: | MESSAGE="Registry 'build-native-images' job completed with status: ${{ job.status }}" REPO="${{ github.repository }}" @@ -296,7 +296,7 @@ jobs: curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} - name: Slack Notification (Error) - if: failure() + if: github.event_name == 'push' && failure() run: | MESSAGE="Registry 'build-native-images' job FAILED" REPO="${{ github.repository }}" @@ -342,7 +342,7 @@ jobs: run: make test - name: Slack Notification (Always) - if: always() + if: github.event_name == 'push' && always() run: | MESSAGE="Registry 'build-verify-python-sdk' job completed with status: ${{ job.status }}" REPO="${{ github.repository }}" @@ -351,7 +351,7 @@ jobs: curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} - name: Slack Notification (Error) - if: failure() + if: github.event_name == 'push' && failure() run: | MESSAGE="Registry 'build-verify-python-sdk' job FAILED" REPO="${{ github.repository }}" @@ -387,7 +387,7 @@ jobs: run: make test - name: Slack Notification (Always) - if: always() + if: github.event_name == 'push' && always() run: | MESSAGE="Registry 'build-verify-go-sdk' job completed with status: ${{ job.status }}" REPO="${{ github.repository }}" @@ -396,7 +396,7 @@ jobs: curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} - name: Slack Notification (Error) - if: failure() + if: github.event_name == 'push' && failure() run: | MESSAGE="Registry 'build-verify-go-sdk' job FAILED" REPO="${{ github.repository }}" diff --git a/pom.xml b/pom.xml index 658d6cd9f3..4201e7859c 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,6 @@ utils/converter utils/kafka utils/maven-plugin - utils/tools utils/importexport utils/exportConfluent utils/protobuf-schema-utilities @@ -166,7 +165,7 @@ 4.12.0 3.9.1 3.9.1 - 3.9.1 + 3.10.2 76.1 3.25.5 4.0.3 @@ -213,7 +212,6 @@ 1.18.36 1.17.1 - 1.2.1.Final 0.1.18.Final 3.6.0 2.6.2.Final @@ -269,7 +267,7 @@ 1.8.2 - 0.0.19 + 0.0.20 1.21.0 60 diff --git a/schema-resolver/src/main/java/io/apicurio/registry/resolver/AbstractSchemaResolver.java b/schema-resolver/src/main/java/io/apicurio/registry/resolver/AbstractSchemaResolver.java index f4063dcafb..42dbf07db8 100644 --- a/schema-resolver/src/main/java/io/apicurio/registry/resolver/AbstractSchemaResolver.java +++ b/schema-resolver/src/main/java/io/apicurio/registry/resolver/AbstractSchemaResolver.java @@ -42,15 +42,20 @@ public abstract class AbstractSchemaResolver implements SchemaResolver configs, SchemaParser schemaParser) { this.schemaParser = schemaParser; - if (this.vertx == null) { - this.vertx = Vertx.vertx(); + if (vertx != null) { + internalReference = vertx; + } + + if (internalReference == null) { + internalReference = Vertx.vertx(); } this.config = new SchemaResolverConfig(configs); @@ -72,7 +77,7 @@ public void configure(Map configs, SchemaParser schemaParser) { if (username != null) { client = configureClientWithBasicAuth(config, baseUrl, username); } else { - var adapter = new VertXRequestAdapter(this.vertx); + var adapter = new VertXRequestAdapter(internalReference); adapter.setBaseUrl(baseUrl); client = new RegistryClient(adapter); } @@ -275,8 +280,12 @@ public void reset() { */ @Override public void close() throws IOException { - if (this.vertx != null) { - this.vertx.close(); + if (internalReference != null) { + if (vertx == null) { + internalReference.close(); + } else { + vertx = null; + } } } @@ -304,7 +313,7 @@ private RequestAdapter configureAuthWithUrl(SchemaResolverConfig config, String final String clientScope = config.getAuthClientScope(); return new VertXRequestAdapter( - buildOIDCWebClient(this.vertx, tokenEndpoint, clientId, clientSecret, clientScope)); + buildOIDCWebClient(internalReference, tokenEndpoint, clientId, clientSecret, clientScope)); } private RegistryClient configureClientWithBasicAuth(SchemaResolverConfig config, String registryUrl, @@ -317,7 +326,8 @@ private RegistryClient configureClientWithBasicAuth(SchemaResolverConfig config, "Missing registry auth password, set " + SchemaResolverConfig.AUTH_PASSWORD); } - var adapter = new VertXRequestAdapter(buildSimpleAuthWebClient(this.vertx, username, password)); + var adapter = new VertXRequestAdapter( + buildSimpleAuthWebClient(internalReference, username, password)); adapter.setBaseUrl(registryUrl); return new RegistryClient(adapter); @@ -340,4 +350,8 @@ protected void loadFromSearchedVersion(SearchedVersion version, resultBuilder.artifactId(version.getArtifactId()); resultBuilder.version(String.valueOf(version.getVersion())); } + + public static void setVertx(Vertx vertx) { + AbstractSchemaResolver.vertx = vertx; + } } diff --git a/schema-util/common/pom.xml b/schema-util/common/pom.xml index d372886726..c6a9e77690 100644 --- a/schema-util/common/pom.xml +++ b/schema-util/common/pom.xml @@ -71,12 +71,6 @@ slf4j-api - - org.jboss.slf4j - slf4j-jboss-logging - ${jboss-slf4j.version} - - com.fasterxml.jackson.datatype jackson-datatype-json-org diff --git a/serdes/generic/serde-common/pom.xml b/serdes/generic/serde-common/pom.xml index a4bcddf16c..c390d8da80 100644 --- a/serdes/generic/serde-common/pom.xml +++ b/serdes/generic/serde-common/pom.xml @@ -27,12 +27,6 @@ slf4j-api - - org.jboss.slf4j - slf4j-jboss-logging - ${jboss-slf4j.version} - - org.junit.jupiter junit-jupiter diff --git a/serdes/kafka/serde-kafka-common/pom.xml b/serdes/kafka/serde-kafka-common/pom.xml index 86f804f9e5..c9a9ba01cb 100644 --- a/serdes/kafka/serde-kafka-common/pom.xml +++ b/serdes/kafka/serde-kafka-common/pom.xml @@ -28,12 +28,6 @@ slf4j-api - - org.jboss.slf4j - slf4j-jboss-logging - ${jboss-slf4j.version} - - org.apache.kafka kafka-clients diff --git a/utils/kafka/pom.xml b/utils/kafka/pom.xml index 79ca4ee46c..f91a1d437c 100644 --- a/utils/kafka/pom.xml +++ b/utils/kafka/pom.xml @@ -31,11 +31,7 @@ org.slf4j slf4j-api - - org.jboss.slf4j - slf4j-jboss-logging - ${jboss-slf4j.version} - + io.quarkus quarkus-test-common diff --git a/utils/tools/pom.xml b/utils/tools/pom.xml deleted file mode 100644 index 16cb757174..0000000000 --- a/utils/tools/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - io.apicurio - apicurio-registry - 3.0.7-SNAPSHOT - ../../pom.xml - - - apicurio-registry-utils-tools - jar - apicurio-registry-utils-tools - - - ${project.basedir}/../.. - - - - - - io.apicurio - apicurio-data-models - - - - org.apache.kafka - kafka-streams - - - - commons-io - commons-io - - - - org.jboss.slf4j - slf4j-jboss-logging - ${jboss-slf4j.version} - - - - org.junit.jupiter - junit-jupiter-api - test - - - - diff --git a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/AddOpenApiAuth.java b/utils/tools/src/main/java/io/apicurio/registry/utils/tools/AddOpenApiAuth.java deleted file mode 100644 index 626a24a5b4..0000000000 --- a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/AddOpenApiAuth.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.apicurio.registry.utils.tools; - -import io.apicurio.datamodels.Library; -import io.apicurio.datamodels.models.openapi.v30.OpenApi30Document; -import io.apicurio.datamodels.models.openapi.v30.OpenApi30SecurityRequirement; -import io.apicurio.datamodels.models.openapi.v30.OpenApi30SecurityScheme; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.nio.charset.StandardCharsets; -import java.util.Collections; - -public class AddOpenApiAuth { - - public static void main(String[] args) throws Exception { - if (args.length != 2) { - System.out.println("Usage: AddOpenApiAuth "); - System.exit(1); - } - File inputFile = new File(args[0]); - File outputFile = new File(args[1]); - - if (!inputFile.isFile()) { - System.out.println("File not found: " + inputFile.getAbsolutePath()); - System.exit(1); - } - - System.out.println("Loading input file from: " + inputFile.getAbsolutePath()); - - // Read the input file - String inputDocumentString; - try (FileInputStream fis = new FileInputStream(inputFile)) { - inputDocumentString = IOUtils.toString(fis, StandardCharsets.UTF_8); - } - - System.out.println("Adding security scheme and requirement."); - - // Read the source openapi document. - OpenApi30Document document = (OpenApi30Document) Library - .readDocumentFromJSONString(inputDocumentString); - - // Create a security scheme for basic auth - OpenApi30SecurityScheme securityScheme = (OpenApi30SecurityScheme) document.getComponents() - .createSecurityScheme(); - securityScheme.setType("http"); - securityScheme.setScheme("basic"); - document.getComponents().addSecurityScheme("basicAuth", securityScheme); - - // And now *use* the basic auth security scheme. - OpenApi30SecurityRequirement securityRequirement = (OpenApi30SecurityRequirement) document - .createSecurityRequirement(); - securityRequirement.addItem("basicAuth", Collections.emptyList()); - document.addSecurity(securityRequirement); - - // Now write out the modified document - String outputDocumentString = Library.writeDocumentToJSONString(document); - - System.out.println("Writing modified document to: " + outputFile.getAbsolutePath()); - - // Write the output to a file - FileUtils.writeStringToFile(outputFile, outputDocumentString, StandardCharsets.UTF_8); - } - -} diff --git a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/TransformOpenApiForClientGen.java b/utils/tools/src/main/java/io/apicurio/registry/utils/tools/TransformOpenApiForClientGen.java deleted file mode 100644 index 552cec3d51..0000000000 --- a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/TransformOpenApiForClientGen.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.apicurio.registry.utils.tools; - -import io.apicurio.datamodels.Library; -import io.apicurio.datamodels.models.Extensible; -import io.apicurio.datamodels.models.openapi.OpenApiOperation; -import io.apicurio.datamodels.models.openapi.v30.OpenApi30Document; -import io.apicurio.datamodels.models.openapi.v30.OpenApi30Schema; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.nio.charset.StandardCharsets; -import java.util.stream.Collectors; - -import static java.lang.System.out; - -/** - * - */ -public class TransformOpenApiForClientGen { - - public static void main(String[] args) throws Exception { - if (args.length != 2) { - out.println("Usage: TransformOpenApiForClientGen "); - System.exit(1); - } - File inputFile = new File(args[0]); - File outputFile = new File(args[1]); - - if (!inputFile.isFile()) { - out.println("File not found: " + inputFile.getAbsolutePath()); - System.exit(1); - } - - out.println("Loading input file from: " + inputFile.getAbsolutePath()); - - // Read the input file - String inputDocumentString; - try (FileInputStream fis = new FileInputStream(inputFile)) { - inputDocumentString = IOUtils.toString(fis, StandardCharsets.UTF_8); - } - - // Read the source openapi document. - OpenApi30Document document = (OpenApi30Document) Library - .readDocumentFromJSONString(inputDocumentString); - - attachHeaderSchema(document.getPaths().getItem("/groups/{groupId}/artifacts/{artifactId}").getPut(), - "/groups/{groupId}/artifacts/{artifactId} PUT"); - attachHeaderSchema(document.getPaths().getItem("/groups/{groupId}/artifacts").getPost(), - "/groups/{groupId}/artifacts POST"); - attachHeaderSchema( - document.getPaths().getItem("/groups/{groupId}/artifacts/{artifactId}/versions").getPost(), - "/groups/{groupId}/artifacts/{artifactId}/versions POST"); - - // Remove duplicated tags - document.getPaths().getItem("/admin/artifactTypes").getGet().getTags().remove("Artifact Type"); - - document.getPaths().getItem("/admin/rules").getGet().getTags().remove("Global rules"); - document.getPaths().getItem("/admin/rules").getPost().getTags().remove("Global rules"); - document.getPaths().getItem("/admin/rules").getDelete().getTags().remove("Global rules"); - - document.getPaths().getItem("/admin/rules/{rule}").getGet().getTags().remove("Global rules"); - document.getPaths().getItem("/admin/rules/{rule}").getPut().getTags().remove("Global rules"); - document.getPaths().getItem("/admin/rules/{rule}").getDelete().getTags().remove("Global rules"); - - document.getPaths().getItem("/search/artifacts").getGet().getTags().remove("Artifacts"); - document.getPaths().getItem("/search/artifacts").getPost().getTags().remove("Artifacts"); - - document.getTags().stream().filter(t -> !"Global rules".equals(t.getName())) - .collect(Collectors.toList()).forEach(tag -> document.removeTag(tag)); - - Extensible extensiblePaths = (Extensible) document.getPaths(); - extensiblePaths.removeExtension("x-codegen-contextRoot"); - - // Now write out the modified document - String outputDocumentString = Library.writeDocumentToJSONString(document); - - out.println("Writing modified document to: " + outputFile.getAbsolutePath()); - - // Write the output to a file - FileUtils.writeStringToFile(outputFile, outputDocumentString, StandardCharsets.UTF_8); - } - - private static void attachHeaderSchema(OpenApiOperation operation, String info) { - out.println("Adding explicit Content-Type header to " + info); - var param = operation.createParameter(); - param.setName("Content-Type"); - param.setDescription( - "This header is explicit so clients using the OpenAPI Generator are able select the content type. Ignore otherwise."); - var schema = (OpenApi30Schema) param.createSchema(); - schema.setType("string"); - param.setSchema(schema); - param.setIn("header"); - operation.addParameter(param); - } -} diff --git a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/Transformer.java b/utils/tools/src/main/java/io/apicurio/registry/utils/tools/Transformer.java deleted file mode 100644 index 21137b8303..0000000000 --- a/utils/tools/src/main/java/io/apicurio/registry/utils/tools/Transformer.java +++ /dev/null @@ -1,112 +0,0 @@ -package io.apicurio.registry.utils.tools; - -import org.apache.kafka.common.serialization.Serdes; -import org.apache.kafka.streams.KafkaStreams; -import org.apache.kafka.streams.StreamsBuilder; -import org.apache.kafka.streams.StreamsConfig; -import org.apache.kafka.streams.Topology; -import org.apache.kafka.streams.kstream.Consumed; -import org.apache.kafka.streams.kstream.KStream; -import org.apache.kafka.streams.kstream.Produced; -import org.apache.kafka.streams.kstream.ValueTransformer; -import org.apache.kafka.streams.processor.ProcessorContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.ByteBuffer; -import java.util.Properties; -import java.util.function.Function; - -/** - * Transform messages between Confluent and Apicurio format. To start from input topic's beginning, use this - * config * auto.offset.reset=earliest / ConsumerConfig.AUTO_OFFSET_RESET_CONFIG - */ -public class Transformer { - private static final Logger log = LoggerFactory.getLogger(Transformer.class); - - enum Type implements Function { - CONFLUENT_TO_APICURIO(bytes -> { - ByteBuffer input = ByteBuffer.wrap(bytes); - ByteBuffer output = ByteBuffer.allocate(bytes.length + 4); // 4more due to long - output.put(input.get()); // magic - output.putLong(input.getInt()); - output.put(input); - return output.array(); - }), APICURIO_TO_CONFLUENT(bytes -> { - ByteBuffer input = ByteBuffer.wrap(bytes); - ByteBuffer output = ByteBuffer.allocate(bytes.length - 4); // 4more less to int - output.put(input.get()); // magic - output.putInt((int) input.getLong()); - output.put(input); - return output.array(); - }); - - private Function fn; - - Type(Function fn) { - this.fn = fn; - } - - @Override - public byte[] apply(byte[] bytes) { - return fn.apply(bytes); - } - } - - public static void main(String[] args) { - Properties properties = new Properties(); - for (String arg : args) { - String[] split = arg.split("="); - properties.put(split[0], split[1]); - } - - String appId = properties.getProperty(StreamsConfig.APPLICATION_ID_CONFIG); - if (appId == null) { - properties.put(StreamsConfig.APPLICATION_ID_CONFIG, "apicurio-registry-transformer"); - } - - String inputTopic = properties.getProperty("input-topic"); - if (inputTopic == null) { - throw new IllegalArgumentException("Missing input topic!"); - } - - String outputTopic = properties.getProperty("output-topic"); - if (outputTopic == null) { - throw new IllegalArgumentException("Missing output topic!"); - } - - String fnType = properties.getProperty("type"); - if (fnType == null) { - throw new IllegalArgumentException("Missing transformation type!"); - } - Type type = Type.valueOf(fnType); - - log.info(String.format("Transforming: %s --> %s [%s]", inputTopic, outputTopic, type)); - - StreamsBuilder builder = new StreamsBuilder(); - KStream input = builder.stream(inputTopic, - Consumed.with(Serdes.String(), Serdes.ByteArray())); - - input.transformValues(() -> new ValueTransformer() { - @Override - public void init(ProcessorContext context) { - } - - @Override - public byte[] transform(byte[] value) { - return type.apply(value); - } - - @Override - public void close() { - } - }).to(outputTopic, Produced.with(Serdes.String(), Serdes.ByteArray())); - - Topology topology = builder.build(properties); - KafkaStreams streams = new KafkaStreams(topology, properties); - - Runtime.getRuntime().addShutdownHook(new Thread(streams::close)); - - streams.start(); - } -} diff --git a/utils/tools/src/test/java/io/apicurio/registry/utils/tools/TransformerTest.java b/utils/tools/src/test/java/io/apicurio/registry/utils/tools/TransformerTest.java deleted file mode 100644 index 79d8110799..0000000000 --- a/utils/tools/src/test/java/io/apicurio/registry/utils/tools/TransformerTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.apicurio.registry.utils.tools; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.nio.ByteBuffer; -import java.util.concurrent.ThreadLocalRandom; - -public class TransformerTest { - - @Test - public void testType() { - ByteBuffer buffer = ByteBuffer.allocate(30); - buffer.put((byte) 0x0); - buffer.putInt(42); - byte[] bytes = new byte[25]; - ThreadLocalRandom.current().nextBytes(bytes); - buffer.put(bytes); - - byte[] input = buffer.array(); - byte[] output = Transformer.Type.CONFLUENT_TO_APICURIO.apply(input); - byte[] copy = Transformer.Type.APICURIO_TO_CONFLUENT.apply(output); - Assertions.assertArrayEquals(input, copy); - - buffer = ByteBuffer.allocate(30); - buffer.put((byte) 0x0); - buffer.putLong(42L); - bytes = new byte[21]; - ThreadLocalRandom.current().nextBytes(bytes); - buffer.put(bytes); - - input = buffer.array(); - output = Transformer.Type.APICURIO_TO_CONFLUENT.apply(input); - copy = Transformer.Type.CONFLUENT_TO_APICURIO.apply(output); - Assertions.assertArrayEquals(input, copy); - } -}