Exemplo n.º 1
0
        private static async Task SetVaultConfig(
            this IConfigurationBuilder builder,
            VaultOptions options,
            string kvp)
        {
            VerifyOptions(options);
            var kvPath = string.IsNullOrWhiteSpace(kvp) ? options.KeyValue?.Path : kvp;

            if (!(options.KeyValue?.Enabled ?? false) && string.IsNullOrWhiteSpace(kvPath))
            {
                return;
            }

            var(client, _) = GetClientAndSettings(options);
            var keyValueService = new KeyValueService(client, options);
            var secret          = await keyValueService.GetAsync(kvPath);

            var parser = new JsonConfigurationParser();
            var data   = parser.Parse(JObject.FromObject(secret));
            var source = new MemoryConfigurationSource {
                InitialData = data
            };

            builder.Add(source);
        }