@@ -284,6 +284,9 @@ type Options struct {
284
284
// MakeSignBytes is a factory for functions that are being used in place of an empty SignBytes.
285
285
// If your implementation of 'SignBytes' needs a request context, set this instead.
286
286
MakeSignBytes func (requestCtx context.Context ) SignBytesFunc
287
+
288
+ // ClientOptions are passed when constructing the storage.Client.
289
+ ClientOptions []option.ClientOption
287
290
}
288
291
289
292
// clear clears all the fields of o.
@@ -306,6 +309,7 @@ func openBucket(ctx context.Context, client *gcp.HTTPClient, bucketName string,
306
309
return nil , errors .New ("gcsblob.OpenBucket: bucketName is required" )
307
310
}
308
311
312
+ // We wrap the provided http.Client to add a Go CDK User-Agent.
309
313
clientOpts := []option.ClientOption {option .WithHTTPClient (useragent .HTTPClient (& client .Client , "blob" ))}
310
314
if host := os .Getenv ("STORAGE_EMULATOR_HOST" ); host != "" {
311
315
clientOpts = []option.ClientOption {
@@ -314,15 +318,14 @@ func openBucket(ctx context.Context, client *gcp.HTTPClient, bucketName string,
314
318
option .WithHTTPClient (http .DefaultClient ),
315
319
}
316
320
}
317
-
318
- // We wrap the provided http.Client to add a Go CDK User-Agent.
321
+ if opts == nil {
322
+ opts = & Options {}
323
+ }
324
+ clientOpts = append (clientOpts , opts .ClientOptions ... )
319
325
c , err := storage .NewClient (ctx , clientOpts ... )
320
326
if err != nil {
321
327
return nil , err
322
328
}
323
- if opts == nil {
324
- opts = & Options {}
325
- }
326
329
return & bucket {name : bucketName , client : c , opts : opts }, nil
327
330
}
328
331
0 commit comments