Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL documentation / consistency fixes #3676

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Add PostgreSQL quota manager and storage backend by @robstradling in https://github.com/google/trillian/pull/3644
* PostgreSQL deployment example by @robstradling in https://github.com/google/trillian/pull/3675
* PostgreSQL documentation / consistency fixes by @robstradling in https://github.com/google/trillian/pull/3676

### Misc

Expand Down
13 changes: 5 additions & 8 deletions scripts/resetpgdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ $(basename $0) [--force] [--verbose] ...
All unrecognised arguments will be passed through to the 'psql' command.
Accepts environment variables:
- POSTGRESQL_ROOT_USER: A user with sufficient rights to create/reset the Trillian
database (default: root).
database (default: postgres).
- POSTGRESQL_ROOT_PASSWORD: The password for \$POSTGRESQL_ROOT_USER (default: none).
- POSTGRESQL_HOST: The hostname of the PostgreSQL} server (default: localhost).
- POSTGRESQL_HOST: The hostname of the PostgreSQL server (default: localhost).
- POSTGRESQL_PORT: The port the PostgreSQL server is listening on (default: 5432).
- POSTGRESQL_DATABASE: The name to give to the new Trillian user and database
(default: test).
(default: defaultdb).
- POSTGRESQL_USER: The name to give to the new Trillian user (default: test).
- POSTGRESQL_PASSWORD: The password to use for the new Trillian user
(default: zaphod).
- POSTGRESQL_USER_HOST: The host that the Trillian user will connect from; use '%' as
a wildcard (default: localhost).
- POSTGRESQL_IN_CONTAINER: If set, the script will assume it is running in a Docker
container and will exec into the container to operate.
container and will exec into the container to operate (default: false).
- POSTGRESQL_CONTAINER_NAME: The name of the Docker container to exec into (default:
pgsql).
EOF
Expand All @@ -39,7 +37,6 @@ collect_vars() {
[ -z ${POSTGRESQL_DATABASE+x} ] && POSTGRESQL_DATABASE="defaultdb"
[ -z ${POSTGRESQL_USER+x} ] && POSTGRESQL_USER="test"
[ -z ${POSTGRESQL_PASSWORD+x} ] && POSTGRESQL_PASSWORD="zaphod"
[ -z ${POSTGRESQL_USER_HOST+x} ] && POSTGRESQL_USER_HOST="localhost"
[ -z ${POSTGRESQL_INSECURE+x} ] && POSTGRESQL_INSECURE="true"
[ -z ${POSTGRESQL_IN_CONTAINER+x} ] && POSTGRESQL_IN_CONTAINER="false"
[ -z ${POSTGRESQL_CONTAINER_NAME+x} ] && POSTGRESQL_CONTAINER_NAME="pgsql"
Expand Down Expand Up @@ -103,7 +100,7 @@ main() {
$CMD "${FLAGS[@]}" -c "CREATE USER ${POSTGRESQL_USER} WITH PASSWORD '${POSTGRESQL_PASSWORD}';" || \
die "Error: Failed to create user '${POSTGRESQL_USER}'."
fi
$CMD "${FLAGS[@]}" -c "GRANT ALL PRIVILEGES ON DATABASE ${POSTGRESQL_DATABASE} TO ${POSTGRESQL_USER} WITH GRANT OPTION" || \
$CMD "${FLAGS[@]}" -c "GRANT ALL PRIVILEGES ON DATABASE ${POSTGRESQL_DATABASE} TO ${POSTGRESQL_USER} WITH GRANT OPTION;" || \
die "Error: Failed to grant '${POSTGRESQL_USER}' user all privileges on '${POSTGRESQL_DATABASE}'."
$CMD "${FLAGS[@]}" -d ${POSTGRESQL_DATABASE} < ${TRILLIAN_PATH}/storage/postgresql/schema/storage.sql || \
die "Error: Failed to create tables in '${POSTGRESQL_DATABASE}' database."
Expand Down
2 changes: 1 addition & 1 deletion storage/postgresql/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
postgreSQLURI = flag.String("postgresql_uri", "postgresql:///ctlog?host=localhost&user=ctlog", "Connection URI for PostgreSQL database")
postgreSQLURI = flag.String("postgresql_uri", "postgresql:///defaultdb?host=localhost&user=test", "Connection URI for PostgreSQL database")

postgresqlMu sync.Mutex
postgresqlErr error
Expand Down
Loading