private static void InitializeCloudFoundry(ConfigServerClientSettings settings, IConfigurationRoot root)
        {
            var clientConfigsection = root.GetSection(PREFIX);

            settings.Uri            = ResovlePlaceholders(GetUri(clientConfigsection, root, settings.Uri), root);
            settings.AccessTokenUri = ResovlePlaceholders(GetAccessTokenUri(clientConfigsection, root), root);
            settings.ClientId       = ResovlePlaceholders(GetClientId(clientConfigsection, root), root);
            settings.ClientSecret   = ResovlePlaceholders(GetClientSecret(clientConfigsection, root), root);
        }
        private static void InitializeCloudFoundry(ConfigServerClientSettings settings, IConfiguration root)
        {
            var clientConfigsection = root.GetSection(PREFIX);

            settings.Uri            = GetUri(clientConfigsection, root, settings.Uri);
            settings.AccessTokenUri = GetAccessTokenUri(clientConfigsection, root);
            settings.ClientId       = GetClientId(clientConfigsection, root);
            settings.ClientSecret   = GetClientSecret(clientConfigsection, root);
            settings.TokenRenewRate = GetTokenRenewRate(clientConfigsection, root);
            settings.TokenTtl       = GetTokenTtl(clientConfigsection, root);
        }
        public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, string environment, string applicationName, ILoggerFactory logFactory = null)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            var settings = new ConfigServerClientSettings()
            {
                Name        = applicationName ?? Assembly.GetEntryAssembly()?.GetName().Name,
                Environment = environment ?? ConfigServerClientSettings.DEFAULT_ENVIRONMENT
            };

            return(configurationBuilder.AddConfigServer(settings, logFactory));
        }
예제 #4
0
        /// <summary>
        /// Add Config Server and Cloud Foundry as application configuration sources
        /// </summary>
        /// <param name="configurationBuilder">Your <see cref="IConfigurationBuilder"/></param>
        /// <param name="environment">Your <see cref="IHostingEnvironment"/></param>
        /// <param name="logFactory">An <see cref="ILoggerFactory"/> for logging inside the config server client</param>
        /// <returns><see cref="IConfigurationBuilder"/>With additional configuration providers</returns>
        public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, IHostingEnvironment environment, ILoggerFactory logFactory = null)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            if (environment == null)
            {
                throw new ArgumentNullException(nameof(environment));
            }

            var settings = new ConfigServerClientSettings()
            {
                Name        = environment.ApplicationName,
                Environment = environment.EnvironmentName
            };

            configurationBuilder.AddConfigServer(settings, logFactory);
            return(configurationBuilder);
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigServerConfigurationProvider"/> class.
 /// </summary>
 /// <param name="settings">the configuration settings the provider uses when accessing the server.</param>
 /// <param name="httpClient">a HttpClient the provider uses to make requests of the server.</param>
 /// <param name="logFactory">optional logging factory</param>
 /// </summary>
 public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, HttpClient httpClient, ILoggerFactory logFactory = null)
     : base(settings, httpClient, logFactory)
 {
 }
예제 #6
0
 public ConfigServerConfigurationSource(ConfigServerClientSettings defaultSettings, IList <IConfigurationSource> sources, IDictionary <string, object> properties = null, ILoggerFactory logFactory = null)
     : base(defaultSettings, sources, properties, logFactory)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="ConfigServerConfigurationProvider"/>.
 /// </summary>
 /// <param name="settings">the configuration settings the provider uses when accessing the server.</param>
 /// <param name="environment">required Hosting environment, used in establishing config server profile</param>
 /// <param name="logFactory">optional logging factory</param>
 /// </summary>
 public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, IHostingEnvironment environment, ILoggerFactory logFactory = null) :
     base(settings, environment, logFactory)
 {
 }
        public static IConfigurationBuilder AddConfigServer(this IConfigurationBuilder configurationBuilder, ConfigServerClientSettings defaultSettings, ILoggerFactory logFactory = null)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            if (defaultSettings == null)
            {
                throw new ArgumentNullException(nameof(defaultSettings));
            }

            if (!configurationBuilder.Sources.Any(c => c.GetType() == typeof(CloudFoundryConfigurationSource)))
            {
                configurationBuilder.Add(new CloudFoundryConfigurationSource());
            }

            configurationBuilder.Add(new ConfigServerConfigurationSource(defaultSettings, configurationBuilder.Sources, configurationBuilder.Properties, logFactory));

            return(configurationBuilder);
        }