-
Notifications
You must be signed in to change notification settings - Fork 685
Change Redis Insights to use environment variables for preconfigured database connections #8524
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
Conversation
…atabase connections
@eerhardt, could you import the new Redis Insights tag to |
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.
Pull Request Overview
This PR refactors the RedisInsight integration in the Aspire.Hosting.Redis library to simplify the WithRedisInsight method, update the RedisInsight image tag, and improve test coverage by replacing outdated tests with a dedicated test for environment variables.
- Simplified the WithRedisInsight method by removing the ImportRedisDatabases logic and event subscriptions
- Updated the RedisInsight image tag from 2.66 to 2.68
- Enhanced tests with a new test verifying correct environment variable configuration and removed quarantined tests
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/Aspire.Hosting.Redis.Tests/RedisFunctionalTests.cs | Removed quarantined tests to streamline the RedisInsight test suite |
tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs | Added new test to verify RedisInsight environment variable configuration |
src/Aspire.Hosting.Redis/RedisContainerImageTags.cs | Updated RedisInsight image tag to 2.68 |
src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs | Simplified the WithRedisInsight method and refactored environment setup |
Comments suppressed due to low confidence (2)
src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs:251
- Ensure that each redis instance's PrimaryEndpoint is allocated before accessing its TargetPort to avoid potential null reference issues. Consider adding a conditional check before adding the environment variable.
context.EnvironmentVariables.Add("RI_REDIS_PORT" + counter, redisInstance.PrimaryEndpoint.TargetPort!.Value);
src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs:244
- [nitpick] If a deterministic order of redisInstances is important for consistent environment variable names, consider sorting the redisInstances collection before iterating.
var counter = 1;
Done. |
This also fixes #7291. |
@eerhardt, After this change, the |
Yep - that is intentional / by design. It isn't necessarily an "ideal" user experience, but it isn't Aspire's to decision to make. (note the user should be able to make the redis and redis-insights persistent to not have to accept the EULA as well). Check out |
I updated the PR description. This PR fixes four issues. See the description for those. |
- Remove IsAllocated check - Minor code clean up.
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.
This is great work, @Alirexaa! Thanks for the contribution.
LTGM.
Description
This pull request includes significant changes to the
Aspire.Hosting.Redis
library, focusing on simplifying theWithRedisInsight
method, updating the RedisInsight image tag, and improving test coverage. The most important changes are grouped into codebase simplification, image tag updates, and test improvements.Codebase Simplification:
src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs
: Simplified theWithRedisInsight
method by removing theImportRedisDatabases
function and associated logic, and refactoring the environment variable setup for Redis instances.Image Tag Updates:
src/Aspire.Hosting.Redis/RedisContainerImageTags.cs
: Updated the RedisInsight image tag from2.66
to2.68
.Test Improvements:
tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs
: Added a new testWithRedisInsightProducesCorrectEnvironmentVariables
to verify the correct environment variables are set for RedisInsight.tests/Aspire.Hosting.Redis.Tests/RedisFunctionalTests.cs
: Removed outdated and quarantined tests related to RedisInsight database import and persistence to streamline the test suite. [1] [2] [3]Fixes #8506
Fixes #7291
Fixes #6099
Fixes #7176
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):