Skip to content

Local Testing — GCP (floci-gcp)

GCP has no native deployment service — Deployment Manager is retired, and Config Connector needs a cluster running its operator. gcpApply bridges chant’s Config Connector output to a local emulator directly: it maps each resource to its underlying Google REST API and drives create, update, and delete itself against floci-gcp.

A GCS bucket, described as data. It synthesizes to a Config Connector manifest:

src/gcp/infra.ts
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 },
});

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.

ops/gcp.op.ts
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()]),
],
});

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 — Storage buckets, PubSub topics and subscriptions, Secret Manager secrets, IAM service accounts, Cloud Run services.
  • Orders resources by their references so a dependency applies before its dependent.
  • Drives full CRUD, following long-running operations to completion where the API returns one.
  • Prunes orphans it owns — resources carrying the managed-by: chant label 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.

Requires Docker and curl on PATH.

Terminal window
cd examples/local-cloud-trio
npm install
chant run gcp

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.