embulk-input-gcs 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -0
- data/build.gradle +5 -5
- data/secretkeys.tar +0 -0
- data/secretkeys.tar.enc +0 -0
- data/src/main/java/org/embulk/input/gcs/FileList.java +2 -2
- data/src/main/java/org/embulk/input/gcs/GcsAuthentication.java +2 -2
- data/src/main/java/org/embulk/input/gcs/GcsFileInput.java +4 -4
- data/src/main/java/org/embulk/input/gcs/GcsFileInputPlugin.java +4 -4
- data/src/main/java/org/embulk/input/gcs/PluginTask.java +1 -1
- data/src/main/java/org/embulk/input/gcs/SingleFileProvider.java +6 -3
- data/src/test/java/org/embulk/input/gcs/TestGcsAuthentication.java +1 -1
- data/src/test/java/org/embulk/input/gcs/TestGcsFileInputPlugin.java +4 -4
- data/src/test/resources/secretkeys.tar.enc +0 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc015455f0851ec196018a6ede5835653ef7f5a
|
4
|
+
data.tar.gz: 47185bd68f3bbe58070094fd9d87bda3635476e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1608fd099a302e4977b3808d7adb39ea2718937b893545f147167579b9d0ff0dab8b231ab033650c340f0c66588f4fb4568704ea19af499979f0cb7c51276a
|
7
|
+
data.tar.gz: e1a57cf92f6c81bb79bd7476d08eaecfab9c9d8c21f61f5d5b32e680cf70b0c9503c8bbc2ff7f2331f50a073c60010a55d105c37c0559cf66c82c439c47d7d5a
|
data/.travis.yml
CHANGED
@@ -4,8 +4,8 @@ jdk:
|
|
4
4
|
- oraclejdk8
|
5
5
|
|
6
6
|
before_install:
|
7
|
-
- openssl aes-256-cbc -K $
|
8
|
-
-in src/test/resources/secretkeys.tar.enc -out secretkeys.tar -d
|
7
|
+
- openssl aes-256-cbc -K $encrypted_407f38382059_key -iv $encrypted_407f38382059_iv
|
8
|
+
-in src/test/resources/secretkeys.tar.enc -out ./secretkeys.tar -d
|
9
9
|
- tar xvf secretkeys.tar
|
10
10
|
|
11
11
|
env:
|
@@ -13,8 +13,8 @@ env:
|
|
13
13
|
- GCP_EMAIL=unittest@embulk-input-gcs-test.iam.gserviceaccount.com
|
14
14
|
- GCP_BUCKET=embulk-input-gcs-test
|
15
15
|
- GCP_BUCKET_DIRECTORY=unittests_import
|
16
|
-
- GCP_P12_KEYFILE=./embulk-input-gcs-test-
|
17
|
-
- GCP_JSON_KEYFILE=./embulk-input-gcs-test-
|
16
|
+
- GCP_P12_KEYFILE=./embulk-input-gcs-test-9d51de6767a8.p12
|
17
|
+
- GCP_JSON_KEYFILE=./embulk-input-gcs-test-65cfe930dca1.json
|
18
18
|
|
19
19
|
script:
|
20
20
|
- ./gradlew gem
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.3.0 - 2018-12-26
|
2
|
+
* [maintenance] Use file name output feature in Embulk core to show file name in cmdout [#37](https://github.com/embulk/embulk-input-gcs/pull/37)
|
3
|
+
|
1
4
|
## 0.2.8 - 2018-06-29
|
2
5
|
* [maintenance] Improve retry logic to retry "400 Bad Request" "Invalid JWT: No valid verifier found for issuer" [#34](https://github.com/embulk/embulk-input-gcs/pull/34)
|
3
6
|
|
data/README.md
CHANGED
data/build.gradle
CHANGED
@@ -17,18 +17,18 @@ configurations {
|
|
17
17
|
sourceCompatibility = 1.8
|
18
18
|
targetCompatibility = 1.8
|
19
19
|
|
20
|
-
version = "0.
|
20
|
+
version = "0.3.0"
|
21
21
|
|
22
22
|
dependencies {
|
23
|
-
compile "org.embulk:embulk-core:0.
|
24
|
-
provided "org.embulk:embulk-core:0.
|
23
|
+
compile "org.embulk:embulk-core:0.9.12"
|
24
|
+
provided "org.embulk:embulk-core:0.9.12"
|
25
25
|
|
26
26
|
compile "com.google.http-client:google-http-client-jackson2:1.21.0"
|
27
27
|
compile ("com.google.apis:google-api-services-storage:v1-rev59-1.21.0") {exclude module: "guava-jdk5"}
|
28
28
|
|
29
29
|
testCompile "junit:junit:4.12"
|
30
|
-
testCompile "org.embulk:embulk-core:0.
|
31
|
-
testCompile "org.embulk:embulk-standards:0.
|
30
|
+
testCompile "org.embulk:embulk-core:0.9.12:tests"
|
31
|
+
testCompile "org.embulk:embulk-standards:0.9.12"
|
32
32
|
}
|
33
33
|
|
34
34
|
task classpath(type: Copy, dependsOn: ["jar"]) {
|
data/secretkeys.tar
ADDED
Binary file
|
data/secretkeys.tar.enc
ADDED
Binary file
|
@@ -3,7 +3,6 @@ package org.embulk.input.gcs;
|
|
3
3
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
4
4
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
5
5
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
6
|
-
import com.google.common.base.Optional;
|
7
6
|
import com.google.common.base.Throwables;
|
8
7
|
import org.embulk.config.Config;
|
9
8
|
import org.embulk.config.ConfigDefault;
|
@@ -21,6 +20,7 @@ import java.nio.charset.StandardCharsets;
|
|
21
20
|
import java.util.AbstractList;
|
22
21
|
import java.util.ArrayList;
|
23
22
|
import java.util.List;
|
23
|
+
import java.util.Optional;
|
24
24
|
import java.util.regex.Pattern;
|
25
25
|
import java.util.zip.GZIPInputStream;
|
26
26
|
import java.util.zip.GZIPOutputStream;
|
@@ -176,7 +176,7 @@ public class FileList
|
|
176
176
|
catch (IOException ex) {
|
177
177
|
throw Throwables.propagate(ex);
|
178
178
|
}
|
179
|
-
return new FileList(binary.toByteArray(), getSplits(entries), Optional.
|
179
|
+
return new FileList(binary.toByteArray(), getSplits(entries), Optional.ofNullable(last));
|
180
180
|
}
|
181
181
|
|
182
182
|
private List<List<Entry>> getSplits(List<Entry> all)
|
@@ -11,7 +11,6 @@ import com.google.api.client.json.JsonFactory;
|
|
11
11
|
import com.google.api.client.json.jackson2.JacksonFactory;
|
12
12
|
import com.google.api.services.storage.Storage;
|
13
13
|
import com.google.api.services.storage.StorageScopes;
|
14
|
-
import com.google.common.base.Optional;
|
15
14
|
import com.google.common.base.Throwables;
|
16
15
|
import com.google.common.collect.ImmutableList;
|
17
16
|
import org.embulk.config.ConfigException;
|
@@ -28,6 +27,7 @@ import java.io.IOException;
|
|
28
27
|
import java.io.InterruptedIOException;
|
29
28
|
import java.security.GeneralSecurityException;
|
30
29
|
import java.util.Collections;
|
30
|
+
import java.util.Optional;
|
31
31
|
|
32
32
|
public class GcsAuthentication
|
33
33
|
{
|
@@ -74,7 +74,7 @@ public class GcsAuthentication
|
|
74
74
|
return new GoogleCredential.Builder()
|
75
75
|
.setTransport(httpTransport)
|
76
76
|
.setJsonFactory(jsonFactory)
|
77
|
-
.setServiceAccountId(serviceAccountEmail.
|
77
|
+
.setServiceAccountId(serviceAccountEmail.orElseGet(null))
|
78
78
|
.setServiceAccountScopes(
|
79
79
|
ImmutableList.of(
|
80
80
|
StorageScopes.DEVSTORAGE_READ_ONLY
|
@@ -6,8 +6,6 @@ import com.google.api.services.storage.model.Bucket;
|
|
6
6
|
import com.google.api.services.storage.model.Objects;
|
7
7
|
import com.google.api.services.storage.model.StorageObject;
|
8
8
|
import com.google.common.base.Charsets;
|
9
|
-
import com.google.common.base.Function;
|
10
|
-
import com.google.common.base.Optional;
|
11
9
|
import com.google.common.io.BaseEncoding;
|
12
10
|
import org.embulk.config.ConfigException;
|
13
11
|
import org.embulk.config.TaskReport;
|
@@ -21,6 +19,8 @@ import java.io.IOException;
|
|
21
19
|
import java.math.BigInteger;
|
22
20
|
import java.security.GeneralSecurityException;
|
23
21
|
import java.util.List;
|
22
|
+
import java.util.Optional;
|
23
|
+
import java.util.function.Function;
|
24
24
|
|
25
25
|
public class GcsFileInput
|
26
26
|
extends InputStreamFileInput
|
@@ -53,8 +53,8 @@ public class GcsFileInput
|
|
53
53
|
return new GcsAuthentication(
|
54
54
|
task.getAuthMethod().getString(),
|
55
55
|
task.getServiceAccountEmail(),
|
56
|
-
task.getP12Keyfile().
|
57
|
-
task.getJsonKeyfile().
|
56
|
+
task.getP12Keyfile().map(localFileToPathString()),
|
57
|
+
task.getJsonKeyfile().map(localFileToPathString()),
|
58
58
|
task.getApplicationName()
|
59
59
|
);
|
60
60
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
3
|
import com.google.api.services.storage.Storage;
|
4
|
-
import com.google.common.base.Function;
|
5
|
-
import com.google.common.base.Optional;
|
6
4
|
import com.google.common.base.Throwables;
|
7
5
|
import org.embulk.config.ConfigDiff;
|
8
6
|
import org.embulk.config.ConfigException;
|
@@ -18,6 +16,8 @@ import org.slf4j.Logger;
|
|
18
16
|
import java.io.IOException;
|
19
17
|
import java.security.GeneralSecurityException;
|
20
18
|
import java.util.List;
|
19
|
+
import java.util.Optional;
|
20
|
+
import java.util.function.Function;
|
21
21
|
|
22
22
|
public class GcsFileInputPlugin
|
23
23
|
implements FileInputPlugin
|
@@ -86,8 +86,8 @@ public class GcsFileInputPlugin
|
|
86
86
|
return new GcsAuthentication(
|
87
87
|
task.getAuthMethod().getString(),
|
88
88
|
task.getServiceAccountEmail(),
|
89
|
-
task.getP12Keyfile().
|
90
|
-
task.getJsonKeyfile().
|
89
|
+
task.getP12Keyfile().map(localFileToPathString()),
|
90
|
+
task.getJsonKeyfile().map(localFileToPathString()),
|
91
91
|
task.getApplicationName()
|
92
92
|
);
|
93
93
|
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
|
-
import com.google.common.base.Optional;
|
4
3
|
import org.embulk.config.Config;
|
5
4
|
import org.embulk.config.ConfigDefault;
|
6
5
|
import org.embulk.config.ConfigInject;
|
@@ -9,6 +8,7 @@ import org.embulk.spi.BufferAllocator;
|
|
9
8
|
import org.embulk.spi.unit.LocalFile;
|
10
9
|
|
11
10
|
import java.util.List;
|
11
|
+
import java.util.Optional;
|
12
12
|
|
13
13
|
public interface PluginTask
|
14
14
|
extends Task, FileList.Task
|
@@ -5,6 +5,7 @@ import com.google.api.services.storage.Storage;
|
|
5
5
|
import com.google.common.base.Throwables;
|
6
6
|
import org.embulk.spi.Exec;
|
7
7
|
import org.embulk.spi.util.InputStreamFileInput;
|
8
|
+
import org.embulk.spi.util.InputStreamFileInput.InputStreamWithHints;
|
8
9
|
import org.embulk.spi.util.RetryExecutor;
|
9
10
|
import org.slf4j.Logger;
|
10
11
|
|
@@ -14,7 +15,6 @@ import java.io.File;
|
|
14
15
|
import java.io.FileInputStream;
|
15
16
|
import java.io.FileOutputStream;
|
16
17
|
import java.io.IOException;
|
17
|
-
import java.io.InputStream;
|
18
18
|
import java.util.Iterator;
|
19
19
|
|
20
20
|
import static org.embulk.spi.util.RetryExecutor.retryExecutor;
|
@@ -38,7 +38,7 @@ public class SingleFileProvider
|
|
38
38
|
}
|
39
39
|
|
40
40
|
@Override
|
41
|
-
public
|
41
|
+
public InputStreamWithHints openNextWithHints() throws IOException
|
42
42
|
{
|
43
43
|
if (opened) {
|
44
44
|
return null;
|
@@ -50,7 +50,10 @@ public class SingleFileProvider
|
|
50
50
|
String key = iterator.next();
|
51
51
|
File tempFile = Exec.getTempFileSpace().createTempFile();
|
52
52
|
getRemoteContentsWithRetry(tempFile, client, bucket, key, maxConnectionRetry);
|
53
|
-
return new
|
53
|
+
return new InputStreamWithHints(
|
54
|
+
new BufferedInputStream(new FileInputStream(tempFile)),
|
55
|
+
String.format("gcs://%s/%s", bucket, key)
|
56
|
+
);
|
54
57
|
}
|
55
58
|
|
56
59
|
@Override
|
@@ -2,7 +2,6 @@ package org.embulk.input.gcs;
|
|
2
2
|
|
3
3
|
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
4
4
|
import com.google.api.services.storage.Storage;
|
5
|
-
import com.google.common.base.Optional;
|
6
5
|
import org.embulk.EmbulkTestRuntime;
|
7
6
|
import org.embulk.config.ConfigException;
|
8
7
|
import org.junit.BeforeClass;
|
@@ -14,6 +13,7 @@ import java.io.FileNotFoundException;
|
|
14
13
|
import java.io.IOException;
|
15
14
|
import java.lang.reflect.Field;
|
16
15
|
import java.security.GeneralSecurityException;
|
16
|
+
import java.util.Optional;
|
17
17
|
|
18
18
|
import static org.junit.Assert.assertEquals;
|
19
19
|
import static org.junit.Assume.assumeNotNull;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
3
|
import com.google.api.services.storage.Storage;
|
4
|
-
import com.google.common.base.Optional;
|
5
4
|
import com.google.common.collect.ImmutableList;
|
6
5
|
import com.google.common.collect.ImmutableMap;
|
7
6
|
import com.google.common.collect.Lists;
|
@@ -29,6 +28,7 @@ import java.security.GeneralSecurityException;
|
|
29
28
|
import java.util.ArrayList;
|
30
29
|
import java.util.Arrays;
|
31
30
|
import java.util.List;
|
31
|
+
import java.util.Optional;
|
32
32
|
|
33
33
|
import static org.junit.Assert.assertEquals;
|
34
34
|
import static org.junit.Assume.assumeNotNull;
|
@@ -295,7 +295,7 @@ public class TestGcsFileInputPlugin
|
|
295
295
|
method.setAccessible(true);
|
296
296
|
Storage client = GcsFileInput.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
|
297
297
|
FileList.Builder builder = new FileList.Builder(config);
|
298
|
-
GcsFileInput.listGcsFilesByPrefix(builder, client, GCP_BUCKET, GCP_PATH_PREFIX, Optional
|
298
|
+
GcsFileInput.listGcsFilesByPrefix(builder, client, GCP_BUCKET, GCP_PATH_PREFIX, Optional.empty());
|
299
299
|
FileList fileList = builder.build();
|
300
300
|
assertEquals(expected.get(0), fileList.get(0).get(0));
|
301
301
|
assertEquals(expected.get(1), fileList.get(1).get(0));
|
@@ -325,7 +325,7 @@ public class TestGcsFileInputPlugin
|
|
325
325
|
method.setAccessible(true);
|
326
326
|
Storage client = GcsFileInput.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
|
327
327
|
FileList.Builder builder = new FileList.Builder(configWithPattern);
|
328
|
-
GcsFileInput.listGcsFilesByPrefix(builder, client, GCP_BUCKET, GCP_PATH_PREFIX, Optional
|
328
|
+
GcsFileInput.listGcsFilesByPrefix(builder, client, GCP_BUCKET, GCP_PATH_PREFIX, Optional.empty());
|
329
329
|
FileList fileList = builder.build();
|
330
330
|
assertEquals(expected.get(0), fileList.get(0).get(0));
|
331
331
|
assertEquals(GCP_BUCKET_DIRECTORY + "sample_01.csv", configDiff.get(String.class, "last_path"));
|
@@ -353,7 +353,7 @@ public class TestGcsFileInputPlugin
|
|
353
353
|
method.setAccessible(true);
|
354
354
|
Storage client = GcsFileInput.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
|
355
355
|
FileList.Builder builder = new FileList.Builder(config);
|
356
|
-
GcsFileInput.listGcsFilesByPrefix(builder, client, "non-exists-bucket", "prefix", Optional
|
356
|
+
GcsFileInput.listGcsFilesByPrefix(builder, client, "non-exists-bucket", "prefix", Optional.empty()); // no errors happens
|
357
357
|
}
|
358
358
|
|
359
359
|
@Test
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-gcs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Akama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,6 +57,8 @@ files:
|
|
57
57
|
- gradlew
|
58
58
|
- gradlew.bat
|
59
59
|
- lib/embulk/input/gcs.rb
|
60
|
+
- secretkeys.tar
|
61
|
+
- secretkeys.tar.enc
|
60
62
|
- settings.gradle
|
61
63
|
- src/main/java/org/embulk/input/gcs/FileList.java
|
62
64
|
- src/main/java/org/embulk/input/gcs/GcsAuthentication.java
|
@@ -75,11 +77,11 @@ files:
|
|
75
77
|
- classpath/commons-logging-1.1.1.jar
|
76
78
|
- classpath/google-api-services-storage-v1-rev59-1.21.0.jar
|
77
79
|
- classpath/google-http-client-1.21.0.jar
|
78
|
-
- classpath/embulk-input-gcs-0.2.8.jar
|
79
80
|
- classpath/google-oauth-client-1.21.0.jar
|
80
81
|
- classpath/commons-codec-1.3.jar
|
81
82
|
- classpath/google-http-client-jackson2-1.21.0.jar
|
82
83
|
- classpath/httpcore-4.0.1.jar
|
84
|
+
- classpath/embulk-input-gcs-0.3.0.jar
|
83
85
|
homepage: https://github.com/embulk/embulk-input-gcs
|
84
86
|
licenses:
|
85
87
|
- Apache-2.0
|