-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
destination-s3: convert prod code to kotlin (#40574)
## What <!-- * Describe what the change is solving. Link all GitHub issues related to this change. --> ## How <!-- * Describe how code changes achieve the solution. --> ## Review guide <!-- 1. `x.py` 2. `y.py` --> ## User Impact <!-- * What is the end result perceived by the user? * If there are negative side effects, please list them. --> ## Can this PR be safely reverted and rolled back? <!-- * If unsure, leave it blank. --> - [ ] YES 💚 - [ ] NO ❌
- Loading branch information
1 parent
a88d9e8
commit 4b3d780
Showing
8 changed files
with
84 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...rs/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3Destination.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...tination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationRunner.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
...n-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationStrictEncrypt.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...rs/destination-s3/src/main/kotlin/io/airbyte/integrations/destination/s3/S3Destination.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
package io.airbyte.integrations.destination.s3 | ||
|
||
import com.google.common.annotations.VisibleForTesting | ||
import io.airbyte.cdk.integrations.base.IntegrationRunner | ||
import io.airbyte.cdk.integrations.destination.s3.BaseS3Destination | ||
import io.airbyte.cdk.integrations.destination.s3.S3DestinationConfigFactory | ||
import io.airbyte.cdk.integrations.destination.s3.StorageProvider | ||
|
||
open class S3Destination : BaseS3Destination { | ||
constructor() | ||
|
||
@VisibleForTesting | ||
constructor( | ||
s3DestinationConfigFactory: S3DestinationConfigFactory, | ||
env: Map<String, String> | ||
) : super(s3DestinationConfigFactory, env) | ||
|
||
override fun storageProvider(): StorageProvider { | ||
return StorageProvider.AWS_S3 | ||
} | ||
|
||
companion object { | ||
@Throws(Exception::class) | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
IntegrationRunner(S3Destination()).run(args) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...tination-s3/src/main/kotlin/io/airbyte/integrations/destination/s3/S3DestinationRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
package io.airbyte.integrations.destination.s3 | ||
|
||
import io.airbyte.cdk.integrations.base.adaptive.AdaptiveDestinationRunner.baseOnEnv | ||
|
||
object S3DestinationRunner { | ||
@Throws(Exception::class) | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
baseOnEnv() | ||
.withOssDestination { S3Destination() } | ||
.withCloudDestination { S3DestinationStrictEncrypt() } | ||
.run(args) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...n-s3/src/main/kotlin/io/airbyte/integrations/destination/s3/S3DestinationStrictEncrypt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
package io.airbyte.integrations.destination.s3 | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.google.common.annotations.VisibleForTesting | ||
import io.airbyte.cdk.integrations.destination.s3.S3BaseChecks.testCustomEndpointSecured | ||
import io.airbyte.cdk.integrations.destination.s3.S3DestinationConfigFactory | ||
import io.airbyte.protocol.models.v0.AirbyteConnectionStatus | ||
|
||
class S3DestinationStrictEncrypt : S3Destination { | ||
constructor() : super() | ||
|
||
@VisibleForTesting | ||
constructor( | ||
configFactory: S3DestinationConfigFactory, | ||
environment: Map<String, String> | ||
) : super(configFactory, environment) | ||
|
||
override fun check(config: JsonNode): AirbyteConnectionStatus? { | ||
val destinationConfig = | ||
configFactory.getS3DestinationConfig(config, super.storageProvider(), super.environment) | ||
|
||
// Fails early to avoid extraneous validations checks if custom endpoint is not secure | ||
if (!testCustomEndpointSecured(destinationConfig.endpoint)) { | ||
return AirbyteConnectionStatus() | ||
.withStatus(AirbyteConnectionStatus.Status.FAILED) | ||
.withMessage("Custom endpoint does not use HTTPS") | ||
} | ||
return super.check(config) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters