Provision the managed repository
For each product, create one managed repository in Code Storage. Save the repository id on your product record, so a later request finds the right repository. The examples useproducts and
productFiles for services that you own.
Set PIERRE_ORG and PIERRE_PRIVATE_KEY as shown in the
Quick Start.
Create the first active revision
Build and validate the complete file set before you save it. Save the files as one commit. Apply that exact commit, then record it as the active revision.activeRevision only after the apply step succeeds.
Validate and save a user edit
Build the complete file set that would result from the edit. Validate all files before you save any of them. If validation fails, return the errors and keep the active revision unchanged.precondition_failed; treat it as success with no new
revision.
After a timeout, the commit can still exist. Do not resend the same request. Read the current head
again. Rebuild the candidate file set from the current product state. Send a new commit with the new
head as expectedHeadSha.
Apply the saved version
After a successful save, read the complete file set by its commit SHA. Apply only those files. Mark the commit as active only after the apply step succeeds.Show history and undo a change
Keep repository details behind your product interface. UselistCommits and getCommitDiff to show
who changed the product and what changed.
restoreCommit to create a new commit from an earlier version. Apply and record the new commit,
not the old commit that supplied its files.
Limit service access
Keep the organization private key on your server or in a secret manager. Give each product service a temporary token for one managed repository. Grant only the permissions that the service needs. Use a separaterepo:write token when the provisioning service creates a managed repository. See
Authentication for token details.