CommunityToolkit / Aspire

A community project with additional components and extensions for .NET Aspire
MIT License
227 stars 29 forks source link

Golang fixed PORT #209

Closed tommasodotNET closed 1 week ago

tommasodotNET commented 2 weeks ago

Describe the bug

Golang PORT should not be fixed to a user hardcoded by the user, but Aspire should be able to randomly assign one using a custom env PORT.

Regression

No response

Steps to reproduce

Currently user can only assign a PORT manually when calling `AddGolangApp()` and that needs to match the PORT to which the server is listening on.

Expected behavior

User should be able to not choose a PORT value and let Aspire assign one.

Screenshots

No response

IDE and version

Other

IDE version

No response

Nuget packages

Nuget package version(s)

9.0.0-beta.54

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

tommasodotNET commented 2 weeks ago

@aaronpowell we have two ways to handle this. Either we DO NOT configure http endpoint in the extension and let the user configure that when calling AddGolangApp(), or we configure it as

.WithHttpEndpoint(env: "PORT", name: GolangAppExecutableResource.HttpEndpointName)

Which one seems better?

aaronpowell commented 2 weeks ago

It shouldn't be on the AddGolangApp method as the port is only valid/used when you specify that you want a HTTP/HTTPS endpoint

tommasodotNET commented 2 weeks ago

We might have the same issue in the NodeJs extensions

aaronpowell commented 2 weeks ago

I don't think so, only the Vite support sets a port but it does that by adding an endpoint

tommasodotNET commented 2 weeks ago

Kinda confused on this. In Golang we demand to the AppHost the task to use the WithHttpEndpoint(env: "PORT"), but in Vite we have the WithHttpEndpoint(env: "PORT") inside the AddViteApp() method. Isn't this behavior inconsistent?