Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Make parameters and connection strings visible in dashboard by removi…
…ng IsHidden=true

Co-authored-by: davidfowl <[email protected]>
  • Loading branch information
Copilot and davidfowl committed Jul 11, 2025
commit f1c4749ec7238fcd4bc35e4d02ac96eb2bb5200d
2 changes: 0 additions & 2 deletions src/Aspire.Hosting/ConnectionStringBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public static IResourceBuilder<ConnectionStringResource> AddConnectionString(thi
{
ResourceType = KnownResourceTypes.ConnectionString,
State = KnownResourceStates.Waiting,
// TODO: We'll hide this until we come up with a sane representation of these in the dashboard
IsHidden = true,
Properties = []
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/Aspire.Hosting/Orchestrator/ParameterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ await notificationService.PublishUpdateAsync(parameterResource, s =>
return s with
{
State = new(stateText, KnownResourceStateStyles.Error),
Properties = s.Properties.SetResourceProperty(KnownProperties.Parameter.Value, ex.Message),
IsHidden = false
Properties = s.Properties.SetResourceProperty(KnownProperties.Parameter.Value, ex.Message)
};
})
.ConfigureAwait(false);
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ internal static IResourceBuilder<T> AddParameter<T>(this IDistributedApplication
var state = new CustomResourceSnapshot
{
ResourceType = KnownResourceTypes.Parameter,
// hide parameters by default
IsHidden = true,
Properties = [
new("parameter.secret", resource.Secret.ToString()),
new(CustomResourceKnownProperties.Source, resource.ConfigurationKey)
Expand Down
30 changes: 28 additions & 2 deletions tests/Aspire.Hosting.Tests/AddParameterTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Dashboard.Model;
using Aspire.Hosting.Publishing;
using Aspire.Hosting.Utils;
using Microsoft.AspNetCore.InternalTesting;
Expand All @@ -13,7 +14,7 @@ namespace Aspire.Hosting.Tests;
public class AddParameterTests
{
[Fact]
public void ParametersAreHiddenByDefault()
public void ParametersAreVisibleByDefault()
{
var appBuilder = DistributedApplication.CreateBuilder();
appBuilder.Configuration["Parameters:pass"] = "pass1";
Expand All @@ -31,7 +32,7 @@ public void ParametersAreHiddenByDefault()

var state = annotation.InitialSnapshot;

Assert.True(state.IsHidden);
Assert.False(state.IsHidden);
Assert.Collection(state.Properties,
prop =>
{
Expand Down Expand Up @@ -360,4 +361,29 @@ public override void WriteToManifest(ManifestPublishingContext context)
throw new NotImplementedException();
}
}

[Fact]
public void ConnectionStringsAreVisibleByDefault()
{
var appBuilder = DistributedApplication.CreateBuilder();
var endpoint = appBuilder.AddParameter("endpoint", "http://localhost:3452");
var key = appBuilder.AddParameter("key", "secretKey", secret: true);

appBuilder.AddConnectionString("testcs", ReferenceExpression.Create($"Endpoint={endpoint};Key={key}"));

using var app = appBuilder.Build();

var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();

var connectionStringResource = Assert.Single(appModel.Resources.OfType<ConnectionStringResource>());
var annotation = connectionStringResource.Annotations.OfType<ResourceSnapshotAnnotation>().SingleOrDefault();

Assert.NotNull(annotation);

var state = annotation.InitialSnapshot;

Assert.False(state.IsHidden);
Assert.Equal(KnownResourceTypes.ConnectionString, state.ResourceType);
Assert.Equal(KnownResourceStates.Waiting, state.State?.Text);
}
}
Loading