Table of Contents

Class ConfigServerConfigurationProvider

Namespace
Steeltoe.Extensions.Configuration.ConfigServer
Assembly
Steeltoe.Extensions.Configuration.ConfigServerBase.dll

A Spring Cloud Config Server based ConfigurationProvider.

public class ConfigServerConfigurationProvider : ConfigurationProvider, IConfigurationProvider, IConfigurationSource
Inheritance
ConfigServerConfigurationProvider
Implements
Inherited Members

Constructors

ConfigServerConfigurationProvider(ILoggerFactory)

Initializes a new instance of the ConfigServerConfigurationProvider class with default configuration settings. ConfigServerClientSettings

public ConfigServerConfigurationProvider(ILoggerFactory logFactory = null)

Parameters

logFactory ILoggerFactory

optional logging factory

ConfigServerConfigurationProvider(ConfigServerClientSettings, ILoggerFactory)

Initializes a new instance of the ConfigServerConfigurationProvider class.

public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, ILoggerFactory logFactory = null)

Parameters

settings ConfigServerClientSettings

the configuration settings the provider uses when accessing the server.

logFactory ILoggerFactory

optional logging factory

ConfigServerConfigurationProvider(ConfigServerClientSettings, HttpClient, ILoggerFactory)

Initializes a new instance of the ConfigServerConfigurationProvider class.

public ConfigServerConfigurationProvider(ConfigServerClientSettings settings, HttpClient httpClient, ILoggerFactory logFactory = null)

Parameters

settings ConfigServerClientSettings

the configuration settings the provider uses when accessing the server.

httpClient HttpClient

a HttpClient the provider uses to make requests of the server.

logFactory ILoggerFactory

optional logging factory

ConfigServerConfigurationProvider(ConfigServerConfigurationSource)

Initializes a new instance of the ConfigServerConfigurationProvider class from a ConfigServerConfigurationSource

public ConfigServerConfigurationProvider(ConfigServerConfigurationSource source)

Parameters

source ConfigServerConfigurationSource

the ConfigServerConfigurationSource the provider uses when accessing the server.

ConfigServerConfigurationProvider(ConfigServerConfigurationSource, HttpClient)

Initializes a new instance of the ConfigServerConfigurationProvider class from a ConfigServerConfigurationSource

public ConfigServerConfigurationProvider(ConfigServerConfigurationSource source, HttpClient httpClient)

Parameters

source ConfigServerConfigurationSource

the ConfigServerConfigurationSource the provider uses when accessing the server.

httpClient HttpClient

the httpClient to use

Fields

PREFIX

