Skip to content

Commit

Permalink
configure got to not do retry request
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob committed Mar 20, 2023
1 parent b641bbc commit 2bb4005
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/daemon-commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/

import type { Response } from 'got';
import got from 'got';
import { isWindows } from './util';

Expand Down Expand Up @@ -61,7 +62,7 @@ export class DaemonCommander {
const url = this.apiPath + '/status';

try {
const { body } = await got.get(url);
const { body } = await this.get(url);
return JSON.parse(body);
} catch (error) {
// ignore status error, as it may happen when no cluster created
Expand All @@ -73,41 +74,45 @@ export class DaemonCommander {

async logs() {
const url = this.apiPath + '/logs';
const { body } = await got.get(url);
const { body } = await this.get(url);
return JSON.parse(body);
}

async version() {
const url = this.apiPath + '/version';

const { body } = await got(url);
const { body } = await this.get(url);
return JSON.parse(body);
}

async start() {
const url = this.apiPath + '/start';
const { body } = await got.get(url);
return JSON.parse(body);
const response = await this.get(url);

if (response.statusCode !== 200) {
throw new Error(response.body);
}
return JSON.parse(response.body);
}

async stop() {
const url = this.apiPath + '/stop';

const { body } = await got.get(url);
const { body } = await this.get(url);
return body;
}

async delete() {
const url = this.apiPath + '/delete';

const { body } = await got.get(url);
const { body } = await this.get(url);
return body;
}

async configGet(): Promise<Configuration> {
const url = this.apiPath + '/config';

const { body } = await got(url);
const { body } = await this.get(url);
return JSON.parse(body).Configs;
}

Expand All @@ -127,7 +132,7 @@ export class DaemonCommander {
async consoleUrl() {
const url = this.apiPath + '/webconsoleurl';

const { body } = await got(url);
const { body } = await this.get(url);
return JSON.parse(body);
}

Expand All @@ -136,16 +141,30 @@ export class DaemonCommander {

await got.post(url, {
json: value,
throwHttpErrors: false,
retry: {
limit: 0,
},
});
return 'OK';
}

async pullSecretAvailable() {
const url = this.apiPath + '/pull-secret';

const { body } = await got.get(url);
const { body } = await this.get(url);
return body;
}

private get(url: string): Promise<Response<string>> {
return got.get(url, {
enableUnixSockets: true,
throwHttpErrors: false,
retry: {
limit: 0,
},
});
}
}

export const commander = new DaemonCommander();
Expand Down

0 comments on commit 2bb4005

Please sign in to comment.