Skip to content

Commit

Permalink
Allow passing options to SecretClient
Browse files Browse the repository at this point in the history
  • Loading branch information
asimmon committed Jul 7, 2022
1 parent d9aa3d2 commit f284439
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace ShareGate.Extensions.Configuration.Secrets;

public interface ISecretClientProvider
{
SecretClient GetSecretClient(KeyVaultKind keyVaultKind);
SecretClient GetSecretClient(KeyVaultKind keyVaultKind, SecretClientOptions? options = null);

SecretClient GetSecretClient(Uri keyVaultUri);
SecretClient GetSecretClient(Uri keyVaultUri, SecretClientOptions? options = null);

SecretClient GetSecretClient(string configurationKey);
SecretClient GetSecretClient(string configurationKey, SecretClientOptions? options = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public SecretClientProvider(IConfigurationBuilder configurationBuilder, IHostEnv
{
}

public SecretClient GetSecretClient(KeyVaultKind keyVaultKind)
public SecretClient GetSecretClient(KeyVaultKind keyVaultKind, SecretClientOptions? options = null)
{
var keyVaultUri = this.GetKeyVaultUri(keyVaultKind);
return this.GetSecretClient(keyVaultUri);
return this.GetSecretClient(keyVaultUri, options);
}

public SecretClient GetSecretClient(Uri keyVaultUri)
public SecretClient GetSecretClient(Uri keyVaultUri, SecretClientOptions? options = null)
{
if (keyVaultUri == null)
{
Expand All @@ -44,18 +44,18 @@ public SecretClient GetSecretClient(Uri keyVaultUri)
var azureCredential = this._tokenCredentialProvider.GetTokenCredential();

// SecretClient already has a default retry policy (max 3 retries)
return new SecretClient(keyVaultUri, azureCredential);
return new SecretClient(keyVaultUri, azureCredential, options);
}

public SecretClient GetSecretClient(string configurationKey)
public SecretClient GetSecretClient(string configurationKey, SecretClientOptions? options = null)
{
if (configurationKey == null)
{
throw new ArgumentNullException(nameof(configurationKey));
}

var keyVaultUri = this.GetKeyVaultUri(configurationKey);
return this.GetSecretClient(keyVaultUri);
return this.GetSecretClient(keyVaultUri, options);
}

private Uri GetKeyVaultUri(KeyVaultKind keyVaultKind)
Expand Down

0 comments on commit f284439

Please sign in to comment.