dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.65k stars 413 forks source link

Make PgAdmin, RedisCommander, and incoming MyPhpAdmin opt in per resource. #2060

Open mitchdenny opened 7 months ago

mitchdenny commented 7 months ago

Currently if we use WithPgAdmin (for example) on one resource, it opts all postgres resources in. It would be better to opt a particular resource into working with PgAdmin on a resource by resource basis.

davidfowl commented 7 months ago

Use an annotation to opt in?

mitchdenny commented 7 months ago

I'm actually thinking of creating a base annotation type. Something like this:

public class RelationshipAnnotation<TSource, TDestination>(TSource source, TDestination) where TSource: IResource where TDestination: IResource
{
    public TSource Source { get; } = source;
    public TDestination Destination { get; } = destination;
}

The idea is that folks could sub class it - perhaps like this:

public class PgAdminRegistrationAnnotation<PostgresDatabaseResource, PostgresServerREsource>(...) : RelationshipAnnotation(...)
{
}

The base class probably doesn't add much but perhaps we might be able to use this for things like expressing dependencies (its just a relationship after all).

davidfowl commented 7 months ago

Is it usable if it's generic? Can consuming code fill those type arguments?

mitchdenny commented 7 months ago

Yeah that is a good point. Non generic would be better for general purpose usage. The derivation might still be helpful for adding relationship data though.

joperezr commented 6 months ago

@mitchdenny are we doing this for P5? If so, is it okay if I assign this to you?

davidfowl commented 6 months ago

No, we should try to give this to someone else. @mitchdenny is focused on CDK work