Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include traceroute checks with terraform config #396

Merged
merged 3 commits into from Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/TerraformConfig/TerraformConfig.test.tsx
Expand Up @@ -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);
});
10 changes: 0 additions & 10 deletions src/components/TerraformConfig/TerraformConfig.tsx
Expand Up @@ -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`
Expand Down Expand Up @@ -43,10 +41,6 @@ export const TerraformConfig = () => {
throw new Error("Couldn't generate TF config");
}
const checksConfig = checks?.reduce<TFCheckConfig>((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]) {
Expand Down Expand Up @@ -134,10 +128,6 @@ export const TerraformConfig = () => {
{error && <Alert title={error} />}
{config && (
<>
<Alert title="Traceroute checks" severity="warning">
Traceroute checks are not yet supported by the Grafana Terraform provider. They have been ignored from the
generated config.
</Alert>
<Alert title="Terraform and JSON" severity="info">
The exported config is using{' '}
<a href="https://www.terraform.io/docs/language/syntax/json.html">Terraform JSON syntax</a>. You can place
Expand Down
21 changes: 10 additions & 11 deletions src/components/TerraformConfig/terraformConfigUtils.ts
Expand Up @@ -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}`);
}
Expand Down