mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-12-18 08:58:30 +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';
|
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) {
|
export function svcName(svc, protocol) {
|
||||||
let env = process.env['BYC_ENV'];
|
let env = process.env['BYC_ENV'];
|
||||||
if (!env) {
|
if (!env) {
|
||||||
|
@ -33,20 +33,29 @@
|
|||||||
// noinspection JSUnresolvedFunction
|
// noinspection JSUnresolvedFunction
|
||||||
// noinspection ES6PreferShortImport
|
// 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 pkg from '@ory/hydra-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
const { Configuration, PublicApi, AdminApi } = pkg;
|
const { Configuration, PublicApi, AdminApi } = pkg;
|
||||||
|
|
||||||
export function hydraPublicUrl() {
|
export function hydraPublicUrl() {
|
||||||
|
return envOverridable('hydra_public', 'http', () => {
|
||||||
const svc = svcNameHttp('hydra-public');
|
const svc = svcNameHttp('hydra-public');
|
||||||
return endpointHttp(svc, NS('hydra-public'), ':4444');
|
return endpointHttp(svc, NS('hydra-public'), ':4444');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hydraAdminUrl() {
|
function hydraAdminUrl() {
|
||||||
|
return envOverridable('hydra_admin', 'http', () => {
|
||||||
const svc = svcNameHttp('hydra-admin');
|
const svc = svcNameHttp('hydra-admin');
|
||||||
return endpointHttp(svc, NS('hydra-admin'), ':4445');
|
return endpointHttp(svc, NS('hydra-admin'), ':4445');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const hydraAdmin = new AdminApi(
|
const hydraAdmin = new AdminApi(
|
||||||
|
Loading…
Reference in New Issue
Block a user