|
17 | 17 | package io.cdap.plugin.gcp.gcs.actions; |
18 | 18 |
|
19 | 19 | import com.google.cloud.kms.v1.CryptoKeyName; |
20 | | -import com.google.cloud.storage.Bucket; |
21 | | -import com.google.cloud.storage.Storage; |
22 | | -import com.google.cloud.storage.StorageException; |
23 | | -import com.google.common.base.Strings; |
24 | 20 | import io.cdap.cdap.api.annotation.Description; |
25 | 21 | import io.cdap.cdap.api.annotation.Macro; |
26 | 22 | import io.cdap.cdap.api.annotation.Name; |
|
30 | 26 | import io.cdap.cdap.etl.api.action.Action; |
31 | 27 | import io.cdap.cdap.etl.api.action.ActionContext; |
32 | 28 | import io.cdap.plugin.gcp.common.CmekUtils; |
33 | | -import io.cdap.plugin.gcp.common.GCPUtils; |
34 | 29 | import io.cdap.plugin.gcp.gcs.GCSPath; |
35 | 30 | import io.cdap.plugin.gcp.gcs.StorageClient; |
36 | 31 |
|
37 | 32 | import java.io.IOException; |
38 | 33 | import java.util.ArrayList; |
39 | | -import java.util.Collections; |
40 | 34 | import java.util.List; |
41 | 35 | import javax.annotation.Nullable; |
42 | 36 |
|
@@ -68,8 +62,16 @@ public void run(ActionContext context) throws IOException { |
68 | 62 | collector.getOrThrowException(); |
69 | 63 | return; |
70 | 64 | } |
71 | | - StorageClient storageClient = StorageClient.create(config.getProject(), config.getServiceAccount(), |
72 | | - isServiceAccountFilePath, config.readTimeout); |
| 65 | + StorageClient storageClient = null; |
| 66 | + try { |
| 67 | + storageClient = StorageClient.create(config.getProject(), config.getServiceAccount(), isServiceAccountFilePath, |
| 68 | + config.readTimeout); |
| 69 | + } catch (IOException e) { |
| 70 | + String errorReason = "Failed to create storage client, unable to load service account credentials."; |
| 71 | + collector.addFailure(String.format("%s %s", errorReason, e.getMessage()), null) |
| 72 | + .withStacktrace(e.getStackTrace()); |
| 73 | + collector.getOrThrowException(); |
| 74 | + } |
73 | 75 | GCSPath destPath = config.getDestPath(); |
74 | 76 | CryptoKeyName cmekKeyName = CmekUtils.getCmekKey(config.cmekKey, context.getArguments().asMap(), collector); |
75 | 77 | collector.getOrThrowException(); |
|
0 commit comments