This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch hashicorp-vault in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit b0743869035719abaed9394feb8e9c59ea2b40ac Author: Andrea Cosentino <[email protected]> AuthorDate: Thu Jul 21 10:22:39 2022 +0200 Added Hashicorp Vault Camel Quarkus Extension --- extensions-jvm/hashicorp-vault/deployment/pom.xml | 63 +++++++++++++ .../vault/deployment/HashicorpVaultProcessor.java | 46 ++++++++++ extensions-jvm/hashicorp-vault/pom.xml | 39 ++++++++ extensions-jvm/hashicorp-vault/runtime/pom.xml | 100 +++++++++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 32 +++++++ extensions-jvm/pom.xml | 1 + integration-tests-jvm/hashicorp-vault/pom.xml | 84 +++++++++++++++++ .../hashicorp/vault/it/HashicorpVaultResource.java | 55 ++++++++++++ .../hashicorp/vault/it/HashicorpVaultTest.java | 37 ++++++++ integration-tests-jvm/pom.xml | 1 + poms/bom/pom.xml | 15 ++++ 11 files changed, 473 insertions(+) diff --git a/extensions-jvm/hashicorp-vault/deployment/pom.xml b/extensions-jvm/hashicorp-vault/deployment/pom.xml new file mode 100644 index 0000000000..30271794a6 --- /dev/null +++ b/extensions-jvm/hashicorp-vault/deployment/pom.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault-parent</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hashicorp-vault-deployment</artifactId> + <name>Camel Quarkus :: Hashicorp Vault :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions-jvm/hashicorp-vault/deployment/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/deployment/HashicorpVaultProcessor.java b/extensions-jvm/hashicorp-vault/deployment/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/deployment/HashicorpVaultProcessor.java new file mode 100644 index 0000000000..70e60bb05f --- /dev/null +++ b/extensions-jvm/hashicorp-vault/deployment/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/deployment/HashicorpVaultProcessor.java @@ -0,0 +1,46 @@ +/* + * 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 org.apache.camel.quarkus.component.hashicorp.vault.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.pkg.steps.NativeBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class HashicorpVaultProcessor { + + private static final Logger LOG = Logger.getLogger(HashicorpVaultProcessor.class); + private static final String FEATURE = "camel-hashicorp-vault"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/hashicorp-vault/pom.xml b/extensions-jvm/hashicorp-vault/pom.xml new file mode 100644 index 0000000000..c82611bea1 --- /dev/null +++ b/extensions-jvm/hashicorp-vault/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-extensions-jvm</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hashicorp-vault-parent</artifactId> + <name>Camel Quarkus :: Hashicorp Vault</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions-jvm/hashicorp-vault/runtime/pom.xml b/extensions-jvm/hashicorp-vault/runtime/pom.xml new file mode 100644 index 0000000000..fdafcda677 --- /dev/null +++ b/extensions-jvm/hashicorp-vault/runtime/pom.xml @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault-parent</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-hashicorp-vault</artifactId> + <name>Camel Quarkus :: Hashicorp Vault :: Runtime</name> + <description>Manage secrets in Hashicorp Vault Service</description> + + <properties> + <camel.quarkus.jvmSince>2.11.0</camel.quarkus.jvmSince> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-hashicorp-vault</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals> + <goal>update-extension-doc-page</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions-jvm/hashicorp-vault/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/hashicorp-vault/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..05c0b7653d --- /dev/null +++ b/extensions-jvm/hashicorp-vault/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel Hashicorp Vault" +description: "Manage secrets in Hashicorp Vault Service" +metadata: + unlisted: true + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/hashicorp-vault.html" + categories: + - "integration" + status: + - "preview" diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 9062895964..3bb2e66992 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -68,6 +68,7 @@ <module>groovy</module> <module>groovy-dsl</module> <module>guava-eventbus</module> + <module>hashicorp-vault</module> <module>hbase</module> <module>hdfs</module> <module>huaweicloud-smn</module> diff --git a/integration-tests-jvm/hashicorp-vault/pom.xml b/integration-tests-jvm/hashicorp-vault/pom.xml new file mode 100644 index 0000000000..d01a28d227 --- /dev/null +++ b/integration-tests-jvm/hashicorp-vault/pom.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent-it</artifactId> + <version>2.11.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-hashicorp-vault</artifactId> + <name>Camel Quarkus :: Integration Tests :: Hashicorp Vault</name> + <description>Integration tests for Camel Quarkus Hashicorp Vault extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> +</project> diff --git a/integration-tests-jvm/hashicorp-vault/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultResource.java b/integration-tests-jvm/hashicorp-vault/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultResource.java new file mode 100644 index 0000000000..4ba8b63d3e --- /dev/null +++ b/integration-tests-jvm/hashicorp-vault/src/main/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultResource.java @@ -0,0 +1,55 @@ +/* + * 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 org.apache.camel.quarkus.component.hashicorp.vault.it; + +import java.net.URI; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.CamelContext; +import org.jboss.logging.Logger; + +@Path("/hashicorp-vault") +@ApplicationScoped +public class HashicorpVaultResource { + + private static final Logger LOG = Logger.getLogger(HashicorpVaultResource.class); + + private static final String COMPONENT_HASHICORP_VAULT = "hashicorp-vault"; + @Inject + CamelContext context; + + @Path("/load/component/hashicorp-vault") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response loadComponentHashicorpVault() throws Exception { + /* This is an autogenerated test */ + if (context.getComponent(COMPONENT_HASHICORP_VAULT) != null) { + return Response.ok().build(); + } + LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_HASHICORP_VAULT); + return Response.status(500, COMPONENT_HASHICORP_VAULT + " could not be loaded from the Camel context").build(); + } +} diff --git a/integration-tests-jvm/hashicorp-vault/src/test/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultTest.java b/integration-tests-jvm/hashicorp-vault/src/test/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultTest.java new file mode 100644 index 0000000000..c9c221afc7 --- /dev/null +++ b/integration-tests-jvm/hashicorp-vault/src/test/java/org/apache/camel/quarkus/component/hashicorp/vault/it/HashicorpVaultTest.java @@ -0,0 +1,37 @@ +/* + * 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 org.apache.camel.quarkus.component.hashicorp.vault.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class HashicorpVaultTest { + + @Test + public void loadComponentHashicorpVault() { + /* A simple autogenerated test */ + RestAssured.get("/hashicorp-vault/load/component/hashicorp-vault") + .then() + .statusCode(200); + } + +} diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml index 6adc9d1725..49b333c147 100644 --- a/integration-tests-jvm/pom.xml +++ b/integration-tests-jvm/pom.xml @@ -66,6 +66,7 @@ <module>groovy</module> <module>groovy-dsl</module> <module>guava-eventbus</module> + <module>hashicorp-vault</module> <module>hbase</module> <module>hdfs</module> <module>huaweicloud-smn</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index b8a0613b09..1e9556361e 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -2657,6 +2657,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-hashicorp-vault</artifactId> + <version>${camel.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-hazelcast</artifactId> @@ -7154,6 +7159,16 @@ <artifactId>camel-quarkus-guava-eventbus-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-hashicorp-vault-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-hazelcast</artifactId>
