feat(oci): add floci oci command group for the Floci OCI emulator (#15)

* feat(oci): add floci oci command group for the Floci OCI emulator

Adds the fourth product tree targeting floci-oci (port 4599, container
floci-oci, control prefix /_floci-oci, FLOCI_OCI_* env overrides):
start/stop/restart/status/logs/wait/version/services/doctor/env/config
plus stub snapshot commands, mirroring the GCP/Azure trees.

- 'floci oci env' exports OCI_CLI_ENDPOINT, FLOCI_OCI_ENDPOINT, and
  TF_VAR_CLIENT_HOST_OVERRIDES for the OCI CLI, the ocilocal wrapper,
  and the oracle/oci Terraform provider; also OCI_CLI_PROFILE=FLOCI
  when that profile exists.
- 'floci oci setup' generates an RSA-2048 API signing key with a real
  computed fingerprint and writes a throwaway [FLOCI] profile to
  ~/.oci/config (idempotent, never touches existing profiles) — the
  OCI CLI/SDKs refuse to run without them.
- FlociHttpClient now accepts both health 'services' shapes: the array
  reported by AWS/GCP/Azure servers and the {name: status} object
  reported by floci-oci.
- 'floci config default-product oci' routes bare commands to the tree.

* fix(oci): address review findings on env, services, and setup profile

- Single-quote 'oci env' exports with per-shell escaping (bash/fish/
  PowerShell) so endpoint values containing shell metacharacters cannot
  inject commands through the documented 'eval $(floci oci env)' flow.
- 'oci services' resolves the endpoint from the container port mapping
  like status/wait/env, so a container started with --port <n> is found
  without passing --endpoint.
- 'oci env' exports OCI_CLI_PROFILE for whichever profile 'oci setup'
  wrote (detected via its key_file marker) instead of only the
  hardcoded FLOCI name; DEFAULT is skipped as the CLI uses it
  implicitly.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-07-28 21:15:42 -05:00
1 parent 2ff3181198
commit 0a65de2303
34 files changed
+1924 -33

No files matched your search

@@ -0,0 +1,39 @@
package io.floci.cli.unit;
import io.floci.cli.commands.oci.OciEnvCommand;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/** Pins the shell-quoting of `floci oci env` output — it is documented as `eval` input. */
class OciEnvFormatTest {
@Test
void bashExportsAreSingleQuoted() {
assertEquals("export OCI_CLI_ENDPOINT='http://localhost:4599'",
OciEnvCommand.formatExport("bash", "OCI_CLI_ENDPOINT", "http://localhost:4599"));
}
@Test
void hostileValuesCannotEscapeBashQuoting() {
String hostile = "http://x\"; echo pwned; $(touch /tmp/pwned) `id` $HOME";
String export = OciEnvCommand.formatExport("bash", "K", hostile);
// Entire value stays inside single quotes; no interpolation possible.
assertEquals("export K='" + hostile + "'", export);
String withQuote = "it's";
assertEquals("export K='it'\\''s'", OciEnvCommand.formatExport("bash", "K", withQuote));
}
@Test
void fishEscapesBackslashesAndQuotes() {
assertEquals("set -x K 'a\\\\b\\'c'",
OciEnvCommand.formatExport("fish", "K", "a\\b'c"));
}
@Test
void powershellDoublesSingleQuotes() {
assertEquals("$env:K = 'it''s $x'",
OciEnvCommand.formatExport("powershell", "K", "it's $x"));
}
}