@@ -180,6 +180,32 @@ function Test-ConfigFiles {
180180 }
181181}
182182
183+ function Initialize-MasterConfig {
184+ [CmdletBinding ()]
185+ param (
186+ [string ]$ProjectRoot ,
187+ [string ]$MasterConfigPath
188+ )
189+
190+ if (Test-Path $MasterConfigPath ) {
191+ return
192+ }
193+
194+ $exampleCandidates = @ (
195+ (Join-Path $ProjectRoot ' config\variables\variables.example.yml' ),
196+ (Join-Path $ProjectRoot ' config\variables.example.yml' )
197+ )
198+
199+ $examplePath = $exampleCandidates | Where-Object { Test-Path $_ } | Select-Object - First 1
200+ if (-not $examplePath ) {
201+ Write-Error " Master config not found: $MasterConfigPath . No variables.example.yml template found."
202+ }
203+
204+ New-Item - ItemType Directory - Path (Split-Path - Parent $MasterConfigPath ) - Force | Out-Null
205+ Copy-Item - Path $examplePath - Destination $MasterConfigPath - Force
206+ Write-Host " [WARN] Master config was missing. Created $MasterConfigPath from $examplePath " - ForegroundColor Yellow
207+ }
208+
183209# ---- Directory Structure ----
184210function Initialize-DirectoryStructure {
185211 [CmdletBinding (SupportsShouldProcess )]
@@ -229,6 +255,8 @@ $defaultCluster = Join-Path $ProjectRoot 'config\clusters\cluster.yml'
229255$masterConfig = if ($MasterConfigPath ) { $MasterConfigPath } else { $defaultMaster }
230256$clusterConfig = if ($ClusterConfigPath ) { $ClusterConfigPath } else { $defaultCluster }
231257
258+ Initialize-MasterConfig - ProjectRoot $ProjectRoot - MasterConfigPath $masterConfig
259+
232260Test-ConfigFiles - MasterConfigPath $masterConfig - ClusterConfigPath $clusterConfig
233261
234262Write-Host " `n Environment initialized successfully." - ForegroundColor Green
0 commit comments