From 3d95c1cc959bddba8a2b9cf36a9633d6cfe296f7 Mon Sep 17 00:00:00 2001 From: Azzurriii Date: Tue, 10 Nov 2026 16:19:33 +0700 Subject: [PATCH] feat: clearer runtime vs CLI updates, default checkpoint path, self-update - update: checkpoint defaults to /backups/ (or COSIGNER_BACKUP_DIR); backups/ is the only folder inside an instance that may hold archives - update: shows the plan and asks before stopping Cosigner (--yes without a terminal), prints the restore command afterwards, adds --check (exit 10) and --json - name the component everywhere: runtime update vs cosigner-cli update notices, version prints both (--check, --json) - self-update: cosign-verified, atomic replacement of the CLI binary - runtime needing a newer CLI points at self-update; errors carry hint: lines - backup --out is optional; restore accepts a directory holding backups/ - doctor --json, help environment Co-Authored-By: Claude Opus 5.5 --- README.md | 65 ++++++-- cmd/cosigner-cli/main.go | 9 + internal/app/app.go | 35 ++-- internal/app/app_test.go | 10 -- internal/app/commands.go | 36 ++-- internal/app/cosign.go | 6 + internal/app/hints.go | 53 ++++++ internal/app/password.go | 6 +- internal/app/recovery.go | 94 ++++++++++- internal/app/registry.go | 39 ++++- internal/app/selfupdate.go | 232 ++++++++++++++++++++++++++ internal/app/selfupdate_test.go | 146 ++++++++++++++++ internal/app/update.go | 263 ++++++++++++++++++++--------- internal/app/update_test.go | 286 ++++++++++++++++++++++++++++++++ internal/app/version.go | 126 ++++++++++++++ 15 files changed, 1269 insertions(+), 137 deletions(-) create mode 100644 internal/app/hints.go create mode 100644 internal/app/selfupdate.go create mode 100644 internal/app/selfupdate_test.go create mode 100644 internal/app/update_test.go create mode 100644 internal/app/version.go diff --git a/README.md b/README.md index 869aa7e..2f2cfe0 100644 --- a/README.md +++ b/README.md @@ -165,11 +165,18 @@ cosigner-cli logs -f | `backup` | Encrypted backup of the instance (must be stopped) | | `restore` | Restore a backup into an empty directory | | `export` | Write `.mshare` files for Fystack Recovery (must be stopped) | -| `update` | Verify and install a newer release | -| `version` | Print CLI and runtime versions | +| `update` | Update the **runtime** (container image) to a newer signed release | +| `self-update` | Update **cosigner-cli** itself to a newer signed release | +| `version` | Print CLI and runtime versions (`--check` looks up the newest) | +| `help environment` | List every environment variable the CLI reads | Global flags: `--home DIR` (or `COSIGNER_HOME`), `--docker CMD`. +For scripts and agents: `version`, `doctor`, `update` and `self-update` take `--json` (the +document goes to stdout, progress to stderr). `update --check` and `self-update --check` exit +with status `10` when a newer release exists. Commands never prompt without a terminal: they +fail, and a `hint:` line names the flag or variable to set (for example `--yes`). + ## Approval callback `callback add` connects a paired cosigner to your approval callback. It generates the cosigner's @@ -236,7 +243,7 @@ COSIGNER_PASSWORD_FD=3 cosigner-cli start 3< /run/secrets/cosigner-pw | Variable | Used by | | ------------------------------- | ----------------- | | `COSIGNER_PASSWORD_FD` | storage password | -| `COSIGNER_RECOVERY_PASSWORD_FD` | `backup`/`restore` | +| `COSIGNER_RECOVERY_PASSWORD_FD` | `backup`/`restore`/`update` | `COSIGNER_PASSWORD` / `COSIGNER_RECOVERY_PASSWORD` also work but leak into the environment. Avoid them. @@ -244,16 +251,19 @@ COSIGNER_PASSWORD_FD=3 cosigner-cli start 3< /run/secrets/cosigner-pw ```bash cosigner-cli stop -cosigner-cli backup --out /secure/backups/cosigner.enc +cosigner-cli backup # -> ./backups/backup--