-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerSecretsConfigurationSource.cs
More file actions
61 lines (52 loc) · 2.07 KB
/
Copy pathDockerSecretsConfigurationSource.cs
File metadata and controls
61 lines (52 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
namespace Microsoft.Extensions.Configuration.DockerSecrets
{
using FileProviders;
using System;
/// <summary>
/// An <see cref="ConfigurationProvider"/> for docker secrets.
/// </summary>
public class DockerSecretsConfigurationSource : IConfigurationSource
{
/// <summary>
/// Constructor
/// </summary>
public DockerSecretsConfigurationSource()
{
IgnoreCondition = s => IgnorePrefix != null && s.StartsWith(IgnorePrefix);
}
/// <summary>
/// The secrets directory which will be used if FileProvider is not set.
/// </summary>
public string SecretsDirectory { get; set; } = "/run/secrets";
/// <summary>
/// Gets or sets the docker secrets word separator.
/// </summary>
/// <value>
/// The docker secrets word separator.
/// </value>
public string DockerSecretsWordSeparator { get; set; } = "__";
/// <summary>
/// The FileProvider representing the secrets directory.
/// </summary>
public IFileProvider FileProvider { get; set; }
/// <summary>
/// Docker secrets that start with this prefix will be excluded.
/// </summary>
public string IgnorePrefix { get; set; } = "ignore.";
/// <summary>
/// Used to determine if a file should be ignored using its name.
/// </summary>
public Func<string, bool> IgnoreCondition { get; set; }
/// <summary>
/// If false, will throw if the secrets directory doesn't exist.
/// </summary>
public bool Optional { get; set; }
/// <summary>
/// Builds the <see cref="DockerSecretsConfigurationProvider"/> for this source.
/// </summary>
/// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
/// <returns>A <see cref="DockerSecretsConfigurationProvider"/></returns>
public IConfigurationProvider Build(IConfigurationBuilder builder) =>
new DockerSecretsConfigurationProvider(this);
}
}