File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
examples/typescript/watch Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
- import k8s = require ( '@kubernetes/client-node' ) ;
1
+ import * as k8s from '@kubernetes/client-node' ;
2
2
3
- let kc = new k8s . KubeConfig ( ) ;
3
+ const kc = new k8s . KubeConfig ( ) ;
4
4
kc . loadFromDefault ( ) ;
5
5
6
- let watch = new k8s . Watch ( kc ) ;
7
- let req = watch . watch ( '/api/v1/namespaces' ,
6
+ const watch = new k8s . Watch ( kc ) ;
7
+ const req = watch . watch ( '/api/v1/namespaces' ,
8
8
// optional query parameters can go here.
9
- { } ,
9
+ { } ,
10
10
// callback is called for each received object.
11
11
( type , obj ) => {
12
- if ( type == 'ADDED' ) {
12
+ if ( type === 'ADDED' ) {
13
13
console . log ( 'new object:' ) ;
14
- } else if ( type == 'MODIFIED' ) {
15
- console . log ( 'changed object:' )
16
- } else if ( type == 'DELETED' ) {
14
+ } else if ( type === 'MODIFIED' ) {
15
+ console . log ( 'changed object:' ) ;
16
+ } else if ( type === 'DELETED' ) {
17
17
console . log ( 'deleted object:' ) ;
18
18
} else {
19
19
console . log ( 'unknown type: ' + type ) ;
20
20
}
21
+
21
22
console . log ( obj ) ;
22
23
} ,
23
24
// done callback is called if the watch terminates normally
24
25
( err ) => {
25
- if ( err ) {
26
- console . log ( err ) ;
27
- }
26
+ console . log ( err ) ;
28
27
} ) ;
29
28
30
29
// watch returns a request object which you can use to abort the watch.
You can’t perform that action at this time.
0 commit comments