The Simplest Way to Make Gogs and Spanner Work Like They Should
You pair gogs and spanner by running schema migrations from git webhooks. Gogs stores your code and triggers jobs that update your Spanner tables. Teams use Gogs as a fast, self-hosted git server for their code. They use Google Cloud Spanner as a global SQL database for their apps. Linking them lets developers push schema changes through normal code reviews. A merge in Gogs triggers a runner that applies the change to Spanner. This setup stops manual database edits and keeps every change in ver
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You pair gogs and spanner by running schema migrations from git webhooks. Gogs stores your code and triggers jobs that update your Spanner tables.
Teams use Gogs as a fast, self-hosted git server for their code. They use Google Cloud Spanner as a global SQL database for their apps. Linking them lets developers push schema changes through normal code reviews. A merge in Gogs triggers a runner that applies the change to Spanner. This setup stops manual database edits and keeps every change in version control.
How data and roles flow between gogs and spanner
Gogs does not talk to Cloud Spanner out of the box. Gogs needs a local SQL or Postgres database for its own state. Your build runner bridges the gap between your Gogs server and Spanner. When a developer merges a pull request, Gogs sends a webhook event. The build runner catches this event and pulls the latest migration files.
Next, the runner logs in to Google Cloud using a service account. Cloud IAM checks the role attached to that service account before allowing queries. If the role allows schema updates, Spanner runs the new SQL statements. The runner then sends the pass or fail status back to Gogs. Developers see the result right inside their pull request page.
Common failure modes and how to scope access
Many teams make mistakes when they first link these two systems. The biggest mistake is using one shared service account with broad permissions. Teams often put a static JSON key file inside the Gogs runner. If someone leaks that key, an attacker can read or delete production data. Broad roles also let a bad script drop tables by mistake.
Another common issue is unlogged queries during debug sessions. When a build fails, an engineer might log in with that same shared key. The database logs then show the service account name, not the human user. Security teams cannot tell who ran a query or changed a row. If those tables hold emails, phone numbers, or card numbers, audits fail.
You can fix these risks by scoping roles and network paths tightly. First, split your service accounts by task and stage. Give your Gogs test runner a role that only touches test databases. Give your production runner a role that only runs schema changes, not data reads. Second, drop static JSON keys and use workload identity where you can.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Setting up safe schema reviews and network rules
Good network rules keep your git server and database safe from outside traffic. Run your Gogs server and build runners inside a private network. Use private Google access so Spanner traffic never crosses the public internet. Set firewall rules so only the build runner can reach the database API. Block direct database traffic from developer laptops.
You should also enforce branch rules inside Gogs before any job runs. Require at least one peer review on every pull request that touches SQL files. Set up a check that tests the SQL syntax before merging to main. Only allow the main branch to trigger jobs that touch production Spanner instances. This keeps bad queries out of your live tables.
Finally, plan how your team handles emergency database fixes and data checks. Developers sometimes need to inspect live rows when an app breaks. Do not hand out permanent database keys for these rare tasks. Require user identity checks for every query and mask sensitive fields in results. Rewriting emails or national IDs in query results keeps customer data safe during debugging.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can Gogs use Cloud Spanner as its own backing database?
No, Gogs does not support Cloud Spanner for its own internal storage. You should run Gogs on a standard MySQL, Postgres, or SQLite database instead.
How should a Gogs runner log in to Spanner?
Use short-lived tokens through Google Cloud workload identity federation instead of static keys. Assign a dedicated service account with the smallest possible IAM role for the job.
How do we protect PII in Spanner during developer debug sessions?
Tie every database session to an individual user identity and turn on data masking. Data masking rewrites matched fields like phone numbers or card numbers in query results.
Related guides
In this post