Skip to content

Commit

Permalink
fix: allow loop creds to be empty if not enabled (#1891)
Browse files Browse the repository at this point in the history
* fix: allow loop creds to be empty if not enabled
* chore: throw error when getLoopConfig() is called without swapEnabled
* fix: allow undefined tracingConfig properties
Co-authored-by: ntheile <[email protected]>
Co-authored-by: bodymindarts <[email protected]>
  • Loading branch information
openoms committed Oct 28, 2022
1 parent a05d005 commit 11f878c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
27 changes: 16 additions & 11 deletions src/config/process.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getCronConfig } from "./yaml"

import { ConfigError } from "./error"

type TwilioConfig = {
Expand Down Expand Up @@ -103,18 +105,21 @@ export const LND_HEALTH_REFRESH_TIME_MS = parseInt(
)

export const getLoopConfig = () => {
if (!process.env.LND1_LOOP_TLS) throw new ConfigError("Missing LND1_LOOP_TLS config")
if (!process.env.LND2_LOOP_TLS) throw new ConfigError("Missing LND2_LOOP_TLS config")
if (!process.env.LND1_LOOP_MACAROON)
throw new ConfigError("Missing LND1_LOOP_MACAROON config")
if (!process.env.LND2_LOOP_MACAROON)
throw new ConfigError("Missing LND2_LOOP_MACAROON config")
return {
lnd1LoopTls: process.env.LND1_LOOP_TLS,
lnd1LoopMacaroon: process.env.LND1_LOOP_MACAROON as Macaroon,
lnd2LoopTls: process.env.LND2_LOOP_TLS,
lnd2LoopMacaroon: process.env.LND2_LOOP_MACAROON as Macaroon,
if (getCronConfig().swapEnabled) {
if (!process.env.LND1_LOOP_TLS) throw new ConfigError("Missing LND1_LOOP_TLS config")
if (!process.env.LND2_LOOP_TLS) throw new ConfigError("Missing LND2_LOOP_TLS config")
if (!process.env.LND1_LOOP_MACAROON)
throw new ConfigError("Missing LND1_LOOP_MACAROON config")
if (!process.env.LND2_LOOP_MACAROON)
throw new ConfigError("Missing LND2_LOOP_MACAROON config")
return {
lnd1LoopTls: process.env.LND1_LOOP_TLS,
lnd1LoopMacaroon: process.env.LND1_LOOP_MACAROON as Macaroon,
lnd2LoopTls: process.env.LND2_LOOP_TLS,
lnd2LoopMacaroon: process.env.LND2_LOOP_MACAROON as Macaroon,
}
}
throw new ConfigError("getLoopConfig() was called though swapEnabled is false")
}

export const getKratosMasterPhonePassword = () => {
Expand Down
8 changes: 4 additions & 4 deletions src/services/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ registerInstrumentations({
const provider = new NodeTracerProvider({
resource: Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: tracingConfig.tracingServiceName,
[SemanticResourceAttributes.SERVICE_NAME]: tracingConfig?.tracingServiceName,
}),
),
})
Expand All @@ -209,16 +209,16 @@ class SpanProcessorWrapper extends SimpleSpanProcessor {
provider.addSpanProcessor(
new SpanProcessorWrapper(
new JaegerExporter({
host: tracingConfig.jaegerHost,
port: tracingConfig.jaegerPort,
host: tracingConfig?.jaegerHost,
port: tracingConfig?.jaegerPort,
}),
),
)

provider.register()

export const tracer = trace.getTracer(
tracingConfig.tracingServiceName,
tracingConfig?.tracingServiceName,
process.env.COMMITHASH || "dev",
)
export const addAttributesToCurrentSpan = (attributes: Attributes) => {
Expand Down

0 comments on commit 11f878c

Please sign in to comment.