-
Notifications
You must be signed in to change notification settings - Fork 9
Load feature flags from new endpoint #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v2.7.0-preview
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package loader | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
| "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" | ||
| azappconfig "github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig/v2" | ||
| ) | ||
|
|
||
| // AppConfigurationClient abstracts the Azure App Configuration operations used by the provider. | ||
| type AppConfigurationClient interface { | ||
| // Key-value configuration operations. | ||
| NewListSettingsPager(selector azappconfig.SettingSelector, options *azappconfig.ListSettingsOptions) *runtime.Pager[azappconfig.ListSettingsPageResponse] | ||
| GetSetting(ctx context.Context, key string, options *azappconfig.GetSettingOptions) (azappconfig.GetSettingResponse, error) | ||
| GetSnapshot(ctx context.Context, snapshotName string, options *azappconfig.GetSnapshotOptions) (azappconfig.GetSnapshotResponse, error) | ||
| NewListSettingsForSnapshotPager(snapshotName string, options *azappconfig.ListSettingsForSnapshotOptions) *runtime.Pager[azappconfig.ListSettingsForSnapshotResponse] | ||
|
|
||
| // Feature flag operations served by the enhanced feature flag endpoint. | ||
| NewListFeatureFlagsPager(selector azappconfig.FeatureFlagSelector, options *azappconfig.ListFeatureFlagsOptions) *runtime.Pager[azappconfig.ListFeatureFlagsPageResponse] | ||
|
Check failure on line 23 in internal/loader/app_configuration_client.go
|
||
| } | ||
|
|
||
| type appConfigurationClient struct { | ||
| configurationClient *azappconfig.Client | ||
| featureFlagClient *azappconfig.FeatureFlagClient | ||
|
Check failure on line 28 in internal/loader/app_configuration_client.go
|
||
| } | ||
|
|
||
| func NewAppConfigurationClient(endpoint string, credential azcore.TokenCredential, options *azappconfig.ClientOptions) (AppConfigurationClient, error) { | ||
| configurationClient, err := azappconfig.NewClient(endpoint, credential, options) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| featureFlagClient, err := azappconfig.NewFeatureFlagClient(endpoint, credential, featureFlagClientOptions(options)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &appConfigurationClient{ | ||
| configurationClient: configurationClient, | ||
| featureFlagClient: featureFlagClient, | ||
| }, nil | ||
| } | ||
|
|
||
| func NewAppConfigurationClientFromConnectionString(connectionString string, options *azappconfig.ClientOptions) (AppConfigurationClient, error) { | ||
| configurationClient, err := azappconfig.NewClientFromConnectionString(connectionString, options) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| featureFlagClient, err := azappconfig.NewFeatureFlagClientFromConnectionString(connectionString, featureFlagClientOptions(options)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &appConfigurationClient{ | ||
| configurationClient: configurationClient, | ||
| featureFlagClient: featureFlagClient, | ||
| }, nil | ||
| } | ||
|
|
||
| // featureFlagClientOptions mirrors the configuration client options onto feature flag client options | ||
| func featureFlagClientOptions(options *azappconfig.ClientOptions) *azappconfig.FeatureFlagClientOptions { | ||
|
Check failure on line 66 in internal/loader/app_configuration_client.go
|
||
| if options == nil { | ||
| return nil | ||
| } | ||
|
|
||
| return &azappconfig.FeatureFlagClientOptions{ClientOptions: options.ClientOptions} | ||
| } | ||
|
|
||
| func (c *appConfigurationClient) NewListSettingsPager(selector azappconfig.SettingSelector, options *azappconfig.ListSettingsOptions) *runtime.Pager[azappconfig.ListSettingsPageResponse] { | ||
| return c.configurationClient.NewListSettingsPager(selector, options) | ||
| } | ||
|
|
||
| func (c *appConfigurationClient) GetSetting(ctx context.Context, key string, options *azappconfig.GetSettingOptions) (azappconfig.GetSettingResponse, error) { | ||
| return c.configurationClient.GetSetting(ctx, key, options) | ||
| } | ||
|
|
||
| func (c *appConfigurationClient) GetSnapshot(ctx context.Context, snapshotName string, options *azappconfig.GetSnapshotOptions) (azappconfig.GetSnapshotResponse, error) { | ||
| return c.configurationClient.GetSnapshot(ctx, snapshotName, options) | ||
| } | ||
|
|
||
| func (c *appConfigurationClient) NewListSettingsForSnapshotPager(snapshotName string, options *azappconfig.ListSettingsForSnapshotOptions) *runtime.Pager[azappconfig.ListSettingsForSnapshotResponse] { | ||
| return c.configurationClient.NewListSettingsForSnapshotPager(snapshotName, options) | ||
| } | ||
|
|
||
| func (c *appConfigurationClient) NewListFeatureFlagsPager(selector azappconfig.FeatureFlagSelector, options *azappconfig.ListFeatureFlagsOptions) *runtime.Pager[azappconfig.ListFeatureFlagsPageResponse] { | ||
|
Check failure on line 90 in internal/loader/app_configuration_client.go
|
||
| return c.featureFlagClient.NewListFeatureFlagsPager(selector, options) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.