Create the app and handle installs
This server sends customers to Entire and accepts their receipts:saveState, loadState and saveInstallation are your own functions. AcceptReceipt checks the state, the receipt’s signature, issuer, audience, plugin, expiry and single use, and returns plugin.ErrAccessDenied when the customer canceled. Store receipt.CoreURL with the installation ID; it is a convenient Core to call later.
Set Config.Permissions to the permissions your service requests, including Trails if needed. inst.Token sends that set without a repository ID: a broad token must request every effective permission currently accepted by the installation. A subset can return 400 repository_required, while a newly registered permission awaiting customer acceptance returns 403 permission_not_accepted. The installations-only and create-only scopes are separate unscoped exceptions. Calls such as inst.Checks and inst.Deployments request only the permission they need for one repository, which must also be accepted.
Two defaults matter for production. With Config.Cores empty, the SDK trusts the validated production jurisdiction-origin pattern under auth.entire.io and auth.entire.com, including new jurisdictions; it is not a fixed host list. Set Config.Cores for an explicit allowlist. Receipt replay protection defaults to memory, so use a durable shared Config.ReplayStore across processes and restarts.
Read the customer’s repositories
RepositoryClient returns an ordinary SDK client whose token reaches one repository, with the permissions you pass. It routes repository API calls to the discovered region and renews the token as it nears expiry. Core methods still use Core routing. If the repository moves, call inst.Repositories(ctx) to refresh cached placement data, then obtain a new repository client:
Installation instance. If you need the raw token, call inst.RepositoryToken or, for the whole installation, inst.Token.
The same client comments on trails when you add Discussions: plugin.Write to the permissions you pass.
Clone with Git
Clone throughgit-remote-entire, the Git helper that ships with the Entire CLI. A repository’s EntireCloneURL names it, and RemoteHelperEnv returns environment variables that hand the helper the installation’s token in ENTIRE_TOKEN:
RemoteHelperEnv uses the installation’s token, which reaches every repository in the installation, so run Git only where you trust it as much as your plugin. The token lasts about 45 minutes; call RemoteHelperEnv again for later fetches.
Use the returned EntireCloneURL and RemoteHelperEnv together for the helper-based workflow above.
Code that speaks the Git protocol itself, such as a proxy, calls GitAuthorization instead. It returns an Authorization header value with a token narrowed to one repository and the permissions you pass, cached and renewed like RepositoryToken’s, so call it for every request:
Config.HostPolicy approves its host: it carries a credential.
Create a repository
Plugins registered withrepositories:create create repositories in the installation’s project. Add Repositories: plugin.Create to Config.Permissions, and Contents: plugin.Write if you push to them. CreateRepository mints the create token, creates the repository, then polls the installation list for a primary with an API URL. Save any returned ID before handling the error:
RepositoryClient or RepositoryToken to obtain credentials for your next operation. The helper has discovered routing metadata; token minting and repository operations still report their own readiness and permission errors. Follow the provisioning steps for recovery. saveRepository is your own durable persistence function; recover a failed save before retrying this workflow.
Pass &plugin.CreateRepositoryOptions{ObjectFormat: "sha256"} for a SHA-256 repository. An existing name returns plugin.ErrRepositoryExists, and the create limit returns plugin.ErrCreateLimit; inspect the wrapped *entire.HTTPError for details. If the post-create polling fails, the SDK can return a nonempty repository ID with plugin.ErrRepositoryNotReady or the last repository-list error. Creation has already succeeded in that case: retain the ID and never issue another create merely because waiting or minting failed. See Create a repository for recovery, the default limit and ownership.
Report check runs
Plugins registered withchecks:write write check runs on a commit in any repository the installation covers. A write is idempotent, so retry it freely. ExternalUpdatedAt is when the state changed on your side, and Entire applies writes to a run in that order:
checks:write, and follows a repository that moved. Server validation and live authorization remain authoritative. See Report checks for suite state, attempt IDs, cancellation and readback.
Your plugin’s gate
Each plugin that can write checks gets its own gate on every repository it covers, keyed by its slug. Entire creates the gate the first time it evaluates a repository’s gates after the install. The gate is enabled and blocking, so your reports can stop a trail from merging:- No required names. The gate doesn’t apply until you report on the trail’s head commit. After that, every suite on the head commit must pass.
- Required names. The customer lists names, as Review and require checks describes, under the repository’s Settings then Gates. A name is a suite key, such as
ci, or a suite key and a run key, such asci / lint. A listed name with no report on the head commit waits, unless the commit was pushed before the plugin was connected. Checks that aren’t listed never block.
success, neutral, skipped and action_required conclusions don’t fail a run. Keep your suite and run keys stable, because customers name them in their gate settings.
Deployments never count toward this gate. To show the resources you deployed and links to them on the Change, report deployments with inst.Deployments.
Receive events
App.WebhookHandler verifies each delivery’s signature, checks its delivery store for already handled IDs, and calls your function. Make queue insertion idempotent using the delivery ID, answer within seconds, and process slow work from durable storage. Webhooks are experimental, and field names may change:
Config.DeliveryJWKSURL to the delivery JWKS URL Entire gives you when it registers your webhook. enqueueBuild is your application code: persist work before acknowledging the delivery and propagate queue failures. See Receive webhooks for durable handling and response codes.
The SDK exposes Receipt.ProjectID and InstallationState.ProjectID, but not the project display fields. Don’t display Receipt.Project: it can be an internal mirror name. InstallationChange.Installation.ManageURL is empty on installation.deleted. To read the webhook’s project object, use Event.Decode with your own struct after the handler verifies the delivery.
Entire delivers fifteen events:
Both ref and trail events need live
contents:read or contents:write on the covered repository; installation lifecycle events do not. See Receive webhooks for delivery verification, installation revisions, ref events and trail events.
Try it on your machine
The SDK’sexamples/plugin-reader example runs the whole flow without a public server. It serves the post-install callback on https://localhost:8443/callback, prints an install link for you to open, verifies the receipt, then reads each repository with a client scoped to it.
Run the following commands from a checkout of the Go SDK source at release v0.3.1. Installing the module with go get in your own application does not create its examples directory.
- Generate a private key with
openssl genpkey -algorithm ed25519 -out plugin-key.pem, then print its public half withgo run ./examples/plugin-reader -key plugin-key.pem pubkey. Thepubkeycommand reads an existing key. - Ask Entire to register a test plugin with that key,
contents:readandhttps://localhost:8443/callbackas a post-install URL. - Make a certificate your browser trusts, for example with
mkcert localhost. - Run the install, and choose a test project and repository on the install page.
run.