-
Notifications
You must be signed in to change notification settings - Fork 715
Introduce IAppHostEnvironment interface for centralized AppHost environment information #12156
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
Draft
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/add-apphost-environment-interface
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.
Draft
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
806a6bf
Initial plan
Copilot 0e5e344
Add IAppHostEnvironment interface and replace configuration access
Copilot 532ae4e
Add tests for IAppHostEnvironment and fix test files
Copilot 8e7e8fa
Fix ResourceLoggerForwarderServiceTests to use IAppHostEnvironment
Copilot d7e6daf
Implement PR feedback: Rename properties and remove BrowserToken
Copilot 308eecb
Rename ProjectNameSha256 to ProjectNameHash and use same instance in DI
Copilot cc8a186
Replace IHostEnvironment with IAppHostEnvironment in Azure provisioni…
Copilot 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
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,63 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Hosting; | ||
|
|
||
| namespace Aspire.Hosting; | ||
|
|
||
| /// <summary> | ||
| /// Provides information about the AppHost environment. | ||
| /// </summary> | ||
| internal sealed class AppHostEnvironment : IAppHostEnvironment | ||
| { | ||
| private readonly IConfiguration _configuration; | ||
| private readonly IHostEnvironment _hostEnvironment; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="AppHostEnvironment"/> class. | ||
| /// </summary> | ||
| /// <param name="configuration">The configuration.</param> | ||
| /// <param name="hostEnvironment">The host environment.</param> | ||
| public AppHostEnvironment(IConfiguration configuration, IHostEnvironment hostEnvironment) | ||
| { | ||
| _configuration = configuration; | ||
| _hostEnvironment = hostEnvironment; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public string ProjectName => _configuration["AppHost:DashboardApplicationName"] ?? _hostEnvironment.ApplicationName; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string ProjectDirectory => _configuration["AppHost:Directory"]!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string FullPath => _configuration["AppHost:Path"]!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string DashboardApplicationName => _configuration["AppHost:DashboardApplicationName"] ?? _hostEnvironment.ApplicationName; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string DefaultHash => _configuration["AppHost:Sha256"]!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string FullPathHash => _configuration["AppHost:PathSha256"]!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string ProjectNameSha256 => _configuration["AppHost:ProjectNameSha256"]!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string? ContainerHostname => _configuration["AppHost:ContainerHostname"]; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string? DefaultLaunchProfileName => _configuration["AppHost:DefaultLaunchProfileName"]; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string? OtlpApiKey => _configuration["AppHost:OtlpApiKey"]; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string? ResourceServiceApiKey => _configuration["AppHost:ResourceService:ApiKey"]; | ||
|
|
||
| /// <inheritdoc /> | ||
| public string? ResourceServiceAuthMode => _configuration["AppHost:ResourceService:AuthMode"]; | ||
| } |
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
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
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
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
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
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
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
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,85 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting; | ||
|
|
||
| /// <summary> | ||
| /// Provides information about the AppHost environment. | ||
| /// </summary> | ||
| public interface IAppHostEnvironment | ||
| { | ||
| /// <summary> | ||
| /// Gets the name of the AppHost project. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This is the project name used in multiple places throughout the application, | ||
| /// including for generating resource names and configuration keys. | ||
| /// </remarks> | ||
| string ProjectName { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the directory of the project where the app host is located. | ||
| /// </summary> | ||
| string ProjectDirectory { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the full path to the app host. | ||
| /// </summary> | ||
| string FullPath { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the application name used for the dashboard. | ||
| /// </summary> | ||
| string DashboardApplicationName { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the SHA256 hash of the app host. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// For backward compatibility, this uses mode-dependent logic: | ||
| /// - Publish mode: ProjectNameSha (stable across paths) | ||
| /// - Run mode: FullPathHash (disambiguates by path) | ||
| /// </remarks> | ||
| string DefaultHash { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the SHA256 hash based on the app host path. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Used for disambiguating projects with the same name in different locations (deployment state). | ||
| /// </remarks> | ||
| string FullPathHash { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the SHA256 hash based on the project name. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Used for stable naming across deployments regardless of path (Azure Functions, Azure environments). | ||
| /// </remarks> | ||
| string ProjectNameSha256 { get; } | ||
|
||
|
|
||
| /// <summary> | ||
| /// Gets the container hostname. | ||
| /// </summary> | ||
| string? ContainerHostname { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the default launch profile name. | ||
| /// </summary> | ||
| string? DefaultLaunchProfileName { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the OTLP API key. | ||
| /// </summary> | ||
| string? OtlpApiKey { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the resource service API key. | ||
| /// </summary> | ||
| string? ResourceServiceApiKey { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the resource service authentication mode. | ||
| /// </summary> | ||
| string? ResourceServiceAuthMode { get; } | ||
| } | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.