Skip to content

Commit b21db06

Browse files
committed
Remove migration CLI command
1 parent 07d8aa2 commit b21db06

2 files changed

Lines changed: 7 additions & 32 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sudo apt-get install libtss2-dev swtpm tpm2-tools pkg-config
2424
cp config.example.toml config.toml # edit to taste
2525
docker compose -f docker-compose.postgres.yml up -d
2626
export AGENT_GATEWAY_DATABASE_URL=postgres://agent_gateway_admin:agent_gateway_dev@localhost:5432/agent_gateway
27-
cargo run -- --config config.toml migrate
27+
psql "$AGENT_GATEWAY_DATABASE_URL" -f migrations/0001_signed_authorization_registry.sql
2828
```
2929

3030
`generate-certs.sh` only creates **server** TLS material (`server-ca.pem`, `server.pem`, ...). Each agent platform enrolls with `./examples/demo-agent.sh`, which starts a local `swtpm`, creates a persistent P-256 signing key in that simulated TPM, and prepares `machine-client.pem` as a certificate carrier for that public key and identity extension. The gateway does not trust a client CA bundle; it authorizes the exact subject public key recorded in signed Postgres permission rows.
@@ -95,7 +95,7 @@ agent_gateway --config config.toml
9595
Run migrations explicitly before starting the gateway:
9696

9797
```bash
98-
agent_gateway --config config.toml migrate
98+
psql "$AGENT_GATEWAY_DATABASE_URL" -f migrations/0001_signed_authorization_registry.sql
9999
```
100100

101101
Gateway startup verifies the authorization registry schema version and fails fast if the database is not migrated. The runtime gateway database role should be read-only for authorization tables; use a separate admin role for migrations and registry writes.

src/main.rs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
1-
mod config;
2-
mod observability;
3-
mod policy;
4-
mod proxy;
5-
mod registry;
6-
mod tls;
7-
81
use std::path::PathBuf;
92
use std::str::FromStr;
103
use std::sync::Arc;
114

5+
use agent_gateway::policy::PostgresPolicyEngine;
6+
use agent_gateway::proxy::MakeProxyService;
7+
use agent_gateway::{config, observability, policy, proxy, registry, tls};
128
use anyhow::Context;
13-
use clap::{Parser, Subcommand};
9+
use clap::Parser;
1410
use hyper_util::rt::TokioExecutor;
1511
use sqlx::postgres::{PgConnectOptions, PgPool, PgPoolOptions};
1612
use tokio::net::TcpListener;
1713
use tracing::{error, info};
1814

19-
use crate::policy::PostgresPolicyEngine;
20-
use crate::proxy::MakeProxyService;
21-
2215
#[derive(Parser)]
2316
#[command(name = "agent_gateway", about = "mTLS HTTP/2 CONNECT proxy")]
2417
struct Cli {
2518
/// Path to the TOML configuration file
2619
#[arg(short, long, default_value = "config.toml")]
2720
config: PathBuf,
28-
29-
#[command(subcommand)]
30-
command: Option<CliCommand>,
31-
}
32-
33-
#[derive(Clone, Copy, Subcommand)]
34-
enum CliCommand {
35-
/// Run authorization registry database migrations and exit
36-
Migrate,
3721
}
3822

3923
#[tokio::main]
@@ -46,10 +30,7 @@ async fn main() -> anyhow::Result<()> {
4630
let config = config::Config::load(&cli.config)
4731
.with_context(|| format!("loading config from {}", cli.config.display()))?;
4832

49-
match cli.command {
50-
None => serve(config).await,
51-
Some(CliCommand::Migrate) => migrate(config).await,
52-
}
33+
serve(config).await
5334
}
5435

5536
async fn serve(config: config::Config) -> anyhow::Result<()> {
@@ -85,12 +66,6 @@ async fn serve(config: config::Config) -> anyhow::Result<()> {
8566
Ok(())
8667
}
8768

88-
async fn migrate(config: config::Config) -> anyhow::Result<()> {
89-
let db_pool = build_pg_pool(&config.policy).await?;
90-
registry::RegistryStore::run_migrations(&db_pool).await?;
91-
Ok(())
92-
}
93-
9469
async fn build_pg_pool(policy: &config::PolicyConfig) -> anyhow::Result<PgPool> {
9570
let database_url = policy.database_url()?;
9671
let connect_options = PgConnectOptions::from_str(&database_url)

0 commit comments

Comments
 (0)