Skip to content

Commit 84f4e32

Browse files
authored
MINOR refactor env var lookup for consistency with other repos (#2368)
1 parent 97cdbd6 commit 84f4e32

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/Confluent.SchemaRegistry.Encryption.HcVault/HcVaultKmsClient.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ public class HcVaultKmsClient : IKmsClient
2121

2222
public HcVaultKmsClient(string kekId, string ns, string tokenId)
2323
{
24-
if (tokenId == null)
25-
{
26-
tokenId = Environment.GetEnvironmentVariable("VAULT_TOKEN");
27-
ns = Environment.GetEnvironmentVariable("VAULT_NAMESPACE");
28-
}
2924
KekId = kekId;
3025
Namespace = ns;
3126
TokenId = tokenId;

src/Confluent.SchemaRegistry.Encryption.HcVault/HcVaultKmsDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public IKmsClient NewKmsClient(IDictionary<string, string> config, string keyUrl
2323
{
2424
config.TryGetValue(TokenId, out string tokenId);
2525
config.TryGetValue(Namespace, out string ns);
26+
if (tokenId == null)
27+
{
28+
tokenId = Environment.GetEnvironmentVariable("VAULT_TOKEN");
29+
ns = Environment.GetEnvironmentVariable("VAULT_NAMESPACE");
30+
}
2631
return new HcVaultKmsClient(keyUrl, ns, tokenId);
2732
}
2833
}

src/Confluent.SchemaRegistry.Encryption/LocalKmsClient.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ public class LocalKmsClient : IKmsClient
1616

1717
public LocalKmsClient(string secret)
1818
{
19-
if (secret == null)
20-
{
21-
secret = Environment.GetEnvironmentVariable("LOCAL_SECRET");
22-
}
23-
if (secret == null)
24-
{
25-
throw new ArgumentNullException("Cannot load secret");
26-
}
2719
Secret = secret;
2820
cryptor = new Cryptor(DekFormat.AES128_GCM);
2921
byte[] rawKey = Hkdf.DeriveKey(

src/Confluent.SchemaRegistry.Encryption/LocalKmsDriver.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ public string GetKeyUrlPrefix()
2222
public IKmsClient NewKmsClient(IDictionary<string, string> config, string keyUrl)
2323
{
2424
config.TryGetValue(Secret, out string secret);
25+
if (secret == null)
26+
{
27+
secret = Environment.GetEnvironmentVariable("LOCAL_SECRET");
28+
}
29+
if (secret == null)
30+
{
31+
throw new ArgumentNullException("Cannot load secret");
32+
}
2533
return new LocalKmsClient(secret);
2634
}
2735
}

0 commit comments

Comments
 (0)