Repository navigation
feat: add manifest server endpoints (unit 9) - #62
Merged
Merged
Conversation
PUT/GET /vaults/{name}/manifest, wired behind APIKeyAuth alongside the
blob routes. The server never inspects the manifest's contents - it's
opaque ciphertext either way - so this is just a generation-checked
blob write for optimistic concurrency.
PUT takes a JSON body {expected_generation, ciphertext (base64)} and
returns {generation}. expected_generation 0 means "no manifest exists
yet"; any other value must match the stored generation or the write
is rejected with 409. GET returns {generation, ciphertext}, 404 if
the vault has no manifest pushed yet.
store.PutManifest does the compare-and-swap via INSERT ... ON
CONFLICT DO NOTHING (first write) or UPDATE ... WHERE generation = ?
(subsequent writes), both RETURNING the row and mapping a zero-rows
sql.ErrNoRows to ErrManifestConflict - mirrors the ON CONFLICT +
sql.ErrNoRows idiom CreateVault already uses.
Chose a JSON envelope over the blob endpoints' raw-bytes-plus-header
style since the generation has to travel both directions for the CAS
to work, matching how Register/CreateVault already do JSON bodies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PUT/GET /vaults/{name}/manifest, wired behind APIKeyAuth alongside the blob routes. The server never inspects the manifest's contents - it's opaque ciphertext either way - so this is just a generation-checked blob write for optimistic concurrency.
PUT takes a JSON body {expected_generation, ciphertext (base64)} and returns {generation}. expected_generation 0 means "no manifest exists yet"; any other value must match the stored generation or the write is rejected with 409. GET returns {generation, ciphertext}, 404 if the vault has no manifest pushed yet.
store.PutManifest does the compare-and-swap via INSERT ... ON CONFLICT DO NOTHING (first write) or UPDATE ... WHERE generation = ? (subsequent writes), both RETURNING the row and mapping a zero-rows sql.ErrNoRows to ErrManifestConflict - mirrors the ON CONFLICT + sql.ErrNoRows idiom CreateVault already uses.
Chose a JSON envelope over the blob endpoints' raw-bytes-plus-header style since the generation has to travel both directions for the CAS to work, matching how Register/CreateVault already do JSON bodies.