Skip to content

Commit df9329f

Browse files
author
Kristopher Turner
committed
chore: standardize variable file paths and update standards docs
1 parent f7cc74f commit df9329f

9 files changed

Lines changed: 490 additions & 12 deletions

File tree

common/helpers/Initialize-Environment.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ----
184210
function 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+
232260
Test-ConfigFiles -MasterConfigPath $masterConfig -ClusterConfigPath $clusterConfig
233261

234262
Write-Host "`nEnvironment initialized successfully." -ForegroundColor Green

0 commit comments

Comments
 (0)