feat(datastore): Adopt LabKit infrastructure configuration.

feat(datastore): Adopt LabKit infrastructure configuration.

Rewire NewAppClient to delegate to postgres.New(), which loads its PostgreSQL configuration and credentials from the LabKit infrastructure config at the well-known /etc/labkit/infrastructure.yaml path. Service operators now configure the database via the Fairway-generated Helm chart instead of a hand-rolled Config struct passed in by the caller.

NewAppClient's signature changes from (Config, *trace.Tracer) to (context.Context, ...postgres.NewOption), exposing LabKit's option-based API directly to callers. The logical database name is now set from the parsed DSN. Integration tests construct an *infrastructure.Config from the test container DSN via the configFromDSN helper and pass it through postgres.WithInfrastructure. The helper uses the CNPG-style MemoryProvider secret format, populating host, port, and dbname alongside a SecretRef that points to the CNPG format, aligning the test setup with the updated infrastructure.Config contract. configFromDSN returns (*Config, error) so it can be called outside test context, and infraConfig is built once in TestMain as a package-level var. paralleltest is disabled file-wide since it applies to all infrastructure tests. The DSN is no longer printed to STDERR, since it contains credentials.

NewMigrationClient is intentionally left on the legacy DSN-based path: the migration client needs a direct-to-PostgreSQL connection (advisory locks are session-level and break under PgBouncer transaction pooling), which the shared infrastructure config cannot yet express. Its signature is simplified to take a bare dsn string since the surrounding Config struct is no longer needed, and QueryExecMode is now set explicitly to pgx.QueryExecModeSimpleProtocol rather than relying on the LabKit default. The TODO(pgbouncer-split) markers remain.

The corresponding Config struct and its now-redundant *_EmptyDSN / *_InvalidDSN tests for NewAppClient are removed; equivalent coverage for NewMigrationClient is retained. The ErrNotConfigured error return from the new API path is documented.

Issue: gitlab-com/gl-infra/platform/runway/team#884 (closed)

Edited by Florian Forster

Merge request reports

Loading
Loading