Skip to content

Commit

Permalink
fix: restore S3Presigner bean production behavior (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
scrocquesel authored Oct 26, 2024
1 parent 2caa60b commit 899fd73
Show file tree
Hide file tree
Showing 56 changed files with 1,376 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:quarkus-version: 3.15.1
:quarkus-version: 3.16.0
:quarkus-amazon-services-version: 2.18.1
:maven-version: 3.8.1+

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-cloudwatch.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-cloudwatchlogs.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
:summaryTableId: quarkus-amazon-dynamodb-enhanced_quarkus-dynamodbenhanced
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
Expand Down Expand Up @@ -46,5 +45,3 @@ endif::add-copy-button-to-env-var[]

|===


:!summaryTableId:
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
:summaryTableId: quarkus-amazon-dynamodb-enhanced_quarkus-dynamodbenhanced
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
Expand Down Expand Up @@ -46,5 +45,3 @@ endif::add-copy-button-to-env-var[]

|===


:!summaryTableId:
55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-dynamodb.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-ecr.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-eventbridge.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-iam.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-inspector.adoc

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-inspector2.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-kinesis.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-kms.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-lambda.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

72 changes: 43 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-s3.adoc

Large diffs are not rendered by default.

72 changes: 43 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-s3_quarkus.s3.adoc

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-secretsmanager.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-ses.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-sfn.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-sns.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-sqs.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-ssm.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 26 additions & 29 deletions docs/modules/ROOT/pages/includes/quarkus-amazon-sts.adoc

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
:summaryTableId: quarkus-amazon_quarkus-aws
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
Expand Down Expand Up @@ -237,5 +236,3 @@ endif::add-copy-button-to-env-var[]

|===


:!summaryTableId:
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
:summaryTableId: quarkus-amazon_quarkus-otel
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
Expand Down Expand Up @@ -95,5 +94,3 @@ endif::add-copy-button-to-env-var[]

|===


:!summaryTableId:
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkus.amazon.s3.deployment;

import org.jboss.jandex.DotName;

import io.quarkus.amazon.common.deployment.RequireAmazonClientInjectionBuildItem;
import io.quarkus.amazon.common.runtime.ClientUtil;
import io.quarkus.amazon.s3.runtime.S3PresignerBuildTimeConfig;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

/**
* This processor ensures backward compatibility for applications using `S3Presigner`, such as `camel-quarkus-aws2-s3`.
* Previously, `S3Presigner` was produced even when no injection points were discovered.
* With support for multiple named clients, `S3Presigner` beans are now produced in the same way as other clients.
*/
public class S3PresignerProcessor {

S3PresignerBuildTimeConfig buildTimeConfig;

protected DotName presignerClientName() {
return DotName.createSimple(S3Presigner.class.getName());
}

@BuildStep
void setup(CombinedIndexBuildItem combinedIndexBuildItem,
BuildProducer<RequireAmazonClientInjectionBuildItem> requireClientInjectionProducer) {

if (buildTimeConfig.unremovableS3PresignerBean()) {
requireClientInjectionProducer
.produce(new RequireAmazonClientInjectionBuildItem(presignerClientName(), ClientUtil.DEFAULT_CLIENT_NAME));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.amazon.s3.deployment;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

public class S3PresignerConfigTest {

@Inject
Instance<S3Client> client;

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource("sync-urlconn-full-config.properties", "application.properties"));

@Test
public void test() {
assertNotNull(client.get());
assertNotNull(CDI.current().select(S3Presigner.class).get());
// should finish with success
client.get().close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.amazon.s3.deployment;

import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

public class S3PresignerDisabledConfigTest {

@Inject
Instance<S3Client> client;

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource("s3presigner-disabled.properties", "application.properties"));

@Test
public void test() {
assertNotNull(client.get());
assertFalse(CDI.current().select(S3Presigner.class).isResolvable());
// should finish with success
client.get().close();
}
}
21 changes: 21 additions & 0 deletions s3/deployment/src/test/resources/s3presigner-disabled.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
quarkus.s3.accelerate-mode=false
quarkus.s3.checksum-validation=true
quarkus.s3.chunked-encoding=true
quarkus.s3.dualstack=false
quarkus.s3.path-style-access=false
quarkus.s3.use-arn-region-enabled=true
#quarkus.s3.profile-name=foo

quarkus.s3.endpoint-override=http://localhost:9090

quarkus.s3.aws.region=us-east-2
quarkus.s3.aws.credentials.type=static
quarkus.s3.aws.credentials.static-provider.access-key-id=test-key
quarkus.s3.aws.credentials.static-provider.secret-access-key=test-secret

quarkus.s3.sync-client.type = url
quarkus.s3.sync-client.connection-timeout = 0.100S
quarkus.s3.sync-client.socket-timeout = 0.100S


quarkus.s3.unremovable-s3-presigner-bean=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.amazon.s3.runtime;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* Amazon S3 build time configuration
*/
@ConfigMapping(prefix = "quarkus.s3")
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
public interface S3PresignerBuildTimeConfig {

/**
* When `true`, a `S3Presigner` default bean is produced even if no injection points are discovered.
*
* Note: The default value ensures backward compatibility; you can disable it. It will be removed in the next major version.
*/
@WithDefault(value = "true")
boolean unremovableS3PresignerBean();
}

0 comments on commit 899fd73

Please sign in to comment.