File tree 2 files changed +31
-3
lines changed
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -593,9 +593,13 @@ class Logging {
593
593
reqOpts . resourceNames = arrify ( reqOpts . resourceNames ! ) ;
594
594
this . projectId = await this . auth . getProjectId ( ) ;
595
595
const resourceName = 'projects/' + this . projectId ;
596
- if ( reqOpts . resourceNames . indexOf ( resourceName ) === - 1 ) {
597
- reqOpts . resourceNames . push ( resourceName ) ;
598
- }
596
+ const isReadFromBucket = reqOpts . resourceNames . some ( resourceName =>
597
+ resourceName . startsWith ( resourceName )
598
+ ) ;
599
+ if (
600
+ reqOpts . resourceNames . indexOf ( resourceName ) === - 1 &&
601
+ ! isReadFromBucket
602
+ ) {
599
603
delete reqOpts . autoPaginate ;
600
604
delete reqOpts . gaxOptions ;
601
605
let gaxOptions = extend (
Original file line number Diff line number Diff line change @@ -616,6 +616,30 @@ describe('Logging', () => {
616
616
await logging . getEntries ( options ) ;
617
617
} ) ;
618
618
619
+ it ( 'should not push project id if include logging bucket view' , async ( ) => {
620
+ const options = {
621
+ resourceNames : [
622
+ 'projects/' +
623
+ logging . projectId +
624
+ '/locations/global/buckets/test-bucket/views/test-view' ,
625
+ ] ,
626
+ } ;
627
+
628
+ logging . loggingService . listLogEntries = async (
629
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
630
+ reqOpts : any
631
+ ) => {
632
+ assert . deepStrictEqual ( reqOpts . resourceNames , [
633
+ 'projects/' +
634
+ logging . projectId +
635
+ '/locations/global/buckets/test-bucket/views/test-view' ,
636
+ ] ) ;
637
+ return [ [ ] ] ;
638
+ } ;
639
+
640
+ await logging . getEntries ( options ) ;
641
+ } ) ;
642
+
619
643
describe ( 'error' , ( ) => {
620
644
const error = new Error ( 'Error.' ) ;
621
645
You can’t perform that action at this time.
0 commit comments