22
33import fs from 'fs' ;
44import path from 'path' ;
5- import type { TFCheckConfig , TFProbeConfig , TFCheckAlertsConfig , TFConfig } from '../../src/components/TerraformConfig/terraformTypes' ;
5+ import type {
6+ TFCheckConfig ,
7+ TFProbeConfig ,
8+ TFCheckAlertsConfig ,
9+ TFConfig ,
10+ } from '../../src/components/TerraformConfig/terraformTypes' ;
611
712async function generateConfigs ( ) {
813 try {
914 console . log ( 'Loading test fixtures...' ) ;
1015 const fixtures = await import ( '../../src/test/fixtures/checks' ) ;
1116 const probeFixtures = await import ( '../../src/test/fixtures/probes' ) ;
12-
17+
1318 console . log ( 'Loading REAL production terraform utilities...' ) ;
14- const { checkToTF, probeToTF, sanitizeName } = await import ( '../../src/components/TerraformConfig/terraformConfigUtils' ) ;
19+ const { checkToTF, probeToTF, sanitizeName } = await import (
20+ '../../src/components/TerraformConfig/terraformConfigUtils'
21+ ) ;
1522
1623 // Comprehensive test cases covering all check types and probe types
1724 const testCases = [
@@ -50,18 +57,18 @@ async function generateConfigs() {
5057 check : fixtures . BASIC_MULTIHTTP_CHECK ,
5158 probe : probeFixtures . ONLINE_PROBE ,
5259 } ,
53- // Scripted Check
54- {
55- name : 'basic-scripted' ,
56- check : fixtures . BASIC_SCRIPTED_CHECK ,
57- probe : probeFixtures . SCRIPTED_DISABLED_PROBE ,
58- } ,
59- // Browser Check with template literals
60- {
61- name : 'complex-browser' ,
62- check : fixtures . COMPLEX_BROWSER_CHECK ,
63- probe : probeFixtures . PRIVATE_PROBE ,
64- } ,
60+ // Scripted Check
61+ {
62+ name : 'basic-scripted' ,
63+ check : fixtures . BASIC_SCRIPTED_CHECK ,
64+ probe : probeFixtures . SCRIPTED_DISABLED_PROBE ,
65+ } ,
66+ // Browser Check with template literals
67+ {
68+ name : 'complex-browser' ,
69+ check : fixtures . COMPLEX_BROWSER_CHECK ,
70+ probe : probeFixtures . PRIVATE_PROBE ,
71+ } ,
6572 // Traceroute Check
6673 {
6774 name : 'basic-traceroute' ,
@@ -71,7 +78,7 @@ async function generateConfigs() {
7178 ] ;
7279
7380 const outputDir = 'artifacts/terraform-validation' ;
74-
81+
7582 // Ensure output directory exists
7683 if ( ! fs . existsSync ( outputDir ) ) {
7784 fs . mkdirSync ( outputDir , { recursive : true } ) ;
@@ -81,13 +88,13 @@ async function generateConfigs() {
8188 const allChecks : TFCheckConfig = { } ;
8289 const allProbes : TFProbeConfig = { } ;
8390 const allCheckAlerts : TFCheckAlertsConfig = { } ;
84-
91+
8592 for ( const testCase of testCases ) {
8693 console . log ( `Transforming ${ testCase . name } using REAL production checkToTF and probeToTF...` ) ;
87-
94+
8895 const checkTF = checkToTF ( testCase . check ) ;
8996 const probeTF = probeToTF ( testCase . probe ) ;
90-
97+
9198 // Add to comprehensive config
9299 allChecks [ testCase . name . replace ( '-' , '_' ) ] = checkTF ;
93100 allProbes [ `${ testCase . name . replace ( '-' , '_' ) } _probe` ] = probeTF ;
@@ -101,7 +108,7 @@ async function generateConfigs() {
101108 name : alert . name ,
102109 threshold : alert . threshold ,
103110 period : alert . period ,
104- runbook_url : alert . runbookUrl || "" ,
111+ runbook_url : alert . runbookUrl || '' ,
105112 } ) ) ,
106113 } ;
107114 console . log ( ` → Added alerts for ${ testCase . name } : ${ testCase . check . alerts . length } alert(s)` ) ;
@@ -113,15 +120,15 @@ async function generateConfigs() {
113120 terraform : {
114121 required_providers : {
115122 grafana : {
116- source : " grafana/grafana" ,
117- version : " >= 4.3.0"
118- }
119- }
123+ source : ' grafana/grafana' ,
124+ version : ' >= 4.3.0' ,
125+ } ,
126+ } ,
120127 } ,
121128 resource : {
122129 grafana_synthetic_monitoring_check : allChecks ,
123- grafana_synthetic_monitoring_probe : allProbes
124- }
130+ grafana_synthetic_monitoring_probe : allProbes ,
131+ } ,
125132 } ;
126133
127134 // Add alerts resource if any checks have alerts
@@ -152,11 +159,10 @@ async function generateConfigs() {
152159 console . log ( '\n🧪 To validate:' ) ;
153160 console . log ( ' cd artifacts/terraform-validation' ) ;
154161 console . log ( ' terraform validate' ) ;
155-
156162 } catch ( error ) {
157163 console . error ( '❌ Error generating configurations:' , error ) ;
158164 process . exit ( 1 ) ;
159165 }
160166}
161167
162- generateConfigs ( ) ;
168+ generateConfigs ( ) ;
0 commit comments