embulk-output-s3v2 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcc56a0b48b656da07bac95bf806ddfb834ec62decd8f0cbf7afeb461b8d89bd
4
- data.tar.gz: 4689c8b5fafdc1444fa3851dea5e809885d3ee019c8f4ba2c99e97128339e931
3
+ metadata.gz: 38c87b938e84dcad47a5b47f65872b15d6a549877003bc1379bf9ca32c44eddb
4
+ data.tar.gz: 3505a9c76d0c385e25d8b1b11676143cca4b3c798d130a0e0c0724abd63dc1a1
5
5
  SHA512:
6
- metadata.gz: 4d2b74adcc5bffc412fd1b6066d55df546f781d9e04b02ec5bfd69ec0cdc1196aeb120ee778ded69512fb588ca5f6b0c7e51a8b0b50ba0853979b36f77a1e47c
7
- data.tar.gz: ea66f45405bd13af9de2a375d53a02d18ca0d6e93a08f25d2b542661381bbe9063bbdf2b5932efe8f212eb7707ebd7187dcabe880ca24a9d720113b8a7340416
6
+ metadata.gz: bc999df40b640047ba878092a623b22ad25b8c975600a4615165446703b3827e823d24ed7df17b7bcc1aa64ef181847414ef72381a529b41642573a868e0c045
7
+ data.tar.gz: 3d3b4f6360528d541fff6d84963dd96b4d44360c0d9ab0f47f657ec0fee550858ff03faa64f4c0d0f2b30ee8910516a497a43b6a2ba38ae4bf67cd8272caa848
data/README.md CHANGED
@@ -13,6 +13,10 @@ Files stores on Amazon S3.
13
13
 
14
14
  ## Configuration
15
15
  - **region**: AWS region name. (string, required)
16
+ - **enable_profile**: If true, AWS credentials profile will be used when authenticating AWS. (boolean, default: `false`)
17
+ - Supported in v0.2.0 or later
18
+ - **profile**: AWS credentials profile name. If `enable_profile` is false, this parameter will be ignored. (string, default: `default`)
19
+ - Supported in v0.2.0 or later
16
20
  - **bucket**: S3 bucket name. (string, required)
17
21
  - **object_key_prefix**: Prefix of S3 Objects key name. (string, required)
18
22
  - **enable_multi_part_upload**: If true, multipart upload will be enable. (boolean, default: `false`)
