fix(cli): treat a profile port equal to the default as a chosen port

A profile with a non-default container and the product's default port yields the default endpoint, which read as no endpoint chosen, so env exited 1 and status reported null. The provider now records that the port came from the profile. A profile with neither a port nor an endpoint stays unknown. Addresses the review of #75.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura committed 2026-11-04 17:29:33 -06:00
1 parent 0a8d1dcd57
commit 2a745d66bc
3 files changed
+40 -1

No files matched your search

+10 -1
View File
@@ -50,6 +50,10 @@ public class GlobalOptions {
// The value FLOCI_ENDPOINT supplied, if any: that is a choice, like typing --endpoint.
private final String endpointFromEnv;
// Whether the endpoint came from a profile's port. The string cannot say: a profile with
// port 4566 yields the product's default endpoint, yet that port was chosen.
private boolean portFromProfile;
@Option(names = {"--endpoint"},
description = "Floci server endpoint URL (default: ${DEFAULT-VALUE})",
paramLabel = "<url>")
@@ -195,9 +199,14 @@ public class GlobalOptions {
return noEmoji || !terminal || noColorEnv;
}
/** Called by the profile provider when it derives the endpoint from a profile's {@code port}. */
public void endpointCameFromProfilePort() {
portFromProfile = true;
}
/** Whether a configured endpoint can identify this instance without a container lookup. */
public boolean canUseConfiguredEndpoint() {
return typed("--endpoint") || endpoint.equals(endpointFromEnv)
return typed("--endpoint") || endpoint.equals(endpointFromEnv) || portFromProfile
|| !product.defaultEndpoint().equals(endpoint)
|| product.defaultContainer().equals(container);
}