Skip to content

Commit 93891c7

Browse files
committed
Fix formatting and linting errors.
1 parent e53ed44 commit 93891c7

12 files changed

+124
-187
lines changed

src/attach.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,17 @@ export class Attach {
3333
};
3434
const queryStr = querystring.stringify(query);
3535
const path = `/api/v1/namespaces/${namespace}/pods/${podName}/attach?${queryStr}`;
36-
const conn = await this.handler.connect(
37-
path,
38-
null,
39-
(streamNum: number, buff: Buffer): boolean => {
40-
WebSocketHandler.handleStandardStreams(streamNum, buff, stdout, stderr);
41-
return true;
42-
},
43-
);
36+
const conn = await this.handler.connect(path, null, (streamNum: number, buff: Buffer): boolean => {
37+
WebSocketHandler.handleStandardStreams(streamNum, buff, stdout, stderr);
38+
return true;
39+
});
4440
if (stdin != null) {
4541
WebSocketHandler.handleStandardInput(conn, stdin, WebSocketHandler.StdinStream);
4642
}
4743
if (isResizable(stdout)) {
4844
this.terminalSizeQueue = new TerminalSizeQueue();
4945
WebSocketHandler.handleStandardInput(conn, this.terminalSizeQueue, WebSocketHandler.ResizeStream);
50-
this.terminalSizeQueue.handleResizes((stdout as any) as ResizableStream);
46+
this.terminalSizeQueue.handleResizes(stdout as any as ResizableStream);
5147
}
5248
return conn;
5349
}

