@@ -141,15 +141,26 @@ func NewSpannerDatastore(ctx context.Context, database string, opts ...Option) (
141
141
cfg := spanner .DefaultSessionPoolConfig
142
142
cfg .MinOpened = config .minSessions
143
143
cfg .MaxOpened = config .maxSessions
144
- client , err := spanner .NewClientWithConfig (context .Background (), database ,
145
- spanner.ClientConfig {SessionPoolConfig : cfg },
144
+
145
+ var spannerOpts []option.ClientOption
146
+ if config .credentialsJSON != nil {
147
+ spannerOpts = append (spannerOpts , option .WithCredentialsJSON (config .credentialsJSON ))
148
+ }
149
+
150
+ spannerOpts = append (spannerOpts ,
146
151
option .WithCredentialsFile (config .credentialsFilePath ),
147
- option .WithCredentialsJSON (config .credentialsJSON ),
148
152
option .WithGRPCConnectionPool (max (config .readMaxOpen , config .writeMaxOpen )),
149
153
option .WithGRPCDialOption (
150
154
grpc .WithStatsHandler (otelgrpc .NewClientHandler ()),
151
155
),
152
156
)
157
+
158
+ client , err := spanner .NewClientWithConfig (
159
+ context .Background (),
160
+ database ,
161
+ spanner.ClientConfig {SessionPoolConfig : cfg },
162
+ spannerOpts ... ,
163
+ )
153
164
if err != nil {
154
165
return nil , common .RedactAndLogSensitiveConnString (ctx , errUnableToInstantiate , err , database )
155
166
}
0 commit comments