https://github.com/frederikhs/pg_user
a cli application for managing postgres users using .pgpass
https://github.com/frederikhs/pg_user
cli go postgres
Last synced: 5 months ago
JSON representation
a cli application for managing postgres users using .pgpass
- Host: GitHub
- URL: https://github.com/frederikhs/pg_user
- Owner: frederikhs
- License: gpl-3.0
- Created: 2022-12-05T22:53:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-29T11:01:38.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T08:15:20.407Z (over 1 year ago)
- Topics: cli, go, postgres
- Language: Go
- Homepage:
- Size: 91.8 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# pg_user
[](https://github.com/frederikhs/pg_user/releases/latest)
[](https://godoc.org/github.com/frederikhs/pg_user)
[](https://goreportcard.com/report/github.com/frederikhs/pg_user)
[](https://github.com/frederikhs/pg_user/actions/workflows/test.yml)
Is a cli application for managing postgres users.
Features
- Creating new users with roles
- Deleting existing users
- Extending the validity of existing users
- Resetting passwords (random or specific) of existing users
- Listing existing users and their associated roles
- Listing all configured hosts
- Listing existing roles
## Installation
### Linux amd64
```bash
# install
curl -L https://github.com/frederikhs/pg_user/releases/latest/download/pg_user_Linux_x86_64.tar.gz -o pg_user.tar.gz
tar -xvf pg_user.tar.gz
sudo chmod +x pg_user
sudo mv pg_user /usr/local/bin/pg_user
# clean up
rm pg_user.tar.gz
```
### Other
Other distributions or OS visit the [releases page](https://github.com/frederikhs/pg_user/releases/latest)
## Configuration
`pg_user` uses the format and location of the `.pgpass` file the resides in the `$HOME` directory of the user running the program.
---
Example of a host details in the `.pgpass` format
```
::::
```
## Examples of usage
`$ pg_user add test@example.org --host mydatabase.com`
This requires the hostname `mydatabase.com` must be configured in the `.pgpass` file
To also add roles to the user when creating use
`$ pg_user add test@example.org --host mydatabase.com --roles role1,role2`
## Development
This repository is very plain and simple and development of the application only required `go`.
`$ go run main.go hosts` will compile the application and list all configured hosts in your `.pgpass` file.
## Release
release a new version by creating a tag and pushing it, then goreleaser will do the rest
```bash
git tag -a v0.x.0 -m "v0.x.0"
git push origin v0.x.0
```