feat(release): add reversible production cutover gates
This commit is contained in:
@@ -10,8 +10,11 @@ export interface CanaryRuntimeEnvironment {
|
||||
readonly CANARY_PORT?: string;
|
||||
readonly CANARY_UPSTREAM_PORT?: string;
|
||||
readonly MULTI_SIMADMIN_GATEWAY_TOKEN?: string;
|
||||
readonly MULTI_SIMADMIN_CUTOVER_ACK?: string;
|
||||
}
|
||||
|
||||
export const PRODUCTION_CUTOVER_ACK = 'I ACKNOWLEDGE MULTI-SIMADMIN OWNS PORT 8788';
|
||||
|
||||
function environmentPort(value: string | undefined, name: string, fallback: number): number {
|
||||
if (value === undefined || value === '') return fallback;
|
||||
const port = Number(value);
|
||||
@@ -41,3 +44,15 @@ export function readCanaryRuntimeOptions(
|
||||
gatewayToken,
|
||||
});
|
||||
}
|
||||
|
||||
export function readProductionGatewayRuntimeOptions(
|
||||
environment: CanaryRuntimeEnvironment,
|
||||
): CanaryGatewayOptions {
|
||||
if (environment.MULTI_SIMADMIN_CUTOVER_ACK !== PRODUCTION_CUTOVER_ACK) {
|
||||
throw new Error(
|
||||
`Production gateway requires MULTI_SIMADMIN_CUTOVER_ACK=${PRODUCTION_CUTOVER_ACK}`,
|
||||
);
|
||||
}
|
||||
const options = readCanaryRuntimeOptions({ ...environment, CANARY_PORT: '8788' });
|
||||
return Object.freeze({ ...options, ownsProductionPort: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user