pg-spot-ops / pg-spot-operator

Maintains stateful Postgres on Spot VMs
Other
2 stars 0 forks source link

New feature: --connstr-output-only mode #24

Closed kmoppel closed 6 days ago

kmoppel commented 1 week ago

Ensure VM, set up Postgres, print connstr and exit. Helps with all kinds of integrations / pipelines

$ python3 -m pg_spot_operator --verbose  --instance-name pg1 --region eu-north-1 --cpu-min 2 --storage-type local --storage-min 100 --admin-user pgso --admin-user-password pgsopass  --connstr-output-only
postgresql://pgso:pgsopass@13.53.43.27:5432/postgres?sslmode=require
kmoppel commented 1 week ago

Fixes https://github.com/pg-spot-ops/pg-spot-operator/issues/19

kmoppel commented 1 week ago

Actually needs probably a JDBC version also to be useful for everyone. Two separate flags probably OK as there's probably no 3rd common connectstring option, right @scorpevans ?

https://tembo.io/docs/getting-started/postgres_guides/connecting-to-postgres-with-java

scorpevans commented 6 days ago

Actually needs probably a JDBC version also to be useful for everyone. Two separate flags probably OK as there's probably no 3rd common connectstring option, right @scorpevans ?

https://tembo.io/docs/getting-started/postgres_guides/connecting-to-postgres-with-java

then probably you can return a dict with the different types:

{
jdbc: {connstring:}
postgresql: {connstring: postgresql://pgso:pgsopass@13.53.43.27:5432/postgres?sslmode=require}
}
kmoppel commented 6 days ago

Hmm, I'm on the fence on returning an object also...maybe still too premature to solve it even, given that the current users mostly will be power users, they could probably glue the "jdbc:" prefix via some pipe a la ... --connstr-output-only | sed -E 's/(.*)/jdbc:\1/'