-
Notifications
You must be signed in to change notification settings - Fork 36
feat: Adding OpenFeature provider for AWS AppConfig #310
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
Open
wani-guanxi
wants to merge
44
commits into
open-feature:main
Choose a base branch
from
wani-guanxi:feature/appconfig-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
ba0a4e4
chore(main): release OpenFeature.Contrib.Providers.Flipt 0.0.5 (#302)
github-actions[bot] 7ef76a4
Initial project and test project for aws appconfig provider
wani-guanxi 49e6e86
added project refrence to test project
wani-guanxi bd9fc74
Create AwsAppCofnig Provider
wani-guanxi 2d9cadf
adding Resolve Function for other types
wani-guanxi 5b11cdf
created separate static class for Aws app config parsing
wani-guanxi 1c1001a
removed unused usings
wani-guanxi eb96056
added constructor to AppConfig provider
wani-guanxi ae84a9f
cleaned and reused code, and also now accepting key in flagKey:attrib…
wani-guanxi ca4479a
put some more checkts in ResolveFeatureFlagValue function
wani-guanxi 81716b8
Adding AppConfigRetriebalAPI class with memory caching for app config…
wani-guanxi dd40afa
updating constructor and how configuration profile id is passed along
wani-guanxi 1ffe667
Adding extension function for adding OpenFeature AppConfig provider
wani-guanxi 668ccf8
Added comments for OpenFeature extension class
wani-guanxi 7c58dcc
adding ReadMe.md file with details about usable of the nuget package
wani-guanxi 8fbea1a
mermaid in Readme
wani-guanxi c4951b5
Update README.md
wani-guanxi 96b5ee4
Update README.md
wani-guanxi 0be3b5a
Update README.md
wani-guanxi d0c38fa
Update README.md
wani-guanxi 648668c
Update README.md
wani-guanxi 1b4d148
Update README.md
wani-guanxi ce982c9
Updating Readme
wani-guanxi cf24964
Update README.md
wani-guanxi 2c71695
Update README.md
wani-guanxi c7af807
Update README.md
wani-guanxi 44e4597
Update README.md
wani-guanxi 3f626f7
Update README.md
wani-guanxi 93a141e
adding tests
wani-guanxi 5aa4875
added more tests
wani-guanxi ac3cfd6
added more tests
wani-guanxi 178a15c
Adding FeatureFlagParser class's unit tests
wani-guanxi e9186a9
tests for AppConfigProvider
wani-guanxi 4057e5c
fixed test cases for appconfig provider
wani-guanxi 3791029
fixed tests for RetrievalAPi
wani-guanxi ca58683
Updating for allowing RequiredMinimumPollIntervalInSeconds property t…
wani-guanxi 81e53f5
added important information section
wani-guanxi 288a1e2
update readme
wani-guanxi c5f048c
Update README.md for Multi-variant flag information.
wani-guanxi f2a9907
fix: AppConfig through exception if calling too frequently, use whats…
wani-guanxi 79e4f0b
Update FeatureFlagProfile.cs - updated comments
wani-guanxi a14bc85
fixing broken test after exception catching when calling AWS
wani-guanxi c31db95
modifying comment to signoff
wani-guanxi 7455bb7
Merge branch 'main' into feature/appconfig-provider
wani-guanxi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/OpenFeature.Contrib.Providers.AwsAppConfig/AppConfigKey.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace OpenFeature.Contrib.Providers.AwsAppConfig | ||
{ | ||
/// <summary> | ||
/// Represents a key structure for AWS AppConfig feature flags with optional attributes. | ||
/// Keys can be in the format "flagKey" or "flagKey:attributeKey" | ||
/// </summary> | ||
public class AppConfigKey | ||
{ | ||
/// <summary> | ||
/// The separator used to split the flag key from its attribute key | ||
/// </summary> | ||
private const string Separator = ":"; | ||
|
||
/// <summary> | ||
/// Gets the App config's Configuration Profile ID | ||
/// </summary> | ||
public string ConfigurationProfileId {get; } | ||
|
||
/// <summary> | ||
/// Gets the main feature flag key | ||
/// </summary> | ||
public string FlagKey { get; } | ||
|
||
/// <summary> | ||
/// Gets the optional attribute key associated with the feature flag | ||
/// </summary> | ||
public string AttributeKey { get; } | ||
|
||
/// <summary> | ||
/// Gets whether this key has an attribute component | ||
/// </summary> | ||
public bool HasAttribute => !string.IsNullOrWhiteSpace(AttributeKey); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AppConfigKey"/> class that represents a structured key | ||
/// for AWS AppConfig feature flags. | ||
/// </summary> | ||
/// <param name="key"> | ||
/// The composite key string that must be in the format "configurationProfileId:flagKey[:attributeKey]" where: | ||
/// <list type="bullet"> | ||
/// <item><description>configurationProfileId - The AWS AppConfig configuration profile identifier</description></item> | ||
/// <item><description>flagKey - The feature flag key name</description></item> | ||
/// <item><description>attributeKey - (Optional) The specific attribute key to access within the feature flag</description></item> | ||
/// </list> | ||
/// </param> | ||
/// <exception cref="ArgumentException"> | ||
/// Thrown when: | ||
/// <list type="bullet"> | ||
/// <item><description>The key parameter is null, empty, or consists only of whitespace</description></item> | ||
/// <item><description>The key format is invalid (missing required parts)</description></item> | ||
/// <item><description>The key doesn't contain at least configurationProfileId and flagKey parts</description></item> | ||
/// </list> | ||
/// </exception> | ||
/// <remarks> | ||
/// The constructor parses the provided key string and populates the corresponding properties: | ||
/// <list type="bullet"> | ||
/// <item><description><see cref="ConfigurationProfileId"/> - First part of the key</description></item> | ||
/// <item><description><see cref="FlagKey"/> - Second part of the key</description></item> | ||
/// <item><description><see cref="AttributeKey"/> - Third part of the key (if provided)</description></item> | ||
/// </list> | ||
/// </remarks> | ||
/// <example> | ||
/// Valid key formats: | ||
/// <code> | ||
/// // Basic usage with configuration profile and flag key | ||
/// var key1 = new AppConfigKey("myProfile:myFlag"); | ||
/// | ||
/// // Usage with an attribute key | ||
/// var key2 = new AppConfigKey("myProfile:myFlag:myAttribute"); | ||
/// </code> | ||
/// </example> | ||
public AppConfigKey(string key) | ||
{ | ||
if(string.IsNullOrWhiteSpace(key)) | ||
{ | ||
throw new ArgumentException("Key cannot be null or empty"); | ||
} | ||
|
||
// Regular expression for validating the format with last part as 0 or 1 or empty | ||
string pattern = @"^[^:]+:[^:]+(:[^:]+)?$"; | ||
var match = Regex.IsMatch(key, pattern); | ||
|
||
if(!match) throw new ArgumentException("Invalid key format. Flag key is expected in configurationProfileId:flagKey[:attributeKey] format"); | ||
|
||
|
||
var parts = key.Split(Separator, StringSplitOptions.RemoveEmptyEntries); | ||
|
||
if(parts.Length < 2 ) | ||
{ | ||
throw new ArgumentException("Invalid key format. Flag key is expected in configurationProfileId:flagKey[:attributeKey] format"); | ||
} | ||
|
||
ConfigurationProfileId = parts[0]; | ||
FlagKey = parts[1]; | ||
// At this point, AWS AppConfig allows only value types for attributes. | ||
// Hence ignoring anything afterwords. | ||
if (parts.Length > 2) | ||
{ | ||
AttributeKey = parts[2]; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Constructs an AppConfigKey using individual components. | ||
/// </summary> | ||
/// <param name="configurationProfileId">The AWS AppConfig configuration profile identifier</param> | ||
/// <param name="flagKey">The feature flag key name</param> | ||
/// <param name="attributeKey">Optional. The specific attribute key to access</param> | ||
/// <exception cref="ArgumentException"> | ||
/// Thrown when: | ||
/// - configurationProfileId is null, empty, or whitespace | ||
/// - flagKey is null, empty, or whitespace | ||
/// </exception> | ||
public AppConfigKey(string configurationProfileId, string flagKey, string attributeKey = null) | ||
{ | ||
if (string.IsNullOrWhiteSpace(configurationProfileId)) | ||
{ | ||
throw new ArgumentNullException("Configuration Profile ID cannot be null or empty"); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(flagKey)) | ||
{ | ||
throw new ArgumentNullException("Flag key cannot be null or empty"); | ||
} | ||
|
||
ConfigurationProfileId = configurationProfileId; | ||
FlagKey = flagKey; | ||
AttributeKey = attributeKey; | ||
} | ||
|
||
/// <summary> | ||
/// Converts the AppConfigKey object back to its string representation. | ||
/// </summary> | ||
/// <returns> | ||
/// A string in the format "configurationProfileId:flagKey[:attributeKey]". | ||
/// The attributeKey part is only included if it exists. | ||
/// </returns> | ||
public override string ToString() | ||
{ | ||
return $"{ConfigurationProfileId}{Separator}{FlagKey}{(HasAttribute ? Separator + AttributeKey : "")}"; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please investigate using Source Generators for the Regex?