Commit Graph
29 Commits
Author SHA1 Message Date
Hector Ventura 522e54ef3c fix(config): write profiles and config atomically and report files that cannot be read (#45)
* fix(config): write profiles and config atomically and report files that cannot be read

Profile files and ~/.floci/config.yaml are replaced through a temporary file, so an interrupted write leaves the old file intact; an unknown key in config.yaml no longer resets the default product to aws, and an unreadable config.yaml or profile file is reported on stderr instead of being ignored.

* fix(config): warn when the config file cannot be opened and keep long profile names saving

A config.yaml in a directory the user cannot search is no longer taken for a missing file, the profile list warning quotes the real cause instead of calling every failure bad YAML, and the temporary file name no longer grows with the profile name. Adds tests for failed saves.
2026-10-10 15:54:34 -05:00
Hector Ventura fbdc3ef713 fix(env): show how to load the variables in the chosen shell and reject unknown shells (#46)
The closing hint of floci env (all four products) now uses source for fish and Invoke-Expression for PowerShell instead of always suggesting eval, and an unknown --shell exits 2 with the accepted values instead of silently printing bash syntax. zsh, sh and pwsh are accepted by name.
2026-10-09 22:17:21 -05:00
Hector Ventura 22668a1200 feat(profile): warn when a profile sets a key floci does not read (#37) 2026-10-08 22:47:51 -05:00
Hector Ventura 01d6133548 perf: restart without a fixed pause and wait no longer than --timeout (#36) 2026-10-08 22:41:35 -05:00
Hector Ventura fc67e72a62 fix(cli): honour --no-color on parse errors and show profile defaults in --help (#35) 2026-10-08 22:30:28 -05:00
Hector Ventura bc59dff8c3 refactor(profile): read the parse's profile snapshot in restart and config show (#34) 2026-10-08 22:25:23 -05:00
Hector Ventura 5c0cc339bf fix(profile): make profile names, files and exit codes consistent (#33) 2026-10-08 22:21:02 -05:00
Hector Ventura bf9ee4037b feat(start): give each instance its own Docker resource namespace and base URL (#31) 2026-10-08 21:44:17 -05:00
Hector Ventura 788eb470fb feat(config): create profiles for instances that run side by side (#30) 2026-10-08 21:34:15 -05:00
Hector Ventura 7b58a38c5a feat(az): configure the az CLI against floci-az with floci az setup (#29) 2026-10-08 21:29:02 -05:00
Hector Ventura dd38f6dc27 perf(doctor): run checks concurrently and share docker lookups (#32) 2026-10-08 21:28:58 -05:00
Hector Ventura 7343a539c2 fix(profile): keep legacy profile names usable and expand values consistently (#25)
* fix(profile): keep legacy profile names usable and expand values consistently

Two edges of the 0.2.2 profile work, both found by an oversight pass over what
landed since 0.2.1.

Profile names that earlier versions accepted became unreachable. The path
traversal guard added in #23 was an allow-list over the whole character set
([A-Za-z0-9._-]+), which also rejects names 0.2.1 created happily: a space, a
plus, an at sign. Such a profile stayed visible in 'config profile list' while
show, --profile and delete all refused it, so it could not even be removed
through the CLI.

The guard is now a deny-list on what actually traverses ('.', '..', and path
separators), and the guarantee is carried by resolving the file and asserting
its parent is the profiles directory. A name that is illegal on the running
platform but legal elsewhere, such as a colon on Windows, now reports a clean
message instead of InvalidPathException.

Profile values were expanded on one path and not the others. Interpolation of
${env:HOME} and friends is picocli's, applied when it fills an option default,
so 'start --profile p' expanded it while 'restart --profile p' and
'config show --profile p' read the Profile bean directly and got the literal
text. Restart therefore asked docker for a directory named '${env:HOME}/...',
which is the silent state loss #23 set out to fix.

Both now resolve through StartCommand.resolvedFor, the same provider and the
same precedence a real start invocation uses, so one profile cannot mean two
different directories. That also removes the duplicated field mapping in
RestartCommand: ProfileDefaults is the only place a profile field maps to a
flag again.

Restart now resolves the profile before stopping the container, so a profile
that fails to resolve no longer leaves the container stopped.

* fix(profile): stop denying backslash, and read the profile once in config show

Two P2s from the review on this PR, both correct.

Backslash is a separator on Windows and an ordinary file-name character on
Unix. Denying it outright orphaned a 'team\alpha' profile that 0.2.1 could
create and that list() still returns, which is the same bug class this PR
exists to fix, left half fixed. The character check is now forward slash only;
resolveInProfilesDir already rejects a real Windows traversal on the parent
assertion, so the guarantee is unchanged.

config show read the profile twice: key presence from one read, values from a
second through resolvedFor. A concurrent edit could print half of one version
next to half of another. ProfileDefaultValueProvider already memoizes the
profile it resolved, so exposing that memo gives both from one snapshot, and
resolvedFor gained a provider overload to pass it through. If the profile has
gone since the outer parse, the command now fails loudly instead of printing a
mixed row.

RestartCommand has the same shape between the outer parse and resolvedFor.
Closing it means making the outer provider reachable from commands, which is
wider than this fix; documented in place rather than left silent.
2026-09-14 21:50:32 -05:00
Hector Ventura 52c08ecec5 fix(profile): apply --profile to every command, not just config show (#23)
`--profile <name>` was declared on the shared GlobalOptions mixin but only
ConfigShowCommand ever read it. Every other command, `start` included, fell
through to the built-in defaults, so a profile's container, image, port,
persistDir and services were silently dropped.

The worst consequence was silent data loss: the `-v <dir>:/app/data` mount and
`FLOCI_STORAGE_MODE=persistent` were gated on the `--persist` flag alone, so a
profile with `persistDir` set produced neither. The image declares
`VOLUME /app/data`, so every start attached a fresh anonymous volume and the
server stayed in-memory.

A profile is now applied by a single picocli IDefaultValueProvider registered in
FlociCli.buildCommandLine(). Picocli consults it only for options the user did
not pass, and only after that command's arguments are processed, which gives the
documented precedence without per-command plumbing:

    command-line flag > --profile <name> > FLOCI_* env var > product default

Behaviour changes:

- An unknown, unreadable or invalid profile is now an error (exit 2) rather than
  a silent fall back to the defaults. `--help` still works with a bad profile.
- `restart --profile <name>` re-applies the profile's persistDir, image, port
  and services. It builds its StartCommand programmatically, so it carries the
  profile across by hand.
- `config show` merges instead of replacing, so an explicit --endpoint /
  --container / -o is no longer discarded when --profile resolves. It now also
  reports the profile's start-only fields.
- `config profile create` seeds the file from the tree it was run under;
  previously every tree wrote AWS values.
- Profile names are validated, closing a path traversal
  (`config profile delete ../../foo` resolved the raw name).
- Reads accept the `.yml` spelling that `config profile list` has always
  listed, and `list` backfills a missing `name:` from the file name.
- The readiness poll after `start` keeps the endpoint's host when swapping in
  the bound port, instead of always rewriting it to localhost.

Adds 64 tests, including the first coverage of ProfileStore.

Closes #22
2026-09-13 18:23:56 -05:00
Hector Ventura 6496795708 fix(env): single-quote exported values in every product tree (#19)
`floci az env` printed the semicolon-separated Azure connection string
unquoted, so `eval $(floci az env)` set only
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=http and ran the
remaining segments as commands — `az` then reported "Invalid connection
string".

`floci env` and `floci gcp env` carried a byte-identical copy of the same
unquoted emitter (their values are `;`-free URLs today, so nobody hit it),
and the aws.cli.endpoint / az.cli.connection-string doctor checks suggested
export lines with the same flaw.

Extract the correct emitter that `floci oci env` already had into
io.floci.cli.output.ShellExport and use it everywhere: values are single
quoted with per-shell escaping for bash, fish, and PowerShell, so `;`, `$`,
backticks, and quotes can neither break nor inject through `eval`.

OciEnvFormatTest becomes ShellExportTest, keeping its four assertions and
adding the connection-string regression from the issue.

Closes #18
2026-08-26 22:12:29 -05:00
Hector Ventura 6dc8fc9df4 refactor!: unify the four product command trees behind ProductProfile (#16)
* refactor!: unify the four product command trees behind ProductProfile

Every shared command now has ONE implementation in commands/,
parameterized by ProductProfile (the single source of per-product
config: endpoint, container, image, env prefix, control prefix,
display name). The gcp/az/oci command classes become ~8-line shims
(GcpStartCommand extends StartCommand { super(ProductProfile.GCP); })
that carry only their per-product help description; the three
near-identical *GlobalOptions clones are deleted. Each product tree
drops from ~1,360 to ~530 lines and copy-drift becomes impossible.

Mechanics: per-product option defaults are constructor-set field
values rendered in help via ${DEFAULT-VALUE} (annotation defaults are
compile-time constants); commands pre-initialize their GlobalOptions
mixin with the profile (picocli uses a non-null mixin field instance
as-is). Verified against a captured baseline of 480 CLI outputs
(every --help x 5 trees, env/status/doctor JSON, exit codes, routing)
plus new pinning tests: ProductProfileTest, ProductTreesParsingTest,
DoctorCheckListTest, GlobalOptionsTest.

Behavior changes, all deliberate:
- snapshot commands in gcp/az/oci trees now perform the real
  /snapshots API calls with graceful degradation and exit 1 while the
  server lacks the endpoints (previously: note + exit 0)
- product logs/services gained --service/--mode, and services now
  resolves the endpoint from the container port mapping in all trees
- the AWS tree brands itself 'Floci AWS' in banners and help,
  matching the other products
- snapshot errors link the product issue tracker instead of TODO.md
- completion generates from spec.root() instead of a hardcoded
  FlociCli instance (output unchanged)

BREAKING CHANGE: 'floci gcp|az|oci snapshot export/import' (and bare
'floci snapshot ...' with a non-AWS default product) now exit 1
instead of 0 while server-side snapshot support is pending; CI
scripts relying on the silent success of stubbed snapshot commands
will fail.

* 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.
2026-07-28 21:45:52 -05:00
Hector Ventura 0a65de2303 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.
2026-07-28 21:15:42 -05:00
Juan Diego López 2498ea05b2 Feature/notifier-update (#13)
* fix: align ContainerInfo fields with inspect format template

* feat(update): add self-update command with checksum verification

* fix(update): harden self-update checksum, cleanup, and exit code

* feat(update): notify when a new release is available

* fix(update): validate release tag, avoid pre-release downgrades, clarify empty-body error

* feat(update): notify when a new release is available

* fix(cli): exempt update from default-product routing
2026-07-11 12:29:15 -05:00
Juan Diego López 235be41f2a feat(update): add self-update command with checksum verification (#12)
* fix: align ContainerInfo fields with inspect format template

* feat(update): add self-update command with checksum verification

* fix(update): harden self-update checksum, cleanup, and exit code
2026-07-04 21:44:41 -05:00
Juan Diego López 0300251a0a fix: align ContainerInfo fields with inspect format template (#11) 2026-06-29 21:38:26 -05:00
Hector Ventura 6af6ee096a fix(start): enable persistent storage mode when --persist is set (#9)
The server defaults to FLOCI_STORAGE_MODE=memory, so the --persist
bind mount to /app/data was a no-op: state was never written to disk
and did not survive a container restart.

Set FLOCI_STORAGE_MODE=persistent (per-cloud prefixed variant for GCP
and Azure) whenever --persist is provided, so emulator state is written
to the mounted host directory and survives restarts. Verified
end-to-end with S3 and DynamoDB across a stop --remove + start cycle.
2026-06-21 09:50:48 -05:00
MAN$I VERMA dfec24c123 fix(start): mount host persistent path to /app/data in container (#8) 2026-06-20 11:34:10 -05:00
Hector Ventura 97ab1d527b fix(doctor): make docker.daemon check work under Podman (#7)
isDaemonReachable() probed the daemon with 'docker info --format
{{.ServerVersion}}', a Docker-only template field. Under the podman-docker shim
'podman info' has no .ServerVersion, so the template errors and exits non-zero —
a false 'Docker daemon not reachable' even while containers run fine via the
DOCKER_HOST socket. Probe by exit code instead (docker/podman info exit 0 when
reachable) and discard output to avoid a pipe-buffer deadlock on waitFor().
2026-06-11 00:33:21 -05:00
Hector Ventura 6862c0dd81 feat: honor DOCKER_HOST for Docker daemon resolution (#4)
Resolve the Docker endpoint from DOCKER_HOST (with the legacy DOCKER_SOCK
override and an OS default fallback) so Podman, rootless setups, and remote
Docker contexts work without assuming /var/run/docker.sock.

start/az start/gcp start bind-mount the resolved unix socket or pass a remote
tcp:// daemon through via DOCKER_HOST; doctor's docker.socket check reports the
resolved endpoint. Adds DockerHostResolveTest and README documentation.

Closes #3
2026-06-10 17:19:44 -05:00
Hector Ventura e9931123aa fix: gcp health check fix 2026-06-03 20:55:06 -05:00
Hector Ventura 88362364b2 feat: adding gcp management 2026-06-02 20:24:55 -05:00
Hector Ventura 003277340d fix: showing wrong version on floci version command 2026-05-15 23:07:30 -05:00
Hector Ventura 11883f5b67 fix: adding floci aws/az commands 2026-05-15 18:08:45 -05:00
Hector Ventura 1d7f9f81d0 fix: updating with latest floci changes 2026-05-15 02:34:27 -05:00
Hector Ventura aef1df595f chore: first commit 2026-05-12 17:10:46 -05:00