Skip to content

Add JSON output to cog push - #3178

Merged
michaeldwan merged 7 commits into
mainfrom
push-json
Sep 22, 2026
Merged

michaeldwan merged 7 commits into
mainfrom
push-json

Conversation

@michaeldwan

Copy link
Copy Markdown
Contributor

Adds cog push <target> --json for image and bundle projects. The output contains digest-pinned image, model, and managed-weight references while progress stays on stderr.

Cog push can now emit one versioned JSON document containing immutable image, model, and managed-weight references after the full push and provider workflow succeeds. Progress and diagnostics remain on stderr, while failures leave stdout empty.\n\nA positional target now works for both image and bundle projects, overrides configured and environment destinations, rejects digest destinations, and keeps managed weights in their imported repository. Existing human-readable pushes retain their prior output and digest fallback.
Explain how positional targets interact with image and bundle projects, configured destinations, tags, and managed weights. The deployment guide now defines the versioned JSON schema, immutable-reference guarantees, output streams, and failure behavior for automation.\n\nRegenerate the CLI reference and llms index from the updated command help and documentation.
Carry the digest reported by each Docker push implementation into image and bundle results instead of resolving a mutable tag after upload. Concurrent pushes to the same tag can no longer make one command report or package another command's image.\n\nBundle output now follows cog.yaml weight order and positional bundle tags receive the same validation as configured tags. Registry tests cover image and bundle JSON output, weight counts and ordering, target forms, human output, and empty stdout across failure paths.
Include the generated PushResultCommand mock introduced by digest-aware image pushes. The checked-in mock output now matches the interfaces in pkg/docker/command and can be reproduced by the repository's generator.

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

Adds cog push <target> --json for image and bundle projects. Output is one versioned, digest-pinned JSON document on stdout, with progress/warnings on stderr; bundle pushes now use the upload-reported manifest digest instead of HEADing the tag.

Overall this is well-designed and thoroughly tested: digest-pinned refs are validated before emitting JSON, the destination/format resolution is unified so the CLI and Resolver can't disagree on a timestamp tag, weights are ordered by config, and progress stays off stdout. I ran the Go build, go vet, and the pkg/cli, pkg/model, and pkg/docker test suites — all pass.

One finding below (bundle push digest hard-requirement), plus a couple of informational notes.

Informational (not blocking):

  • This is a deliberate, documented behavior change: positional targets are now accepted for model: projects (previously rejected), and a positional target now also bypasses the image: + COG_MODEL* conflict. Docs/tests cover it, but scripts that relied on the old error will now get a bundle push to the given destination.
  • MockPushResultCommand2 in pkg/docker/dockertest/command_mocks.go is generated but unused.
  • docs/deploy.md says "Non-JSON pushes keep their existing fallback when a registry can't resolve the pushed image's digest" — this is only true for the image path; bundle pushes always require the digest.

Comment thread pkg/model/pusher.go Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Adds cog push <target> --json for image and bundle projects: one versioned, digest-pinned JSON document on stdout, progress/diagnostics on stderr, and bundle pushes now pin to the upload-reported manifest digest.

Findings (1 inline suggestion submitted):

  1. Bundle push hard-requires the upload-reported digest with no fallback (pkg/model/pusher.go:153). Even in non-JSON mode, a daemon/proxy whose push output doesn't match the parsed digest: sha256:… size: N status/aux format (or an alternate command.Command that lacks PushResultCommand) fails a bundle push that already succeeded at the registry, leaving an orphan image. The FormatImage path keeps a HEAD-on-tag fallback gated on RequireDigest; the bundle path doesn't. Suggested gating the same fallback on opts.RequireDigest so --json stays strict while plain cog push retains the old behavior.

Informational (not blocking): positional targets are now accepted for model: projects and bypass the image:+COG_MODEL* conflict (documented behavior change); MockPushResultCommand2 is generated-but-unused; the docs/deploy.md "non-JSON keeps fallback" promise only holds for the image path.

Verified: go build, go vet, and the pkg/cli, pkg/model, pkg/docker suites all pass.

github run

Move rustls to 0.23.45, which rejects TLS 1.3 handshake messages received at the wrong encryption level and resolves RUSTSEC-2026-0285. Cargo also updates rustls-webpki and unifies compatible windows-sys lockfile entries.
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

When Docker completes a bundle image push without reporting its manifest digest, human-readable pushes now fall back to the previous tag-based descriptor lookup. JSON output remains strict so it never trusts a mutable tag when producing immutable references.\n\nNarrow the fallback documentation to image-format pushes and cover both permissive and strict bundle behavior.
Exercise the non-JSON bundle fallback when a Docker command doesn't expose push results, not only when it returns an empty digest. Keep the new failure-path assertions within the repository's Testify conventions.
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@michaeldwan Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@michaeldwan
michaeldwan marked this pull request as ready for review September 22, 2026 14:12
@michaeldwan
michaeldwan requested a review from a team as a code owner September 22, 2026 14:12
@michaeldwan
michaeldwan added this pull request to the merge queue Sep 22, 2026
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

Merged via the queue into main with commit 7240143 Sep 22, 2026
47 of 48 checks passed
@michaeldwan
michaeldwan deleted the push-json branch September 22, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants