[
https://issues.apache.org/jira/browse/BEAM-8169?focusedWorklogId=308364&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-308364
]
ASF GitHub Bot logged work on BEAM-8169:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Sep/19 16:29
Start Date: 07/Sep/19 16:29
Worklog Time Spent: 10m
Work Description: lukecwik commented on pull request #9511: [BEAM-8169]
DataCatalogTableProvider to use GCP credentials from PipelineOptions
URL: https://github.com/apache/beam/pull/9511#discussion_r321975162
##########
File path:
sdks/java/extensions/sql/datacatalog/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datacatalog/DataCatalogClientAdapter.java
##########
@@ -31,63 +30,51 @@
import io.grpc.ManagedChannelBuilder;
import io.grpc.MethodDescriptor;
import io.grpc.auth.MoreCallCredentials;
-import java.io.IOException;
+import java.util.function.Supplier;
import javax.annotation.Nullable;
+import org.apache.beam.sdk.extensions.gcp.options.GcpOptions;
import org.apache.beam.sdk.extensions.sql.meta.Table;
/** Wraps DataCatalog GRPC client and exposes simplified APIS for Data Catalog
Table Provider. */
class DataCatalogClientAdapter {
- private DataCatalogBlockingStub dcClient;
+ private DataCatalogPipelineOptions options;
- private DataCatalogClientAdapter(DataCatalogBlockingStub dcClient) {
- this.dcClient = dcClient;
+ private Supplier<DataCatalogBlockingStub> dcClient = () ->
newClient(options);
+
+ private DataCatalogClientAdapter(DataCatalogPipelineOptions options) {
+ this.options = options;
}
/** Prod endpoint (default set in pipeline options):
datacatalog.googleapis.com. */
- public static DataCatalogClientAdapter withDefaultCredentials(String
endpoint)
- throws IOException {
- return new DataCatalogClientAdapter(newClient(endpoint));
+ public static DataCatalogClientAdapter
withOptions(DataCatalogPipelineOptions options) {
+ return new DataCatalogClientAdapter(options);
}
- private static DataCatalogBlockingStub newClient(String endpoint) throws
IOException {
+ private DataCatalogBlockingStub newClient(DataCatalogPipelineOptions
options) {
Channel authedChannel =
ClientInterceptors.intercept(
- ManagedChannelBuilder.forTarget(endpoint).build(),
- CredentialsInterceptor.defaultCredentials());
+
ManagedChannelBuilder.forTarget(options.getDataCatalogEndpoint()).build(),
+ new CredentialsInterceptor());
return DataCatalogGrpc.newBlockingStub(authedChannel);
Review comment:
You don't need to create a CredentialsInterceptor class, you can invoke
`withCallCredentials(creds)` on the return from `newBlockingStub`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 308364)
Time Spent: 40m (was: 0.5h)
> DataCatalogTableProvider should use credentials from PipelineOptions
> --------------------------------------------------------------------
>
> Key: BEAM-8169
> URL: https://issues.apache.org/jira/browse/BEAM-8169
> Project: Beam
> Issue Type: Bug
> Components: dsl-sql
> Reporter: Kenneth Knowles
> Assignee: Kenneth Knowles
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Currently it is hardcoded to the default credentials, but the use should be
> in control via PipelineOptions. This is also the mechanism for injecting
> mock/test credentials.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)