From 71998caef9f1994e3f50892359351d20525f6876 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:46:44 +0000 Subject: [PATCH 1/5] remove unecessary http request when running all checks Signed-off-by: goenning --- plugins/tech-insights/src/api/TechInsightsClient.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index 43979e60b0..e69fb5ceeb 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -66,20 +66,20 @@ export class TechInsightsClient implements TechInsightsApi { async runChecks( entityParams: EntityName, - checks: Check[], + checks?: Check[], ): Promise { 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}` }), From 96fb10fe254d34448aab45e45eb20ccaa8250f12 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:47:33 +0000 Subject: [PATCH 2/5] remove unecessary http request when running all checks Signed-off-by: goenning --- .changeset/small-monkeys-live.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/small-monkeys-live.md diff --git a/.changeset/small-monkeys-live.md b/.changeset/small-monkeys-live.md new file mode 100644 index 0000000000..be07e28e3a --- /dev/null +++ b/.changeset/small-monkeys-live.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-tech-insights': patch +--- + +remove unecessary http request when running all checks From 462c445892c6841bdd82e439387ae487347c445c Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:51:15 +0000 Subject: [PATCH 3/5] remove unecessary type Signed-off-by: goenning --- plugins/tech-insights/src/api/TechInsightsClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index e69fb5ceeb..d9d56f8048 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -71,7 +71,7 @@ export class TechInsightsClient implements TechInsightsApi { const url = await this.discoveryApi.getBaseUrl('tech-insights'); const token = await this.identityApi.getIdToken(); const { namespace, kind, name } = entityParams; - const checkIds = checks ? checks.map((check: Check) => check.id) : []; + const checkIds = checks ? checks.map(check => check.id) : []; const requestBody = { checks: checkIds.length > 0 ? checkIds : null }; const response = await fetch( `${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent( From e1aed5231fd47fa23dfb9a4986229f3b7e09570c Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:53:08 +0000 Subject: [PATCH 4/5] fix typo Signed-off-by: goenning --- .changeset/small-monkeys-live.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/small-monkeys-live.md b/.changeset/small-monkeys-live.md index be07e28e3a..2e5a8ff719 100644 --- a/.changeset/small-monkeys-live.md +++ b/.changeset/small-monkeys-live.md @@ -2,4 +2,4 @@ '@backstage/plugin-tech-insights': patch --- -remove unecessary http request when running all checks +remove unnecessary http request when running all checks From e4abf1870864cc3e2d6764f79da13acf6976026f Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:57:30 +0000 Subject: [PATCH 5/5] replace null with undefined Signed-off-by: goenning --- plugins/tech-insights/src/api/TechInsightsClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index d9d56f8048..2298f463f5 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -72,7 +72,7 @@ export class TechInsightsClient implements TechInsightsApi { const token = await this.identityApi.getIdToken(); const { namespace, kind, name } = entityParams; const checkIds = checks ? checks.map(check => check.id) : []; - const requestBody = { checks: checkIds.length > 0 ? checkIds : null }; + const requestBody = { checks: checkIds.length > 0 ? checkIds : undefined }; const response = await fetch( `${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent( kind,