You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/12/20 13:26:33 UTC
[camel] 01/03: CAMEL-17351 - Camel Google Functions: Make it possible to configure service account key file as we do in Pubsub and Storage
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0de88e913b3593e3297f7c4ccc002f465d6c0298
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 20 14:21:57 2021 +0100
CAMEL-17351 - Camel Google Functions: Make it possible to configure service account key file as we do in Pubsub and Storage
---
.../google/functions/GoogleCloudFunctionsClientFactory.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsClientFactory.java b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsClientFactory.java
index 354c543..32ad7c2 100644
--- a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsClientFactory.java
+++ b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsClientFactory.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.google.functions;
import java.io.FileInputStream;
+import java.io.InputStream;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.Credentials;
@@ -25,6 +26,7 @@ import com.google.cloud.functions.v1.CloudFunctionsServiceClient;
import com.google.cloud.functions.v1.CloudFunctionsServiceSettings;
import com.google.common.base.Strings;
import org.apache.camel.CamelContext;
+import org.apache.camel.support.ResourceHelper;
public final class GoogleCloudFunctionsClientFactory {
/**
@@ -39,8 +41,10 @@ public final class GoogleCloudFunctionsClientFactory {
throws Exception {
CloudFunctionsServiceClient cloudFunctionsClient = null;
if (!Strings.isNullOrEmpty(configuration.getServiceAccountKey())) {
+ InputStream resolveMandatoryResourceAsInputStream
+ = ResourceHelper.resolveMandatoryResourceAsInputStream(context, configuration.getServiceAccountKey());
Credentials myCredentials = ServiceAccountCredentials
- .fromStream(new FileInputStream(configuration.getServiceAccountKey()));
+ .fromStream(resolveMandatoryResourceAsInputStream);
CloudFunctionsServiceSettings settings = CloudFunctionsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
cloudFunctionsClient = CloudFunctionsServiceClient.create(settings);