forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(postgres): ssl for postgres (testcontainers#2473)
* SSL for postgres * Add entrypoint wrapper * Add in init so we can test ssl+init path * Remove unused fields from options * Remove unused consts * Separate entrypoint from ssl * Use external cert generation * Make entrypoint not-optional * Add docstring * Spaces to tab in entrypoint * Add postgres ssl docs * Remove WithEntrypoint * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Embed resources + Use custom conf automatically * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update docs/modules/postgres.md Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Revert to use passed in conf * Update doc for required conf * Error checking in the customizer * Few formatting fix * Use non-nil error when err is nil * Update modules/postgres/postgres_test.go Co-authored-by: Steven Hartland <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Steven Hartland <[email protected]> * Update modules/postgres/postgres.go Co-authored-by: Steven Hartland <[email protected]> * Update modules/postgres/postgres.go Co-authored-by: Steven Hartland <[email protected]> * Update modules/postgres/postgres_test.go Co-authored-by: Steven Hartland <[email protected]> * Addresses review modulo cleanup * Remove unused type * Use ContainerCleanup * Lint pass * Add t.Helper and Linting * Remove SSLSetting struct, use raw paths * Use single command for chown key material * docs: remove spaces * fix: use non-deprecated APIs * chore: rename variable --------- Co-authored-by: bstrausser <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]> Co-authored-by: Steven Hartland <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]>
- Loading branch information
1 parent
6ec91f1
commit 3330dc1
Showing
7 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -Eeo pipefail | ||
|
||
|
||
pUID=$(id -u postgres) | ||
pGID=$(id -g postgres) | ||
|
||
if [ -z "$pUID" ] | ||
then | ||
echo "Unable to find postgres user id, required in order to chown key material" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$pGID" ] | ||
then | ||
echo "Unable to find postgres group id, required in order to chown key material" | ||
exit 1 | ||
fi | ||
|
||
chown "$pUID":"$pGID" \ | ||
/tmp/testcontainers-go/postgres/ca_cert.pem \ | ||
/tmp/testcontainers-go/postgres/server.cert \ | ||
/tmp/testcontainers-go/postgres/server.key | ||
|
||
/usr/local/bin/docker-entrypoint.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ----------------------------- | ||
# PostgreSQL configuration file | ||
# ----------------------------- | ||
# | ||
# This file consists of lines of the form: | ||
# | ||
# name = value | ||
# | ||
# (The "=" is optional.) Whitespace may be used. Comments are introduced with | ||
# "#" anywhere on a line. The complete list of parameter names and allowed | ||
# values can be found in the PostgreSQL documentation. | ||
# | ||
# The commented-out settings shown in this file represent the default values. | ||
# Re-commenting a setting is NOT sufficient to revert it to the default value; | ||
# you need to reload the server. | ||
# | ||
# This file is read on server startup and when the server receives a SIGHUP | ||
# signal. If you edit the file on a running system, you have to SIGHUP the | ||
# server for the changes to take effect, run "pg_ctl reload", or execute | ||
# "SELECT pg_reload_conf()". Some parameters, which are marked below, | ||
# require a server shutdown and restart to take effect. | ||
# | ||
# Any parameter can also be given as a command-line option to the server, e.g., | ||
# "postgres -c log_connections=on". Some parameters can be changed at run time | ||
# with the "SET" SQL command. | ||
# | ||
# Memory units: B = bytes Time units: ms = milliseconds | ||
# kB = kilobytes s = seconds | ||
# MB = megabytes min = minutes | ||
# GB = gigabytes h = hours | ||
# TB = terabytes d = days | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# FILE LOCATIONS | ||
#------------------------------------------------------------------------------ | ||
|
||
# The default values of these variables are driven from the -D command-line | ||
# option or PGDATA environment variable, represented here as ConfigDir. | ||
|
||
#data_directory = 'ConfigDir' # use data in another directory | ||
# (change requires restart) | ||
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file | ||
# (change requires restart) | ||
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file | ||
# (change requires restart) | ||
|
||
# If external_pid_file is not explicitly set, no extra PID file is written. | ||
#external_pid_file = '' # write an extra PID file | ||
# (change requires restart) | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# CONNECTIONS AND AUTHENTICATION | ||
#------------------------------------------------------------------------------ | ||
|
||
# - Connection Settings - | ||
|
||
listen_addresses = '*' | ||
# comma-separated list of addresses; | ||
# defaults to 'localhost'; use '*' for all | ||
# (change requires restart) | ||
#port = 5432 # (change requires restart) | ||
#max_connections = 100 # (change requires restart) | ||
|
||
# - SSL - | ||
|
||
ssl = on | ||
ssl_ca_file = '/tmp/testcontainers-go/postgres/ca_cert.pem' | ||
ssl_cert_file = '/tmp/testcontainers-go/postgres/server.cert' | ||
#ssl_crl_file = '' | ||
ssl_key_file = '/tmp/testcontainers-go/postgres/server.key' | ||
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers | ||
#ssl_prefer_server_ciphers = on | ||
#ssl_ecdh_curve = 'prime256v1' | ||
#ssl_dh_params_file = '' | ||
#ssl_passphrase_command = '' | ||
#ssl_passphrase_command_supports_reload = off | ||
|
||
|