mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-18 03:11:24 +00:00
Make servicecatalog/js able to do env overridable services
This commit is contained in:
parent
78cf89a3ae
commit
8e342ff2ba
@ -32,6 +32,15 @@
|
||||
|
||||
import os from 'os';
|
||||
|
||||
export function envOverridable(svcName, protocol, x) {
|
||||
const envName = `${svcName}_${protocol}_ENDPOINT_OVERRIDE`.toUpperCase();
|
||||
const envValue = process.env[envName];
|
||||
if (envValue) {
|
||||
return envValue;
|
||||
}
|
||||
return x();
|
||||
}
|
||||
|
||||
export function svcName(svc, protocol) {
|
||||
let env = process.env['BYC_ENV'];
|
||||
if (!env) {
|
||||
|
@ -33,20 +33,29 @@
|
||||
// noinspection JSUnresolvedFunction
|
||||
// noinspection ES6PreferShortImport
|
||||
|
||||
import { svcNameHttp, endpointHttp, NS } from '../../../common/frontend_server/upstream.mjs';
|
||||
import {
|
||||
svcNameHttp,
|
||||
endpointHttp,
|
||||
NS,
|
||||
envOverridable
|
||||
} from '../../../common/frontend_server/upstream.mjs';
|
||||
import pkg from '@ory/hydra-client';
|
||||
import os from 'os';
|
||||
|
||||
const { Configuration, PublicApi, AdminApi } = pkg;
|
||||
|
||||
export function hydraPublicUrl() {
|
||||
const svc = svcNameHttp('hydra-public');
|
||||
return endpointHttp(svc, NS('hydra-public'), ':4444');
|
||||
return envOverridable('hydra_public', 'http', () => {
|
||||
const svc = svcNameHttp('hydra-public');
|
||||
return endpointHttp(svc, NS('hydra-public'), ':4444');
|
||||
});
|
||||
}
|
||||
|
||||
function hydraAdminUrl() {
|
||||
const svc = svcNameHttp('hydra-admin');
|
||||
return endpointHttp(svc, NS('hydra-admin'), ':4445');
|
||||
return envOverridable('hydra_admin', 'http', () => {
|
||||
const svc = svcNameHttp('hydra-admin');
|
||||
return endpointHttp(svc, NS('hydra-admin'), ':4445');
|
||||
});
|
||||
}
|
||||
|
||||
const hydraAdmin = new AdminApi(
|
||||
|
Loading…
Reference in New Issue
Block a user