From b4ee55612ae703da9821c361a6bd1650541270c0 Mon Sep 17 00:00:00 2001 From: Russ <8377044+rdubrock@users.noreply.github.com> Date: Wed, 29 Dec 2021 10:35:42 -0900 Subject: [PATCH 1/2] feat: include traceroute checks with terraform config --- .../TerraformConfig/TerraformConfig.test.tsx | 2 +- .../TerraformConfig/TerraformConfig.tsx | 8 ------- .../TerraformConfig/terraformConfigUtils.ts | 21 +++++++++---------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/components/TerraformConfig/TerraformConfig.test.tsx b/src/components/TerraformConfig/TerraformConfig.test.tsx index 4de993019..8fbb9aef9 100644 --- a/src/components/TerraformConfig/TerraformConfig.test.tsx +++ b/src/components/TerraformConfig/TerraformConfig.test.tsx @@ -71,7 +71,7 @@ it('displays correct config', async () => { }, }; if (!config[0].textContent) { - throw new Error('config has not content'); + throw new Error('config has no content'); } expect(JSON.parse(config[0].textContent)).toEqual(expectedConfig); }); diff --git a/src/components/TerraformConfig/TerraformConfig.tsx b/src/components/TerraformConfig/TerraformConfig.tsx index 453d715ee..ec011d979 100644 --- a/src/components/TerraformConfig/TerraformConfig.tsx +++ b/src/components/TerraformConfig/TerraformConfig.tsx @@ -43,10 +43,6 @@ export const TerraformConfig = () => { throw new Error("Couldn't generate TF config"); } const checksConfig = checks?.reduce((acc, check) => { - const type = checkType(check.settings); - if (type === CheckType.Traceroute) { - return acc; - } const checkConfig = checkToTF(check); const resourceName = sanitizeName(`${check.job}_${check.target}`); if (!acc[resourceName]) { @@ -134,10 +130,6 @@ export const TerraformConfig = () => { {error && } {config && ( <> - - Traceroute checks are not yet supported by the Grafana Terraform provider. They have been ignored from the - generated config. - The exported config is using{' '} Terraform JSON syntax. You can place diff --git a/src/components/TerraformConfig/terraformConfigUtils.ts b/src/components/TerraformConfig/terraformConfigUtils.ts index 77b8cad24..dcc1b1d65 100644 --- a/src/components/TerraformConfig/terraformConfigUtils.ts +++ b/src/components/TerraformConfig/terraformConfigUtils.ts @@ -99,17 +99,16 @@ const settingsToTF = (check: Check): TFCheckSettings => { }, }; case CheckType.Traceroute: - throw new Error('traceroute checks are not yet supported in the Grafana Terraform provider'); - // if (!check.settings.traceroute) { - // throw new Error(`could not translate settings to terraform config for check ${check.job}`); - // } - // return { - // traceroute: { - // max_hops: check.settings.traceroute.maxHops, - // max_unknown_hops: check.settings.traceroute.maxUnknownHops, - // ptr_lookup: check.settings.traceroute.ptrLookup, - // }, - // }; + if (!check.settings.traceroute) { + throw new Error(`could not translate settings to terraform config for check ${check.job}`); + } + return { + traceroute: { + max_hops: check.settings.traceroute.maxHops, + max_unknown_hops: check.settings.traceroute.maxUnknownHops, + ptr_lookup: check.settings.traceroute.ptrLookup, + }, + }; default: throw new Error(`could not translate settings for check to terraform config: ${check.job}`); } From 8f0a62bd86c6f9fc263b11aa4baf35231adaaf19 Mon Sep 17 00:00:00 2001 From: Russ <8377044+rdubrock@users.noreply.github.com> Date: Fri, 14 Jan 2022 07:43:42 -0900 Subject: [PATCH 2/2] chore: linting cleanup --- src/components/TerraformConfig/TerraformConfig.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/TerraformConfig/TerraformConfig.tsx b/src/components/TerraformConfig/TerraformConfig.tsx index 7f1974e3d..33a6a4887 100644 --- a/src/components/TerraformConfig/TerraformConfig.tsx +++ b/src/components/TerraformConfig/TerraformConfig.tsx @@ -7,8 +7,6 @@ import { css } from '@emotion/css'; import { GrafanaTheme2 } from '@grafana/data'; import { TFCheckConfig, TFConfig, TFProbeConfig, TFOutput } from './terraformTypes'; import { checkToTF, probeToTF, sanitizeName } from './terraformConfigUtils'; -import { checkType } from 'utils'; -import { CheckType } from 'types'; const getStyles = (theme: GrafanaTheme2) => ({ modal: css`