src/cache.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T>, In
2727
private objects: CacheMap<T> = new Map();
2828
private resourceVersion: string;
2929
private readonly callbackCache: {
30-
[key: string]: Array<ObjectCallback<T> | ErrorCallback>;
30+
[key: string]: (ObjectCallback<T> | ErrorCallback)[];
3131
} = {};
3232
private request: RequestResult | undefined;
3333
private stopped: boolean = false;
@@ -242,7 +242,7 @@ export function cacheMapFromList<T extends KubernetesObject>(newObjects: T[]): C
242242
export function deleteItems<T extends KubernetesObject>(
243243
oldObjects: CacheMap<T>,
244244
newObjects: T[],
245-
deleteCallback?: Array<ObjectCallback<T>>,
245+
deleteCallback?: ObjectCallback<T>[],
246246
): CacheMap<T> {
247247
const newObjectsMap = cacheMapFromList(newObjects);
248248

@@ -274,8 +274,8 @@ export function deleteItems<T extends KubernetesObject>(
274274
export function addOrUpdateObject<T extends KubernetesObject>(
275275
objects: CacheMap<T>,
276276
obj: T,
277-
addCallbacks?: Array<ObjectCallback<T>>,
278-
updateCallbacks?: Array<ObjectCallback<T>>,
277+
addCallbacks?: ObjectCallback<T>[],
278+
updateCallbacks?: ObjectCallback<T>[],
279279
): void {
280280
let namespaceObjects = objects.get(obj.metadata!.namespace || '');
281281
if (!namespaceObjects) {
@@ -312,7 +312,7 @@ function isSameVersion<T extends KubernetesObject>(o1: T, o2: T): boolean {
312312
export function deleteObject<T extends KubernetesObject>(
313313
objects: CacheMap<T>,
314314
obj: T,
315-
deleteCallbacks?: Array<ObjectCallback<T>>,
315+
deleteCallbacks?: ObjectCallback<T>[],
316316
): void {
317317
const namespace = obj.metadata!.namespace || '';
318318
const name = obj.metadata!.name || '';

src/cache_test.ts

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const fakeConfig: {
5353
describe('ListWatchCache', () => {
5454
it('should throw on unknown update', () => {
5555
const fake = mock.mock(Watch);
56-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
56+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
5757
response: http.IncomingMessage;
5858
body: V1NamespaceList;
5959
}> {
@@ -116,7 +116,7 @@ describe('ListWatchCache', () => {
116116
} as V1PodList;
117117

118118
let calls = 0;
119-
const listFn: ListPromise<V1Pod> = function(): Promise<{
119+
const listFn: ListPromise<V1Pod> = function (): Promise<{
120120
response: http.IncomingMessage;
121121
body: V1PodList;
122122
}> {
@@ -238,7 +238,7 @@ describe('ListWatchCache', () => {
238238
} as V1NamespaceList;
239239

240240
let calls = 0;
241-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
241+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
242242
response: http.IncomingMessage;
243243
body: V1NamespaceList;
244244
}> {
@@ -339,7 +339,7 @@ describe('ListWatchCache', () => {
339339
items: list,
340340
} as V1NamespaceList;
341341

342-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
342+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
343343
response: http.IncomingMessage;
344344
body: V1NamespaceList;
345345
}> {
@@ -399,15 +399,11 @@ describe('ListWatchCache', () => {
399399
} as V1Namespace);
400400

401401
return Promise.all([
402-
expect(addPromise)
403-
.to.eventually.have.property('metadata')
404-
.that.deep.equals({ name: 'name3' }),
402+
expect(addPromise).to.eventually.have.property('metadata').that.deep.equals({ name: 'name3' }),
405403
expect(updatePromise)
406404
.to.eventually.have.property('metadata')
407405
.that.deep.equals({ name: 'name3', resourceVersion: 'baz' }),
408-
expect(deletePromise)
409-
.to.eventually.have.property('metadata')
410-
.that.deep.equals({ name: 'name2' }),
406+
expect(deletePromise).to.eventually.have.property('metadata').that.deep.equals({ name: 'name2' }),
411407
]);
412408
});
413409

@@ -432,7 +428,7 @@ describe('ListWatchCache', () => {
432428
items: list,
433429
} as V1NamespaceList;
434430

435-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
431+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
436432
response: http.IncomingMessage;
437433
body: V1NamespaceList;
438434
}> {
@@ -495,7 +491,7 @@ describe('ListWatchCache', () => {
495491
items: [],
496492
} as V1NamespaceList;
497493

498-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
494+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
499495
response: http.IncomingMessage;
500496
body: V1NamespaceList;
501497
}> {
@@ -536,12 +532,8 @@ describe('ListWatchCache', () => {
536532
} as V1Namespace);
537533

538534
return Promise.all([
539-
expect(addPromise)
540-
.to.eventually.have.property('metadata')
541-
.that.deep.equals({ name: 'name3' }),
542-
expect(addPromise2)
543-
.to.eventually.have.property('metadata')
544-
.that.deep.equals({ name: 'name3' }),
535+
expect(addPromise).to.eventually.have.property('metadata').that.deep.equals({ name: 'name3' }),
536+
expect(addPromise2).to.eventually.have.property('metadata').that.deep.equals({ name: 'name3' }),
545537
]);
546538
});
547539

@@ -568,7 +560,7 @@ describe('ListWatchCache', () => {
568560
items: list,
569561
} as V1NamespaceList;
570562

571-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
563+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
572564
response: http.IncomingMessage;
573565
body: V1NamespaceList;
574566
}> {
@@ -644,7 +636,7 @@ describe('ListWatchCache', () => {
644636
items: list,
645637
} as V1NamespaceList;
646638

647-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
639+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
648640
response: http.IncomingMessage;
649641
body: V1NamespaceList;
650642
}> {
@@ -724,7 +716,7 @@ describe('ListWatchCache', () => {
724716
items: list,
725717
} as V1NamespaceList;
726718

727-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
719+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
728720
response: http.IncomingMessage;
729721
body: V1NamespaceList;
730722
}> {
@@ -854,7 +846,7 @@ describe('ListWatchCache', () => {
854846
} as V1ListMeta,
855847
items: list,
856848
} as V1NamespaceList;
857-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
849+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
858850
response: http.IncomingMessage;
859851
body: V1NamespaceList;
860852
}> {
@@ -870,11 +862,11 @@ describe('ListWatchCache', () => {
870862
const informer = new ListWatch('/some/path', mock.instance(fakeWatch), listFn);
871863

872864
const addedList1: V1Namespace[] = [];
873-
const addToList1Fn = function(obj?: V1Namespace) {
865+
const addToList1Fn = function (obj?: V1Namespace) {
874866
addedList1.push(obj!);
875867
};
876868
const addedList2: V1Namespace[] = [];
877-
const addToList2Fn = function(obj?: V1Namespace) {
869+
const addToList2Fn = function (obj?: V1Namespace) {
878870
addedList2.push(obj!);
879871
};
880872

@@ -913,7 +905,7 @@ describe('ListWatchCache', () => {
913905
} as V1ListMeta,
914906
items: list,
915907
} as V1NamespaceList;
916-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
908+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
917909
response: http.IncomingMessage;
918910
body: V1NamespaceList;
919911
}> {
@@ -929,10 +921,10 @@ describe('ListWatchCache', () => {
929921
const informer = new ListWatch('/some/path', mock.instance(fakeWatch), listFn);
930922

931923
const addedList: V1Namespace[] = [];
932-
const addToListFn = function(obj?: V1Namespace) {
924+
const addToListFn = function (obj?: V1Namespace) {
933925
addedList.push(obj!);
934926
};
935-
const removeSelf = function() {
927+
const removeSelf = function () {
936928
informer.off('add', removeSelf);
937929
};
938930

@@ -974,7 +966,7 @@ describe('ListWatchCache', () => {
974966
items: list,
975967
} as V1NamespaceList;
976968

977-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
969+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
978970
response: http.IncomingMessage;
979971
body: V1NamespaceList;
980972
}> {
@@ -1001,7 +993,7 @@ describe('ListWatchCache', () => {
1001993
} as V1ListMeta,
1002994
items: list,
1003995
} as V1NamespaceList;
1004-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
996+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
1005997
response: http.IncomingMessage;
1006998
body: V1NamespaceList;
1007999
}> {
@@ -1017,11 +1009,11 @@ describe('ListWatchCache', () => {
10171009
const informer = new ListWatch('/some/path', mock.instance(fakeWatch), listFn);
10181010

10191011
const addedList1: V1Namespace[] = [];
1020-
const addToList1Fn = function(obj?: V1Namespace) {
1012+
const addToList1Fn = function (obj?: V1Namespace) {
10211013
addedList1.push(obj!);
10221014
};
10231015
const addedList2: V1Namespace[] = [];
1024-
const addToList2Fn = function(obj?: V1Namespace) {
1016+
const addToList2Fn = function (obj?: V1Namespace) {
10251017
addedList2.push(obj!);
10261018
};
10271019

@@ -1079,7 +1071,7 @@ describe('ListWatchCache', () => {
10791071
items: list,
10801072
} as V1NamespaceList;
10811073

1082-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1074+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
10831075
response: http.IncomingMessage;
10841076
body: V1NamespaceList;
10851077
}> {
@@ -1142,7 +1134,7 @@ describe('ListWatchCache', () => {
11421134
items: list,
11431135
} as V1NamespaceList;
11441136

1145-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1137+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
11461138
response: http.IncomingMessage;
11471139
body: V1NamespaceList;
11481140
}> {
@@ -1188,7 +1180,7 @@ describe('ListWatchCache', () => {
11881180
items: list,
11891181
} as V1NamespaceList;
11901182

1191-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1183+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
11921184
response: http.IncomingMessage;
11931185
body: V1NamespaceList;
11941186
}> {
@@ -1245,7 +1237,7 @@ describe('ListWatchCache', () => {
12451237
} as V1NamespaceList;
12461238

12471239
let listCalls = 0;
1248-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1240+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
12491241
response: http.IncomingMessage;
12501242
body: V1NamespaceList;
12511243
}> {
@@ -1326,7 +1318,7 @@ describe('ListWatchCache', () => {
13261318
} as V1NamespaceList;
13271319

13281320
let listCalls = 0;
1329-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1321+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
13301322
response: http.IncomingMessage;
13311323
body: V1NamespaceList;
13321324
}> {
@@ -1417,7 +1409,7 @@ describe('ListWatchCache', () => {
14171409
items: list,
14181410
} as V1NamespaceList;
14191411

1420-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1412+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
14211413
response: http.IncomingMessage;
14221414
body: V1NamespaceList;
14231415
}> {
@@ -1456,7 +1448,7 @@ describe('ListWatchCache', () => {
14561448
items: list,
14571449
} as V1NamespaceList;
14581450

1459-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1451+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
14601452
response: http.IncomingMessage;
14611453
body: V1NamespaceList;
14621454
}> {
@@ -1547,7 +1539,7 @@ describe('delete items', () => {
15471539
items: [],
15481540
} as V1NamespaceList;
15491541

1550-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1542+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
15511543
response: http.IncomingMessage;
15521544
body: V1NamespaceList;
15531545
}> {
@@ -1591,7 +1583,7 @@ describe('delete items', () => {
15911583
items: list,
15921584
} as V1NamespaceList;
15931585

1594-
const listFn: ListPromise<V1Namespace> = function(): Promise<{
1586+
const listFn: ListPromise<V1Namespace> = function (): Promise<{
15951587
response: http.IncomingMessage;
15961588
body: V1NamespaceList;
15971589
}> {

src/config.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,15 @@ export function bufferFromFileOrString(file?: string, data?: string): Buffer | n
526526
}
527527

528528
function dropDuplicatesAndNils(a: string[]): string[] {
529-
return a.reduce(
530-
(acceptedValues, currentValue) => {
531-
// Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
532-
// of unique non-empty strings.
533-
if (currentValue && !acceptedValues.includes(currentValue)) {
534-
return acceptedValues.concat(currentValue);
535-
} else {
536-
return acceptedValues;
537-
}
538-
},
539-
[] as string[],
540-
);
529+
return a.reduce((acceptedValues, currentValue) => {
530+
// Good-enough algorithm for reducing a small (3 items at this point) array into an ordered list
531+
// of unique non-empty strings.
532+
if (currentValue && !acceptedValues.includes(currentValue)) {
533+
return acceptedValues.concat(currentValue);
534+
} else {
535+
return acceptedValues;
536+
}
537+
}, [] as string[]);
541538
}
542539

543540
// Only public for testing.

0 commit comments

Comments
 (0)