-
Notifications
You must be signed in to change notification settings - Fork 650
Add dot notation support for aspire config commands #10035
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
Add dot notation support for aspire config commands #10035
Conversation
…hensive tests Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
…stead of custom GetConfigurationAsync Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
@copilot I now want you to extend the work you've done so far by implementing an internal interface IFeatureFlags
{
bool IsFeatureEnabled(string featureFlag);
} This service will read configuration keys with the form This shouldn't require changing any of the existing configuration code that you've already added so far in this PR, this would just be a new API injected into DI which uses |
- Add IFeatureFlags interface and FeatureFlags implementation - Feature flags read from config keys with pattern featureFlags.[featureName] - Deploy command is only available when deployCommandEnabled feature flag is true - Add comprehensive tests for feature flag functionality - Backward compatible: all existing commands work unchanged Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
I've implemented the The deploy command is now controlled by the Key features:
(commit fadb1de) |
.aspire/settings.json
Outdated
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.
@copilot remove this file from the PR.
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.
Removed the .aspire/settings.json file from the PR as requested.
|
||
if (value is not null) | ||
{ | ||
Console.WriteLine(value); | ||
return Task.FromResult(0); | ||
return 0; |
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.
@copilot use the success exit code constants here.
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.
Updated to use ExitCodeConstants.Success
instead of hardcoded return 0;
.
…o use IConfiguration, implement factory pattern, remove .aspire/settings.json Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
@davidfowl this is ready to go. @captainsafia as a heads up this PR introduces feature flagging. Currently as a proof point I've put the deploy command behind a feature flag. To enable it for local testing you will need to do this:
|
Summary
Enhances the
aspire config set
,get
, anddelete
commands to support dot notation for creating and managing nested JSON configuration structures.Changes
Before
After
Key Features
aspire config set foo.bar.baz hello
creates{ "foo": { "bar": { "baz": "hello" } } }
foo.bar
afterfoo
exists as a string automatically converts it to an objectaspire config get foo.bar.baz
correctly navigates nested structuresaspire config list
shows nested keys with dot notation (e.g.,foo.bar.baz=hello
)Implementation Details
ConfigurationService Enhancements
SetNestedValue()
: Parses dot-separated keys and creates nested JSON objectsDeleteNestedValue()
: Removes values and cleans up empty parent objectsGetNestedValue()
: Traverses nested paths for value retrievalFlattenJsonObject()
: Recursively flattens JSON for list operationsGetConfigurationAsync()
: New method for single key lookups with dot notation supportUpdated Commands
ConfigurationService.GetConfigurationAsync()
instead of flatIConfiguration
lookupExamples
Testing
Breaking Changes
None. This is a fully backward-compatible enhancement. Existing configurations and usage patterns continue to work unchanged.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.