Add option to force namespace

This commit is contained in:
Mustafa Gezen 2022-07-19 23:45:20 +02:00
parent 0e58d6e9d3
commit ccba0d90ca
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
2 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,9 @@ import os from 'os';
export function svcName(svc, protocol) { export function svcName(svc, protocol) {
let env = process.env['BYC_ENV']; let env = process.env['BYC_ENV'];
if (!env) {
env = 'dev';
}
return `${svc}-${protocol}-${env}-service`; return `${svc}-${protocol}-${env}-service`;
} }
@ -42,6 +45,10 @@ export function svcNameHttp(svc) {
} }
export function endpoint(generatedServiceName, ns, port) { export function endpoint(generatedServiceName, ns, port) {
const forceNs = process.env['BYC_FORCE_NS'];
if (forceNs) {
ns = forceNs;
}
return `${generatedServiceName}.${ns}.svc.cluster.local${port}`; return `${generatedServiceName}.${ns}.svc.cluster.local${port}`;
} }

View File

@ -50,6 +50,9 @@ func SvcNameGrpc(svc string) string {
} }
func Endpoint(svcName string, ns string, port string) string { func Endpoint(svcName string, ns string, port string) string {
if forceNs := os.Getenv("BYC_FORCE_NS"); forceNs != "" {
ns = forceNs
}
return fmt.Sprintf("%s.%s.svc.cluster.local%s", svcName, ns, port) return fmt.Sprintf("%s.%s.svc.cluster.local%s", svcName, ns, port)
} }