generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenv-gen.ps1
41 lines (30 loc) · 1.24 KB
/
env-gen.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
.SYNOPSIS
This script is an environment generator for backend.
.DESCRIPTION
This script sets up the necessary environment variables and configurations required for the backend system to function properly.
.EXAMPLE
# To run this script, use the following command:
# .\env-gen.ps1 "
#>
$file_path = "$PSScriptRoot/../backend/.env"
# Log in to OpenShift
Start-Process "oc" -Wait -ArgumentList "login --server=https://api.silver.devops.gov.bc.ca:6443 --web"
#switch to dev,
oc project d37bb7-dev
# Get the secret data
$secretData = oc get secret nr-oracle-service -n d37bb7-dev -o json | ConvertFrom-Json
# Decode the secret data and create the .env file
$envContent = ""
foreach ($key in $secretData.data.PSObject.Properties.Name) {
if ($key -eq "apiKey") {
$decodedValue = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($secretData.data.$key))
$envContent += "NR_ORACLE_SERVICE_KEY=$decodedValue`n"
}
}
$envContent += "NR_ORACLE_SERVICE_URL=http://localhost:9080`n"
$envContent += "OMRR_AUTHZ_DOCS_FLAG=true`n"
$envContent += "OMRR_APP_STATUS_FLAG=flase"
# Write the content to the output file
$envContent | Out-File -FilePath "$file_path" -Encoding utf8
Write-Host "Environment file created at $file_path"