azureappconfiguration package - github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration - Go Packages (original) (raw)
Package azureappconfiguration provides a client for Azure App Configuration, enabling Go applications to manage application settings with Microsoft's Azure App Configuration service.
The azureappconfiguration package allows loading configuration data from Azure App Configuration in a structured way, with support for automatic Key Vault reference resolution, hierarchical configuration construction, and strongly typed configuration binding.
For more information about Azure App Configuration, see:https://learn.microsoft.com/en-us/azure/azure-app-configuration/
- type AuthenticationOptions
- type AzureAppConfiguration
- func (azappcfg *AzureAppConfiguration) GetBytes(options *ConstructionOptions) ([]byte, error)
- func (azappcfg *AzureAppConfiguration) OnRefreshSuccess(callback func())
- func (azappcfg *AzureAppConfiguration) Refresh(ctx context.Context) error
- func (azappcfg *AzureAppConfiguration) Unmarshal(v any, options *ConstructionOptions) error
- type ConstructionOptions
- type FeatureFlagOptions
- type KeyValueRefreshOptions
- type KeyVaultOptions
- type Options
- type RefreshOptions
- type SecretResolver
- type Selector
- type StartupOptions
- type WatchedSetting
This section is empty.
This section is empty.
This section is empty.
AuthenticationOptions contains parameters for authenticating with the Azure App Configuration service. Either a connection string or an endpoint with credential must be provided.
type AzureAppConfiguration struct {
}
An AzureAppConfiguration is a configuration provider that stores and manages settings sourced from Azure App Configuration.
Load initializes a new AzureAppConfiguration instance and loads the configuration data from Azure App Configuration service.
Parameters:
- ctx: The context for the operation.
- authentication: Authentication options for connecting to the Azure App Configuration service
- options: Configuration options to customize behavior, such as key filters and prefix trimming
Returns:
- A configured AzureAppConfiguration instance that provides access to the loaded configuration data
- An error if the operation fails, such as authentication errors or connectivity issues
GetBytes returns the configuration as a JSON byte array with hierarchical structure. This method is particularly useful for integrating with "encoding/json" package or third-party configuration packages like Viper or Koanf.
Parameters:
- options: Optional parameters for controlling JSON construction, particularly the key separator
Returns:
- A byte array containing the JSON representation of the configuration
- An error if JSON marshalling fails or if an invalid separator is specified
func (azappcfg *AzureAppConfiguration) OnRefreshSuccess(callback func())
OnRefreshSuccess registers a callback function that will be executed whenever the configuration is successfully refreshed and actual changes were detected.
Multiple callback functions can be registered, and they will be executed in the order they were added. Callbacks are only executed when configuration values actually change. They run synchronously in the thread that initiated the refresh.
Parameters:
- callback: A function with no parameters that will be called after a successful refresh
Refresh manually triggers a refresh of the configuration from Azure App Configuration. It checks if any watched settings have changed, and if so, reloads all configuration data.
The refresh only occurs if:
- Refresh has been configured with RefreshOptions when the client was created
- The configured refresh interval has elapsed since the last refresh
- No other refresh operation is currently in progress
If the configuration has changed, any callback functions registered with OnRefreshSuccess will be executed.
Parameters:
- ctx: The context for the operation.
Returns:
- An error if refresh is not configured, or if the refresh operation fails
Unmarshal parses the configuration and stores the result in the value pointed to v. It builds a hierarchical configuration structure based on key separators. It supports converting values to appropriate target types.
Fields in the target struct are matched with configuration keys using the field name by default. For custom field mapping, use json struct tags.
Parameters:
- v: A pointer to the struct to populate with configuration values
- options: Optional parameters (e,g, separator) for controlling the unmarshalling behavior
Returns:
- An error if unmarshalling fails due to type conversion issues or invalid configuration
type ConstructionOptions struct {
Separator [string](/builtin#string)}
ConstructionOptions contains parameters for parsing keys with hierarchical structure.
type FeatureFlagOptions struct {
Enabled [bool](/builtin#bool)
Selectors [][Selector](#Selector)
RefreshOptions [RefreshOptions](#RefreshOptions)}
FeatureFlagOptions contains optional parameters for Azure App Configuration feature flags that will be parsed and transformed into feature management configuration.
type KeyValueRefreshOptions struct {
WatchedSettings [][WatchedSetting](#WatchedSetting)
Interval [time](/time).[Duration](/time#Duration)
Enabled [bool](/builtin#bool)}
KeyValueRefreshOptions contains optional parameters to configure the behavior of key-value settings refresh
KeyVaultOptions contains parameters to configure the build-in Key Vault reference resolution. These options determine how the provider will authenticate with and retrieve
type Options struct {
TrimKeyPrefixes [][string](/builtin#string)
Selectors [][Selector](#Selector)
RefreshOptions [KeyValueRefreshOptions](#KeyValueRefreshOptions)
KeyVaultOptions [KeyVaultOptions](#KeyVaultOptions)
FeatureFlagOptions [FeatureFlagOptions](#FeatureFlagOptions)
ClientOptions *azappconfig.ClientOptions
ReplicaDiscoveryEnabled *[bool](/builtin#bool)
LoadBalancingEnabled [bool](/builtin#bool)
StartupOptions [StartupOptions](#StartupOptions)}
Options contains optional parameters to configure the behavior of an Azure App Configuration provider. It provides control over which key-values to fetch, how to trim key prefixes, and how to handle Key Vault references.
RefreshOptions contains optional parameters to configure the behavior of refresh
SecretResolver is an interface to resolve secrets from Key Vault references. Implement this interface to provide custom secret resolution logic.
Selector specifies what key-values to load from Azure App Configuration.
StartupOptions is used when initially loading data into the configuration provider.
WatchedSetting specifies the key and label of a key-value setting to watch for changes