Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d1a4a5

Browse files
MINOR refactor env var lookup for consistency with other repos (#187)
1 parent 539279f commit 2d1a4a5

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

‎schemaregistry/rules/encryption/hcvault/hcvault-client.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ export class HcVaultClient implements KmsClient {
99
private keyName: string
1010

1111
constructor(keyUri: string, namespace?: string, token?: string) {
12-
if (token == null)
13-
{
14-
namespace = process.env["VAULT_NAMESPACE"]
15-
}
1612
if (!keyUri.startsWith(HcVaultDriver.PREFIX)) {
1713
throw new Error(`key uri must start with ${HcVaultDriver.PREFIX}`)
1814
}

‎schemaregistry/rules/encryption/hcvault/hcvault-driver.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ export class HcVaultDriver implements KmsDriver {
2020

2121
newKmsClient(config: Map<string, string>, keyUrl?: string): KmsClient {
2222
const uriPrefix = keyUrl != null ? keyUrl : HcVaultDriver.PREFIX
23-
const tokenId = config.get(HcVaultDriver.TOKEN_ID)
24-
const ns = config.get(HcVaultDriver.NAMESPACE)
23+
let tokenId = config.get(HcVaultDriver.TOKEN_ID)
24+
let ns = config.get(HcVaultDriver.NAMESPACE)
25+
if (tokenId == null)
26+
{
27+
tokenId = process.env["VAULT_TOKEN"]
28+
ns = process.env["VAULT_NAMESPACE"]
29+
}
2530
return new HcVaultClient(uriPrefix, ns, tokenId)
2631
}
2732
}

‎schemaregistry/rules/encryption/localkms/local-client.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ export class LocalKmsClient implements KmsClient {
1010
private secret: string
1111
private cryptor: Cryptor
1212

13-
constructor(secret?: string) {
14-
if (secret == null) {
15-
secret = process.env['LOCAL_SECRET']
16-
}
17-
if (secret == null) {
18-
throw new Error('cannot load secret')
19-
}
13+
constructor(secret: string) {
2014
this.secret = secret
2115
this.cryptor = new Cryptor(DekFormat.AES128_GCM)
2216
}

‎schemaregistry/rules/encryption/localkms/local-driver.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ export class LocalKmsDriver implements KmsDriver {
1818
}
1919

2020
newKmsClient(config: Map<string, string>, keyUrl: string): KmsClient {
21-
const secret = config.get(LocalKmsDriver.SECRET)
21+
let secret = config.get(LocalKmsDriver.SECRET)
22+
if (secret == null) {
23+
secret = process.env['LOCAL_SECRET']
24+
}
25+
if (secret == null) {
26+
throw new Error('cannot load secret')
27+
}
2228
return new LocalKmsClient(secret)
2329
}
2430
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /