Commit Graph

1 Commits

Author SHA1 Message Date
Robert Lin
63403f2a16
sg: add 'sg msp postgresql connect' (#59106)
This change introduces an `mi2`-like experience for interacting with MSP databases. By default we use the new readonly-SA introduced in https://github.com/sourcegraph/sourcegraph/pull/59105, otherwise with the `--write-access` flag you can connect as the same user as the Cloud Run workload, which gives a lot more permissions.

An alias, `sg msp pg connect`, is available for those less inclined to type out the entire `postgresql` subcommand name.

Closes https://github.com/sourcegraph/managed-services/issues/207

## Test plan

Applied to `msp-testbed`, which has a PG instance and provisioned tables.
Try both service accounts:

```
sg msp pg connect --write-access msp-testbed test
sg msp pg connect msp-testbed test 
```

![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/c75bcb8c-5f7d-4f3b-90ec-9effb3306ba9)

With both of the above:

```
primary=> select * from users;
 id | created_at | updated_at | deleted_at | external_id | name | avatar_url 
----+------------+------------+------------+-------------+------+------------
(0 rows)
```
2023-12-20 14:53:34 -08:00