@@ -6,7 +6,7 @@ plugins {
6
6
  import com.github.jrubygradle.JRubyExec
7
7
 
8
8
  group 'com.github.ttksm'
9
- version '0.1.0'
9
+ version '0.2.0'
10
10
 
11
11
  sourceCompatibility = 1.8
12
12
  targetCompatibility = 1.8
@@ -10,6 +10,14 @@ public interface PluginTask
10
10
  @Config("region")
11
11
  public String getRegion();
12
12
 
13
+ @Config("enable_profile")
14
+ @ConfigDefault("false")
15
+ public boolean getEnableProfile();
16
+
17
+ @Config("profile")
18
+ @ConfigDefault("\"default\"")
19
+ public String getProfile();
20
+
13
21
  @Config("bucket")
14
22
  public String getBucket();
15
23
 
@@ -16,9 +16,13 @@ import java.util.concurrent.ExecutorService;
16
16
  import java.util.concurrent.Executors;
17
17
 
18
18
  import org.embulk.output.s3v2.util.ChunksizeComputation;
19
+ import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
20
+ import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
21
+ import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
19
22
  import software.amazon.awssdk.core.sync.RequestBody;
20
23
  import software.amazon.awssdk.regions.Region;
21
24
  import software.amazon.awssdk.services.s3.S3Client;
25
+ import software.amazon.awssdk.services.s3.S3ClientBuilder;
22
26
  import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest;
23
27
  import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest;
24
28
  import software.amazon.awssdk.services.s3.model.CompletedMultipartUpload;
@@ -37,16 +41,26 @@ public class S3ClientManager
37
41
  {
38
42
  private final S3Client s3;
39
43
 
40
- public S3ClientManager(String regionName)
44
+ public S3ClientManager(String regionName, boolean enableProfile, String profileName)
41
45
  {
46
+ S3ClientBuilder builder = S3Client.builder();
47
+
42
48
  Region region = Region.of(regionName);
43
49
  if (Region.regions().stream().noneMatch(o -> o.equals(region))) {
44
50
  throw new IllegalArgumentException("Not found aws region: " + regionName);
45
51
  }
52
+ builder = builder.region(region);
46
53
 
47
- s3 = S3Client.builder()
48
- .region(region)
49
- .build();
54
+ AwsCredentialsProvider provider;
55
+ if (enableProfile) {
56
+ provider = ProfileCredentialsProvider.create(profileName);
57
+ }
58
+ else {
59
+ provider = DefaultCredentialsProvider.builder().profileName("").build();
60
+ }
61
+ builder = builder.credentialsProvider(provider);
62
+
63
+ s3 = builder.build();
50
64
  }
51
65
 
52
66
  /**
@@ -13,7 +13,7 @@ abstract class AbstractStrategy implements TransactionalFileOutput
13
13
 
14
14
  public AbstractStrategy(PluginTask task, int taskIndex)
15
15
  {
16
- s3 = new S3ClientManager(task.getRegion());
16
+ s3 = new S3ClientManager(task.getRegion(), task.getEnableProfile(), task.getProfile());
17
17
  this.task = task;
18
18
  this.taskIndex = taskIndex;
19
19
 
@@ -0,0 +1,43 @@
1
+ package org.embulk.output.s3v2.util;
2
+
3
+ import org.junit.jupiter.api.Assertions;
4
+ import org.junit.jupiter.api.DisplayName;
5
+ import org.junit.jupiter.api.Test;
6
+ import org.junit.jupiter.api.extension.ExtendWith;
7
+ import org.mockito.junit.jupiter.MockitoExtension;
8
+
9
+ import java.nio.ByteBuffer;
10
+
11
+ /**
12
+ * @see ThresholdComputation
13
+ */
14
+ @ExtendWith(MockitoExtension.class)
15
+ public class ThresholdComputationTests
16
+ {
17
+ @Test
18
+ @DisplayName("Threshold check returns true")
19
+ public void testThresholdCheckReturnsTrue() throws Exception
20
+ {
21
+ ByteBuffer bf = ByteBuffer.allocate(1000001);
22
+ Assertions.assertTrue(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
23
+ }
24
+
25
+ @Test
26
+ @DisplayName("Threshold check returns false")
27
+ public void testThresholdCheckReturnsFalse() throws Exception
28
+ {
29
+ ByteBuffer bf = ByteBuffer.allocate(1000000);
30
+ Assertions.assertFalse(ThresholdComputation.largerThanThreshold("1MB", bf.capacity()));
31
+ }
32
+
33
+ @Test
34
+ @DisplayName("Invalid threshold string")
35
+ public void testInvalidThresholdString() throws Exception
36
+ {
37
+ ByteBuffer bf = ByteBuffer.allocate(1000000);
38
+ String threshold = "1MB1MB";
39
+ IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class,
40
+ () -> ThresholdComputation.largerThanThreshold(threshold, bf.capacity()));
41
+ Assertions.assertEquals("Unrecognized value of multipart_threshold: " + threshold, ex.getMessage());
42
+ }
43
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-s3v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshihiro Takushima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stores files on Amazon S3 using aws-sdk-java-v2.
14
14
  email:
@@ -23,45 +23,45 @@ files:
23
23
  - LICENSE
24
24
  - README.md
25
25
  - build.gradle
26
- - classpath/annotations-2.15.60.jar
27
- - classpath/apache-client-2.15.60.jar
28
- - classpath/arns-2.15.60.jar
29
- - classpath/auth-2.15.60.jar
30
- - classpath/aws-core-2.15.60.jar
31
- - classpath/aws-query-protocol-2.15.60.jar
32
- - classpath/aws-xml-protocol-2.15.60.jar
26
+ - classpath/annotations-2.15.61.jar
27
+ - classpath/apache-client-2.15.61.jar
28
+ - classpath/arns-2.15.61.jar
29
+ - classpath/auth-2.15.61.jar
30
+ - classpath/aws-core-2.15.61.jar
31
+ - classpath/aws-query-protocol-2.15.61.jar
32
+ - classpath/aws-xml-protocol-2.15.61.jar
33
33
  - classpath/commons-codec-1.11.jar
34
34
  - classpath/commons-logging-1.2.jar
35
- - classpath/embulk-output-s3v2-0.1.0.jar
35
+ - classpath/embulk-output-s3v2-0.2.0.jar
36
36
  - classpath/eventstream-1.0.1.jar
37
- - classpath/http-client-spi-2.15.60.jar
37
+ - classpath/http-client-spi-2.15.61.jar
38
38
  - classpath/httpclient-4.5.13.jar
39
39
  - classpath/httpcore-4.4.13.jar
40
40
  - classpath/jackson-annotations-2.10.5.jar
41
41
  - classpath/jackson-core-2.10.5.jar
42
42
  - classpath/jackson-databind-2.10.5.1.jar
43
- - classpath/metrics-spi-2.15.60.jar
43
+ - classpath/metrics-spi-2.15.61.jar
44
44
  - classpath/netty-buffer-4.1.53.Final.jar
45
45
  - classpath/netty-codec-4.1.53.Final.jar
46
46
  - classpath/netty-codec-http-4.1.53.Final.jar
47
47
  - classpath/netty-codec-http2-4.1.53.Final.jar
48
48
  - classpath/netty-common-4.1.53.Final.jar
49
49
  - classpath/netty-handler-4.1.53.Final.jar
50
- - classpath/netty-nio-client-2.15.60.jar
50
+ - classpath/netty-nio-client-2.15.61.jar
51
51
  - classpath/netty-reactive-streams-2.0.4.jar
52
52
  - classpath/netty-reactive-streams-http-2.0.4.jar
53
53
  - classpath/netty-resolver-4.1.53.Final.jar
54
54
  - classpath/netty-transport-4.1.53.Final.jar
55
55
  - classpath/netty-transport-native-epoll-4.1.53.Final-linux-x86_64.jar
56
56
  - classpath/netty-transport-native-unix-common-4.1.53.Final.jar
57
- - classpath/profiles-2.15.60.jar
58
- - classpath/protocol-core-2.15.60.jar
57
+ - classpath/profiles-2.15.61.jar
58
+ - classpath/protocol-core-2.15.61.jar
59
59
  - classpath/reactive-streams-1.0.3.jar
60
- - classpath/regions-2.15.60.jar
61
- - classpath/s3-2.15.60.jar
62
- - classpath/sdk-core-2.15.60.jar
60
+ - classpath/regions-2.15.61.jar
61
+ - classpath/s3-2.15.61.jar
62
+ - classpath/sdk-core-2.15.61.jar
63
63
  - classpath/slf4j-api-1.7.28.jar
64
- - classpath/utils-2.15.60.jar
64
+ - classpath/utils-2.15.61.jar
65
65
  - config/checkstyle/checkstyle.xml
66
66
  - config/checkstyle/default.xml
67
67
  - gradle/wrapper/gradle-wrapper.jar
@@ -82,6 +82,7 @@ files:
82
82
  - src/main/java/org/embulk/output/s3v2/util/ThresholdComputation.java
83
83
  - src/test/java/org/embulk/output/s3v2/strategy/BufferedStrategyTests.java
84
84
  - src/test/java/org/embulk/output/s3v2/util/ChunksizeComputationTests.java
85
+ - src/test/java/org/embulk/output/s3v2/util/ThresholdComputationTests.java
85
86
  - src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
86
87
  homepage: https://github.com/ttksm/embulk-output-s3v2
87
88
  licenses: