Skip to content

Conversation

@ivanauth
Copy link
Contributor

@ivanauth ivanauth commented Oct 10, 2025

Fixes #2218

Summary

Adds individual connection parameter flags as an alternative to --datastore-conn-uri for easier configuration from Kubernetes secrets or environment variables.

New Flags

  • --datastore-host: database host
  • --datastore-port: database port (defaults: 5432 for Postgres/CRDB, 3306 for MySQL)
  • --datastore-username: database username
  • --datastore-password: database password
  • --datastore-database: database name

Features

  • Auto-builds connection URI from granular params when --datastore-conn-uri is not provided
  • Supports Postgres, CockroachDB, and MySQL
  • Full backward compatibility with existing --datastore-conn-uri flag
  • URI takes precedence if both provided

Example Usage

spicedb serve \
  --datastore-engine=postgres \
  --datastore-host=localhost \
  --datastore-port=5432 \
  --datastore-username=spicedb \
  --datastore-password=secret \
  --datastore-database=spicedb

@ivanauth ivanauth requested a review from a team as a code owner October 10, 2025 14:25
@github-actions github-actions bot added area/cli Affects the command line area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Oct 10, 2025
@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.57%. Comparing base (dad989c) to head (bfd967f).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cmd/datastore/datastore.go 85.72% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2604      +/-   ##
==========================================
+ Coverage   77.07%   77.57%   +0.51%     
==========================================
  Files         466      471       +5     
  Lines       49199    49606     +407     
==========================================
+ Hits        37914    38476     +562     
+ Misses       8502     8279     -223     
- Partials     2783     2851      +68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ivanauth ivanauth force-pushed the feature/granular-datastore-flags branch from 2f8ef15 to ed8f808 Compare November 26, 2025 05:00
@github-actions github-actions bot added the area/schema Affects the Schema Language label Nov 26, 2025
Add individual connection parameter flags as an alternative to
--datastore-conn-uri for easier configuration from Kubernetes secrets
or environment variables.

New flags: --datastore-host, --datastore-port, --datastore-username,
--datastore-password, --datastore-database

- Auto-builds connection URI from granular params when URI not provided
- Supports Postgres, CockroachDB, and MySQL
- Sets default ports (5432 for Postgres/CRDB, 3306 for MySQL)
- Full backward compatibility with existing --datastore-conn-uri flag
- Comprehensive test coverage

Fixes authzed#2218
@ivanauth ivanauth force-pushed the feature/granular-datastore-flags branch from ed8f808 to 2f8d85b Compare December 2, 2025 15:04
@github-actions github-actions bot removed the area/schema Affects the Schema Language label Dec 2, 2025
@ivanauth ivanauth force-pushed the feature/granular-datastore-flags branch 2 times, most recently from bfd967f to a771834 Compare December 13, 2025 02:34
- MySQL: Use DSN format (user:pass@tcp(host:port)/db?parseTime=true)
  instead of URI format (mysql://...) which is incompatible with driver
- CockroachDB: Use correct default port 26257 instead of 5432
- URL encode credentials for Postgres/CockroachDB to handle special chars
- Update tests to use correct MySQL DSN format
@ivanauth ivanauth force-pushed the feature/granular-datastore-flags branch from a771834 to 42cb4ce Compare January 8, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Affects the command line area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Granular Flags/Vars for Datastore Connections

1 participant