public async Task <string> ResolveAsync(Secret secret) { if (secret == null) { SecretNotDefinedException.Raise(); } if (string.IsNullOrWhiteSpace(secret.Source)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (string.IsNullOrWhiteSpace(secret.Identifier)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (secret.Source.ToUpperInvariant() != Source) { SecretNotFoundException.Raise(secret.Source, secret.Identifier); } var result = Environment.GetEnvironmentVariable(secret.Identifier); if (result != null) { return(await Task.FromResult(result.Trim())); } if (!secret.Optional) { SecretNotFoundException.Raise(secret.Source, secret.Identifier); } return(default);
public async Task <string> ResolveAsync(Secret secret) { if (secret == null) { SecretNotDefinedException.Raise(); } if (string.IsNullOrWhiteSpace(secret.Source)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (string.IsNullOrWhiteSpace(secret.Identifier)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (secret.Source.ToUpperInvariant() != Source) { SecretNotFoundException.Raise(secret.Source, secret.Identifier); } if (!File.Exists(secret.Identifier)) { if (!secret.Optional) { SecretNotFoundException.Raise(secret.Source, secret.Identifier); } return(default);
public async Task <string> ResolveSecretAsync(Secret secret) { if (secret == null) { SecretNotDefinedException.Raise(); } if (string.IsNullOrWhiteSpace(secret.Source)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (string.IsNullOrWhiteSpace(secret.Identifier)) { InvalidSecretDefinitionException.Raise(secret.Source, secret.Identifier); } if (!sources.ContainsKey(secret.Source.ToUpperInvariant())) { InvalidSecretSourceException.Raise(secret.Source, secret.Identifier); } var source = sources[secret.Source.ToUpperInvariant()]; var result = await source.ResolveAsync(secret); if (result != null) { return(result); } if (!secret.Optional) { SecretNotFoundException.Raise(secret.Source, secret.Identifier); } return(default);