The prefix (IConfigurationSection under which all Spring Cloud Config Server configuration settings (ConfigServerClientSettings are found. (e.g. spring:cloud:config:env, spring:cloud:config:uri, spring:cloud:config:enabled, etc.)

public const string PREFIX = "spring:cloud:config"

Field Value

string

STATE_HEADER

public const string STATE_HEADER = "X-Config-State"

Field Value

string

TOKEN_HEADER

public const string TOKEN_HEADER = "X-Config-Token"

Field Value

string

_configuration

protected IConfiguration _configuration

Field Value

IConfiguration

_httpClient

protected HttpClient _httpClient

Field Value

HttpClient

_logger

protected ILogger _logger

Field Value

ILogger

_loggerFactory

protected ILoggerFactory _loggerFactory

Field Value

ILoggerFactory

_settings

protected ConfigServerClientSettings _settings

Field Value

ConfigServerClientSettings

Properties

Settings

Gets the configuration settings the provider uses when accessing the server.

public virtual ConfigServerClientSettings Settings { get; }

Property Value

ConfigServerClientSettings

Methods

AddConfigServerClientSettings()

Adds the client settings for the Configuration Server to the Data dictionary

protected virtual void AddConfigServerClientSettings()

AddConfigServerClientSettings(IDictionary<string, string>)

Adds the client settings for the Configuration Server to the data dictionary

protected virtual void AddConfigServerClientSettings(IDictionary<string, string> data)

Parameters

data IDictionary<string, string>

AddPropertySource(PropertySource)

Adds values from a PropertySource to the Configurtation Data dictionary managed by this provider

[Obsolete("Will be removed in next release.")]
protected virtual void AddPropertySource(PropertySource source)

Parameters

source PropertySource

a property source to add

AddPropertySource(PropertySource, IDictionary<string, string>)

Adds values from a PropertySource to the provided dictionary.

protected void AddPropertySource(PropertySource source, IDictionary<string, string> data)

Parameters

source PropertySource

a property source to add

data IDictionary<string, string>

the dictionary to add the property source to

Build(IConfigurationBuilder)

Builds the IConfigurationProvider for this source.

[Obsolete("Will be removed in next release, use the ConfigServerConfigurationSource")]
public virtual IConfigurationProvider Build(IConfigurationBuilder builder)

Parameters

builder IConfigurationBuilder

The IConfigurationBuilder.

Returns

IConfigurationProvider

An IConfigurationProvider

ConvertArrayKey(string)

protected virtual string ConvertArrayKey(string key)

Parameters

key string

Returns

string

ConvertKey(string)

protected virtual string ConvertKey(string key)

Parameters

key string

Returns

string

ConvertValue(object)

protected virtual string ConvertValue(object value)

Parameters

value object

Returns

string

Deserialize(Stream)

Deserialize the response from the Configuration Server

protected virtual ConfigEnvironment Deserialize(Stream stream)

Parameters

stream Stream

the stream representing the response from the Configuration Server

Returns

ConfigEnvironment

The ConfigEnvironment object representing the response from the server

FetchAccessToken()

Conduct the OAuth2 client_credentials grant flow returning a task that can be used to obtain the results

protected string FetchAccessToken()

Returns

string

The task object representing asynchronous operation

GetConfigServerUri(string)

Create the Uri that will be used in accessing the Configuration Server

[Obsolete("Will be removed in next release. See GetConfigServerUri(string, string)")]
protected virtual string GetConfigServerUri(string label)

Parameters

label string

a label to add

Returns

string

The request URI for the Configuration Server

GetConfigServerUri(string, string)

Create the Uri that will be used in accessing the Configuration Server

protected virtual string GetConfigServerUri(string baseRawUri, string label)

Parameters

baseRawUri string

base server uri to use

label string

a label to add

Returns

string

The request URI for the Configuration Server

GetEncoded(string, string)

Encode the username password for a http request

protected string GetEncoded(string user, string password)

Parameters

user string

the username

password string

the password

Returns

string

Encoded user + password

GetHttpClient(ConfigServerClientSettings)

Creates an appropriatly configured HttpClient that will be used in communicating with the Spring Cloud Configuration Server

protected static HttpClient GetHttpClient(ConfigServerClientSettings settings)

Parameters

settings ConfigServerClientSettings

the settings used in configuring the HttpClient

Returns

HttpClient

The HttpClient used by the provider

GetRequestMessage(string)

Create the HttpRequestMessage that will be used in accessing the Spring Cloud Configuration server

[Obsolete("Will be removed in next release. See GetRequestMessage(string, string, string)")]
protected virtual HttpRequestMessage GetRequestMessage(string requestUri)

Parameters

requestUri string

the Uri used when accessing the server

Returns

HttpRequestMessage

The HttpRequestMessage built from the path

GetRequestMessage(string, string, string)

Create the HttpRequestMessage that will be used in accessing the Spring Cloud Configuration server

protected virtual HttpRequestMessage GetRequestMessage(string requestUri, string username, string password)

Parameters

requestUri string

the Uri used when accessing the server

username string

username to use if required

password string

password to use if required

Returns

HttpRequestMessage

The HttpRequestMessage built from the path

GetValutRenewMessage(string)

[Obsolete("Will be removed in next release. See GetVaultRenewMessage(string)")]
protected virtual HttpRequestMessage GetValutRenewMessage(string requestUri)

Parameters

requestUri string

Returns

HttpRequestMessage

GetVaultRenewMessage(string)

protected virtual HttpRequestMessage GetVaultRenewMessage(string requestUri)

Parameters

requestUri string

Returns

HttpRequestMessage

GetVaultRenewUri()

protected virtual string GetVaultRenewUri()

Returns

string

IsDiscoveryFirstEnabled()

protected bool IsDiscoveryFirstEnabled()

Returns

bool

Load()

Loads configuration data from the Spring Cloud Configuration Server as specified by the Settings

public override void Load()

RefreshVaultTokenAsync(object)

protected void RefreshVaultTokenAsync(object state)

Parameters

state object

RemoteLoadAsync(string)

Asynchronously calls the Spring Cloud Configuration Server using the provided Uri and returning a a task that can be used to obtain the results

[Obsolete("Will be removed in next release. See RemoteLoadAsync(string[], string)")]
protected virtual Task<ConfigEnvironment> RemoteLoadAsync(string requestUri)

Parameters

requestUri string

the Uri used in accessing the Spring Cloud Configuration Server

Returns

Task<ConfigEnvironment>

The task object representing the asynchronous operation

RemoteLoadAsync(string[], string)

protected Task<ConfigEnvironment> RemoteLoadAsync(string[] requestUris, string label)

Parameters

requestUris string[]
label string

Returns

Task<ConfigEnvironment>

RenewToken(string)

protected virtual void RenewToken(string token)

Parameters

token string

Split(string)

protected virtual string[] Split(string source)

Parameters

source string

Returns

string[]