cli: carlos ship --from-release ships a pulled release unchanged
#1389 item 1, task 4. carlos ship --from-release <dir> ships a directory written by carlos releases pull to another console: same version, same label, notes, swap, capabilities, stateless, mail, assets and (rootfs) processes, hibernate and jit. Every file is hashed against manifest.json before anything is uploaded; the meta part carries the source digests as expect_artifacts so the console stores those exact bytes or nothing, and the answer's artifacts are compared again. The target hashes, writes and signs its own manifest. Flags the release already settles, and file arguments, are refused. Two-console witness: copy, promote on B under B's key, idempotent re-ship, tampered file refused locally, forged expect refused by the console, different bytes under the same version, and a rootfs copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cli.go+11 −0docs/site/cli.md+15 −0release_copy_e2e_test.go+247 −0ship_from_release.go+345 −0ship_from_release_test.go+75 −0testdata/clireg-golden.jsonl+2 −2
CI cancelled — superseded by a newer push — run details
CI log
=== gate === go: downloading go1.26.10 (linux/arm64) go version go1.26.10 linux/arm64 opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1 tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz tofu: downloaded, digest verified aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip aws: downloaded, digest verified archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip archive: downloaded, digest verified installed in /tmp/carlos-opentofu-KjQX6q .amadan/test-gate.sh go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0 go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5 go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0 go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0 go: downloading github.com/aws/smithy-go v1.28.1 go: downloading github.com/benbjohnson/litestream v0.5.14 go: downloading github.com/superfly/ltx v0.5.1 go: downloading golang.org/x/net v0.62.0 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0 go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0 go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0 go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2 go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0 go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1 go: downloading golang.org/x/sys v0.49.0 go: downloading golang.org/x/mod v0.41.0 go: downloading golang.org/x/crypto v0.58.0 go: downloading github.com/oschwald/maxminddb-golang v1.13.1 go: downloading github.com/pion/logging v0.2.4 go: downloading github.com/pion/stun/v3 v3.1.5 go: downloading github.com/pion/turn/v4 v4.1.4 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/pion/randutil v0.1.0 go: downloading github.com/pion/transport/v4 v4.0.2 go: downloading github.com/pion/dtls/v3 v3.1.4 go: downloading golang.org/x/sync v0.24.0 go: downloading github.com/prometheus/client_golang v1.17.0 go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18 go: downloading github.com/lmittmann/tint v1.1.3 go: downloading github.com/wlynxg/anet v0.0.5 go: downloading google.golang.org/protobuf v1.36.10 go: downloading github.com/prometheus/common v0.45.0 go: downloading github.com/cespare/xxhash/v2 v2.3.0 go: downloading github.com/beorn7/perks v1.0.1 go: downloading github.com/prometheus/client_model v0.5.0 go: downloading github.com/prometheus/procfs v0.12.0 go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 go: downloading golang.org/x/text v0.43.0 go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading modernc.org/libc v1.74.1 go: downloading modernc.org/libc v1.74.1 go: downloading modernc.org/memory v1.11.0 go: downloading github.com/google/uuid v1.6.0 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading modernc.org/mathutil v1.7.1 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading modernc.org/mathutil v1.7.1 go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec amadan: job cancelled — a newer push superseded it
Intent
<task-notification> <task-id>ae5d037ff8a6bc6f7</task-id> <tool-use-id>toolu_01TM96na1gXz1HAoHSvnVuZC</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a88005ac-72e4-481c-884f-581940b8c2c5/tasks/ae5d037ff8a6bc6f7.output</output-file> <status>completed</status> <summary>Agent "Implement Task 3: releases pull" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Fixed round 2's open finding: a pull no longer replaces a `manifest.json` that another pull wrote into the same folder. Commits: - 03a3f3d8 cli: releases pull never replaces an existing manifest.json (fix round 2) - 6ca21a4c cli: releases pull writes through temp files (fix round 1) - f47d0d8d cli: carlos releases pull copies a release out of a console (task) Fix: the new helper `publishNoReplace(tmp, dst)` publishes the manifest with a hard link (`os.Link`), which fails if `dst` exists, and removes the temp file either way. When it fails that way, the pull gives the same "already holds a release" refusal as the check at the start. That message is now built in one place. Tests: the RED/GREEN run covered the new tests. The existing-file test failed when the helper used rename and passes with the link. All 9 tests pass for `go test . -run 'TestReleasesPull|TestValidPulledFile|TestPublish'`. The filter also matched two older Geoip tests, which pass too. It builds for darwin and windows, and vet and gofmt are clean. Concerns: - File systems without hard links (FAT, some network mounts) will now fail the last step of a pull. Linux, macOS and NTFS are fine. - `make code-health` still fails on two counts from Tasks 1 and 2, deferred to the final review. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/release-copy-across-consoles/.superpowers/sdd/2026-11-25-release-copy-across-consoles/task-3-report.md</result> <usage><subagent_tokens>170551</subagent_tokens><tool_uses>6</tool_uses><duration_ms>82971</duration_ms></usage> </task-notification>
diff --git a/cli.go b/cli.go| index 26f6018cd..a3666090c 100644 |
| --- a/cli.go |
| +++ b/cli.go |
| @@ -2506,10 +2506,21 @@ func runShip(args []string) { |
| check := fs.Bool("check", false, "run the rootfs image here with Docker or Podman, the way a box would, and ship nothing") |
| var envVars shipCheckEnvFlag |
| fs.Var(&envVars, "env", shipEnvFlagHelp) |
| + fromRelease := fs.String("from-release", "", "a directory written by carlos releases pull. ships its files and settings unchanged") |
| fs.Usage = flagUsage(fs, "") |
| fs.Parse(args) |
| // --env is refused before anything else happens, on every ship. |
| checkEnv, err := shipEnvRefusal(fs, *check, envVars) |
| + // A pulled release (ship_from_release.go) is its own body, taken before |
| + // anything below can refuse a ship with no file arguments. |
| + if err == nil && *fromRelease != "" { |
| + if err = runShipFromRelease(fs, fromReleaseOpts{ |
| + dir: *fromRelease, app: *app, console: *consoleFlag, acctRaw: acctRaw, acctIDRaw: acctIDRaw, |
| + programChange: *programChange, messageFlags: messageFlags, |
| + }); err == nil { |
| + return |
| + } |
| + } |
| if err != nil { |
| log.Fatal(err) |
| } |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index dbd5e89e5..938f38506 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -303,6 +303,21 @@ Servers keep a copy only when your app answers with status 200, a `Cache-Control |
| --env KEY=VALUE gives every process in the check a variable, such as a placeholder secret or a store setting. The check never reads the app's real config or secrets. It sets CARLOS_SOCKET, CARLOS_DB, CARLOS_HOST and CARLOS_REGION itself, so --env cannot set those. |
| +`--from-release <dir>` ships a release that |
| +[carlos releases pull](/docs/cli#carlos-releases-pull) wrote into a |
| +directory, so another console stores the exact bytes the first one tested. |
| +It ships under the release's own version, with its label, notes and other |
| +settings, so it takes only `--app`, `--account`, `--account-id`, |
| +`--console`, `--destination`, `--message`, `--no-prompt` and |
| +`--program-change`, and no file arguments. Every file is checked against |
| +`manifest.json` first, and a file that does not match stops the ship before |
| +anything is uploaded. The console then refuses any bytes that differ from |
| +the release's digests, and ship checks the digests it answers with. |
| + |
| +```sh |
| +carlos ship --from-release ./release --app shop |
| +``` |
| + |
| ### carlos promote |
| Points a channel at a version you have already shipped. |
diff --git a/release_copy_e2e_test.go b/release_copy_e2e_test.go| index 2f09c5f50..5cd5bc289 100644 |
| --- a/release_copy_e2e_test.go |
| +++ b/release_copy_e2e_test.go |
| @@ -5,10 +5,22 @@ |
| package main |
| import ( |
| + "bytes" |
| + "context" |
| "crypto/ed25519" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "flag" |
| + "io" |
| + "mime/multipart" |
| "net/http" |
| "net/http/httptest" |
| + "os" |
| "path/filepath" |
| + "reflect" |
| + "strings" |
| "testing" |
| "time" |
| @@ -103,3 +115,238 @@ func useConsole(t *testing.T, c copyConsole, token string) { |
| t.Setenv("CARLOS_CONSOLE", c.url) |
| t.Setenv("CARLOS_SERVICE_TOKEN", token) |
| } |
| + |
| +// copySource ships shop v12 to a fresh console A, with a label, notes and a |
| +// swap demand for the copy to carry, and pulls it into a new directory |
| +// under A's deploy credential. |
| +func copySource(t *testing.T) (copyConsole, string) { |
| + t.Helper() |
| + a := newCopyConsole(t, "shop") |
| + useConsole(t, a, a.token(t, "shop", svcrole.Publish)) |
| + bin := filepath.Join(t.TempDir(), "shop") |
| + if err := os.WriteFile(bin, pullPayload, 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + buf := captureStdout(t) |
| + runShip([]string{"--app", "shop", "--account", release.OpsAccount, "--version", "v12", |
| + "--label", "fixing modals", "--notes", "first cut", "--swap", "hold", "--target", "linux-arm64", bin}) |
| + if !strings.Contains(buf.String(), "shipped shop v12") { |
| + t.Fatalf("ship stdout = %q, want the shipped line", buf.String()) |
| + } |
| + dir := filepath.Join(t.TempDir(), "release") |
| + useConsole(t, a, a.token(t, "shop", svcrole.Deploy)) |
| + if err := runReleasesPull([]string{"v12", "--app", "shop", "--out", dir}); err != nil { |
| + t.Fatalf("pull: %v", err) |
| + } |
| + return a, dir |
| +} |
| + |
| +// manifestOf reads app's version from c's store. |
| +func manifestOf(t *testing.T, c copyConsole, app, version string) *release.Manifest { |
| + t.Helper() |
| + m, err := release.GetManifest(context.Background(), c.rel, release.OpsAccount, app, version) |
| + if err != nil { |
| + t.Fatalf("%s %s: %v", app, version, err) |
| + } |
| + return m |
| +} |
| + |
| +// noRelease fails when c stores anything for storefront v12: a manifest or |
| +// the linux-arm64 artifact. |
| +func noRelease(t *testing.T, c copyConsole) { |
| + t.Helper() |
| + ctx := context.Background() |
| + if _, err := release.GetManifest(ctx, c.rel, release.OpsAccount, "storefront", "v12"); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("storefront v12 manifest on B: err = %v, want not found", err) |
| + } |
| + if _, _, err := c.rel.Get(ctx, release.ArtifactKey(release.OpsAccount, "storefront", "v12", "linux-arm64")); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("storefront v12 linux-arm64 on B: err = %v, want not found", err) |
| + } |
| +} |
| + |
| +// fromReleaseOptsFor is runShip's options for `--from-release dir --app app`. |
| +func fromReleaseOptsFor(t *testing.T, dir, app string) (*flag.FlagSet, fromReleaseOpts) { |
| + t.Helper() |
| + fs := flag.NewFlagSet("ship", flag.ContinueOnError) |
| + messageFlags := addMutationMessageFlags(fs) |
| + fs.String("from-release", "", "") |
| + appName := appFlag(fs, "") |
| + acctRaw, acctIDRaw, _ := accountFlags(fs) |
| + consoleFlag := consoleOption(fs, "") |
| + programChange := fs.Bool("program-change", false, "") |
| + if err := fs.Parse([]string{"--from-release", dir, "--app", app}); err != nil { |
| + t.Fatal(err) |
| + } |
| + return fs, fromReleaseOpts{dir: dir, app: *appName, console: *consoleFlag, acctRaw: acctRaw, acctIDRaw: acctIDRaw, |
| + programChange: *programChange, messageFlags: messageFlags} |
| +} |
| + |
| +func TestE2EReleaseCopyAcrossConsoles(t *testing.T) { |
| + useTempCredentials(t) |
| + clearDeploymentEnv(t) |
| + a, dir := copySource(t) |
| + b := newCopyConsole(t, "storefront") |
| + useConsole(t, b, b.token(t, "storefront", svcrole.Deploy)) |
| + buf := captureStdout(t) |
| + runShip([]string{"--from-release", dir, "--app", "storefront"}) |
| + if !strings.Contains(buf.String(), "every digest matches the source") { |
| + t.Fatalf("ship stdout = %q, want every digest to match", buf.String()) |
| + } |
| + src, got := manifestOf(t, a, "shop", "v12"), manifestOf(t, b, "storefront", "v12") |
| + if !reflect.DeepEqual(got.Artifacts, src.Artifacts) { |
| + t.Fatalf("B's artifacts = %+v, want A's %+v", got.Artifacts, src.Artifacts) |
| + } |
| + if got.Label != "fixing modals" || got.Notes != "first cut" || got.Swap != release.DemandHold { |
| + t.Fatalf("B's label %q notes %q swap %q, want A's", got.Label, got.Notes, got.Swap) |
| + } |
| + if got.Label != src.Label || got.Notes != src.Notes || got.Swap != src.Swap { |
| + t.Fatalf("B's settings differ from A's: %+v vs %+v", got, src) |
| + } |
| + if got.App != "storefront" || !strings.HasPrefix(got.BuiltBy, "console-api") { |
| + t.Fatalf("B's manifest app %q built_by %q, want B's own", got.App, got.BuiltBy) |
| + } |
| + |
| + runPromote([]string{"--app", "storefront", "v12", "edge"}) |
| + ptr, err := release.Channel(context.Background(), b.rel, b.pub, release.OpsAccount, "storefront", "edge") |
| + if err != nil { |
| + t.Fatalf("B's edge channel under B's key: %v", err) |
| + } |
| + if ptr.Version != "v12" { |
| + t.Fatalf("B's edge = %q, want v12", ptr.Version) |
| + } |
| + |
| + buf.Reset() |
| + runShip([]string{"--from-release", dir, "--app", "storefront"}) |
| + if !strings.Contains(buf.String(), "already shipped storefront v12") { |
| + t.Fatalf("second ship stdout = %q, want already shipped", buf.String()) |
| + } |
| +} |
| + |
| +func TestE2EReleaseCopyRefusesATamperedFile(t *testing.T) { |
| + useTempCredentials(t) |
| + clearDeploymentEnv(t) |
| + _, dir := copySource(t) |
| + path := filepath.Join(dir, "linux-arm64") |
| + data, err := os.ReadFile(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + data[0] ^= 0xff |
| + if err := os.WriteFile(path, data, 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + b := newCopyConsole(t, "storefront") |
| + useConsole(t, b, b.token(t, "storefront", svcrole.Deploy)) |
| + err = runShipFromRelease(fromReleaseOptsFor(t, dir, "storefront")) |
| + if err == nil || !strings.Contains(err.Error(), "does not match manifest.json") { |
| + t.Fatalf("ship of a tampered dir = %v, want it refused", err) |
| + } |
| + noRelease(t, b) |
| +} |
| + |
| +func TestE2EReleaseCopyForgedExpectIsRefusedByTheConsole(t *testing.T) { |
| + useTempCredentials(t) |
| + clearDeploymentEnv(t) |
| + _, dir := copySource(t) |
| + b := newCopyConsole(t, "storefront") |
| + pulled, err := os.ReadFile(filepath.Join(dir, "linux-arm64")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + other := bytes.Repeat([]byte{0x43}, len(pulled)) |
| + sum := sha256.Sum256(other) |
| + meta, err := json.Marshal(map[string]any{ |
| + "version": "v12", "kind": "binary", |
| + "expect_artifacts": map[string]any{"linux-arm64": map[string]any{"sha256": hex.EncodeToString(sum[:]), "size": len(other)}}, |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var body bytes.Buffer |
| + mw := multipart.NewWriter(&body) |
| + if err := mw.WriteField("meta", string(meta)); err != nil { |
| + t.Fatal(err) |
| + } |
| + part, err := mw.CreateFormFile("linux-arm64", "linux-arm64") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := part.Write(pulled); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := mw.Close(); err != nil { |
| + t.Fatal(err) |
| + } |
| + req, err := http.NewRequest(http.MethodPost, b.url+"/api/cli/apps/"+release.OpsAccount+"/storefront/releases", &body) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + req.Header.Set("Content-Type", mw.FormDataContentType()) |
| + req.Header.Set("Authorization", "Bearer "+b.token(t, "storefront", svcrole.Deploy)) |
| + res, err := http.DefaultClient.Do(req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + answer, _ := io.ReadAll(res.Body) |
| + res.Body.Close() |
| + if res.StatusCode != http.StatusBadRequest { |
| + t.Fatalf("forged expect = %d %s, want 400", res.StatusCode, answer) |
| + } |
| + noRelease(t, b) |
| +} |
| + |
| +func TestE2EReleaseCopyDifferentBytesUnderTheSameVersion(t *testing.T) { |
| + useTempCredentials(t) |
| + clearDeploymentEnv(t) |
| + _, dir := copySource(t) |
| + b := newCopyConsole(t, "storefront") |
| + useConsole(t, b, b.token(t, "storefront", svcrole.Deploy)) |
| + bin := filepath.Join(t.TempDir(), "storefront") |
| + if err := os.WriteFile(bin, bytes.Repeat([]byte{0x44}, 512), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + captureStdout(t) |
| + runShip([]string{"--app", "storefront", "--account", release.OpsAccount, "--version", "v12", "--target", "linux-arm64", bin}) |
| + before := manifestOf(t, b, "storefront", "v12") |
| + err := runShipFromRelease(fromReleaseOptsFor(t, dir, "storefront")) |
| + if err == nil || !strings.Contains(err.Error(), "already shipped with different content") { |
| + t.Fatalf("ship --from-release over different bytes under v12 = %v, want the console's conflict", err) |
| + } |
| + if after := manifestOf(t, b, "storefront", "v12"); !reflect.DeepEqual(after, before) { |
| + t.Fatalf("B's v12 changed: %+v, was %+v", after, before) |
| + } |
| +} |
| + |
| +func TestE2EReleaseCopyRootfs(t *testing.T) { |
| + useTempCredentials(t) |
| + clearDeploymentEnv(t) |
| + a := newCopyConsole(t, "shop") |
| + image := filepath.Join(t.TempDir(), "rootfs.squashfs") |
| + if err := os.WriteFile(image, bytes.Repeat([]byte{0x45}, 4<<10), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + seed := release.Manifest{ |
| + App: "shop", Version: "v12", Kind: release.KindRootfs, BuiltBy: "e2e", |
| + Processes: map[string]release.Process{release.ProcessWeb: {Command: []string{"/bin/web"}}}, |
| + Hibernate: true, |
| + Artifacts: map[string]release.Artifact{release.RootfsArtifactKey: {File: release.RootfsArtifactFile}}, |
| + } |
| + if err := release.ShipSpooled(context.Background(), a.rel, release.OpsAccount, seed, map[string]string{release.RootfsArtifactKey: image}); err != nil { |
| + t.Fatalf("seed A: %v", err) |
| + } |
| + dir := filepath.Join(t.TempDir(), "release") |
| + useConsole(t, a, a.token(t, "shop", svcrole.Deploy)) |
| + captureStdout(t) |
| + if err := runReleasesPull([]string{"v12", "--app", "shop", "--out", dir}); err != nil { |
| + t.Fatalf("pull: %v", err) |
| + } |
| + b := newCopyConsole(t, "storefront") |
| + useConsole(t, b, b.token(t, "storefront", svcrole.Deploy)) |
| + if err := runShipFromRelease(fromReleaseOptsFor(t, dir, "storefront")); err != nil { |
| + t.Fatalf("ship --from-release rootfs: %v", err) |
| + } |
| + src, got := manifestOf(t, a, "shop", "v12"), manifestOf(t, b, "storefront", "v12") |
| + if !reflect.DeepEqual(got.Artifacts, src.Artifacts) || !reflect.DeepEqual(got.Processes, src.Processes) || got.Hibernate != src.Hibernate { |
| + t.Fatalf("B's rootfs release = %+v, want A's %+v", got, src) |
| + } |
| +} |
diff --git a/ship_from_release.go b/ship_from_release.go| new file mode 100644 |
| index 000000000..ef44128a3 |
| --- /dev/null |
| +++ b/ship_from_release.go |
| @@ -0,0 +1,345 @@ |
| +package main |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "flag" |
| + "fmt" |
| + "io" |
| + "mime/multipart" |
| + "net/http" |
| + "os" |
| + "path/filepath" |
| + "sort" |
| + "strings" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// `carlos ship --from-release <dir>` (#1389 item 1): the target half of |
| +// copying a shipped release from one console to another. It ships the |
| +// files `carlos releases pull` wrote into dir under the release's own |
| +// version and settings, sends the source's digests as expect_artifacts so |
| +// the console stores those exact bytes or nothing, and checks the digests |
| +// the console answers with. The target console hashes what it receives and |
| +// writes and signs its own manifest; only the artifact digests and the |
| +// release's settings come from the source manifest. |
| + |
| +const ( |
| + shipFromReleaseUsage = "usage: carlos ship --from-release <dir> [--app <a>] [--account <sqid-or-name>] [--account-id <sqid>] [--console <origin>] [--program-change] [--message <text>]" |
| + shipFromReleaseNeedsConsole = "carlos ship --from-release ships through a console. set CARLOS_CONSOLE or run carlos login" |
| + shipFromReleaseFlagConflict = "--from-release ships the release's own settings, so it cannot be combined with --%s" |
| + shipFromReleaseNoFileArgs = "--from-release ships the files in its directory, so it takes no file arguments" |
| + shipFromReleaseNoManifest = "%s has no manifest.json. run carlos releases pull first" |
| + shipFromReleaseFileDiffers = "%s does not match manifest.json, so nothing was shipped" |
| + shipFromReleaseDigestDiffer = "the console stored %s with a different digest than the source release. do not promote this version" |
| + shipFromReleaseDone = "shipped %s %s from %s, every digest matches the source" |
| + shipFromReleaseNoOp = "already shipped %s %s with identical content, nothing to do" |
| +) |
| + |
| +// shipFromReleaseFlags are the flags --from-release may be given with: |
| +// where to ship, and the operator's own say on the ship. Everything else |
| +// is a setting the release already carries. |
| +var shipFromReleaseFlags = map[string]bool{ |
| + "from-release": true, "app": true, "a": true, "account": true, "account-id": true, |
| + "console": true, "destination": true, "d": true, "message": true, "no-prompt": true, |
| + "program-change": true, |
| +} |
| + |
| +// fromReleaseOpts is runShip's flags as --from-release reads them. |
| +type fromReleaseOpts struct { |
| + dir, app, console string |
| + acctRaw, acctIDRaw *string |
| + programChange bool |
| + messageFlags mutationMessageFlags |
| +} |
| + |
| +// fromReleaseConflicts refuses a flag the release's own settings would |
| +// contradict, the first in name order, then any file argument. |
| +func fromReleaseConflicts(fs *flag.FlagSet) error { |
| + var other string |
| + // fs.Visit walks the set flags in name order, so the first is named. |
| + fs.Visit(func(f *flag.Flag) { |
| + if other == "" && !shipFromReleaseFlags[f.Name] { |
| + other = f.Name |
| + } |
| + }) |
| + if other != "" { |
| + return fmt.Errorf(shipFromReleaseFlagConflict, other) |
| + } |
| + if fs.NArg() > 0 { |
| + return errors.New(shipFromReleaseNoFileArgs) |
| + } |
| + return nil |
| +} |
| + |
| +// runShipFromRelease is `carlos ship --from-release <dir>`. dir is read and |
| +// every file checked against manifest.json before the console is asked |
| +// anything. |
| +func runShipFromRelease(fs *flag.FlagSet, o fromReleaseOpts) error { |
| + if err := fromReleaseConflicts(fs); err != nil { |
| + return err |
| + } |
| + sess, err := resolveMode(o.console) |
| + if err != nil { |
| + return err |
| + } |
| + if sess == nil { |
| + return errors.New(shipFromReleaseNeedsConsole) |
| + } |
| + m, parts, err := loadReleaseDir(o.dir) |
| + if err != nil { |
| + return err |
| + } |
| + printUsing(stdout, sess) |
| + ctx := context.Background() |
| + acct := apiAccount(o.acctRaw, o.acctIDRaw) |
| + if acct.Seg == "" { |
| + if acct, err = sess.defaultAccount(ctx); err != nil { |
| + return err |
| + } |
| + } |
| + app := strings.TrimSpace(o.app) |
| + if app == "" { |
| + if app, err = sess.defaultApp(ctx, acct, true); err != nil { |
| + return err |
| + } |
| + if app == "" { |
| + return errors.New(shipFromReleaseUsage) |
| + } |
| + } |
| + message, err := resolveMutationMessage(fs, o.messageFlags) |
| + if err != nil { |
| + return err |
| + } |
| + res, err := sess.shipFromRelease(ctx, acct, app, m, parts, o.programChange, message) |
| + if err != nil { |
| + return err |
| + } |
| + if res.NoOp { |
| + mutedf(stdout, shipFromReleaseNoOp+"\n", app, m.Version) |
| + } else { |
| + fmt.Fprintf(stdout, shipFromReleaseDone+"\n", app, m.Version, o.dir) |
| + } |
| + if m.Swap == release.DemandHold { |
| + mutedf(stdout, shipHoldNote) |
| + } |
| + return nil |
| +} |
| + |
| +// loadReleaseDir reads dir/manifest.json and checks every file it names |
| +// against its size and sha256. parts maps each artifact key to its file. |
| +func loadReleaseDir(dir string) (*release.Manifest, map[string]string, error) { |
| + raw, err := os.ReadFile(filepath.Join(dir, "manifest.json")) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return nil, nil, fmt.Errorf(shipFromReleaseNoManifest, dir) |
| + } |
| + if err != nil { |
| + return nil, nil, err |
| + } |
| + var m release.Manifest |
| + if err := json.Unmarshal(raw, &m); err != nil { |
| + return nil, nil, fmt.Errorf("%s: manifest.json does not parse: %w", dir, err) |
| + } |
| + switch m.Kind { |
| + case "binary", "static", release.KindRootfs: |
| + default: |
| + return nil, nil, fmt.Errorf("%s: manifest.json has kind %q, not binary, static or rootfs", dir, m.Kind) |
| + } |
| + // An empty version would have the console mint one: the copy would land |
| + // under a name the source never shipped. |
| + if m.Version == "" || len(m.Artifacts) == 0 { |
| + return nil, nil, fmt.Errorf("%s: manifest.json names no version or no files", dir) |
| + } |
| + for _, art := range m.Artifacts { |
| + if !validPulledFile(art.File) { |
| + return nil, nil, fmt.Errorf("%s: manifest.json names a file %q that cannot be read safely", dir, art.File) |
| + } |
| + } |
| + parts := make(map[string]string, len(m.Artifacts)) |
| + for key, art := range m.Artifacts { |
| + path := filepath.Join(dir, art.File) |
| + size, sum, err := hashReleaseFile(path) |
| + if err != nil { |
| + return nil, nil, err |
| + } |
| + if size != art.Size || sum != art.SHA256 { |
| + return nil, nil, fmt.Errorf(shipFromReleaseFileDiffers, path) |
| + } |
| + parts[key] = path |
| + } |
| + return &m, parts, nil |
| +} |
| + |
| +// hashReleaseFile is path's length and hex sha256. |
| +func hashReleaseFile(path string) (int64, string, error) { |
| + f, err := os.Open(path) |
| + if err != nil { |
| + return 0, "", err |
| + } |
| + defer f.Close() |
| + h := sha256.New() |
| + n, err := io.Copy(h, f) |
| + if err != nil { |
| + return 0, "", err |
| + } |
| + return n, hex.EncodeToString(h.Sum(nil)), nil |
| +} |
| + |
| +// fromReleaseMeta is the ship door's meta part for a copied release: every |
| +// setting the source manifest carries, and its digests as expect_artifacts. |
| +type fromReleaseMeta struct { |
| + Version string `json:"version"` |
| + Kind string `json:"kind"` |
| + Label string `json:"label,omitempty"` |
| + Notes string `json:"notes,omitempty"` |
| + Message string `json:"message,omitempty"` |
| + Capabilities json.RawMessage `json:"capabilities,omitempty"` |
| + ProgramChange bool `json:"program_change,omitempty"` |
| + Swap string `json:"swap,omitempty"` |
| + Stateless bool `json:"stateless,omitempty"` |
| + Mail string `json:"mail,omitempty"` |
| + Assets *release.Assets `json:"assets,omitempty"` |
| + Processes json.RawMessage `json:"processes,omitempty"` |
| + Hibernate bool `json:"hibernate,omitempty"` |
| + JIT bool `json:"jit,omitempty"` |
| + RootfsSize int64 `json:"rootfs_size,omitempty"` |
| + ExpectArtifacts map[string]shippedArtifact `json:"expect_artifacts"` |
| +} |
| + |
| +// shippedArtifact is one artifact's digest on the wire, both ways. |
| +type shippedArtifact struct { |
| + SHA256 string `json:"sha256"` |
| + Size int64 `json:"size"` |
| +} |
| + |
| +// fromReleaseMetaFor builds m's meta part. |
| +func fromReleaseMetaFor(m *release.Manifest, programChange bool, message string) (fromReleaseMeta, error) { |
| + meta := fromReleaseMeta{ |
| + Version: m.Version, Kind: m.Kind, Label: m.Label, Notes: m.Notes, Message: message, |
| + ProgramChange: m.ProgramChange || programChange, |
| + Swap: m.Swap, Stateless: m.Stateless, Mail: m.Mail, Assets: m.Assets, |
| + ExpectArtifacts: make(map[string]shippedArtifact, len(m.Artifacts)), |
| + } |
| + for k, a := range m.Artifacts { |
| + meta.ExpectArtifacts[k] = shippedArtifact{SHA256: a.SHA256, Size: a.Size} |
| + } |
| + if m.Capabilities != nil { |
| + b, err := json.Marshal(m.Capabilities) |
| + if err != nil { |
| + return meta, err |
| + } |
| + meta.Capabilities = b |
| + } |
| + if m.IsRootfs() { |
| + b, err := json.Marshal(m.Processes) |
| + if err != nil { |
| + return meta, err |
| + } |
| + meta.Processes = b |
| + meta.Hibernate, meta.JIT = m.Hibernate, m.JIT |
| + meta.RootfsSize = m.Artifacts[release.RootfsArtifactKey].Size |
| + } |
| + return meta, nil |
| +} |
| + |
| +// shipFromRelease uploads a pulled release: the meta part, then one file |
| +// part per artifact in key order. On success it checks every echo a plain |
| +// ship checks, then that the console stored exactly the source's digests. |
| +func (s *apiSession) shipFromRelease(ctx context.Context, a apiAcct, app string, m *release.Manifest, parts map[string]string, programChange bool, message string) (apiShipResult, error) { |
| + meta, err := fromReleaseMetaFor(m, programChange, message) |
| + if err != nil { |
| + return apiShipResult{}, err |
| + } |
| + metaJSON, err := json.Marshal(meta) |
| + if err != nil { |
| + return apiShipResult{}, err |
| + } |
| + limit := shipTimeout |
| + if m.IsRootfs() { |
| + limit = shipRootfsTimeout |
| + } |
| + ctx, cancel := context.WithTimeout(ctx, limit) |
| + defer cancel() |
| + keys := make([]string, 0, len(parts)) |
| + for k := range parts { |
| + keys = append(keys, k) |
| + } |
| + sort.Strings(keys) |
| + status, body, err := s.c.doMultipart(ctx, apiPath(a, app, "/releases"), func(mw *multipart.Writer) error { |
| + metaPart, err := mw.CreateFormField("meta") |
| + if err != nil { |
| + return err |
| + } |
| + if _, err := metaPart.Write(metaJSON); err != nil { |
| + return err |
| + } |
| + for _, k := range keys { |
| + if err := writeFilePart(mw, k, parts[k]); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| + }) |
| + if err != nil { |
| + return apiShipResult{}, err |
| + } |
| + if status != http.StatusCreated && status != http.StatusOK { |
| + err := apiErrorFromBody(status, body) |
| + if m.IsRootfs() && status == http.StatusBadRequest && err.Error() == shipOldConsoleKind { |
| + return apiShipResult{}, errShipRootfsOldConsole |
| + } |
| + return apiShipResult{}, err |
| + } |
| + for _, err := range []error{ |
| + checkCapabilitiesEcho(m.Capabilities, body), |
| + checkStatelessEcho(m.Stateless, body), |
| + checkMailEcho(m.Mail, body), |
| + checkSwapEcho(m.Swap, body), |
| + compareShippedArtifacts(m.Artifacts, body), |
| + } { |
| + if err != nil { |
| + return apiShipResult{}, err |
| + } |
| + } |
| + var out struct { |
| + Version string `json:"version"` |
| + BuildProbe string `json:"build_probe"` |
| + } |
| + if err := json.Unmarshal(body, &out); err != nil { |
| + return apiShipResult{}, fmt.Errorf("ship: malformed response: %w", err) |
| + } |
| + return apiShipResult{NoOp: status == http.StatusOK, Version: out.Version, BuildProbe: out.BuildProbe}, nil |
| +} |
| + |
| +// compareShippedArtifacts refuses a ship answer whose artifacts differ from |
| +// want in any key, digest or size, the first in key order. A console that |
| +// answers with no artifacts at all is refused too: nothing says what it |
| +// stored. |
| +func compareShippedArtifacts(want map[string]release.Artifact, body []byte) error { |
| + var got struct { |
| + Artifacts map[string]shippedArtifact `json:"artifacts"` |
| + } |
| + _ = json.Unmarshal(body, &got) |
| + keys := make([]string, 0, len(want)+len(got.Artifacts)) |
| + for k := range want { |
| + keys = append(keys, k) |
| + } |
| + for k := range got.Artifacts { |
| + if _, ok := want[k]; !ok { |
| + keys = append(keys, k) |
| + } |
| + } |
| + sort.Strings(keys) |
| + for _, k := range keys { |
| + w, wok := want[k] |
| + g, gok := got.Artifacts[k] |
| + if !wok || !gok || g.SHA256 != w.SHA256 || g.Size != w.Size { |
| + return fmt.Errorf(shipFromReleaseDigestDiffer, k) |
| + } |
| + } |
| + return nil |
| +} |
diff --git a/ship_from_release_test.go b/ship_from_release_test.go| new file mode 100644 |
| index 000000000..35a586f5d |
| --- /dev/null |
| +++ b/ship_from_release_test.go |
| @@ -0,0 +1,75 @@ |
| +package main |
| + |
| +import ( |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +func TestShipFromReleaseRefusesOtherFlags(t *testing.T) { |
| + dir := t.TempDir() |
| + for _, tc := range []struct { |
| + args []string |
| + want string |
| + }{ |
| + {[]string{"--app", "shop", "--label", "x"}, "--from-release ships the release's own settings, so it cannot be combined with --label"}, |
| + {[]string{"--app", "shop", "./bin"}, "--from-release ships the files in its directory, so it takes no file arguments"}, |
| + } { |
| + cmd := exec.Command(sharedCarlos(t), append([]string{"ship", "--from-release", dir}, tc.args...)...) |
| + cmd.Dir = t.TempDir() |
| + cmd.Env = carlosTestEnv(t) |
| + var stderr strings.Builder |
| + cmd.Stderr = &stderr |
| + err := cmd.Run() |
| + if err == nil || !strings.Contains(stderr.String(), tc.want) { |
| + t.Fatalf("carlos ship --from-release %v: err %v stderr %q, want %q", tc.args, err, stderr.String(), tc.want) |
| + } |
| + } |
| +} |
| + |
| +func TestCompareShippedArtifacts(t *testing.T) { |
| + sha := strings.Repeat("a", 64) |
| + want := map[string]release.Artifact{"linux-arm64": {File: "linux-arm64", SHA256: sha, Size: 10}} |
| + for _, tc := range []struct { |
| + name, body string |
| + ok bool |
| + }{ |
| + {"identical", `{"artifacts":{"linux-arm64":{"sha256":"` + sha + `","size":10}}}`, true}, |
| + {"different sha", `{"artifacts":{"linux-arm64":{"sha256":"` + strings.Repeat("b", 64) + `","size":10}}}`, false}, |
| + {"different size", `{"artifacts":{"linux-arm64":{"sha256":"` + sha + `","size":11}}}`, false}, |
| + {"extra key", `{"artifacts":{"linux-arm64":{"sha256":"` + sha + `","size":10},"linux-amd64":{"sha256":"` + sha + `","size":10}}}`, false}, |
| + {"missing key", `{"artifacts":{}}`, false}, |
| + {"old console", `{"result":"shipped","version":"v12"}`, false}, |
| + } { |
| + err := compareShippedArtifacts(want, []byte(tc.body)) |
| + if (err == nil) != tc.ok { |
| + t.Fatalf("%s: err = %v, want ok %v", tc.name, err, tc.ok) |
| + } |
| + if err != nil && !strings.Contains(err.Error(), "do not promote this version") { |
| + t.Fatalf("%s: err = %v, want the do-not-promote sentence", tc.name, err) |
| + } |
| + } |
| +} |
| + |
| +func TestLoadReleaseDirRefusesUnsafeNames(t *testing.T) { |
| + dir := t.TempDir() |
| + manifest := `{"schema":1,"app":"shop","version":"v12","kind":"binary","artifacts":{"linux-arm64":{"file":"../x","sha256":"` + strings.Repeat("a", 64) + `","size":1}}}` |
| + if err := os.WriteFile(filepath.Join(dir, "manifest.json"), []byte(manifest), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, _, err := loadReleaseDir(dir); err == nil { |
| + t.Fatal("loadReleaseDir accepted a file named ../x") |
| + } |
| +} |
| + |
| +func TestLoadReleaseDirNeedsAManifest(t *testing.T) { |
| + dir := t.TempDir() |
| + _, _, err := loadReleaseDir(dir) |
| + if err == nil || err.Error() != dir+" has no manifest.json. run carlos releases pull first" { |
| + t.Fatalf("loadReleaseDir of an empty dir = %v", err) |
| + } |
| +} |
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl| index e9e6052f9..befe59baa 100644 |
| --- a/testdata/clireg-golden.jsonl |
| +++ b/testdata/clireg-golden.jsonl |
| @@ -794,8 +794,8 @@ |
| {"case":"services | bare","argv":["services"],"exit":1,"stdout":"","stderr":"usage: carlos services <create|ls|rotate|revoke> [flags]\n\n create --role <publish|deploy|instance|operate|service|run|admin> [--app <app>] [--account <sqid|name>] [--json] <name>\n mint a credential a SERVER holds, bound to this account —\n not to you. Unlike your own CLI token, its reach is fixed\n at mint: adding you to another account later does not widen\n it, and it draws on its own rate-limit budgets rather than\n yours.\n THE SECRET IS PRINTED EXACTLY ONCE, HERE. Only its hash is\n stored, so losing this output means rotate, not a re-run.\n --role admin INCLUDES `store grant`, which mints a\n path-scoped IAM user. It is a real handover, not a\n convenience bundle. Prefer the narrowest role that works.\n --app binds it to ONE app, which also means it cannot create\n apps. Omit --app for an account-scoped credential.\n --role run needs --app and --commands, the command\n prefixes it may run: --commands \"import classic,import sync\".\n Words are matched exactly, from the start of the command.\n --json prints one JSON object and nothing else, the bare\n secret in its \"secret\" field: carlos services create\n ... --json name | jq -r .secret\n\n ls [--account <sqid|name>]\n list every LIVE credential the account owns — name, role,\n scope, when it was minted and last rotated and used, and\n who minted it. A revoked credential does not appear; there\n is no history view here.\n\n rotate [--account <sqid|name>] [--json] <name>\n mint a FRESH secret for a credential that already exists,\n printed exactly once. This refuses the credential's NEXT\n call with the old secret. ROTATION IS NOT REVOCATION: it\n does not stop work already in flight, and a credential that\n may be COMPROMISED needs revoke. --json prints one JSON\n object, {\"name\", \"account\", \"secret\"}, and nothing else.\n\n revoke [--account <sqid|name>] <name-or-id>\n the hard stop rotate is not: the credential's next call\n fails, whatever secret it holds. Idempotent — revoking a\n name twice, or one that never existed, answers the same.\n Takes a credential's name, or the listing id `ls` shows\n (the only handle a nameless legacy credential has).\n\n --account <sqid|name> account the credential belongs to (default: your only\n account, or the configured/chosen one) —\n resolved by the console against your own\n memberships.\n --account-id <sqid> account sqid, matched as a sqid ONLY — supersedes\n --account\n --console <origin> which logged-in console to use (only needed with\n several)\n\nEvery verb here is signed-in only (carlos auth login), owner-only, and\nclosed to a service credential itself — no service credential can create,\nrotate or revoke any credential, not even itself, not even an admin one.\nService credentials are console-tracked state with no bucket-direct fallback.\n"} |
| {"case":"services | help","argv":["services","help"],"exit":1,"stdout":"","stderr":"usage: carlos services <create|ls|rotate|revoke> [flags]\n\n create --role <publish|deploy|instance|operate|service|run|admin> [--app <app>] [--account <sqid|name>] [--json] <name>\n mint a credential a SERVER holds, bound to this account —\n not to you. Unlike your own CLI token, its reach is fixed\n at mint: adding you to another account later does not widen\n it, and it draws on its own rate-limit budgets rather than\n yours.\n THE SECRET IS PRINTED EXACTLY ONCE, HERE. Only its hash is\n stored, so losing this output means rotate, not a re-run.\n --role admin INCLUDES `store grant`, which mints a\n path-scoped IAM user. It is a real handover, not a\n convenience bundle. Prefer the narrowest role that works.\n --app binds it to ONE app, which also means it cannot create\n apps. Omit --app for an account-scoped credential.\n --role run needs --app and --commands, the command\n prefixes it may run: --commands \"import classic,import sync\".\n Words are matched exactly, from the start of the command.\n --json prints one JSON object and nothing else, the bare\n secret in its \"secret\" field: carlos services create\n ... --json name | jq -r .secret\n\n ls [--account <sqid|name>]\n list every LIVE credential the account owns — name, role,\n scope, when it was minted and last rotated and used, and\n who minted it. A revoked credential does not appear; there\n is no history view here.\n\n rotate [--account <sqid|name>] [--json] <name>\n mint a FRESH secret for a credential that already exists,\n printed exactly once. This refuses the credential's NEXT\n call with the old secret. ROTATION IS NOT REVOCATION: it\n does not stop work already in flight, and a credential that\n may be COMPROMISED needs revoke. --json prints one JSON\n object, {\"name\", \"account\", \"secret\"}, and nothing else.\n\n revoke [--account <sqid|name>] <name-or-id>\n the hard stop rotate is not: the credential's next call\n fails, whatever secret it holds. Idempotent — revoking a\n name twice, or one that never existed, answers the same.\n Takes a credential's name, or the listing id `ls` shows\n (the only handle a nameless legacy credential has).\n\n --account <sqid|name> account the credential belongs to (default: your only\n account, or the configured/chosen one) —\n resolved by the console against your own\n memberships.\n --account-id <sqid> account sqid, matched as a sqid ONLY — supersedes\n --account\n --console <origin> which logged-in console to use (only needed with\n several)\n\nEvery verb here is signed-in only (carlos auth login), owner-only, and\nclosed to a service credential itself — no service credential can create,\nrotate or revoke any credential, not even itself, not even an admin one.\nService credentials are console-tracked state with no bucket-direct fallback.\n"} |
| {"case":"services | zz-unknown","argv":["services","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos services <create|ls|rotate|revoke> [flags]\n\n create --role <publish|deploy|instance|operate|service|run|admin> [--app <app>] [--account <sqid|name>] [--json] <name>\n mint a credential a SERVER holds, bound to this account —\n not to you. Unlike your own CLI token, its reach is fixed\n at mint: adding you to another account later does not widen\n it, and it draws on its own rate-limit budgets rather than\n yours.\n THE SECRET IS PRINTED EXACTLY ONCE, HERE. Only its hash is\n stored, so losing this output means rotate, not a re-run.\n --role admin INCLUDES `store grant`, which mints a\n path-scoped IAM user. It is a real handover, not a\n convenience bundle. Prefer the narrowest role that works.\n --app binds it to ONE app, which also means it cannot create\n apps. Omit --app for an account-scoped credential.\n --role run needs --app and --commands, the command\n prefixes it may run: --commands \"import classic,import sync\".\n Words are matched exactly, from the start of the command.\n --json prints one JSON object and nothing else, the bare\n secret in its \"secret\" field: carlos services create\n ... --json name | jq -r .secret\n\n ls [--account <sqid|name>]\n list every LIVE credential the account owns — name, role,\n scope, when it was minted and last rotated and used, and\n who minted it. A revoked credential does not appear; there\n is no history view here.\n\n rotate [--account <sqid|name>] [--json] <name>\n mint a FRESH secret for a credential that already exists,\n printed exactly once. This refuses the credential's NEXT\n call with the old secret. ROTATION IS NOT REVOCATION: it\n does not stop work already in flight, and a credential that\n may be COMPROMISED needs revoke. --json prints one JSON\n object, {\"name\", \"account\", \"secret\"}, and nothing else.\n\n revoke [--account <sqid|name>] <name-or-id>\n the hard stop rotate is not: the credential's next call\n fails, whatever secret it holds. Idempotent — revoking a\n name twice, or one that never existed, answers the same.\n Takes a credential's name, or the listing id `ls` shows\n (the only handle a nameless legacy credential has).\n\n --account <sqid|name> account the credential belongs to (default: your only\n account, or the configured/chosen one) —\n resolved by the console against your own\n memberships.\n --account-id <sqid> account sqid, matched as a sqid ONLY — supersedes\n --account\n --console <origin> which logged-in console to use (only needed with\n several)\n\nEvery verb here is signed-in only (carlos auth login), owner-only, and\nclosed to a service credential itself — no service credential can create,\nrotate or revoke any credential, not even itself, not even an admin one.\nService credentials are console-tracked state with no bucket-direct fallback.\n"} |
| -{"case":"ship | --zz-unknown-flag","argv":["ship","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos ship [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --assets <value> a folder your build writes files to, for example /assets/. repeat the flag for up to 8 folders. servers near your visitors may keep copies of the files in them\n --capabilities <string> path to a JSON capability block (internal/caps) to embed in the manifest\n --check run the rootfs image here with Docker or Podman, the way a box would, and ship nothing\n --console <string> console origin to ship through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --env <value> with --check, give every process a variable as KEY=VALUE, such as a placeholder secret. repeat it for more than one\n --hibernate let this rootfs app hibernate when idle. rootfs apps are always on unless their first release opts in\n --jit let this rootfs release's processes run a JIT compiler, as Node, Bun, Deno, the JVM and Ruby's YJIT need. without it a box never lets memory be writable and executable at once\n --kind <string> binary | static (default: binary)\n --label <string> one-line human label for this release (\"fixing modals\")\n --mail <string> declare this build's mail transport. the one value is submit: the build sends through carlos's submission socket when CARLOS_MAIL=submit is set\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --notes <string> changelog fragment for this release\n --notes-file <string> file holding the changelog fragment (mutually exclusive with --notes)\n --processes <string> JSON file holding the rootfs release's processes: web, any workers, release and console\n --program-change accept that this release's Go main package differs from the app's previous release (recorded in the manifest)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --rootfs <string> an OCI image (a layout directory, a docker save archive or a local image name) or a directory, shipped as a rootfs release\n --stateless this release keeps no local database. CARLOS_DB, SQLite, restore and Litestream are off\n --swap <string> hold: this release stops each instance before starting it, for a migration the previous build cannot share the database with\n --target <string> GOOS-GOARCH the binary was built for (binary kind, single file) (default: linux-arm64)\n --version, -v <string> version (git short sha); omit to mint the next iteration under the app's version target\n"} |
| -{"case":"ship | -h","argv":["ship","-h"],"exit":0,"stdout":"","stderr":"usage: carlos ship [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --assets <value> a folder your build writes files to, for example /assets/. repeat the flag for up to 8 folders. servers near your visitors may keep copies of the files in them\n --capabilities <string> path to a JSON capability block (internal/caps) to embed in the manifest\n --check run the rootfs image here with Docker or Podman, the way a box would, and ship nothing\n --console <string> console origin to ship through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --env <value> with --check, give every process a variable as KEY=VALUE, such as a placeholder secret. repeat it for more than one\n --hibernate let this rootfs app hibernate when idle. rootfs apps are always on unless their first release opts in\n --jit let this rootfs release's processes run a JIT compiler, as Node, Bun, Deno, the JVM and Ruby's YJIT need. without it a box never lets memory be writable and executable at once\n --kind <string> binary | static (default: binary)\n --label <string> one-line human label for this release (\"fixing modals\")\n --mail <string> declare this build's mail transport. the one value is submit: the build sends through carlos's submission socket when CARLOS_MAIL=submit is set\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --notes <string> changelog fragment for this release\n --notes-file <string> file holding the changelog fragment (mutually exclusive with --notes)\n --processes <string> JSON file holding the rootfs release's processes: web, any workers, release and console\n --program-change accept that this release's Go main package differs from the app's previous release (recorded in the manifest)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --rootfs <string> an OCI image (a layout directory, a docker save archive or a local image name) or a directory, shipped as a rootfs release\n --stateless this release keeps no local database. CARLOS_DB, SQLite, restore and Litestream are off\n --swap <string> hold: this release stops each instance before starting it, for a migration the previous build cannot share the database with\n --target <string> GOOS-GOARCH the binary was built for (binary kind, single file) (default: linux-arm64)\n --version, -v <string> version (git short sha); omit to mint the next iteration under the app's version target\n"} |
| +{"case":"ship | --zz-unknown-flag","argv":["ship","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos ship [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --assets <value> a folder your build writes files to, for example /assets/. repeat the flag for up to 8 folders. servers near your visitors may keep copies of the files in them\n --capabilities <string> path to a JSON capability block (internal/caps) to embed in the manifest\n --check run the rootfs image here with Docker or Podman, the way a box would, and ship nothing\n --console <string> console origin to ship through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --env <value> with --check, give every process a variable as KEY=VALUE, such as a placeholder secret. repeat it for more than one\n --from-release <string> a directory written by carlos releases pull. ships its files and settings unchanged\n --hibernate let this rootfs app hibernate when idle. rootfs apps are always on unless their first release opts in\n --jit let this rootfs release's processes run a JIT compiler, as Node, Bun, Deno, the JVM and Ruby's YJIT need. without it a box never lets memory be writable and executable at once\n --kind <string> binary | static (default: binary)\n --label <string> one-line human label for this release (\"fixing modals\")\n --mail <string> declare this build's mail transport. the one value is submit: the build sends through carlos's submission socket when CARLOS_MAIL=submit is set\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --notes <string> changelog fragment for this release\n --notes-file <string> file holding the changelog fragment (mutually exclusive with --notes)\n --processes <string> JSON file holding the rootfs release's processes: web, any workers, release and console\n --program-change accept that this release's Go main package differs from the app's previous release (recorded in the manifest)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --rootfs <string> an OCI image (a layout directory, a docker save archive or a local image name) or a directory, shipped as a rootfs release\n --stateless this release keeps no local database. CARLOS_DB, SQLite, restore and Litestream are off\n --swap <string> hold: this release stops each instance before starting it, for a migration the previous build cannot share the database with\n --target <string> GOOS-GOARCH the binary was built for (binary kind, single file) (default: linux-arm64)\n --version, -v <string> version (git short sha); omit to mint the next iteration under the app's version target\n"} |
| +{"case":"ship | -h","argv":["ship","-h"],"exit":0,"stdout":"","stderr":"usage: carlos ship [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --assets <value> a folder your build writes files to, for example /assets/. repeat the flag for up to 8 folders. servers near your visitors may keep copies of the files in them\n --capabilities <string> path to a JSON capability block (internal/caps) to embed in the manifest\n --check run the rootfs image here with Docker or Podman, the way a box would, and ship nothing\n --console <string> console origin to ship through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --env <value> with --check, give every process a variable as KEY=VALUE, such as a placeholder secret. repeat it for more than one\n --from-release <string> a directory written by carlos releases pull. ships its files and settings unchanged\n --hibernate let this rootfs app hibernate when idle. rootfs apps are always on unless their first release opts in\n --jit let this rootfs release's processes run a JIT compiler, as Node, Bun, Deno, the JVM and Ruby's YJIT need. without it a box never lets memory be writable and executable at once\n --kind <string> binary | static (default: binary)\n --label <string> one-line human label for this release (\"fixing modals\")\n --mail <string> declare this build's mail transport. the one value is submit: the build sends through carlos's submission socket when CARLOS_MAIL=submit is set\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --notes <string> changelog fragment for this release\n --notes-file <string> file holding the changelog fragment (mutually exclusive with --notes)\n --processes <string> JSON file holding the rootfs release's processes: web, any workers, release and console\n --program-change accept that this release's Go main package differs from the app's previous release (recorded in the manifest)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --rootfs <string> an OCI image (a layout directory, a docker save archive or a local image name) or a directory, shipped as a rootfs release\n --stateless this release keeps no local database. CARLOS_DB, SQLite, restore and Litestream are off\n --swap <string> hold: this release stops each instance before starting it, for a migration the previous build cannot share the database with\n --target <string> GOOS-GOARCH the binary was built for (binary kind, single file) (default: linux-arm64)\n --version, -v <string> version (git short sha); omit to mint the next iteration under the app's version target\n"} |
| {"case":"sidecars create | --zz-unknown-flag","argv":["sidecars","create","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nUsage of sidecars create:\n -account string\n \taccount (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n -account-id string\n \taccount sqid, matched as a sqid ONLY — supersedes -account\n -app string\n \tapp the sidecar belongs to\n -channel string\n \trelease channel the sidecar follows (default: the manifest's, then stable)\n -console string\n \tconsole to create through (default: the only logged-in one)\n -d value\n \talias for --destination\n -destination name\n \tuse the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n -region string\n \tregion code for the record (subject to the manifest's allow-list, or the app's own placement)\n"} |
| {"case":"sidecars create | -h","argv":["sidecars","create","-h"],"exit":0,"stdout":"","stderr":"Usage of sidecars create:\n -account string\n \taccount (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n -account-id string\n \taccount sqid, matched as a sqid ONLY — supersedes -account\n -app string\n \tapp the sidecar belongs to\n -channel string\n \trelease channel the sidecar follows (default: the manifest's, then stable)\n -console string\n \tconsole to create through (default: the only logged-in one)\n -d value\n \talias for --destination\n -destination name\n \tuse the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n -region string\n \tregion code for the record (subject to the manifest's allow-list, or the app's own placement)\n"} |
| {"case":"sidecars enable | --zz-unknown-flag","argv":["sidecars","enable","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nUsage of sidecars enable:\n -account string\n \taccount (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n -account-id string\n \taccount sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n -app string\n \tapp whose sidecars this enables\n -args string\n \targv the activator execs the app's own binary with, whitespace-split (strings.Fields)\n -channel string\n \trelease channel stamped into every record at create\n -console string\n \tconsole to enable through (signed-in mode only; default: the only logged-in one)\n -d value\n \talias for --destination\n -destination name\n \tuse the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n -idle string\n \tidle timeout before a hibernating sidecar sleeps (default 5m; Go duration)\n -max-run string\n \tmax run duration before the sweeper stops a sidecar (default 1h; Go duration)\n -no-hibernate\n \tthis app's sidecars never hibernate (default: they do)\n -placement string\n \t\"any\" (default) or \"no-inbound\"\n -pool string\n \tpool stamped into every record at create (store mode only)\n -regions string\n \tcomma-separated region allow-list, plain region codes only (store mode only); empty = any shape-valid region — see carlos apps place for fleet placement\n -registry string\n \tregistry database (resolves --account) (default \"$DIR/data/registry.db\")\n"} |