Repository navigation
Allow dashboard to run without resource service - #1815
Merged
Drew Noakes (drewnoakes) merged 9 commits intoJan 25, 2024
Merged
Conversation
With the dashboard running OOP, it is configured with the resource server endpoint via an environment variable. The dashboard can actually perform useful work even without this connection, however it requires some code changes to support this. In this change, if the environment variable is not defined, then `IDashboardClient.IsEnabled` will be false, and some code paths become inactive based off the flag. To get tests passing, we introduce an abstraction for environment variables so we can inject the values we need. The navigation tree will not display the "Resources" or "Console logs" items when no resource service endpoint is available. --- Squashed from several other commits: Add singular overload of EnvironmentUtil.GetAddressUris And tidy up some code that parsed `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL`. Change that code to only support a single URI for that purpose, as it only makes one connection. DashboardClient is disabled when no dashboard endpoint When the `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL` variable is not in the dashboard's environment, the `DashboardClient` disables itself. In this state, it will throw when invoked, though you may query the `IsEnabled` property safely before making other calls. Add IEnvironmentVariables abstraction for unit testing Makes it possible to unit test environment variables. Make init properties Remove redundant null suppression Hide navigation items when resource service unavailable Hides the "Resources" and "Console logs" navigation menu items whenever the `DashboardClient` is not enabled (due to `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL` not being available). Check if IDashboardClient is enabled before calling it
Member
|
The title should have a value when there is no resource server. "Aspire dashboard"? An option to set it via argument/env var would be useful, but no one has asked for that yet. |
Member
Author
I like this idea! Added: string IDashboardClient.ApplicationName
{
get => _applicationName
?? _environmentVariables.GetString("DOTNET_DASHBOARD_APPLICATION_NAME")
?? "Aspire";
} |
Member
Author
|
James Newton-King (@JamesNK) PTAL. I'd like to get this merged in so there's more chance it's included in the next round of testing. |
Drew Noakes (drewnoakes)
enabled auto-merge (squash)
January 25, 2024 02:42
James Newton-King (JamesNK)
approved these changes
Jan 25, 2024
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
(Replaces #1795 which closed when we merged the feature branch.)
Relates to #1556
With the dashboard running OOP, it is configured with the resource server endpoint via the
DOTNET_DASHBOARD_GRPC_ENDPOINT_URLenvironment variable.The dashboard can actually perform useful work even without this connection, however it requires some code changes to support this.
In this PR, if the environment variable is not defined, then
IDashboardClient.IsEnabledwill be false, and some code paths become inactive based off the flag.To get tests passing, we introduce an abstraction for environment variables so we can inject the values we need.
The navigation tree will not display the "Resources" or "Console logs" items when no resource service endpoint is available:
Pending work:
/which shows an empty Resources list. Route somewhere else.Microsoft Reviewers: Open in CodeFlow