remove unecessary http request when running all checks

Signed-off-by: goenning <me@goenning.net>
This commit is contained in:
goenning
2021-12-28 14:46:44 +00:00
parent 0fdac13e7d
commit 71998caef9
@@ -66,20 +66,20 @@ export class TechInsightsClient implements TechInsightsApi {
async runChecks(
entityParams: EntityName,
checks: Check[],
checks?: Check[],
): Promise<CheckResult[]> {
const url = await this.discoveryApi.getBaseUrl('tech-insights');
const token = await this.identityApi.getIdToken();
const { namespace, kind, name } = entityParams;
const allChecks = checks ? checks : await this.getAllChecks();
const checkIds = allChecks.map((check: Check) => check.id);
const checkIds = checks ? checks.map((check: Check) => check.id) : [];
const requestBody = { checks: checkIds.length > 0 ? checkIds : null };
const response = await fetch(
`${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent(
kind,
)}/${encodeURIComponent(name)}`,
{
method: 'POST',
body: JSON.stringify({ checks: checkIds }),
body: JSON.stringify(requestBody),
headers: {
'Content-Type': 'application/json',
...(token && { Authorization: `Bearer ${token}` }),