embulk-input-gcs 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +7 -0
- data/build.gradle +25 -7
- data/classpath/embulk-input-gcs-0.1.13.jar +0 -0
- data/classpath/{google-api-client-1.19.1.jar → google-api-client-1.21.0.jar} +0 -0
- data/classpath/google-api-services-storage-v1-rev59-1.21.0.jar +0 -0
- data/classpath/{google-http-client-1.19.0.jar → google-http-client-1.21.0.jar} +0 -0
- data/classpath/{google-http-client-jackson2-1.19.0.jar → google-http-client-jackson2-1.21.0.jar} +0 -0
- data/classpath/{google-oauth-client-1.19.0.jar → google-oauth-client-1.21.0.jar} +0 -0
- data/config/checkstyle/checkstyle.xml +130 -0
- data/config/checkstyle/default.xml +110 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/src/main/java/org/embulk/input/gcs/GcsAuthentication.java +16 -14
- data/src/main/java/org/embulk/input/gcs/GcsFileInputPlugin.java +53 -42
- data/src/test/java/org/embulk/input/gcs/TestGcsAuthentication.java +20 -13
- data/src/test/java/org/embulk/input/gcs/TestGcsFileInputPlugin.java +36 -27
- metadata +10 -8
- data/classpath/embulk-input-gcs-0.1.11.jar +0 -0
- data/classpath/google-api-services-storage-v1-rev27-1.19.1.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e7dc0a163123cb7bb2de1738c46d60b70282d12
|
4
|
+
data.tar.gz: 10370c8b104b51f6e5ed55297181647a9caa1d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 107ca80b29d9f3a0ea45a5d62326c570e8df3c2efea0a979f51cbcca174e8d67dd8d97183ad7856362699fbd693363ba96e10f9a0513122019a76d6e75dffeab
|
7
|
+
data.tar.gz: 39bb76c59dd27373c31280ad20b614d4fa6aab4655eacf9631b29a160838e545d0ec04d3ae7ea140c3897a6020c60f3e4623846bce43edf133708330b4ecd6b4
|
data/ChangeLog
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
Release 0.1.13 - 2016-02-04
|
2
|
+
* Upgraded embulk to v0.8.2
|
3
|
+
* Updated Google HTTP Client Library from 1.19.0 to 2.1.21.0
|
4
|
+
* Updated Google Cloud Storage API Client Library from v1-rev27-1.19.1 to v1-rev59-1.21.0
|
5
|
+
|
1
6
|
Release 0.1.11 - 2016-01-25
|
2
7
|
* Added retry logic
|
3
8
|
|
9
|
+
* Added retry logic
|
10
|
+
|
4
11
|
Release 0.1.10 - 2015-11-07
|
5
12
|
|
6
13
|
* Fix resume download logics
|
data/build.gradle
CHANGED
@@ -2,6 +2,7 @@ plugins {
|
|
2
2
|
id "com.jfrog.bintray" version "1.1"
|
3
3
|
id "com.github.jruby-gradle.base" version "0.1.5"
|
4
4
|
id "java"
|
5
|
+
id "checkstyle"
|
5
6
|
id "jacoco"
|
6
7
|
}
|
7
8
|
import com.github.jrubygradle.JRubyExec
|
@@ -16,18 +17,18 @@ configurations {
|
|
16
17
|
sourceCompatibility = 1.7
|
17
18
|
targetCompatibility = 1.7
|
18
19
|
|
19
|
-
version = "0.1.
|
20
|
+
version = "0.1.13"
|
20
21
|
|
21
22
|
dependencies {
|
22
|
-
compile "org.embulk:embulk-core:0.
|
23
|
-
provided "org.embulk:embulk-core:0.
|
23
|
+
compile "org.embulk:embulk-core:0.8.2"
|
24
|
+
provided "org.embulk:embulk-core:0.8.2"
|
24
25
|
|
25
|
-
compile "com.google.http-client:google-http-client-jackson2:1.
|
26
|
-
compile ("com.google.apis:google-api-services-storage:v1-
|
26
|
+
compile "com.google.http-client:google-http-client-jackson2:1.21.0"
|
27
|
+
compile ("com.google.apis:google-api-services-storage:v1-rev59-1.21.0") {exclude module: "guava-jdk5"}
|
27
28
|
|
28
29
|
testCompile "junit:junit:4.12"
|
29
|
-
testCompile "org.embulk:embulk-core:0.
|
30
|
-
testCompile "org.embulk:embulk-standards:0.
|
30
|
+
testCompile "org.embulk:embulk-core:0.8.2:tests"
|
31
|
+
testCompile "org.embulk:embulk-standards:0.8.2"
|
31
32
|
}
|
32
33
|
|
33
34
|
task classpath(type: Copy, dependsOn: ["jar"]) {
|
@@ -37,6 +38,23 @@ task classpath(type: Copy, dependsOn: ["jar"]) {
|
|
37
38
|
}
|
38
39
|
clean { delete 'classpath' }
|
39
40
|
|
41
|
+
checkstyle {
|
42
|
+
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
|
43
|
+
toolVersion = '6.14.1'
|
44
|
+
}
|
45
|
+
checkstyleMain {
|
46
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
47
|
+
ignoreFailures = true
|
48
|
+
}
|
49
|
+
checkstyleTest {
|
50
|
+
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
|
51
|
+
ignoreFailures = true
|
52
|
+
}
|
53
|
+
task checkstyle(type: Checkstyle) {
|
54
|
+
classpath = sourceSets.main.output + sourceSets.test.output
|
55
|
+
source = sourceSets.main.allJava + sourceSets.test.allJava
|
56
|
+
}
|
57
|
+
|
40
58
|
task gem(type: JRubyExec, dependsOn: ["build", "gemspec", "classpath"]) {
|
41
59
|
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
|
42
60
|
script "build/gemspec"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/classpath/{google-http-client-jackson2-1.19.0.jar → google-http-client-jackson2-1.21.0.jar}
RENAMED
Binary file
|
Binary file
|
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<module name="Checker">
|
6
|
+
<!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
|
7
|
+
<module name="FileTabCharacter"/>
|
8
|
+
<module name="NewlineAtEndOfFile">
|
9
|
+
<property name="lineSeparator" value="lf"/>
|
10
|
+
</module>
|
11
|
+
<module name="RegexpMultiline">
|
12
|
+
<property name="format" value="\r"/>
|
13
|
+
<property name="message" value="Line contains carriage return"/>
|
14
|
+
</module>
|
15
|
+
<module name="RegexpMultiline">
|
16
|
+
<property name="format" value=" \n"/>
|
17
|
+
<property name="message" value="Line has trailing whitespace"/>
|
18
|
+
</module>
|
19
|
+
<module name="RegexpMultiline">
|
20
|
+
<property name="format" value="\{\n\n"/>
|
21
|
+
<property name="message" value="Blank line after opening brace"/>
|
22
|
+
</module>
|
23
|
+
<module name="RegexpMultiline">
|
24
|
+
<property name="format" value="\n\n\s*\}"/>
|
25
|
+
<property name="message" value="Blank line before closing brace"/>
|
26
|
+
</module>
|
27
|
+
<module name="RegexpMultiline">
|
28
|
+
<property name="format" value="\n\n\n"/>
|
29
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
30
|
+
</module>
|
31
|
+
<module name="RegexpMultiline">
|
32
|
+
<property name="format" value="\n\n\Z"/>
|
33
|
+
<property name="message" value="Blank line before end of file"/>
|
34
|
+
</module>
|
35
|
+
<module name="RegexpMultiline">
|
36
|
+
<property name="format" value="Preconditions\.checkNotNull"/>
|
37
|
+
<property name="message" value="Use of checkNotNull"/>
|
38
|
+
</module>
|
39
|
+
|
40
|
+
<module name="TreeWalker">
|
41
|
+
<module name="EmptyBlock">
|
42
|
+
<property name="option" value="text"/>
|
43
|
+
<property name="tokens" value="
|
44
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
45
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
46
|
+
</module>
|
47
|
+
<module name="EmptyStatement"/>
|
48
|
+
<module name="EmptyForInitializerPad"/>
|
49
|
+
<module name="EmptyForIteratorPad">
|
50
|
+
<property name="option" value="space"/>
|
51
|
+
</module>
|
52
|
+
<module name="MethodParamPad">
|
53
|
+
<property name="allowLineBreaks" value="true"/>
|
54
|
+
<property name="option" value="nospace"/>
|
55
|
+
</module>
|
56
|
+
<module name="ParenPad"/>
|
57
|
+
<module name="TypecastParenPad"/>
|
58
|
+
<module name="NeedBraces"/>
|
59
|
+
<module name="LeftCurly">
|
60
|
+
<property name="option" value="nl"/>
|
61
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
62
|
+
</module>
|
63
|
+
<module name="LeftCurly">
|
64
|
+
<property name="option" value="eol"/>
|
65
|
+
<property name="tokens" value="
|
66
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
67
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
68
|
+
</module>
|
69
|
+
<module name="RightCurly">
|
70
|
+
<property name="option" value="alone"/>
|
71
|
+
</module>
|
72
|
+
<module name="GenericWhitespace"/>
|
73
|
+
<module name="WhitespaceAfter"/>
|
74
|
+
<module name="NoWhitespaceBefore"/>
|
75
|
+
|
76
|
+
<module name="UpperEll"/>
|
77
|
+
<module name="DefaultComesLast"/>
|
78
|
+
<module name="ArrayTypeStyle"/>
|
79
|
+
<module name="MultipleVariableDeclarations"/>
|
80
|
+
<module name="ModifierOrder"/>
|
81
|
+
<module name="OneStatementPerLine"/>
|
82
|
+
<module name="StringLiteralEquality"/>
|
83
|
+
<module name="MutableException"/>
|
84
|
+
<module name="EqualsHashCode"/>
|
85
|
+
<module name="InnerAssignment"/>
|
86
|
+
<module name="InterfaceIsType"/>
|
87
|
+
<module name="HideUtilityClassConstructor"/>
|
88
|
+
|
89
|
+
<module name="MemberName"/>
|
90
|
+
<module name="LocalVariableName"/>
|
91
|
+
<module name="LocalFinalVariableName"/>
|
92
|
+
<module name="TypeName"/>
|
93
|
+
<module name="PackageName"/>
|
94
|
+
<module name="ParameterName"/>
|
95
|
+
<module name="StaticVariableName">
|
96
|
+
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
|
97
|
+
</module>
|
98
|
+
<module name="ClassTypeParameterName">
|
99
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
100
|
+
</module>
|
101
|
+
<module name="MethodTypeParameterName">
|
102
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
103
|
+
</module>
|
104
|
+
|
105
|
+
<module name="AvoidStarImport"/>
|
106
|
+
<module name="RedundantImport"/>
|
107
|
+
<module name="UnusedImports"/>
|
108
|
+
<module name="ImportOrder">
|
109
|
+
<property name="groups" value="*,javax,java"/>
|
110
|
+
<property name="separated" value="true"/>
|
111
|
+
<property name="option" value="bottom"/>
|
112
|
+
<property name="sortStaticImportsAlphabetically" value="true"/>
|
113
|
+
</module>
|
114
|
+
|
115
|
+
<module name="WhitespaceAround">
|
116
|
+
<property name="allowEmptyConstructors" value="true"/>
|
117
|
+
<property name="allowEmptyMethods" value="true"/>
|
118
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
119
|
+
<property name="tokens" value="
|
120
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
121
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
122
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
123
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
124
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
125
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
126
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
127
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
128
|
+
</module>
|
129
|
+
</module>
|
130
|
+
</module>
|
@@ -0,0 +1,110 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE module PUBLIC
|
3
|
+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
+
<!--
|
6
|
+
This is a subset of ./checkstyle.xml which allows some loose styles
|
7
|
+
-->
|
8
|
+
<module name="Checker">
|
9
|
+
<module name="FileTabCharacter"/>
|
10
|
+
<module name="NewlineAtEndOfFile">
|
11
|
+
<property name="lineSeparator" value="lf"/>
|
12
|
+
</module>
|
13
|
+
<module name="RegexpMultiline">
|
14
|
+
<property name="format" value="\r"/>
|
15
|
+
<property name="message" value="Line contains carriage return"/>
|
16
|
+
</module>
|
17
|
+
<module name="RegexpMultiline">
|
18
|
+
<property name="format" value=" \n"/>
|
19
|
+
<property name="message" value="Line has trailing whitespace"/>
|
20
|
+
</module>
|
21
|
+
<module name="RegexpMultiline">
|
22
|
+
<property name="format" value="\n\n\n"/>
|
23
|
+
<property name="message" value="Multiple consecutive blank lines"/>
|
24
|
+
</module>
|
25
|
+
<module name="RegexpMultiline">
|
26
|
+
<property name="format" value="\n\n\Z"/>
|
27
|
+
<property name="message" value="Blank line before end of file"/>
|
28
|
+
</module>
|
29
|
+
|
30
|
+
<module name="TreeWalker">
|
31
|
+
<module name="EmptyBlock">
|
32
|
+
<property name="option" value="text"/>
|
33
|
+
<property name="tokens" value="
|
34
|
+
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
35
|
+
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
36
|
+
</module>
|
37
|
+
<module name="EmptyStatement"/>
|
38
|
+
<module name="EmptyForInitializerPad"/>
|
39
|
+
<module name="EmptyForIteratorPad">
|
40
|
+
<property name="option" value="space"/>
|
41
|
+
</module>
|
42
|
+
<module name="MethodParamPad">
|
43
|
+
<property name="allowLineBreaks" value="true"/>
|
44
|
+
<property name="option" value="nospace"/>
|
45
|
+
</module>
|
46
|
+
<module name="ParenPad"/>
|
47
|
+
<module name="TypecastParenPad"/>
|
48
|
+
<module name="NeedBraces"/>
|
49
|
+
<module name="LeftCurly">
|
50
|
+
<property name="option" value="nl"/>
|
51
|
+
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
52
|
+
</module>
|
53
|
+
<module name="LeftCurly">
|
54
|
+
<property name="option" value="eol"/>
|
55
|
+
<property name="tokens" value="
|
56
|
+
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
57
|
+
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
58
|
+
</module>
|
59
|
+
<module name="RightCurly">
|
60
|
+
<property name="option" value="alone"/>
|
61
|
+
</module>
|
62
|
+
<module name="GenericWhitespace"/>
|
63
|
+
<module name="WhitespaceAfter"/>
|
64
|
+
<module name="NoWhitespaceBefore"/>
|
65
|
+
|
66
|
+
<module name="UpperEll"/>
|
67
|
+
<module name="DefaultComesLast"/>
|
68
|
+
<module name="ArrayTypeStyle"/>
|
69
|
+
<module name="MultipleVariableDeclarations"/>
|
70
|
+
<module name="ModifierOrder"/>
|
71
|
+
<module name="OneStatementPerLine"/>
|
72
|
+
<module name="StringLiteralEquality"/>
|
73
|
+
<module name="MutableException"/>
|
74
|
+
<module name="EqualsHashCode"/>
|
75
|
+
<module name="InnerAssignment"/>
|
76
|
+
<module name="InterfaceIsType"/>
|
77
|
+
<module name="HideUtilityClassConstructor"/>
|
78
|
+
|
79
|
+
<module name="MemberName"/>
|
80
|
+
<module name="LocalVariableName"/>
|
81
|
+
<module name="LocalFinalVariableName"/>
|
82
|
+
<module name="TypeName"/>
|
83
|
+
<module name="PackageName"/>
|
84
|
+
<module name="ParameterName"/>
|
85
|
+
<module name="StaticVariableName">
|
86
|
+
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
|
87
|
+
</module>
|
88
|
+
<module name="ClassTypeParameterName">
|
89
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
90
|
+
</module>
|
91
|
+
<module name="MethodTypeParameterName">
|
92
|
+
<property name="format" value="^[A-Z][0-9]?$"/>
|
93
|
+
</module>
|
94
|
+
|
95
|
+
<module name="WhitespaceAround">
|
96
|
+
<property name="allowEmptyConstructors" value="true"/>
|
97
|
+
<property name="allowEmptyMethods" value="true"/>
|
98
|
+
<property name="ignoreEnhancedForColon" value="false"/>
|
99
|
+
<property name="tokens" value="
|
100
|
+
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
101
|
+
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
102
|
+
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
103
|
+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
104
|
+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
105
|
+
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
106
|
+
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
107
|
+
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
108
|
+
</module>
|
109
|
+
</module>
|
110
|
+
</module>
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
#Wed Jan 13 12:41:02 JST 2016
|
2
2
|
distributionBase=GRADLE_USER_HOME
|
3
3
|
distributionPath=wrapper/dists
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
5
5
|
zipStorePath=wrapper/dists
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.
|
6
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
|
@@ -1,28 +1,28 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
|
-
import java.io.File;
|
4
|
-
import java.io.FileInputStream;
|
5
|
-
import java.io.IOException;
|
6
|
-
|
7
|
-
import com.google.common.base.Optional;
|
8
|
-
import com.google.common.collect.ImmutableList;
|
9
|
-
import java.security.GeneralSecurityException;
|
10
|
-
import java.util.Collections;
|
11
|
-
|
12
3
|
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
13
4
|
import com.google.api.client.googleapis.compute.ComputeCredential;
|
14
5
|
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
6
|
+
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
7
|
+
import com.google.api.client.http.HttpRequestInitializer;
|
15
8
|
import com.google.api.client.http.HttpTransport;
|
16
9
|
import com.google.api.client.json.JsonFactory;
|
17
10
|
import com.google.api.client.json.jackson2.JacksonFactory;
|
18
|
-
import com.google.api.client.http.HttpRequestInitializer;
|
19
|
-
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
20
11
|
import com.google.api.services.storage.Storage;
|
21
12
|
import com.google.api.services.storage.StorageScopes;
|
22
13
|
import com.google.api.services.storage.model.Objects;
|
14
|
+
import com.google.common.base.Optional;
|
15
|
+
import com.google.common.collect.ImmutableList;
|
23
16
|
import org.embulk.spi.Exec;
|
24
17
|
import org.slf4j.Logger;
|
25
18
|
|
19
|
+
import java.io.File;
|
20
|
+
import java.io.FileInputStream;
|
21
|
+
|
22
|
+
import java.io.IOException;
|
23
|
+
import java.security.GeneralSecurityException;
|
24
|
+
import java.util.Collections;
|
25
|
+
|
26
26
|
public class GcsAuthentication
|
27
27
|
{
|
28
28
|
private final Logger log = Exec.getLogger(GcsAuthentication.class);
|
@@ -48,9 +48,11 @@ public class GcsAuthentication
|
|
48
48
|
|
49
49
|
if (authMethod.equals("compute_engine")) {
|
50
50
|
this.credentials = getComputeCredential();
|
51
|
-
}
|
51
|
+
}
|
52
|
+
else if (authMethod.toLowerCase().equals("json_key")) {
|
52
53
|
this.credentials = getServiceAccountCredentialFromJsonFile();
|
53
|
-
}
|
54
|
+
}
|
55
|
+
else {
|
54
56
|
this.credentials = getServiceAccountCredential();
|
55
57
|
}
|
56
58
|
}
|
@@ -109,4 +111,4 @@ public class GcsAuthentication
|
|
109
111
|
|
110
112
|
return client;
|
111
113
|
}
|
112
|
-
}
|
114
|
+
}
|
@@ -1,49 +1,46 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
|
-
import java.util.List;
|
4
|
-
import java.util.ArrayList;
|
5
|
-
import java.util.Collections;
|
6
|
-
import java.io.IOException;
|
7
|
-
import java.io.InterruptedIOException;
|
8
|
-
import java.io.InputStream;
|
9
|
-
import java.math.BigInteger;
|
10
|
-
|
11
3
|
import com.google.api.client.http.HttpResponseException;
|
12
|
-
import com.google.
|
13
|
-
import com.google.
|
4
|
+
import com.google.api.services.storage.Storage;
|
5
|
+
import com.google.api.services.storage.model.Bucket;
|
6
|
+
import com.google.api.services.storage.model.Objects;
|
7
|
+
import com.google.api.services.storage.model.StorageObject;
|
8
|
+
import com.google.common.annotations.VisibleForTesting;
|
9
|
+
import com.google.common.base.Charsets;
|
14
10
|
import com.google.common.base.Function;
|
11
|
+
import com.google.common.base.Optional;
|
15
12
|
import com.google.common.base.Throwables;
|
16
|
-
import com.google.common.
|
13
|
+
import com.google.common.collect.ImmutableList;
|
17
14
|
import com.google.common.io.BaseEncoding;
|
18
|
-
import com.google.common.annotations.VisibleForTesting;
|
19
|
-
import java.security.GeneralSecurityException;
|
20
|
-
|
21
|
-
import org.embulk.config.TaskReport;
|
22
15
|
import org.embulk.config.Config;
|
23
|
-
import org.embulk.config.ConfigInject;
|
24
|
-
import org.embulk.config.ConfigDiff;
|
25
16
|
import org.embulk.config.ConfigDefault;
|
17
|
+
import org.embulk.config.ConfigDiff;
|
26
18
|
import org.embulk.config.ConfigException;
|
19
|
+
import org.embulk.config.ConfigInject;
|
27
20
|
import org.embulk.config.ConfigSource;
|
28
21
|
import org.embulk.config.Task;
|
22
|
+
import org.embulk.config.TaskReport;
|
29
23
|
import org.embulk.config.TaskSource;
|
30
|
-
import org.embulk.spi.Exec;
|
31
24
|
import org.embulk.spi.BufferAllocator;
|
25
|
+
import org.embulk.spi.Exec;
|
32
26
|
import org.embulk.spi.FileInputPlugin;
|
33
27
|
import org.embulk.spi.TransactionalFileInput;
|
34
28
|
import org.embulk.spi.unit.LocalFile;
|
35
29
|
import org.embulk.spi.util.InputStreamFileInput;
|
36
30
|
import org.embulk.spi.util.ResumableInputStream;
|
37
|
-
import org.embulk.spi.util.RetryExecutor.Retryable;
|
38
31
|
import org.embulk.spi.util.RetryExecutor.RetryGiveupException;
|
39
|
-
import
|
40
|
-
|
32
|
+
import org.embulk.spi.util.RetryExecutor.Retryable;
|
41
33
|
import org.slf4j.Logger;
|
34
|
+
import static org.embulk.spi.util.RetryExecutor.retryExecutor;
|
42
35
|
|
43
|
-
import
|
44
|
-
import
|
45
|
-
import
|
46
|
-
import
|
36
|
+
import java.io.IOException;
|
37
|
+
import java.io.InputStream;
|
38
|
+
import java.io.InterruptedIOException;
|
39
|
+
import java.math.BigInteger;
|
40
|
+
import java.security.GeneralSecurityException;
|
41
|
+
import java.util.ArrayList;
|
42
|
+
import java.util.Collections;
|
43
|
+
import java.util.List;
|
47
44
|
|
48
45
|
public class GcsFileInputPlugin
|
49
46
|
implements FileInputPlugin
|
@@ -108,7 +105,8 @@ public class GcsFileInputPlugin
|
|
108
105
|
}
|
109
106
|
try {
|
110
107
|
task.setP12Keyfile(Optional.of(LocalFile.of(task.getP12KeyfileFullpath().get())));
|
111
|
-
}
|
108
|
+
}
|
109
|
+
catch (IOException ex) {
|
112
110
|
throw Throwables.propagate(ex);
|
113
111
|
}
|
114
112
|
}
|
@@ -117,7 +115,8 @@ public class GcsFileInputPlugin
|
|
117
115
|
if (!task.getJsonKeyfile().isPresent()) {
|
118
116
|
throw new ConfigException("If auth_method is json_key, you have to set json_keyfile");
|
119
117
|
}
|
120
|
-
}
|
118
|
+
}
|
119
|
+
else if (task.getAuthMethod().getString().equals("private_key")) {
|
121
120
|
if (!task.getP12Keyfile().isPresent() || !task.getServiceAccountEmail().isPresent()) {
|
122
121
|
throw new ConfigException("If auth_method is private_key, you have to set both service_account_email and p12_keyfile");
|
123
122
|
}
|
@@ -148,7 +147,8 @@ public class GcsFileInputPlugin
|
|
148
147
|
task.getJsonKeyfile().transform(localFileToPathString()),
|
149
148
|
task.getApplicationName()
|
150
149
|
);
|
151
|
-
}
|
150
|
+
}
|
151
|
+
catch (GeneralSecurityException | IOException ex) {
|
152
152
|
throw new ConfigException(ex);
|
153
153
|
}
|
154
154
|
}
|
@@ -170,7 +170,8 @@ public class GcsFileInputPlugin
|
|
170
170
|
if (task.getLastPath().isPresent()) {
|
171
171
|
configDiff.set("last_path", task.getLastPath().get());
|
172
172
|
}
|
173
|
-
}
|
173
|
+
}
|
174
|
+
else {
|
174
175
|
Collections.sort(files);
|
175
176
|
configDiff.set("last_path", files.get(files.size() - 1));
|
176
177
|
}
|
@@ -190,7 +191,8 @@ public class GcsFileInputPlugin
|
|
190
191
|
Storage client = null;
|
191
192
|
try {
|
192
193
|
client = auth.getGcsClient(task.getBucket());
|
193
|
-
}
|
194
|
+
}
|
195
|
+
catch (IOException ex) {
|
194
196
|
throw new ConfigException(ex);
|
195
197
|
}
|
196
198
|
|
@@ -237,12 +239,12 @@ public class GcsFileInputPlugin
|
|
237
239
|
log.debug("bucket location: " + bk.getLocation());
|
238
240
|
log.debug("bucket timeCreated: " + bk.getTimeCreated());
|
239
241
|
log.debug("bucket owner: " + bk.getOwner());
|
240
|
-
}
|
242
|
+
}
|
243
|
+
catch (IOException e) {
|
241
244
|
log.warn("Could not access to bucket:" + bucket);
|
242
245
|
log.warn(e.getMessage());
|
243
246
|
}
|
244
247
|
|
245
|
-
|
246
248
|
try {
|
247
249
|
// @see https://cloud.google.com/storage/docs/json_api/v1/objects/list
|
248
250
|
Storage.Objects.List listObjects = client.objects().list(bucket);
|
@@ -265,7 +267,8 @@ public class GcsFileInputPlugin
|
|
265
267
|
lastKey = objects.getNextPageToken();
|
266
268
|
listObjects.setPageToken(lastKey);
|
267
269
|
} while (lastKey != null);
|
268
|
-
}
|
270
|
+
}
|
271
|
+
catch (IOException e) {
|
269
272
|
if ((e instanceof HttpResponseException) && ((HttpResponseException) e).getStatusCode() == 400) {
|
270
273
|
throw new ConfigException(String.format("Files listing failed: bucket:%s, prefix:%s, last_path:%s", bucket, prefix, lastKey), e);
|
271
274
|
}
|
@@ -328,10 +331,11 @@ public class GcsFileInputPlugin
|
|
328
331
|
throws RetryGiveupException
|
329
332
|
{
|
330
333
|
String message = String.format("GCS GET request failed. Retrying %d/%d after %d seconds. Message: %s",
|
331
|
-
retryCount, retryLimit, retryWait/1000, exception.getMessage());
|
334
|
+
retryCount, retryLimit, retryWait / 1000, exception.getMessage());
|
332
335
|
if (retryCount % 3 == 0) {
|
333
336
|
log.warn(message, exception);
|
334
|
-
}
|
337
|
+
}
|
338
|
+
else {
|
335
339
|
log.warn(message);
|
336
340
|
}
|
337
341
|
}
|
@@ -342,10 +346,12 @@ public class GcsFileInputPlugin
|
|
342
346
|
{
|
343
347
|
}
|
344
348
|
});
|
345
|
-
}
|
349
|
+
}
|
350
|
+
catch (RetryGiveupException ex) {
|
346
351
|
Throwables.propagateIfInstanceOf(ex.getCause(), IOException.class);
|
347
352
|
throw Throwables.propagate(ex.getCause());
|
348
|
-
}
|
353
|
+
}
|
354
|
+
catch (InterruptedException ex) {
|
349
355
|
throw new InterruptedIOException();
|
350
356
|
}
|
351
357
|
}
|
@@ -360,7 +366,9 @@ public class GcsFileInputPlugin
|
|
360
366
|
super(task.getBufferAllocator(), new SingleFileProvider(task, taskIndex));
|
361
367
|
}
|
362
368
|
|
363
|
-
public void abort()
|
369
|
+
public void abort()
|
370
|
+
{
|
371
|
+
}
|
364
372
|
|
365
373
|
public TaskReport commit()
|
366
374
|
{
|
@@ -368,7 +376,9 @@ public class GcsFileInputPlugin
|
|
368
376
|
}
|
369
377
|
|
370
378
|
@Override
|
371
|
-
public void close()
|
379
|
+
public void close()
|
380
|
+
{
|
381
|
+
}
|
372
382
|
}
|
373
383
|
|
374
384
|
private class SingleFileProvider
|
@@ -399,7 +409,9 @@ public class GcsFileInputPlugin
|
|
399
409
|
}
|
400
410
|
|
401
411
|
@Override
|
402
|
-
public void close()
|
412
|
+
public void close()
|
413
|
+
{
|
414
|
+
}
|
403
415
|
}
|
404
416
|
|
405
417
|
// String nextToken = base64Encode(0x0a + 0x01~0x27 + filePath);
|
@@ -415,11 +427,10 @@ public class GcsFileInputPlugin
|
|
415
427
|
System.arraycopy(utf8, 0, encoding, 2, utf8.length);
|
416
428
|
|
417
429
|
String s = BaseEncoding.base64().encode(encoding);
|
418
|
-
log.debug(String.format("last_path(base64 encoded): %s"
|
430
|
+
log.debug(String.format("last_path(base64 encoded): %s", s));
|
419
431
|
return s;
|
420
432
|
}
|
421
433
|
|
422
|
-
|
423
434
|
public enum AuthMethod
|
424
435
|
{
|
425
436
|
private_key("private_key"),
|
@@ -1,19 +1,20 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
|
+
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
4
|
+
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
5
|
+
import com.google.api.services.storage.Storage;
|
3
6
|
import com.google.common.base.Optional;
|
4
7
|
import org.embulk.EmbulkTestRuntime;
|
5
|
-
import
|
6
|
-
import
|
8
|
+
import org.junit.BeforeClass;
|
9
|
+
import org.junit.Rule;
|
10
|
+
import org.junit.Test;
|
7
11
|
|
8
|
-
import java.io.IOException;
|
9
12
|
import java.io.FileNotFoundException;
|
10
|
-
import java.security.GeneralSecurityException;
|
11
|
-
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
12
13
|
|
14
|
+
import java.io.IOException;
|
13
15
|
import java.lang.reflect.Field;
|
14
|
-
import
|
15
|
-
|
16
|
-
import org.junit.Test;
|
16
|
+
import java.security.GeneralSecurityException;
|
17
|
+
|
17
18
|
import static org.junit.Assert.assertEquals;
|
18
19
|
import static org.junit.Assume.assumeNotNull;
|
19
20
|
|
@@ -35,12 +36,18 @@ public class TestGcsAuthentication
|
|
35
36
|
@BeforeClass
|
36
37
|
public static void initializeConstant()
|
37
38
|
{
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
String gcpEmail = System.getenv("GCP_EMAIL");
|
40
|
+
String gcpP12KeyFile = System.getenv("GCP_P12_KEYFILE");
|
41
|
+
String gcpJsonKeyFile = System.getenv("GCP_JSON_KEYFILE");
|
42
|
+
String gcpBucket = System.getenv("GCP_BUCKET");
|
43
|
+
|
42
44
|
// skip test cases, if environment variables are not set.
|
43
|
-
assumeNotNull(
|
45
|
+
assumeNotNull(gcpEmail, gcpP12KeyFile, gcpJsonKeyFile, gcpBucket);
|
46
|
+
|
47
|
+
GCP_EMAIL = Optional.of(gcpEmail);
|
48
|
+
GCP_P12_KEYFILE = Optional.of(gcpP12KeyFile);
|
49
|
+
GCP_JSON_KEYFILE = Optional.of(gcpJsonKeyFile);
|
50
|
+
GCP_BUCKET = gcpBucket;
|
44
51
|
}
|
45
52
|
|
46
53
|
@Rule
|
@@ -1,45 +1,47 @@
|
|
1
1
|
package org.embulk.input.gcs;
|
2
2
|
|
3
|
-
import
|
4
|
-
import java.util.Arrays;
|
5
|
-
import java.util.List;
|
6
|
-
import com.google.common.collect.ImmutableMap;
|
3
|
+
import com.google.api.services.storage.Storage;
|
7
4
|
import com.google.common.base.Optional;
|
8
5
|
import com.google.common.collect.ImmutableList;
|
6
|
+
import com.google.common.collect.ImmutableMap;
|
9
7
|
import com.google.common.collect.Lists;
|
10
|
-
import java.io.BufferedReader;
|
11
|
-
import java.io.InputStream;
|
12
|
-
import java.io.InputStreamReader;
|
13
|
-
import java.io.IOException;
|
14
|
-
import java.security.GeneralSecurityException;
|
15
|
-
|
16
8
|
import org.embulk.EmbulkTestRuntime;
|
17
|
-
import org.embulk.config.TaskReport;
|
18
|
-
import org.embulk.config.TaskSource;
|
19
9
|
import org.embulk.config.ConfigDiff;
|
20
|
-
import org.embulk.config.ConfigSource;
|
21
10
|
import org.embulk.config.ConfigException;
|
11
|
+
import org.embulk.config.ConfigSource;
|
12
|
+
import org.embulk.config.TaskReport;
|
13
|
+
import org.embulk.config.TaskSource;
|
14
|
+
import org.embulk.input.gcs.GcsFileInputPlugin.PluginTask;
|
22
15
|
import org.embulk.spi.Exec;
|
23
16
|
import org.embulk.spi.FileInputPlugin;
|
24
17
|
import org.embulk.spi.FileInputRunner;
|
25
18
|
import org.embulk.spi.InputPlugin;
|
26
|
-
import org.embulk.spi.util.Pages;
|
27
19
|
import org.embulk.spi.Schema;
|
28
20
|
import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
|
29
|
-
import org.embulk.
|
21
|
+
import org.embulk.spi.util.Pages;
|
30
22
|
import org.embulk.standards.CsvParserPlugin;
|
31
|
-
|
32
|
-
import com.google.api.services.storage.Storage;
|
33
|
-
|
34
|
-
import org.junit.BeforeClass;
|
35
23
|
import org.junit.Before;
|
24
|
+
import org.junit.BeforeClass;
|
36
25
|
import org.junit.Rule;
|
37
26
|
import org.junit.Test;
|
27
|
+
|
28
|
+
import java.io.BufferedReader;
|
29
|
+
|
30
|
+
import java.io.IOException;
|
31
|
+
import java.io.InputStream;
|
32
|
+
import java.io.InputStreamReader;
|
33
|
+
import java.security.GeneralSecurityException;
|
34
|
+
import java.util.ArrayList;
|
35
|
+
import java.util.Arrays;
|
36
|
+
import java.util.List;
|
37
|
+
|
38
38
|
import static org.junit.Assert.assertEquals;
|
39
39
|
import static org.junit.Assume.assumeNotNull;
|
40
|
-
|
40
|
+
|
41
41
|
import java.lang.reflect.InvocationTargetException;
|
42
42
|
|
43
|
+
import java.lang.reflect.Method;
|
44
|
+
|
43
45
|
public class TestGcsFileInputPlugin
|
44
46
|
{
|
45
47
|
private static Optional<String> GCP_EMAIL;
|
@@ -48,7 +50,7 @@ public class TestGcsFileInputPlugin
|
|
48
50
|
private static String GCP_BUCKET;
|
49
51
|
private static String GCP_BUCKET_DIRECTORY;
|
50
52
|
private static String GCP_PATH_PREFIX;
|
51
|
-
private
|
53
|
+
private static String GCP_APPLICATION_NAME;
|
52
54
|
private FileInputRunner runner;
|
53
55
|
private MockPageOutput output;
|
54
56
|
|
@@ -62,12 +64,18 @@ public class TestGcsFileInputPlugin
|
|
62
64
|
@BeforeClass
|
63
65
|
public static void initializeConstant()
|
64
66
|
{
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
String gcpEmail = System.getenv("GCP_EMAIL");
|
68
|
+
String gcpP12KeyFile = System.getenv("GCP_P12_KEYFILE");
|
69
|
+
String gcpJsonKeyFile = System.getenv("GCP_JSON_KEYFILE");
|
70
|
+
String gcpBucket = System.getenv("GCP_BUCKET");
|
71
|
+
|
69
72
|
// skip test cases, if environment variables are not set.
|
70
|
-
assumeNotNull(
|
73
|
+
assumeNotNull(gcpEmail, gcpP12KeyFile, gcpJsonKeyFile, gcpBucket);
|
74
|
+
|
75
|
+
GCP_EMAIL = Optional.of(gcpEmail);
|
76
|
+
GCP_P12_KEYFILE = Optional.of(gcpP12KeyFile);
|
77
|
+
GCP_JSON_KEYFILE = Optional.of(gcpJsonKeyFile);
|
78
|
+
GCP_BUCKET = gcpBucket;
|
71
79
|
|
72
80
|
GCP_BUCKET_DIRECTORY = System.getenv("GCP_BUCKET_DIRECTORY") != null ? getDirectory(System.getenv("GCP_BUCKET_DIRECTORY")) : getDirectory("");
|
73
81
|
GCP_PATH_PREFIX = GCP_BUCKET_DIRECTORY + "sample_";
|
@@ -245,7 +253,8 @@ public class TestGcsFileInputPlugin
|
|
245
253
|
PluginTask task = config.loadConfig(PluginTask.class);
|
246
254
|
ConfigDiff configDiff = plugin.transaction(config, new FileInputPlugin.Control() {
|
247
255
|
@Override
|
248
|
-
public List<TaskReport> run(TaskSource taskSource, int taskCount)
|
256
|
+
public List<TaskReport> run(TaskSource taskSource, int taskCount)
|
257
|
+
{
|
249
258
|
assertEquals(2, taskCount);
|
250
259
|
return emptyTaskReports(taskCount);
|
251
260
|
}
|
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.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Akama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,6 +49,8 @@ files:
|
|
49
49
|
- ChangeLog
|
50
50
|
- README.md
|
51
51
|
- build.gradle
|
52
|
+
- config/checkstyle/checkstyle.xml
|
53
|
+
- config/checkstyle/default.xml
|
52
54
|
- gradle/wrapper/gradle-wrapper.jar
|
53
55
|
- gradle/wrapper/gradle-wrapper.properties
|
54
56
|
- gradlew
|
@@ -63,12 +65,12 @@ files:
|
|
63
65
|
- src/test/resources/sample_02.csv
|
64
66
|
- classpath/commons-codec-1.3.jar
|
65
67
|
- classpath/commons-logging-1.1.1.jar
|
66
|
-
- classpath/embulk-input-gcs-0.1.
|
67
|
-
- classpath/google-api-client-1.
|
68
|
-
- classpath/google-api-services-storage-v1-
|
69
|
-
- classpath/google-http-client-1.
|
70
|
-
- classpath/google-http-client-jackson2-1.
|
71
|
-
- classpath/google-oauth-client-1.
|
68
|
+
- classpath/embulk-input-gcs-0.1.13.jar
|
69
|
+
- classpath/google-api-client-1.21.0.jar
|
70
|
+
- classpath/google-api-services-storage-v1-rev59-1.21.0.jar
|
71
|
+
- classpath/google-http-client-1.21.0.jar
|
72
|
+
- classpath/google-http-client-jackson2-1.21.0.jar
|
73
|
+
- classpath/google-oauth-client-1.21.0.jar
|
72
74
|
- classpath/httpclient-4.0.1.jar
|
73
75
|
- classpath/httpcore-4.0.1.jar
|
74
76
|
- classpath/jsr305-1.3.9.jar
|
Binary file
|
Binary file
|