1818
1919import static feast .core .util .PipelineUtil .detectClassPathResourcesToStage ;
2020
21+ import com .google .api .client .auth .oauth2 .Credential ;
2122import com .google .api .client .googleapis .auth .oauth2 .GoogleCredential ;
2223import com .google .api .client .googleapis .javanet .GoogleNetHttpTransport ;
2324import com .google .api .client .json .jackson2 .JacksonFactory ;
@@ -66,16 +67,15 @@ public class DataflowJobManager implements JobManager {
6667
6768 public DataflowJobManager (
6869 Map <String , String > runnerConfigOptions , MetricsProperties metricsProperties ) {
70+ this (runnerConfigOptions , metricsProperties , getGoogleCredential ());
71+ }
6972
70- DataflowRunnerConfig config = new DataflowRunnerConfig (runnerConfigOptions );
73+ public DataflowJobManager (
74+ Map <String , String > runnerConfigOptions ,
75+ MetricsProperties metricsProperties ,
76+ Credential credential ) {
7177
72- GoogleCredential credential = null ;
73- try {
74- credential = GoogleCredential .getApplicationDefault ().createScoped (DataflowScopes .all ());
75- } catch (IOException e ) {
76- throw new IllegalStateException (
77- "Unable to find credential required for Dataflow monitoring API" , e );
78- }
78+ DataflowRunnerConfig config = new DataflowRunnerConfig (runnerConfigOptions );
7979
8080 Dataflow dataflow = null ;
8181 try {
@@ -97,6 +97,17 @@ public DataflowJobManager(
9797 this .location = config .getRegion ();
9898 }
9999
100+ private static Credential getGoogleCredential () {
101+ GoogleCredential credential = null ;
102+ try {
103+ credential = GoogleCredential .getApplicationDefault ().createScoped (DataflowScopes .all ());
104+ } catch (IOException e ) {
105+ throw new IllegalStateException (
106+ "Unable to find credential required for Dataflow monitoring API" , e );
107+ }
108+ return credential ;
109+ }
110+
100111 @ Override
101112 public Runner getRunnerType () {
102113 return RUNNER_TYPE ;
0 commit comments