@@ -20,7 +20,11 @@ import (
2020
2121// setupVault sets up a Vault server running in Docker then enables the plugins/configs we need for
2222// this example.
23- func setupVault (ctx context.Context , dbHost string , dbPort int ) (* vault.Client , func () error , error ) {
23+ func setupVault (
24+ ctx context.Context ,
25+ dbHost string ,
26+ dbPort int ,
27+ ) (* vault.Client , func () error , error ) {
2428 fmt .Println ("Creating testcontainers Vault instance" )
2529
2630 client , vaultContainer , err := vaulttest .CreateTestVault (ctx )
@@ -46,7 +50,11 @@ func setupVault(ctx context.Context, dbHost string, dbPort int) (*vault.Client,
4650 return nil , nil , err
4751 }
4852
49- uri := fmt .Sprintf ("postgresql://{{username}}:{{password}}@%s:%d/?sslmode=disable" , dbHost , dbPort )
53+ uri := fmt .Sprintf (
54+ "postgresql://{{username}}:{{password}}@%s:%d/?sslmode=disable" ,
55+ dbHost ,
56+ dbPort ,
57+ )
5058
5159 fmt .Println ("Configuring the postgres database and role" )
5260 // TODO: Switch this to using generated methods once the vault client implements the db-specific options
@@ -81,8 +89,8 @@ func setupVault(ctx context.Context, dbHost string, dbPort int) (*vault.Client,
8189
8290// setupDb sets up a test postgres database for use in the example.
8391func setupDb (ctx context.Context ) (* postgres.PostgresContainer , error ) {
84- return postgres .RunContainer (ctx ,
85- testcontainers . WithImage ( "docker.io/postgres:15.2-alpine" ) ,
92+ return postgres .Run (ctx ,
93+ "docker.io/postgres:15.2-alpine" ,
8694 postgres .WithDatabase (dbName ),
8795 postgres .WithUsername (username ),
8896 postgres .WithPassword (password ),
@@ -94,7 +102,10 @@ func setupDb(ctx context.Context) (*postgres.PostgresContainer, error) {
94102}
95103
96104// generateDriverConfig is a convenience method for generating a driver config from a testcontainer db
97- func generateDriverConfig (ctx context.Context , dbc * postgres.PostgresContainer ) (* driver.Config , error ) {
105+ func generateDriverConfig (
106+ ctx context.Context ,
107+ dbc * postgres.PostgresContainer ,
108+ ) (* driver.Config , error ) {
98109 connStr , err := dbc .ConnectionString (ctx , "sslmode=disable" )
99110 if err != nil {
100111 return nil , err
0 commit comments