|
- param(
- [string]$TemplatePath = (Join-Path $PSScriptRoot "setup_test.sql"),
- [string]$OutputPath = (Join-Path $env:TEMP "new-api-asset-setup.sql")
- )
-
- $ak = $env:CHINAMOBILE_ASSET_AK
- $sk = $env:CHINAMOBILE_ASSET_SK
- $poolId = $env:CHINAMOBILE_ASSET_POOL_ID
-
- if ([string]::IsNullOrWhiteSpace($ak) -or [string]::IsNullOrWhiteSpace($sk)) {
- throw "CHINAMOBILE_ASSET_AK and CHINAMOBILE_ASSET_SK are required"
- }
- if ([string]::IsNullOrWhiteSpace($poolId)) {
- $poolId = "CIDC-CORE-00"
- }
- if ($ak.Contains("'") -or $sk.Contains("'") -or $poolId.Contains("'")) {
- throw "China Mobile asset credentials must not contain single quotes"
- }
-
- $sql = Get-Content -LiteralPath $TemplatePath -Raw
- $sql = $sql.Replace("__CHINAMOBILE_ASSET_AK__", $ak)
- $sql = $sql.Replace("__CHINAMOBILE_ASSET_SK__", $sk)
- $sql = $sql.Replace("__CHINAMOBILE_ASSET_POOL_ID__", $poolId)
- [System.IO.File]::WriteAllText($OutputPath, $sql, [System.Text.UTF8Encoding]::new($false))
- Write-Output $OutputPath
|