mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
fix: updating with latest floci changes
This commit is contained in:
16 files changed
+378
-116
No files matched your search
@@ -46,7 +46,7 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -127,7 +127,7 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -153,7 +153,7 @@ jobs:
|
||||
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -85,7 +85,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '24'
|
||||
java-version: '25'
|
||||
distribution: 'graalvm-community'
|
||||
cache: maven
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
Official command-line interface for [Floci](https://floci.io) — the free, open-source local AWS emulator.
|
||||
|
||||
```
|
||||
```sh
|
||||
floci start
|
||||
floci doctor
|
||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
||||
eval $(floci env)
|
||||
aws s3 mb s3://my-bucket
|
||||
```
|
||||
|
||||
@@ -36,14 +36,6 @@ scoop bucket add floci https://github.com/floci-io/scoop-floci
|
||||
scoop install floci
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
```sh
|
||||
docker run --rm floci/cli:latest version
|
||||
# With Docker socket for lifecycle commands:
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock floci/cli status
|
||||
```
|
||||
|
||||
### JVM fallback
|
||||
|
||||
Download `floci.jar` from the [latest release](https://github.com/floci-io/floci-cli/releases/latest) and run:
|
||||
@@ -63,8 +55,8 @@ floci start
|
||||
# Check environment
|
||||
floci doctor
|
||||
|
||||
# Point the AWS CLI at Floci
|
||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
||||
# Export AWS environment variables
|
||||
eval $(floci env)
|
||||
|
||||
# Use AWS services normally
|
||||
aws s3 mb s3://my-bucket
|
||||
@@ -92,21 +84,162 @@ floci stop
|
||||
| `floci version` | Show CLI and server versions |
|
||||
| `floci services` | List enabled AWS services |
|
||||
| `floci doctor` | Run environment diagnostics |
|
||||
| `floci env` | Print AWS environment variables |
|
||||
| `floci config show` | Show active configuration |
|
||||
| `floci config validate` | Validate a docker-compose.yml |
|
||||
| `floci config profile` | Manage named profiles |
|
||||
| `floci snapshot save/load/list/delete` | Manage state snapshots |
|
||||
| `floci completion bash\|zsh` | Generate shell completion |
|
||||
|
||||
All commands support `--help`. Global flags:
|
||||
All commands support `--help`. Global flags available on every command:
|
||||
|
||||
```
|
||||
--endpoint <url> Floci server URL (default: http://localhost:4566, env: FLOCI_ENDPOINT)
|
||||
--container <name> Container name (default: floci, env: FLOCI_CONTAINER)
|
||||
--output text|json|yaml Output format (default: text)
|
||||
--quiet, -q Suppress non-error output
|
||||
--verbose, -v Debug logging to stderr
|
||||
--no-color Disable ANSI colors
|
||||
--endpoint <url> Floci server URL (default: http://localhost:4566, env: FLOCI_ENDPOINT)
|
||||
--container <name> Container name (default: floci, env: FLOCI_CONTAINER)
|
||||
--output|-o text|json|yaml Output format (default: text)
|
||||
--quiet, -q Suppress non-error output
|
||||
--verbose, -v Debug logging to stderr
|
||||
--no-color Disable ANSI colors
|
||||
--profile <name> Load settings from ~/.floci/profiles/<name>.yaml
|
||||
```
|
||||
|
||||
> **Port auto-detection** — `status`, `version`, and `wait` automatically derive the correct
|
||||
> endpoint from the container's port mapping. You don't need to pass `--endpoint` when using
|
||||
> a non-default port, as long as `--container` points to the right container.
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
|
||||
### `floci start`
|
||||
|
||||
Pulls the image (if needed), starts the container, and waits for readiness.
|
||||
|
||||
```sh
|
||||
floci start # default port 4566
|
||||
floci start --port 4599 # custom host port
|
||||
floci start --services s3,dynamodb # enable specific services
|
||||
floci start --persist ./data # persist state to a host directory
|
||||
floci start --pull always # always pull the latest image
|
||||
floci start --detach # return immediately, don't wait
|
||||
```
|
||||
|
||||
### `floci stop`
|
||||
|
||||
```sh
|
||||
floci stop # graceful stop (10s timeout)
|
||||
floci stop --timeout 30 # wait up to 30s before force-kill
|
||||
floci stop --remove # also remove the container after stopping
|
||||
```
|
||||
|
||||
### `floci status`
|
||||
|
||||
```sh
|
||||
floci status # auto-detects endpoint from container port mapping
|
||||
floci status --container myfloci # target a specific container
|
||||
floci status -o json # structured output
|
||||
```
|
||||
|
||||
### `floci env`
|
||||
|
||||
Prints AWS environment variables pointing at the running Floci instance. The default
|
||||
hostname is `localhost.floci.io` (resolves to `127.0.0.1`, enables virtual-hosted S3 bucket names).
|
||||
|
||||
```sh
|
||||
eval $(floci env) # bash/zsh — sets all four AWS vars
|
||||
floci env --shell fish | source # fish
|
||||
floci env --shell powershell | Invoke-Expression # PowerShell
|
||||
|
||||
floci env --host myhost.local # custom hostname
|
||||
floci env --region eu-west-1 # custom region (default: us-east-1)
|
||||
floci env --endpoint http://localhost:4599 # pick up port from a non-default instance
|
||||
floci env -o json # structured output for scripts
|
||||
```
|
||||
|
||||
Variables exported:
|
||||
|
||||
| Variable | Default value |
|
||||
|----------|---------------|
|
||||
| `AWS_ENDPOINT_URL` | `http://localhost.floci.io:4566` |
|
||||
| `AWS_ACCESS_KEY_ID` | `test` |
|
||||
| `AWS_SECRET_ACCESS_KEY` | `test` |
|
||||
| `AWS_DEFAULT_REGION` | `us-east-1` |
|
||||
|
||||
### `floci logs`
|
||||
|
||||
```sh
|
||||
floci logs # last logs from the container
|
||||
floci logs --tail 50 # last 50 lines
|
||||
floci logs --since 5m # logs from the last 5 minutes
|
||||
floci logs --follow # stream live logs (Ctrl-C to stop)
|
||||
```
|
||||
|
||||
### `floci wait`
|
||||
|
||||
```sh
|
||||
floci wait # wait up to 30s (default)
|
||||
floci wait --timeout 2m # custom timeout (supports s, m, h)
|
||||
floci wait --service dynamodb # wait until a specific service is ready
|
||||
floci wait -o json # machine-readable output
|
||||
```
|
||||
|
||||
### `floci doctor`
|
||||
|
||||
```sh
|
||||
floci doctor # run all checks
|
||||
floci doctor --check docker.installed # run a single check by name
|
||||
floci doctor --fix # auto-fix fixable issues
|
||||
floci doctor -o json # structured output for scripts
|
||||
```
|
||||
|
||||
### `floci version`
|
||||
|
||||
```sh
|
||||
floci version # CLI version, server version, image digest
|
||||
floci version -o json
|
||||
```
|
||||
|
||||
### `floci services`
|
||||
|
||||
```sh
|
||||
floci services # list all enabled services
|
||||
floci services --mode docker # only docker-backed services
|
||||
floci services --mode in-process # only in-process services
|
||||
floci services -o json
|
||||
```
|
||||
|
||||
### `floci config`
|
||||
|
||||
```sh
|
||||
floci config show # show active configuration
|
||||
floci config profile list # list saved profiles
|
||||
floci config profile create <name> # create a new profile
|
||||
floci config profile show <name> # show a profile
|
||||
floci config profile delete <name> # delete a profile
|
||||
floci config validate -f docker-compose.yml # validate a Compose file
|
||||
```
|
||||
|
||||
Profiles are stored in `~/.floci/profiles/<name>.yaml` and can override any global option.
|
||||
Use `--profile <name>` on any command to load one.
|
||||
|
||||
### `floci snapshot`
|
||||
|
||||
Save and restore named snapshots of Floci state (requires server-side support — coming soon).
|
||||
|
||||
```sh
|
||||
floci snapshot list
|
||||
floci snapshot save <name> --message "before migration"
|
||||
floci snapshot load <name>
|
||||
floci snapshot delete <name>
|
||||
floci snapshot export <name> -o tarball.tar.gz
|
||||
floci snapshot import tarball.tar.gz
|
||||
```
|
||||
|
||||
### `floci completion`
|
||||
|
||||
```sh
|
||||
floci completion bash >> ~/.bashrc
|
||||
floci completion zsh >> ~/.zshrc
|
||||
```
|
||||
|
||||
---
|
||||
@@ -114,12 +247,21 @@ All commands support `--help`. Global flags:
|
||||
## CI Usage
|
||||
|
||||
```sh
|
||||
floci start --detach
|
||||
floci start --port 4566 --detach
|
||||
floci wait --timeout 60s
|
||||
pytest # or your test command
|
||||
floci stop --remove
|
||||
```
|
||||
|
||||
Set AWS environment variables in CI before running tests:
|
||||
|
||||
```sh
|
||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
||||
export AWS_ACCESS_KEY_ID=test
|
||||
export AWS_SECRET_ACCESS_KEY=test
|
||||
export AWS_DEFAULT_REGION=us-east-1
|
||||
```
|
||||
|
||||
With Docker Compose:
|
||||
|
||||
```yaml
|
||||
|
||||
@@ -14,7 +14,8 @@ import picocli.CommandLine.*;
|
||||
" floci stop — stop the container%n" +
|
||||
" floci status — show health and version%n" +
|
||||
" floci doctor — diagnose environment issues%n" +
|
||||
" floci logs — stream container logs%n",
|
||||
" floci logs — stream container logs%n" +
|
||||
" floci env — print AWS environment variables%n",
|
||||
mixinStandardHelpOptions = true,
|
||||
versionProvider = FlociCli.VersionProvider.class,
|
||||
subcommands = {
|
||||
@@ -27,6 +28,7 @@ import picocli.CommandLine.*;
|
||||
VersionCommand.class,
|
||||
ServicesCommand.class,
|
||||
DoctorCommand.class,
|
||||
EnvCommand.class,
|
||||
ConfigCommand.class,
|
||||
SnapshotCommand.class,
|
||||
CompletionCommand.class,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package io.floci.cli;
|
||||
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.Option;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class GlobalOptions {
|
||||
|
||||
@Option(names = {"--endpoint"},
|
||||
@@ -46,6 +49,38 @@ public class GlobalOptions {
|
||||
return new Printer(System.out, System.err, output, quiet);
|
||||
}
|
||||
|
||||
// Inspects the container and derives the endpoint from its host port mapping.
|
||||
// Falls back to the configured endpoint if the container is not found or has no mapping.
|
||||
public String resolvedEndpoint(DockerClient docker) {
|
||||
try {
|
||||
return docker.inspectContainer(container)
|
||||
.map(info -> endpointFromPorts(info.ports(), endpoint))
|
||||
.orElse(endpoint);
|
||||
} catch (Exception e) {
|
||||
return endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
// Matches the container-side port from the configured endpoint to find the actual host port.
|
||||
public String endpointFromPorts(String ports, String fallback) {
|
||||
if (ports == null || ports.isBlank()) return fallback;
|
||||
try {
|
||||
int containerPort = URI.create(fallback).getPort();
|
||||
if (containerPort == -1) containerPort = 4566;
|
||||
for (String mapping : ports.trim().split("\\s+")) {
|
||||
int arrow = mapping.indexOf("->");
|
||||
if (arrow < 0) continue;
|
||||
String hostPort = mapping.substring(0, arrow);
|
||||
String rest = mapping.substring(arrow + 2);
|
||||
String cPort = rest.contains("/") ? rest.substring(0, rest.indexOf('/')) : rest;
|
||||
if (String.valueOf(containerPort).equals(cPort)) {
|
||||
return "http://localhost:" + hostPort;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private static boolean isStdoutTty() {
|
||||
return System.console() != null;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,18 @@ import io.floci.cli.GlobalOptions;
|
||||
import io.floci.cli.doctor.Check;
|
||||
import io.floci.cli.doctor.CheckResult;
|
||||
import io.floci.cli.doctor.CheckStatus;
|
||||
import io.floci.cli.doctor.checks.*;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.doctor.checks.AwsCliEndpointCheck;
|
||||
import io.floci.cli.doctor.checks.AwsCliS3PathStyleCheck;
|
||||
import io.floci.cli.doctor.checks.ContainerRunningCheck;
|
||||
import io.floci.cli.doctor.checks.DockerDaemonCheck;
|
||||
import io.floci.cli.doctor.checks.DockerInstalledCheck;
|
||||
import io.floci.cli.doctor.checks.DockerSocketCheck;
|
||||
import io.floci.cli.doctor.checks.DockerVersionCheck;
|
||||
import io.floci.cli.doctor.checks.EndpointReachableCheck;
|
||||
import io.floci.cli.doctor.checks.ImagePresentCheck;
|
||||
import io.floci.cli.doctor.checks.ImageVersionCheck;
|
||||
import io.floci.cli.doctor.checks.PortAvailableCheck;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
@@ -43,27 +54,30 @@ public class DoctorCommand implements Callable<Integer> {
|
||||
new ContainerRunningCheck(),
|
||||
new EndpointReachableCheck(),
|
||||
new AwsCliEndpointCheck(),
|
||||
new AwsCliS3PathStyleCheck(),
|
||||
new SdkRustS3XmlCheck(),
|
||||
new SdkGoEndpointCheck()
|
||||
new AwsCliS3PathStyleCheck()
|
||||
);
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
List<CheckResult> results = new ArrayList<>();
|
||||
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
|
||||
|
||||
printer.println(Ansi.bold("Floci Doctor") + " — checking your environment");
|
||||
printer.println("");
|
||||
boolean textMode = printer.format() == OutputFormat.text;
|
||||
|
||||
for (Check check : ALL_CHECKS) {
|
||||
CheckResult result = check.run(global.endpoint, global.container);
|
||||
if (checkName != null && !result.name().equals(checkName)) continue;
|
||||
results.add(result);
|
||||
printResult(printer, result);
|
||||
if (textMode) {
|
||||
printer.println(Ansi.bold("Floci Doctor") + " — checking your environment");
|
||||
printer.println("");
|
||||
}
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
for (Check check : ALL_CHECKS) {
|
||||
CheckResult result = check.run(effectiveEndpoint, global.container);
|
||||
if (checkName != null && !result.name().equals(checkName)) continue;
|
||||
results.add(result);
|
||||
if (textMode) printResult(printer, result);
|
||||
}
|
||||
|
||||
if (!textMode) {
|
||||
List<Map<String, Object>> structured = new ArrayList<>();
|
||||
for (CheckResult r : results) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package io.floci.cli.commands;
|
||||
|
||||
import io.floci.cli.GlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@Command(
|
||||
name = "env",
|
||||
description = "Print AWS environment variables to connect to Floci",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class EnvCommand implements Callable<Integer> {
|
||||
|
||||
@Mixin
|
||||
GlobalOptions global;
|
||||
|
||||
@Option(names = {"--host"},
|
||||
description = "Hostname for the AWS endpoint URL (default: localhost.floci.io)",
|
||||
defaultValue = "${FLOCI_HOST:-localhost.floci.io}",
|
||||
paramLabel = "<host>")
|
||||
String host;
|
||||
|
||||
@Option(names = {"--region"},
|
||||
description = "AWS region (default: us-east-1)",
|
||||
defaultValue = "${AWS_DEFAULT_REGION:-us-east-1}",
|
||||
paramLabel = "<region>")
|
||||
String region;
|
||||
|
||||
@Option(names = {"--shell"},
|
||||
description = "Shell format: bash, fish, powershell (default: bash)",
|
||||
defaultValue = "bash",
|
||||
paramLabel = "bash|fish|powershell")
|
||||
String shell;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
int port = extractPort(global.endpoint);
|
||||
String endpointUrl = "http://" + host + ":" + port;
|
||||
|
||||
Map<String, String> vars = new LinkedHashMap<>();
|
||||
vars.put("AWS_ENDPOINT_URL", endpointUrl);
|
||||
vars.put("AWS_ACCESS_KEY_ID", "test");
|
||||
vars.put("AWS_SECRET_ACCESS_KEY", "test");
|
||||
vars.put("AWS_DEFAULT_REGION", region);
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(vars);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : vars.entrySet()) {
|
||||
printer.println(formatExport(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
printer.println("");
|
||||
printer.println(Ansi.gray("# Run: eval $(floci env)"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
private String formatExport(String key, String value) {
|
||||
return switch (shell.toLowerCase()) {
|
||||
case "fish" -> "set -x " + key + " \"" + value + "\"";
|
||||
case "powershell", "ps1" -> "$env:" + key + " = \"" + value + "\"";
|
||||
default -> "export " + key + "=" + value;
|
||||
};
|
||||
}
|
||||
|
||||
private int extractPort(String endpoint) {
|
||||
try {
|
||||
int port = URI.create(endpoint).getPort();
|
||||
return port == -1 ? 4566 : port;
|
||||
} catch (Exception e) {
|
||||
return 4566;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,9 @@ public class StartCommand implements Callable<Integer> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Update endpoint to match the bound host port before polling readiness
|
||||
global.endpoint = "http://localhost:" + port;
|
||||
|
||||
// Wait for readiness
|
||||
printer.println(Ansi.gray("Waiting for Floci to be ready..."));
|
||||
WaitCommand wait = new WaitCommand();
|
||||
|
||||
@@ -33,12 +33,14 @@ public class StatusCommand implements Callable<Integer> {
|
||||
String containerState = "not found";
|
||||
String containerImage = "";
|
||||
String containerPorts = "";
|
||||
String effectiveEndpoint = global.endpoint;
|
||||
try {
|
||||
Optional<DockerClient.ContainerInfo> info = docker.inspectContainer(global.container);
|
||||
if (info.isPresent()) {
|
||||
containerState = info.get().state();
|
||||
containerImage = info.get().image();
|
||||
containerPorts = info.get().ports();
|
||||
effectiveEndpoint = global.endpointFromPorts(containerPorts, global.endpoint);
|
||||
}
|
||||
} catch (DockerException e) {
|
||||
containerState = "error: " + e.getMessage();
|
||||
@@ -48,7 +50,7 @@ public class StatusCommand implements Callable<Integer> {
|
||||
String serverVersion = "unavailable";
|
||||
String serverEdition = "";
|
||||
boolean reachable = false;
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint);
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
try {
|
||||
var health = client.health();
|
||||
serverVersion = health.version();
|
||||
@@ -61,7 +63,7 @@ public class StatusCommand implements Callable<Integer> {
|
||||
data.put("state", containerState);
|
||||
data.put("image", containerImage);
|
||||
data.put("ports", containerPorts);
|
||||
data.put("endpoint", global.endpoint);
|
||||
data.put("endpoint", effectiveEndpoint);
|
||||
data.put("reachable", reachable);
|
||||
data.put("version", serverVersion);
|
||||
data.put("edition", serverEdition);
|
||||
@@ -81,7 +83,7 @@ public class StatusCommand implements Callable<Integer> {
|
||||
printer.println(" Container: " + global.container + " " + stateColor);
|
||||
if (!containerImage.isBlank()) printer.println(" Image: " + containerImage);
|
||||
if (!containerPorts.isBlank()) printer.println(" Ports: " + containerPorts);
|
||||
printer.println(" Endpoint: " + global.endpoint);
|
||||
printer.println(" Endpoint: " + effectiveEndpoint);
|
||||
printer.println(" Reachable: " + (reachable ? Ansi.green("yes") : Ansi.red("no")));
|
||||
if (reachable) {
|
||||
printer.println(" Version: " + serverVersion);
|
||||
@@ -95,4 +97,5 @@ public class StatusCommand implements Callable<Integer> {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,10 @@ public class VersionCommand implements Callable<Integer> {
|
||||
String serverEdition = null;
|
||||
String imageDigest = null;
|
||||
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint);
|
||||
var docker = new io.floci.cli.docker.DockerClient();
|
||||
String effectiveEndpoint = global.resolvedEndpoint(docker);
|
||||
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
try {
|
||||
var info = client.info();
|
||||
serverVersion = info.version();
|
||||
@@ -41,7 +44,6 @@ public class VersionCommand implements Callable<Integer> {
|
||||
|
||||
// Try to read image digest from Docker (best-effort)
|
||||
try {
|
||||
var docker = new io.floci.cli.docker.DockerClient();
|
||||
imageDigest = docker.imageDigest("floci/floci").orElse(null);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ package io.floci.cli.commands;
|
||||
import io.floci.cli.GlobalOptions;
|
||||
import io.floci.cli.http.FlociHttpClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
|
||||
import java.util.Map;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -30,12 +33,17 @@ public class WaitCommand implements Callable<Integer> {
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
long timeoutMillis = parseDuration(timeout);
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint);
|
||||
String effectiveEndpoint = global.resolvedEndpoint(new io.floci.cli.docker.DockerClient());
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
Instant deadline = Instant.now().plusMillis(timeoutMillis);
|
||||
|
||||
while (Instant.now().isBefore(deadline)) {
|
||||
if (isReady(client, service)) {
|
||||
printer.println(Ansi.green("Floci is ready") + " (" + global.endpoint + ")");
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(Map.of("ready", true, "endpoint", effectiveEndpoint));
|
||||
} else {
|
||||
printer.println(Ansi.green("Floci is ready") + " (" + effectiveEndpoint + ")");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
printSpinner(printer, deadline);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DockerClient {
|
||||
public Optional<ContainerInfo> inspectContainer(String name) throws DockerException {
|
||||
try {
|
||||
String out = run("docker", "inspect", "--format",
|
||||
"{{.Id}}|{{.Name}}|{{.Config.Image}}|{{.Status}}|{{.State.Status}}|{{range $p, $b := .NetworkSettings.Ports}}{{$p}} {{end}}",
|
||||
"{{.Id}}|{{.Name}}|{{.Config.Image}}|{{.State.Status}}|{{.State.Status}}|{{range $p, $b := .NetworkSettings.Ports}}{{if $b}}{{(index $b 0).HostPort}}->{{$p}} {{end}}{{end}}",
|
||||
name);
|
||||
if (out.isBlank()) return Optional.empty();
|
||||
String[] parts = out.trim().split("\\|", -1);
|
||||
@@ -52,7 +52,7 @@ public class DockerClient {
|
||||
parts.length > 4 ? parts[4] : "",
|
||||
parts.length > 5 ? parts[5].trim() : ""));
|
||||
} catch (DockerException e) {
|
||||
if (e.getMessage() != null && e.getMessage().contains("No such")) {
|
||||
if (e.getMessage() != null && e.getMessage().toLowerCase().contains("no such")) {
|
||||
return Optional.empty();
|
||||
}
|
||||
throw e;
|
||||
|
||||
@@ -3,21 +3,51 @@ package io.floci.cli.doctor.checks;
|
||||
import io.floci.cli.doctor.Check;
|
||||
import io.floci.cli.doctor.CheckResult;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class AwsCliEndpointCheck implements Check {
|
||||
|
||||
@Override
|
||||
public CheckResult run(String endpoint, String container) {
|
||||
// Check if aws CLI is installed first
|
||||
if (!isAwsCliInstalled()) {
|
||||
return CheckResult.ok("aws.cli.endpoint", "aws CLI not installed — skipped");
|
||||
}
|
||||
String envVar = System.getenv("AWS_ENDPOINT_URL");
|
||||
int effectivePort = extractPort(endpoint);
|
||||
if (envVar != null && !envVar.isBlank()) {
|
||||
int envPort = extractPort(envVar);
|
||||
if (envPort != -1 && effectivePort != -1 && envPort != effectivePort) {
|
||||
String corrected = replacePort(envVar, effectivePort);
|
||||
return CheckResult.warn("aws.cli.endpoint",
|
||||
"AWS_ENDPOINT_URL=" + envVar + " (port mismatch — Floci is on port " + effectivePort + ")",
|
||||
"export AWS_ENDPOINT_URL=" + corrected);
|
||||
}
|
||||
return CheckResult.ok("aws.cli.endpoint", "AWS_ENDPOINT_URL=" + envVar);
|
||||
}
|
||||
String suggested = "http://localhost.floci.io:" + (effectivePort != -1 ? effectivePort : 4566);
|
||||
return CheckResult.warn("aws.cli.endpoint",
|
||||
"AWS_ENDPOINT_URL is not set",
|
||||
"export AWS_ENDPOINT_URL=" + endpoint);
|
||||
"export AWS_ENDPOINT_URL=" + suggested);
|
||||
}
|
||||
|
||||
private int extractPort(String url) {
|
||||
try {
|
||||
int port = URI.create(url).getPort();
|
||||
return port == -1 ? 80 : port;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private String replacePort(String url, int newPort) {
|
||||
try {
|
||||
URI uri = URI.create(url);
|
||||
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(),
|
||||
newPort, uri.getPath(), uri.getQuery(), uri.getFragment()).toString();
|
||||
} catch (Exception e) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAwsCliInstalled() {
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package io.floci.cli.doctor.checks;
|
||||
|
||||
import io.floci.cli.doctor.Check;
|
||||
import io.floci.cli.doctor.CheckResult;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class SdkGoEndpointCheck implements Check {
|
||||
|
||||
@Override
|
||||
public CheckResult run(String endpoint, String container) {
|
||||
Path goMod = Path.of("go.mod");
|
||||
if (!Files.exists(goMod)) {
|
||||
return CheckResult.ok("sdk.go.endpoint", "No go.mod in CWD — skipped");
|
||||
}
|
||||
try {
|
||||
String content = Files.readString(goMod);
|
||||
if (!content.contains("aws-sdk-go-v2")) {
|
||||
return CheckResult.ok("sdk.go.endpoint", "aws-sdk-go-v2 not in go.mod — skipped");
|
||||
}
|
||||
return CheckResult.warn("sdk.go.endpoint",
|
||||
"aws-sdk-go-v2 detected — use BaseEndpoint instead of deprecated EndpointResolver",
|
||||
"See https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/endpoints/ for migration guide");
|
||||
} catch (IOException e) {
|
||||
return CheckResult.warn("sdk.go.endpoint", "Could not read go.mod", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package io.floci.cli.doctor.checks;
|
||||
|
||||
import io.floci.cli.doctor.Check;
|
||||
import io.floci.cli.doctor.CheckResult;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class SdkRustS3XmlCheck implements Check {
|
||||
|
||||
@Override
|
||||
public CheckResult run(String endpoint, String container) {
|
||||
Path cargoToml = Path.of("Cargo.toml");
|
||||
if (!Files.exists(cargoToml)) {
|
||||
return CheckResult.ok("sdk.rust.s3.xml", "No Cargo.toml in CWD — skipped");
|
||||
}
|
||||
try {
|
||||
String content = Files.readString(cargoToml);
|
||||
if (!content.contains("aws-sdk-s3")) {
|
||||
return CheckResult.ok("sdk.rust.s3.xml", "aws-sdk-s3 not in Cargo.toml — skipped");
|
||||
}
|
||||
return CheckResult.warn("sdk.rust.s3.xml",
|
||||
"aws-sdk-s3 detected — known issue: XmlDecodeError on S3 error responses",
|
||||
"See https://github.com/floci-io/floci/issues/11 for workaround");
|
||||
} catch (IOException e) {
|
||||
return CheckResult.warn("sdk.rust.s3.xml", "Could not read Cargo.toml", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class FlociHttpClient {
|
||||
JsonNode node = getJson("/_floci/health");
|
||||
return new HealthInfo(
|
||||
node.path("version").asText("unknown"),
|
||||
node.path("edition").asText("community"),
|
||||
node.path("original_edition").asText(node.path("edition").asText("community")),
|
||||
node.path("services").isArray()
|
||||
? MAPPER.convertValue(node.path("services"), String[].class)
|
||||
: new String[0]);
|
||||
@@ -47,7 +47,7 @@ public class FlociHttpClient {
|
||||
JsonNode node = getJson("/_floci/info");
|
||||
return new ServerInfo(
|
||||
node.path("version").asText("unknown"),
|
||||
node.path("edition").asText("community"));
|
||||
node.path("original_edition").asText(node.path("edition").asText("community")));
|
||||
}
|
||||
|
||||
public InitState initState() throws FlociException {
|
||||
|
||||
Reference in new issue
Block a user