No longer allow null for the values in the DaprSecretStoreConfigurationSource.

This commit is contained in:
Dirk Lemstra 2021-04-04 12:07:07 +02:00 committed by Ryan Nowak
parent 0de8c79e0f
commit fc82cb55e4
2 changed files with 14 additions and 8 deletions

View File

@ -89,12 +89,18 @@ namespace Dapr.Extensions.Configuration
ArgumentVerifier.ThrowIfNullOrEmpty(store, nameof(store));
ArgumentVerifier.ThrowIfNull(client, nameof(client));
configurationBuilder.Add(new DaprSecretStoreConfigurationSource()
var source = new DaprSecretStoreConfigurationSource
{
Store = store,
KeyDelimiters = keyDelimiters?.ToList(),
Client = client
});
};
if (keyDelimiters != null)
{
source.KeyDelimiters = keyDelimiters.ToList();
}
configurationBuilder.Add(source);
return configurationBuilder;
}

View File

@ -18,7 +18,7 @@ namespace Dapr.Extensions.Configuration.DaprSecretStore
/// <summary>
/// Gets or sets the store name.
/// </summary>
public string? Store { get; set; }
public string Store { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether any key delimiters should be replaced with the delimiter ":".
@ -29,7 +29,7 @@ namespace Dapr.Extensions.Configuration.DaprSecretStore
/// <summary>
/// Gets or sets the custom key delimiters. Contains the '__' delimiter by default.
/// </summary>
public IList<string>? KeyDelimiters { get; set; } = new List<string> { "__" };
public IList<string> KeyDelimiters { get; set; } = new List<string> { "__" };
/// <summary>
/// Gets or sets the secret descriptors.
@ -44,7 +44,7 @@ namespace Dapr.Extensions.Configuration.DaprSecretStore
/// <summary>
/// Gets or sets the http client.
/// </summary>
public DaprClient? Client { get; set; }
public DaprClient Client { get; set; } = default!;
/// <inheritdoc />
public IConfigurationProvider Build(IConfigurationBuilder builder)
@ -56,11 +56,11 @@ namespace Dapr.Extensions.Configuration.DaprSecretStore
throw new ArgumentException($"{nameof(Metadata)} must be null when {nameof(SecretDescriptors)} is set", nameof(Metadata));
}
return new DaprSecretStoreConfigurationProvider(Store!, NormalizeKey, KeyDelimiters, SecretDescriptors, Client!);
return new DaprSecretStoreConfigurationProvider(Store, NormalizeKey, KeyDelimiters, SecretDescriptors, Client);
}
else
{
return new DaprSecretStoreConfigurationProvider(Store!, NormalizeKey, KeyDelimiters, Metadata, Client!);
return new DaprSecretStoreConfigurationProvider(Store, NormalizeKey, KeyDelimiters, Metadata, Client);
}
}
}