-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathupdate-gateway.bat
More file actions
51 lines (42 loc) · 2 KB
/
Copy pathupdate-gateway.bat
File metadata and controls
51 lines (42 loc) · 2 KB
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
42
43
44
45
46
47
48
49
50
51
@echo off
:: GCP sadly doesn't allow us to update the yaml config of an existing gateway config or do direct replacement of an existing config
:: instead, we make a temp config with the new yaml, deploy it, delete the original config, make a new one with the new yaml, migrate to that, and then delete the temp configs
set SPEC_PATH=.\rest\docs\swagger.yaml
IF NOT EXIST %SPEC_PATH% (
IF EXIST .\docs\swagger.yaml (
set SPEC_PATH=.\docs\swagger.yaml
) ELSE (
echo ERROR! Could not find config file at path ".\rest\docs\swagger.yaml" or ".\docs\swagger.yaml"!
exit /B 1
)
)
:: update prod or dev config depending on branch
FOR /F "usebackq delims=" %%i IN (`git branch --show-current`) do set BRANCH=%%i
IF "%BRANCH%"=="master" (
set API_NAME=nebula-api
set CONFIG_NAME=prod-config
set GATEWAY_NAME=api-gateway
) ELSE (
set API_NAME=dev-nebula-api
set CONFIG_NAME=dev-config
set GATEWAY_NAME=dev-gateway
)
:: create temp gateway config
echo Creating temp config.
call gcloud api-gateway api-configs create %CONFIG_NAME%-temp --api=%API_NAME% --openapi-spec=%SPEC_PATH% --display-name=%CONFIG_NAME%-temp --quiet
echo Migrating to temp config.
:: migrate to temp config
call gcloud api-gateway gateways update %GATEWAY_NAME% --location=us-central1 --api %API_NAME% --api-config %CONFIG_NAME%-temp --quiet
echo Deleting old config.
:: delete original config that is no longer in use
call gcloud api-gateway api-configs delete %CONFIG_NAME% --api=%API_NAME% --quiet
echo Creating new config.
:: create new config with original name -- same as temp config
call gcloud api-gateway api-configs create %CONFIG_NAME% --api=%API_NAME% --openapi-spec=%SPEC_PATH% --display-name=%CONFIG_NAME% --quiet
echo Migrating to new config.
:: migrate to new config
call gcloud api-gateway gateways update %GATEWAY_NAME% --location=us-central1 --api %API_NAME% --api-config %CONFIG_NAME% --quiet
echo Deleting temp config.
:: delete temp config
call gcloud api-gateway api-configs delete %CONFIG_NAME%-temp --api=%API_NAME% --quiet
echo Done!