Skip to content

Commit 8528f94

Browse files
authored
Update watch-example.ts
1 parent 0901818 commit 8528f94

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
import k8s = require('@kubernetes/client-node');
1+
import * as k8s from '@kubernetes/client-node';
22

3-
let kc = new k8s.KubeConfig();
3+
const kc = new k8s.KubeConfig();
44
kc.loadFromDefault();
55

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',
88
// optional query parameters can go here.
9-
{},
9+
{},
1010
// callback is called for each received object.
1111
(type, obj) => {
12-
if (type == 'ADDED') {
12+
if (type === 'ADDED') {
1313
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') {
1717
console.log('deleted object:');
1818
} else {
1919
console.log('unknown type: ' + type);
2020
}
21+
2122
console.log(obj);
2223
},
2324
// done callback is called if the watch terminates normally
2425
(err) => {
25-
if (err) {
26-
console.log(err);
27-
}
26+
console.log(err);
2827
});
2928

3029
// watch returns a request object which you can use to abort the watch.
31-
setTimeout(() => { req.abort(); }, 10 * 1000);
30+
setTimeout(() => { req.abort();}, 10 * 1000);

0 commit comments

Comments
 (0)