fix: snapshot save/load/list/delete resolve the container host port

Same port auto-detection status/services/wait use — a container started
with --port <n> is now reachable by the snapshot commands without an
explicit --endpoint. Applies to all four trees via the unified base
commands.
This commit is contained in:
Hector Ventura committed 2026-07-28 21:35:27 -05:00
1 parent f7b934a6be
commit 7314d9982c
5 files changed
+21 -4

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ This project uses [Semantic Versioning](https://semver.org/).
- Internal: the four near-identical product command trees were unified into one `ProductProfile`-parameterized implementation — the `gcp`/`az`/`oci` command classes are now thin subclasses of the root commands, eliminating the copy-drift bug class
- **Snapshot commands are now real API calls in every product tree.** `floci gcp|az|oci snapshot save/load/list/delete` call the product server's `/snapshots` control-plane endpoints and degrade gracefully when the server doesn't support them yet — previously they printed a "not yet available" note and exited 0. `snapshot export`/`import` now exit 1 with an error in all four trees (previously exit 0 with a note on gcp/az/oci); CI scripts that relied on the silent success of stubbed snapshot commands will now see failures. Snapshot error messages point at the product's GitHub issue tracker instead of the maintainer-only TODO.md
- `floci gcp|az|oci logs` gained the `--service` flag and `services` gained `--mode`, matching the AWS tree (they had drifted apart); `version` on the AWS tree now prints the port-auto-detected endpoint in its "not reachable" hint like the other trees
- `services` and `snapshot save/load/list/delete` now auto-detect the endpoint from the running container's port mapping in every tree (like `status`/`wait`/`env` always did), so a container started with `--port <n>` is found without passing `--endpoint`
- Global `--endpoint`/`--container` help text now shows each product's default value
- The AWS tree now brands itself **Floci AWS** in banners, messages, and help text ("Starting Floci AWS container...", "Floci AWS Doctor", "Show Floci AWS container and server status"), matching the Floci GCP / Floci Azure / Floci OCI naming
@@ -2,6 +2,7 @@ package io.floci.cli.commands.snapshot;
import io.floci.cli.GlobalOptions;
import io.floci.cli.ProductProfile;
import io.floci.cli.docker.DockerClient;
import io.floci.cli.http.FlociException;
import io.floci.cli.http.FlociHttpClient;
import io.floci.cli.output.Ansi;
@@ -37,7 +38,10 @@ public class SnapshotDeleteCommand implements Callable<Integer> {
@Override
public Integer call() {
Printer printer = global.printer();
FlociHttpClient client = new FlociHttpClient(global.endpoint, profile.controlPrefix());
// Resolve the endpoint from the container's port mapping, like status/services/wait do,
// so a container started with --port <n> is still found without --endpoint.
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, profile.controlPrefix());
try {
client.deleteSnapshot(name);
printer.println(Ansi.green("Snapshot deleted:") + " " + name);
@@ -2,6 +2,7 @@ package io.floci.cli.commands.snapshot;
import io.floci.cli.GlobalOptions;
import io.floci.cli.ProductProfile;
import io.floci.cli.docker.DockerClient;
import io.floci.cli.http.FlociException;
import io.floci.cli.http.FlociHttpClient;
import io.floci.cli.output.Ansi;
@@ -35,7 +36,10 @@ public class SnapshotListCommand implements Callable<Integer> {
@Override
public Integer call() {
Printer printer = global.printer();
FlociHttpClient client = new FlociHttpClient(global.endpoint, profile.controlPrefix());
// Resolve the endpoint from the container's port mapping, like status/services/wait do,
// so a container started with --port <n> is still found without --endpoint.
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, profile.controlPrefix());
try {
var node = client.listSnapshots();
if (printer.format() != OutputFormat.text) {
@@ -2,6 +2,7 @@ package io.floci.cli.commands.snapshot;
import io.floci.cli.GlobalOptions;
import io.floci.cli.ProductProfile;
import io.floci.cli.docker.DockerClient;
import io.floci.cli.http.FlociException;
import io.floci.cli.http.FlociHttpClient;
import io.floci.cli.output.Ansi;
@@ -37,7 +38,10 @@ public class SnapshotLoadCommand implements Callable<Integer> {
@Override
public Integer call() {
Printer printer = global.printer();
FlociHttpClient client = new FlociHttpClient(global.endpoint, profile.controlPrefix());
// Resolve the endpoint from the container's port mapping, like status/services/wait do,
// so a container started with --port <n> is still found without --endpoint.
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, profile.controlPrefix());
try {
client.loadSnapshot(name);
printer.println(Ansi.green("Snapshot loaded:") + " " + name);
@@ -2,6 +2,7 @@ package io.floci.cli.commands.snapshot;
import io.floci.cli.GlobalOptions;
import io.floci.cli.ProductProfile;
import io.floci.cli.docker.DockerClient;
import io.floci.cli.http.FlociException;
import io.floci.cli.http.FlociHttpClient;
import io.floci.cli.output.Ansi;
@@ -40,7 +41,10 @@ public class SnapshotSaveCommand implements Callable<Integer> {
@Override
public Integer call() {
Printer printer = global.printer();
FlociHttpClient client = new FlociHttpClient(global.endpoint, profile.controlPrefix());
// Resolve the endpoint from the container's port mapping, like status/services/wait do,
// so a container started with --port <n> is still found without --endpoint.
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint, profile.controlPrefix());
try {
client.postSnapshot(name);
printer.println(Ansi.green("Snapshot saved:") + " " + name);