Local Testing — GCP (floci-gcp)
Show the whole prompt
Read https://intentius.io/chant/local-testing/gcp/.
In `examples/local-cloud-trio`, run `npm install` and then `npx chant run gcp --no-record`. The run boots floci-gcp and applies the manifest with `gcpApply`. After checking the bucket it removes the container. Docker has to be running.
Keep the `endpoint` override on the local floci-gcp port, and show me what the run prints.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.Optional: hand this page to your coding agent
Read https://intentius.io/chant/local-testing/gcp/.In `examples/local-cloud-trio`, run `npm install` and then `npx chant run gcp --no-record`. The run boots floci-gcp and applies the manifest with `gcpApply`. After checking the bucket it removes the container. Docker has to be running.Keep the `endpoint` override on the local floci-gcp port, and show me what the run prints.Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.GCP has no native deployment service — Deployment Manager is retired, and Config Connector needs a cluster running its operator. gcpApply applies chant’s Config Connector output to a local emulator itself: it maps each resource to its underlying Google REST API and drives create, update, and delete itself against floci-gcp.
The resource
Section titled “The resource”A GCS bucket, described as data. It synthesizes to a Config Connector manifest:
export const bucket = new StorageBucket({ metadata: { name: "trio-bucket", labels: { "app.kubernetes.io/managed-by": "chant" }, }, location: "US", storageClass: "STANDARD", uniformBucketLevelAccess: true, versioning: { enabled: true },});The op
Section titled “The op”chant run gcp boots floci-gcp, builds the manifest, applies it with gcpApply, verifies the bucket over the GCS REST API, and removes the container.
export default Op({ name: "gcp", taskQueue: "trio-gcp", phases: [ phase("Emulator", [flociGcpUp()]), phase("Build", [build(".", { script: "build:gcp" })]), phase("Apply", [gcpApply("dist/gcp.yaml", { endpoint: "http://localhost:4588", project: "local-project" })]), phase("Verify", [httpCheck("http://localhost:4588/storage/v1/b/trio-bucket")]), phase("Teardown", [flociGcpDown()]), ],});How gcpApply works
Section titled “How gcpApply works”Config Connector normally reconciles a CRD on a cluster into Google API calls. gcpApply performs that reconciliation directly, no cluster involved:
- Maps each kind to its REST resource via a dispatch table (
MAPPERSinlexicons/gcp/src/op/activities/gcp-apply.ts), which covers a VPC network and its subnetworks and the Cloud Run serverless load balancer beside the storage and IAM kinds. - Merges an IAM policy member into its target’s policy with
getIamPolicyand thensetIamPolicy, so the policy’s other bindings stay as they were. - Orders resources by their references so a dependency applies before its dependent.
- Turns Config Connector refs into API fields where the API takes something else: a Cloud Run service’s
serviceAccountRefbecomes the account’s email, and itsvpcAccessnetworkRefandsubnetworkRefbecome network and subnetwork paths. - Drives full CRUD, following long-running operations to completion where the API returns one.
- Updates an existing load balancer resource in place where compute allows it. A backend service or URL map takes a
PATCHwith the livefingerprint. A proxy changes its URL map throughsetUrlMap, and a forwarding rule its target throughsetTarget. Labels go throughsetLabels. A change compute can’t make in place is printed asreplace requiredand left for you; that covers any change to a serverless NEG and a forwarding rule’s IP. - Prunes orphans it owns — resources carrying the
managed-by: chantlabel that are no longer in the manifest — and leaves everything else alone.
Every call is the real GCS/PubSub/IAM shape, pointed at the emulator.
Run it
Section titled “Run it”Requires Docker and curl on PATH.
cd examples/local-cloud-trionpm installchant run gcpThe project
Section titled “The project”Each resource is applied and read in one project, taken from its own spec.projectRef.external, then gcp.project in the member’s chant.config.ts, then GCP_PROJECT_ID, then GOOGLE_CLOUD_PROJECT. With gcp.project set once, chant graph --live reads a load balancer or network resource that has no projectRef of its own without any variable set.
From local to real cloud
Section titled “From local to real cloud”Drop the endpoint override and gcpApply targets the real Google APIs for the same project. The manifest and the reconciliation logic are unchanged — this is the same code path a live apply takes.