-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleSecretsOptions.cs
More file actions
63 lines (56 loc) · 2.26 KB
/
GoogleSecretsOptions.cs
File metadata and controls
63 lines (56 loc) · 2.26 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
62
63
namespace Neolution.Extensions.Configuration.GoogleSecrets
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Google.Cloud.SecretManager.V1;
/// <summary>
/// Options Class for the Google Secrets Configuration Provider
/// </summary>
public class GoogleSecretsOptions
{
/// <summary>
/// The map function. Used to transform a Secret to a IConfiguration Key
/// </summary>
/// <param name="secret">The secret.</param>
/// <returns>The IConfiguration Key</returns>
public delegate string MapFnType(Secret secret);
/// <summary>
/// The filter Function. Used to filter the Secrets.
/// </summary>
/// <param name="secret">The secret.</param>
/// <returns>True if the secret should be exposed, false otherwise</returns>
public delegate bool FilterFnType(Secret secret);
/// <summary>
/// Gets or sets the map function.
/// </summary>
public MapFnType MapFn { get; set; } = secret => secret.SecretName.SecretId.Replace("__", ":");
/// <summary>
/// Gets or sets the filter function.
/// </summary>
public FilterFnType FilterFn { get; set; } = secret => true;
/// <summary>
/// Gets or sets the name of the project.
/// </summary>
/// <value>
/// The name of the project or the numeric project id
/// </value>
public string ProjectName { get; set; } = Environment.GetEnvironmentVariable(EnvironmentVariableNames.GoogleSecretsProject) ?? string.Empty;
/// <summary>
/// Gets or sets the filter.
/// </summary>
/// <value>
/// According to https://cloud.google.com/secret-manager/docs/filtering
/// </value>
public string Filter { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the version dictionary.
/// </summary>
/// <value>
/// By default the latest version will be taken but you can request a specific version by
/// suppling a dictionary entry in the form of SecretId, Version
/// </value>
public IDictionary<string, string> VersionDictionary { get; set; }
}
}