Skip to content

Commit 2519742

Browse files
committed
Run prettier on code base
1 parent b501093 commit 2519742

19 files changed

+267
-219
lines changed

src/attach.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ export class Attach {
1616
}
1717
}
1818

19-
public async attach(namespace: string, podName: string, containerName: string,
20-
stdout: stream.Writable | any, stderr: stream.Writable | any, stdin: stream.Readable | any,
21-
tty: boolean): Promise<WebSocket> {
19+
public async attach(
20+
namespace: string,
21+
podName: string,
22+
containerName: string,
23+
stdout: stream.Writable | any,
24+
stderr: stream.Writable | any,
25+
stdin: stream.Readable | any,
26+
tty: boolean,
27+
): Promise<WebSocket> {
2228
const query = {
2329
container: containerName,
2430
stderr: stderr != null,
@@ -28,10 +34,14 @@ export class Attach {
2834
};
2935
const queryStr = querystring.stringify(query);
3036
const path = `/api/v1/namespaces/${namespace}/pods/${podName}/attach?${queryStr}`;
31-
const conn = await this.handler.connect(path, null, (streamNum: number, buff: Buffer): boolean => {
32-
WebSocketHandler.handleStandardStreams(streamNum, buff, stdout, stderr);
33-
return true;
34-
});
37+
const conn = await this.handler.connect(
38+
path,
39+
null,
40+
(streamNum: number, buff: Buffer): boolean => {
41+
WebSocketHandler.handleStandardStreams(streamNum, buff, stdout, stderr);
42+
return true;
43+
},
44+
);
3545
if (stdin != null) {
3646
WebSocketHandler.handleStandardInput(conn, stdin);
3747
}

src/attach_test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,25 @@ describe('Attach', () => {
2121
const pod = 'somepod';
2222
const container = 'somecontainer';
2323

24-
await attach.attach(
25-
namespace, pod, container, osStream, errStream, isStream, false);
24+
await attach.attach(namespace, pod, container, osStream, errStream, isStream, false);
2625

2726
const path = `/api/v1/namespaces/${namespace}/pods/${pod}/attach`;
2827
let args = `container=${container}&stderr=true&stdin=true&stdout=true&tty=false`;
2928
verify(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).called();
3029

31-
await attach.attach(
32-
namespace, pod, container, null, null, null, false);
30+
await attach.attach(namespace, pod, container, null, null, null, false);
3331
args = `container=${container}&stderr=false&stdin=false&stdout=false&tty=false`;
3432
verify(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).called();
3533

36-
await attach.attach(
37-
namespace, pod, container, osStream, null, null, false);
34+
await attach.attach(namespace, pod, container, osStream, null, null, false);
3835
args = `container=${container}&stderr=false&stdin=false&stdout=true&tty=false`;
3936
verify(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).called();
4037

41-
await attach.attach(
42-
namespace, pod, container, osStream, errStream, null, false);
38+
await attach.attach(namespace, pod, container, osStream, errStream, null, false);
4339
args = `container=${container}&stderr=true&stdin=false&stdout=true&tty=false`;
4440
verify(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).called();
4541

46-
await attach.attach(
47-
namespace, pod, container, osStream, errStream, null, true);
42+
await attach.attach(namespace, pod, container, osStream, errStream, null, true);
4843
args = `container=${container}&stderr=true&stdin=false&stdout=true&tty=true`;
4944
verify(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).called();
5045
});
@@ -67,8 +62,7 @@ describe('Attach', () => {
6762
const fakeConn: WebSocket = mock(WebSocket);
6863
when(fakeWebSocket.connect(`${path}?${args}`, null, anyFunction())).thenResolve(fakeConn);
6964

70-
await attach.attach(
71-
namespace, pod, container, osStream, errStream, isStream, false);
65+
await attach.attach(namespace, pod, container, osStream, errStream, isStream, false);
7266
const [, , outputFn] = capture(fakeWebSocket.connect).last();
7367

7468
/* tslint:disable:no-unused-expression */

src/cache.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T> {
1212
private objects: T[] = [];
1313
private readonly indexCache: { [key: string]: T[] } = {};
1414

15-
public constructor(private readonly path: string,
16-
private readonly watch: Watch,
17-
private readonly listFn: (callback: ListCallback<T>) => void) {
15+
public constructor(
16+
private readonly path: string,
17+
private readonly watch: Watch,
18+
private readonly listFn: (callback: ListCallback<T>) => void,
19+
) {
1820
this.watch = watch;
1921
this.listFn = listFn;
2022
this.doneHandler(null);
2123
}
2224

2325
public get(name: string, namespace?: string): T | undefined {
24-
return this.objects.find((obj: T): boolean => {
25-
return (obj.metadata.name === name &&
26-
(!namespace || obj.metadata.namespace === namespace));
27-
});
26+
return this.objects.find(
27+
(obj: T): boolean => {
28+
return obj.metadata.name === name && (!namespace || obj.metadata.namespace === namespace);
29+
},
30+
);
2831
}
2932

3033
public list(namespace?: string | undefined): ReadonlyArray<T> {
@@ -86,8 +89,7 @@ export function addOrUpdateObject<T extends KubernetesObject>(objects: T[], obj:
8689
}
8790

8891
function isSameObject<T extends KubernetesObject>(o1: T, o2: T): boolean {
89-
return o1.metadata.name === o2.metadata.name &&
90-
o1.metadata.namespace === o2.metadata.namespace;
92+
return o1.metadata.name === o2.metadata.name && o1.metadata.namespace === o2.metadata.namespace;
9193
}
9294

9395
function findKubernetesObject<T extends KubernetesObject>(objects: T[], obj: T): number {

src/cache_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('ListWatchCache', () => {
3131
expect(cache.get('name1')).to.equal(list[0]);
3232
expect(cache.get('name2')).to.equal(list[1]);
3333

34-
watchHandler('ADDED', {
34+
watchHandler('ADDED', {
3535
metadata: {
3636
name: 'name3',
3737
} as V1ObjectMeta,
@@ -40,7 +40,7 @@ describe('ListWatchCache', () => {
4040
expect(cache.list().length).to.equal(3);
4141
expect(cache.get('name3')).to.not.equal(null);
4242

43-
watchHandler('MODIFIED', {
43+
watchHandler('MODIFIED', {
4444
metadata: {
4545
name: 'name3',
4646
resourceVersion: 'baz',
@@ -96,7 +96,7 @@ describe('ListWatchCache', () => {
9696
expect(cache.list('ns2').length).to.equal(1);
9797
expect(cache.list('ns2')[0].metadata.name).to.equal('name2');
9898

99-
watchHandler('ADDED', {
99+
watchHandler('ADDED', {
100100
metadata: {
101101
name: 'name3',
102102
namespace: 'ns3',
@@ -106,7 +106,7 @@ describe('ListWatchCache', () => {
106106
expect(cache.list().length).to.equal(3);
107107
expect(cache.get('name3', 'ns3')).to.not.equal(null);
108108

109-
watchHandler('MODIFIED', {
109+
watchHandler('MODIFIED', {
110110
metadata: {
111111
name: 'name3',
112112
namespace: 'ns3',

src/cloud_auth.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ interface Config {
1919
}
2020
export class CloudAuth implements Authenticator {
2121
public isAuthProvider(user: User): boolean {
22-
return (
23-
user.authProvider.name === 'azure' ||
24-
user.authProvider.name === 'gcp'
25-
);
22+
return user.authProvider.name === 'azure' || user.authProvider.name === 'gcp';
2623
}
2724

2825
public getToken(user: User): string | null {

src/config.ts

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ function fileExists(filepath: string): boolean {
1717
try {
1818
fs.accessSync(filepath);
1919
return true;
20-
// tslint:disable-next-line:no-empty
21-
} catch (ignore) { }
20+
// tslint:disable-next-line:no-empty
21+
} catch (ignore) {}
2222
return false;
2323
}
2424

2525
export class KubeConfig {
26-
private static authenticators: Authenticator[] = [
27-
new CloudAuth(),
28-
new ExecAuth(),
29-
];
26+
private static authenticators: Authenticator[] = [new CloudAuth(), new ExecAuth()];
3027

3128
/**
3229
* The list of all known clusters
@@ -213,7 +210,9 @@ export class KubeConfig {
213210
}
214211
if (process.platform === 'win32' && shelljs.which('wsl.exe')) {
215212
// TODO: Handle if someome set $KUBECONFIG in wsl here...
216-
const result = shelljs.exec('wsl.exe cat $HOME/.kube/config', { silent: true });
213+
const result = shelljs.exec('wsl.exe cat $HOME/.kube/config', {
214+
silent: true,
215+
});
217216
if (result.code === 0) {
218217
this.loadFromString(result.stdout);
219218
return;
@@ -278,12 +277,11 @@ export class KubeConfig {
278277
let token: string | null = null;
279278

280279
if (user.authProvider && user.authProvider.config) {
281-
KubeConfig.authenticators.forEach(
282-
(authenticator: Authenticator) => {
283-
if (authenticator.isAuthProvider(user)) {
284-
token = authenticator.getToken(user);
285-
}
286-
});
280+
KubeConfig.authenticators.forEach((authenticator: Authenticator) => {
281+
if (authenticator.isAuthProvider(user)) {
282+
token = authenticator.getToken(user);
283+
}
284+
});
287285
}
288286

289287
if (user.token) {
@@ -309,17 +307,14 @@ export interface ApiType {
309307
}
310308

311309
export interface ApiConstructor<T extends ApiType> {
312-
new(server: string): T;
310+
new (server: string): T;
313311
}
314312

315313
// This class is deprecated and will eventually be removed.
316314
export class Config {
317-
public static SERVICEACCOUNT_ROOT =
318-
'/var/run/secrets/kubernetes.io/serviceaccount';
319-
public static SERVICEACCOUNT_CA_PATH =
320-
Config.SERVICEACCOUNT_ROOT + '/ca.crt';
321-
public static SERVICEACCOUNT_TOKEN_PATH =
322-
Config.SERVICEACCOUNT_ROOT + '/token';
315+
public static SERVICEACCOUNT_ROOT = '/var/run/secrets/kubernetes.io/serviceaccount';
316+
public static SERVICEACCOUNT_CA_PATH = Config.SERVICEACCOUNT_ROOT + '/ca.crt';
317+
public static SERVICEACCOUNT_TOKEN_PATH = Config.SERVICEACCOUNT_ROOT + '/token';
323318

324319
public static fromFile(filename: string): api.Core_v1Api {
325320
return Config.apiFromFile(filename, api.Core_v1Api);
@@ -362,7 +357,7 @@ export class Config {
362357
}
363358

364359
// This is public really only for testing.
365-
export function bufferFromFileOrString(file ?: string, data ?: string): Buffer | null {
360+
export function bufferFromFileOrString(file?: string, data?: string): Buffer | null {
366361
if (file) {
367362
return fs.readFileSync(file);
368363
}
@@ -379,7 +374,7 @@ export function findHomeDir(): string | null {
379374
fs.accessSync(process.env.HOME);
380375
return process.env.HOME;
381376
// tslint:disable-next-line:no-empty
382-
} catch (ignore) { }
377+
} catch (ignore) {}
383378
}
384379
if (process.platform !== 'win32') {
385380
return null;
@@ -390,13 +385,13 @@ export function findHomeDir(): string | null {
390385
fs.accessSync(dir);
391386
return dir;
392387
// tslint:disable-next-line:no-empty
393-
} catch (ignore) { }
388+
} catch (ignore) {}
394389
}
395390
if (process.env.USERPROFILE) {
396391
try {
397392
fs.accessSync(process.env.USERPROFILE);
398393
return process.env.USERPROFILE;
399-
// tslint:disable-next-line:no-empty
394+
// tslint:disable-next-line:no-empty
400395
} catch (ignore) {}
401396
}
402397
return null;

0 commit comments

Comments
 (0)