Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void InitializeConnectionString(ConnectionStringResource connectionStringResourc
await PublishConnectionStringAvailableEvent(connectionStringResource, cancellationToken).ConfigureAwait(false);
await _notificationService.PublishUpdateAsync(connectionStringResource, s => s with
{
State = new(KnownResourceStates.Active, KnownResourceStateStyles.Info),
State = new(KnownResourceStates.Active, KnownResourceStateStyles.Success),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this just a mistake previously?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I changed the previous ones to Success in this PR #10235 for parameters.

}).ConfigureAwait(false);
}, cancellationToken);
}
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