1
+ import { ObjectSerializer } from './api' ;
1
2
import {
2
3
ADD ,
3
4
CHANGE ,
@@ -15,6 +16,7 @@ import { RequestResult, Watch } from './watch';
15
16
16
17
export interface ObjectCache < T > {
17
18
get ( name : string , namespace ?: string ) : T | undefined ;
19
+
18
20
list ( namespace ?: string ) : ReadonlyArray < T > ;
19
21
}
20
22
@@ -31,6 +33,7 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T>, In
31
33
private readonly watch : Watch ,
32
34
private readonly listFn : ListPromise < T > ,
33
35
autoStart : boolean = true ,
36
+ private readonly labelSelector ?: string ,
34
37
) {
35
38
this . callbackCache [ ADD ] = [ ] ;
36
39
this . callbackCache [ UPDATE ] = [ ] ;
@@ -142,9 +145,18 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T>, In
142
145
}
143
146
} ) ;
144
147
this . addOrUpdateItems ( list . items ) ;
148
+ const queryParams = {
149
+ resourceVersion : list . metadata ! . resourceVersion ,
150
+ } as {
151
+ resourceVersion : string | undefined ,
152
+ labelSelector : string | undefined ,
153
+ } ;
154
+ if ( this . labelSelector !== undefined ) {
155
+ queryParams . labelSelector = ObjectSerializer . serialize ( this . labelSelector , 'string' ) ;
156
+ }
145
157
this . request = await this . watch . watch (
146
158
this . path ,
147
- { resourceVersion : list . metadata ! . resourceVersion } ,
159
+ queryParams ,
148
160
this . watchHandler . bind ( this ) ,
149
161
this . doneHandler . bind ( this ) ,
150
162
) ;
0 commit comments