Documentation
¶
Overview ¶
Package sql emulates Cloud SQL for PostgreSQL (SRS 5.6). The control plane is the sqladmin REST API (v1beta4 and v1) with its own Operation resource; each instance's data plane is a real PostgreSQL server in a container whose entrypoint is the gcpemu sql-proxy agent (package proxy), which enforces authorized networks, SSL modes and IAM database authentication and terminates the Cloud SQL connector's TLS on port 3307.
Index ¶
- func New(env *emu.Env) emu.Service
- type Service
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) EnvVars(gateway string, _ map[string]string) map[string]string
- func (s *Service) HostAddrs() map[string]string
- func (s *Service) InstanceRegion(project, instance string) (string, error)
- func (s *Service) Name() string
- func (s *Service) Operations() []emu.OperationInfo
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) ReservedAddrs() []string
- func (s *Service) Reset(ctx context.Context) error
- func (s *Service) ResourceCounts() map[string]int
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) SetUserPassword(ctx context.Context, project, instance, user, password string) error
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Cloud SQL service module.
func (*Service) EnvVars ¶
EnvVars implements emu.EnvVarer. gcloud's sql API client uses base URL https://sqladmin.googleapis.com/ with paths "sql/v1beta4/...", so the override is the "/sqladmin/" mount (which also accepts the version-less form). Each instance's published PostgreSQL port is exported as GCPEMU_SQL_<INSTANCE> (upper-cased, '-' → '_') = host:port.
func (*Service) HostAddrs ¶
HostAddrs returns "P/I" → host:port of every instance's published PostgreSQL port.
func (*Service) InstanceRegion ¶ added in v0.3.0
InstanceRegion implements emu.SQLUsers.
func (*Service) Operations ¶ added in v0.2.0
func (s *Service) Operations() []emu.OperationInfo
Operations implements emu.OperationLister.
func (*Service) Ready ¶
Ready reports not-ready while instances are being recovered after a restart.
func (*Service) Register ¶
Register mounts the API: "/sql/v1beta4/..." at the gateway root (gcloud, OpenTofu and the Cloud SQL connector address it there) and everything (v1beta4, v1 and the agent endpoint) under "/sqladmin/" and in host mode for sqladmin.googleapis.com.
func (*Service) ReservedAddrs ¶ added in v0.4.0
ReservedAddrs implements emu.AddressReserver: the public and private IPs instances ask for again when their containers are recreated.
func (*Service) ResourceCounts ¶ added in v0.2.0
ResourceCounts implements emu.ResourceCounter.
func (*Service) ServeHTTP ¶
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes the sqladmin REST API. Both API versions share one implementation (the resource shapes are identical): v1beta4 at "/sql/v1beta4/..." (gcloud, OpenTofu, the Cloud SQL connector) and v1 at "/v1/..." (google.golang.org/api/sqladmin/v1). The agent endpoint lives at "/_agent/v1/...".
func (*Service) SetUserPassword ¶ added in v0.3.0
func (s *Service) SetUserPassword(ctx context.Context, project, instance, user, password string) error
SetUserPassword implements emu.SQLUsers: it sets a built-in user's password as users.update would, without an Operation.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
genflags
command
Command genflags generates Cloud SQL for PostgreSQL's database flag allow-list (FR-SQL-003) from Google's documentation:
|
Command genflags generates Cloud SQL for PostgreSQL's database flag allow-list (FR-SQL-003) from Google's documentation: |
|
Package proxy is the Cloud SQL in-container agent (FR-SQL-004..007).
|
Package proxy is the Cloud SQL in-container agent (FR-SQL-004..007). |