Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
189fd32
Initial plan
Copilot Jul 11, 2025
df9960b
Implement uninstrumented peer visualization for parameters, connectio…
Copilot Jul 11, 2025
d1fb28f
Support direct URL connection strings in peer resolution
Copilot Jul 11, 2025
138b2a7
Initial implementation of comprehensive connection string parser
Copilot Jul 11, 2025
5f58e3f
Add comprehensive connection string parser with extensive test coverage
Copilot Jul 11, 2025
40c8305
Update src/Aspire.Dashboard/Model/ConnectionStringParser.cs
davidfowl Jul 12, 2025
748f053
Fix failing ConnectionStringParser tests for comprehensive connection…
Copilot Jul 12, 2025
7d232fc
Refactor ConnectionStringParser with source-generated regexes and imp…
Copilot Jul 12, 2025
2c7129f
Use ConnectionStringParser for Parameter resources and remove TryPars…
Copilot Jul 12, 2025
01ae0cb
Implement robust hostname validation using RFC-compliant logic
Copilot Jul 12, 2025
40f8cb8
Simplify hostname validation using URI parsing as suggested
Copilot Jul 12, 2025
fe4c50f
Optimize ConnectionStringParser by using static readonly arrays and s…
Copilot Jul 12, 2025
7334208
Enhance GitHubModel resource initialization with connection string re…
davidfowl Jul 12, 2025
0792ea7
Change ConnectionStringParser class from public to internal
Copilot Jul 12, 2025
67540a7
Refactor to eliminate nested transformer loops and extend change dete…
Copilot Jul 14, 2025
d0c1afb
Cache resource addresses on ResourceOutgoingPeerResolver to avoid rec…
Copilot Jul 14, 2025
b7c2862
Move cache from ResourceOutgoingPeerResolver to ResourceViewModel
Copilot Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support direct URL connection strings in peer resolution
Co-authored-by: davidfowl <[email protected]>
  • Loading branch information
Copilot and davidfowl committed Jul 11, 2025
commit d1fb28f5ef5e6676cd53aaed35beda208cdaf228
15 changes: 11 additions & 4 deletions src/Aspire.Dashboard/Model/ResourceOutgoingPeerResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ internal static bool TryResolvePeerNameCore(IDictionary<string, ResourceViewMode

bool TryMatchResourceAddress(string value, [NotNullWhen(true)] out string? name, [NotNullWhen(true)] out ResourceViewModel? resourceMatch)
{
// First, try to match against resource URLs
foreach (var (resourceName, resource) in resources)
{
// Try to match against URL endpoints
foreach (var service in resource.Urls)
{
var hostAndPort = service.Url.GetComponents(UriComponents.HostAndPort, UriFormat.UriEscaped);

if (string.Equals(hostAndPort, value, StringComparison.OrdinalIgnoreCase))
if (DoesAddressMatch(hostAndPort, value))
{
name = ResourceViewModel.GetResourceName(resource, resources);
resourceMatch = resource;
return true;
}
}

// Try to match against connection strings (for GitHub models and other resources with connection strings)
// Try to match against connection strings (both direct URLs and Endpoint= patterns)
if (resource.Properties.TryGetValue(KnownProperties.Resource.ConnectionString, out var connectionStringProperty) &&
connectionStringProperty.Value.TryConvertToString(out var connectionString) &&
TryExtractEndpointFromConnectionString(connectionString, out var endpoint) &&
Expand All @@ -160,7 +160,7 @@ bool TryMatchResourceAddress(string value, [NotNullWhen(true)] out string? name,
if (resource.Properties.TryGetValue(KnownProperties.Parameter.Value, out var parameterValueProperty) &&
parameterValueProperty.Value.TryConvertToString(out var parameterValue) &&
TryParseUrlHostAndPort(parameterValue, out var parameterHostAndPort) &&
string.Equals(parameterHostAndPort, value, StringComparison.OrdinalIgnoreCase))
DoesAddressMatch(parameterHostAndPort, value))
{
name = ResourceViewModel.GetResourceName(resource, resources);
resourceMatch = resource;
Expand All @@ -183,6 +183,13 @@ private static bool TryExtractEndpointFromConnectionString(string connectionStri
return false;
}

// First, check if the entire connection string is a URL (e.g., blob storage, key vault)
if (Uri.TryCreate(connectionString, UriKind.Absolute, out var directUri))
{
endpoint = directUri.GetComponents(UriComponents.HostAndPort, UriFormat.UriEscaped);
return true;
}

// Parse connection string for Endpoint= pattern (used by GitHub Models and other resources)
var parts = connectionString.Split(';', StringSplitOptions.RemoveEmptyEntries);
foreach (var part in parts)
Expand Down
30 changes: 30 additions & 0 deletions tests/Aspire.Dashboard.Tests/ResourceOutgoingPeerResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,36 @@ public void ParameterWithNonUrlValue_NoMatch()
Assert.False(TryResolvePeerName(resources, [KeyValuePair.Create("peer.service", "localhost:5000")], out _));
}

[Fact]
public void ConnectionStringAsDirectUrl_Match()
{
// Arrange - Connection string that is itself a URL (e.g., blob storage)
var connectionString = "https://mystorageaccount.blob.core.windows.net/";
var resources = new Dictionary<string, ResourceViewModel>
{
["blob-storage"] = CreateResourceWithConnectionString("blob-storage", connectionString)
};

// Act & Assert
Assert.True(TryResolvePeerName(resources, [KeyValuePair.Create("peer.service", "mystorageaccount.blob.core.windows.net:443")], out var value));
Assert.Equal("blob-storage", value);
}

[Fact]
public void ConnectionStringAsDirectUrlWithCustomPort_Match()
{
// Arrange - Connection string that is itself a URL with custom port
var connectionString = "https://myvault.vault.azure.net:8080/";
var resources = new Dictionary<string, ResourceViewModel>
{
["key-vault"] = CreateResourceWithConnectionString("key-vault", connectionString)
};

// Act & Assert
Assert.True(TryResolvePeerName(resources, [KeyValuePair.Create("peer.service", "myvault.vault.azure.net:8080")], out var value));
Assert.Equal("key-vault", value);
}

private static ResourceViewModel CreateResourceWithConnectionString(string name, string connectionString)
{
var properties = new Dictionary<string, ResourcePropertyViewModel>
Expand Down