-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't wait until after we've started the entire app to print the token (
#3472) - Print it right after we print the dashboard url - Refactored the dashboard resource to use DashboardOptions instead of DcpOptions
- Loading branch information
Showing
5 changed files
with
87 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,53 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.Dcp; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Aspire.Hosting.Dashboard; | ||
|
||
internal class DashboardOptions | ||
{ | ||
public string? DashboardPath { get; set; } | ||
public string? DashboardUrl { get; set; } | ||
public string? DashboardToken { get; set; } | ||
public string? OtlpEndpointUrl { get; set; } | ||
public string? OtlpApiKey { get; set; } | ||
public string AspNetCoreEnvironment { get; set; } = "Production"; | ||
} | ||
|
||
internal class ConfigureDefaultDashboardOptions(IConfiguration configuration, IOptions<DcpOptions> dcpOptions) : IConfigureOptions<DashboardOptions> | ||
{ | ||
public void Configure(DashboardOptions options) | ||
{ | ||
options.DashboardPath = dcpOptions.Value.DashboardPath; | ||
options.DashboardUrl = configuration["ASPNETCORE_URLS"]; | ||
options.DashboardToken = configuration["AppHost:BrowserToken"]; | ||
|
||
options.OtlpEndpointUrl = configuration["DOTNET_DASHBOARD_OTLP_ENDPOINT_URL"]; | ||
options.OtlpApiKey = configuration["AppHost:OtlpApiKey"]; | ||
|
||
options.AspNetCoreEnvironment = configuration["ASPNETCORE_ENVIRONMENT"] ?? "Production"; | ||
} | ||
} | ||
|
||
internal class ValidateDashboardOptions : IValidateOptions<DashboardOptions> | ||
{ | ||
public ValidateOptionsResult Validate(string? name, DashboardOptions options) | ||
{ | ||
var builder = new ValidateOptionsResultBuilder(); | ||
|
||
if (string.IsNullOrEmpty(options.DashboardUrl)) | ||
{ | ||
builder.AddError("Failed to configure dashboard resource because ASPNETCORE_URLS environment variable was not set."); | ||
} | ||
|
||
if (string.IsNullOrEmpty(options.OtlpEndpointUrl)) | ||
{ | ||
builder.AddError("Failed to configure dashboard resource because DOTNET_DASHBOARD_OTLP_ENDPOINT_URL environment variable was not set."); | ||
} | ||
|
||
return builder.Build(); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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