embulk-output-gcs 0.4.0 → 0.4.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41fdc69131fe0099ff844875bafa6d160510e10
|
4
|
+
data.tar.gz: 5b084d56f12509c0c273ea295519a1534d310579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f51eec122063edaffe94aa065f9bdd1dcc09752d46296f3f8d276d5af250ef82f1a2f56b7e0163f646c98731954d4bf5ce2b901f4e22b4e09033fd20fbf627
|
7
|
+
data.tar.gz: 7ed822140abca79f035a9bf59af3d472472b6bdfa4c1db505a22ae4ca0a80ca1fd380635487f72eb8fd74f706fd1e531fdf421f63b1614f6fcc5731b319c1489
|
data/build.gradle
CHANGED
@@ -255,7 +255,7 @@ public class GcsOutputPlugin implements FileOutputPlugin
|
|
255
255
|
@Override
|
256
256
|
public void finish()
|
257
257
|
{
|
258
|
-
String path = pathPrefix
|
258
|
+
String path = generateRemotePath(pathPrefix, sequenceFormat, taskIndex, fileIndex, pathSuffix);
|
259
259
|
close();
|
260
260
|
if (tempFile != null) {
|
261
261
|
currentUpload = startUpload(path);
|
@@ -419,6 +419,19 @@ public class GcsOutputPlugin implements FileOutputPlugin
|
|
419
419
|
}
|
420
420
|
}
|
421
421
|
|
422
|
+
/**
|
423
|
+
* GCS has character limitation in object names.
|
424
|
+
* @see https://cloud.google.com/storage/docs/naming#objectnames
|
425
|
+
* Although "." isn't listed at above pages, we can't access "./" path from GUI console.
|
426
|
+
* And in many cases, user don't intend of creating "/" directory under the bucket.
|
427
|
+
* This method normalizes path when it contains "./" and "/" and its variations at the beginning
|
428
|
+
*/
|
429
|
+
private static String generateRemotePath(String pathPrefix, String sequenceFormat, int taskIndex, int fileIndex, String pathSuffix)
|
430
|
+
{
|
431
|
+
String path = pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + pathSuffix;
|
432
|
+
return path.replaceFirst("^\\.*/*", "");
|
433
|
+
}
|
434
|
+
|
422
435
|
public enum AuthMethod
|
423
436
|
{
|
424
437
|
private_key("private_key"),
|
@@ -70,7 +70,7 @@ public class TestGcsOutputPlugin
|
|
70
70
|
assumeNotNull(GCP_EMAIL, GCP_P12_KEYFILE, GCP_JSON_KEYFILE, GCP_BUCKET);
|
71
71
|
|
72
72
|
GCP_BUCKET_DIRECTORY = System.getenv("GCP_BUCKET_DIRECTORY") != null ? getDirectory(System.getenv("GCP_BUCKET_DIRECTORY")) : getDirectory("");
|
73
|
-
GCP_PATH_PREFIX = GCP_BUCKET_DIRECTORY + "
|
73
|
+
GCP_PATH_PREFIX = GCP_BUCKET_DIRECTORY + "output_";
|
74
74
|
LOCAL_PATH_PREFIX = GcsOutputPlugin.class.getClassLoader().getResource("sample_01.csv").getPath();
|
75
75
|
GCP_APPLICATION_NAME = "embulk-output-gcs";
|
76
76
|
}
|
@@ -275,10 +275,28 @@ public class TestGcsOutputPlugin
|
|
275
275
|
output.finish();
|
276
276
|
output.commit();
|
277
277
|
|
278
|
-
String remotePath = GCP_PATH_PREFIX + String.format(task.getSequenceFormat(), 0,
|
278
|
+
String remotePath = GCP_PATH_PREFIX + String.format(task.getSequenceFormat(), 0, 1) + task.getFileNameExtension();
|
279
279
|
assertRecords(remotePath);
|
280
280
|
}
|
281
281
|
|
282
|
+
@Test
|
283
|
+
public void testGenerateRemotePath() throws Exception
|
284
|
+
{
|
285
|
+
ConfigSource configSource = config();
|
286
|
+
PluginTask task = configSource.loadConfig(PluginTask.class);
|
287
|
+
Method method = GcsOutputPlugin.class.getDeclaredMethod("generateRemotePath", String.class, String.class, int.class, int.class, String.class);
|
288
|
+
method.setAccessible(true);
|
289
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "/sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
290
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "./sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
291
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "../sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
292
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "//sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
293
|
+
assertEquals("path/to/sample.000.01.csv", method.invoke(plugin, "/path/to/sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
294
|
+
assertEquals("path/to/./sample.000.01.csv", method.invoke(plugin, "path/to/./sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
295
|
+
assertEquals("path/to/../sample.000.01.csv", method.invoke(plugin, "path/to/../sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
296
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "....../sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
297
|
+
assertEquals("sample.000.01.csv", method.invoke(plugin, "......///sample", task.getSequenceFormat(), 0, 1, ".csv"));
|
298
|
+
}
|
299
|
+
|
282
300
|
public ConfigSource config()
|
283
301
|
{
|
284
302
|
return Exec.newConfigSource()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-gcs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuyuki Honda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ files:
|
|
71
71
|
- src/test/resources/sample_02.csv
|
72
72
|
- classpath/commons-codec-1.3.jar
|
73
73
|
- classpath/commons-logging-1.1.1.jar
|
74
|
-
- classpath/embulk-output-gcs-0.4.
|
74
|
+
- classpath/embulk-output-gcs-0.4.1.jar
|
75
75
|
- classpath/google-api-client-1.19.1.jar
|
76
76
|
- classpath/google-api-services-storage-v1-rev28-1.19.1.jar
|
77
77
|
- classpath/google-http-client-1.19.0.jar
|