Skip to content

Commit 8b5edc1

Browse files
committed
fix: optional auth
1 parent 3101861 commit 8b5edc1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/SourcePlusPlus.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ namespace SourcePlusPlus {
6464

6565
probeConfig.skywalking.collector.backend_service = getConfigValueString("SW_COLLECTOR_BACKEND_SERVICE",
6666
probeConfig.skywalking.collector.backend_service, `${probeConfig.spp.host}:${probeConfig.spp.grpc_port}`);
67-
probeConfig.skywalking.agent.authentication = probeConfig.spp.authentication.tenant_id ?
68-
`${probeConfig.spp.authentication.client_id}:${probeConfig.spp.authentication.client_secret}:${probeConfig.spp.authentication.tenant_id}`
69-
: `${probeConfig.spp.authentication.client_id}:${probeConfig.spp.authentication.client_secret}`;
67+
68+
let authTenantId = probeConfig.spp?.authentication?.tenant_id;
69+
let authClientId = probeConfig.spp?.authentication?.client_id;
70+
let authClientSecret = probeConfig.spp?.authentication?.client_secret;
71+
if (authTenantId && authClientId && authClientSecret) {
72+
probeConfig.skywalking.agent.authentication = `${authClientId}:${authClientSecret}:${authTenantId}`;
73+
} else if (authClientId && authClientSecret) {
74+
probeConfig.skywalking.agent.authentication = `${authClientId}:${authClientSecret}`;
75+
}
7076

7177
// Copy given config
7278
Object.assign(probeConfig, config);

0 commit comments

Comments
 (0)