Skip to content

Commit 1d184f1

Browse files
committed
Ran gofmt against all files
1 parent fe38cef commit 1d184f1

File tree

6 files changed

+44
-20
lines changed

6 files changed

+44
-20
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ lint-setup: _bin
5656

5757
_bin:
5858
mkdir -p "$(GO_BIN)"
59+
60+
format:
61+
gofmt -w -e .

driver/driver.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ func init() { //nolint:gochecknoinits
4949
// Note: Register behaves similarly to database/sql.Register except that it doesn't
5050
// panic on duplicate registrations, it just ignores them and continues.
5151
// The reason we Register drivers separately from database/sql is because
52-
// a) most DB drivers already call database/sql.Register in an init() func
53-
// b) we need to carry a lot more information along with the driver to ensure our
54-
// connector logic works correctly.
52+
//
53+
// a) most DB drivers already call database/sql.Register in an init() func
54+
// b) we need to carry a lot more information along with the driver to ensure our
55+
// connector logic works correctly.
5556
func Register(name string, f factory) error {
5657
driverMu.Lock()
5758
defer driverMu.Unlock()

store/awsrds/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ type Store struct {
3737

3838
// Config contains configuration information.
3939
type Config struct {
40+
Credentials aws.CredentialsProvider
4041
Endpoint string // Endpoint takes the form of host:port
4142
Region string
4243
User string
43-
Credentials aws.CredentialsProvider
4444
}
4545

4646
// NewStore creates a new RDS-backed store.
@@ -61,7 +61,7 @@ func NewStore(c *Config) (*Store, error) {
6161
return nil, &errMissingConfigItem{item: "user"}
6262
}
6363

64-
if !(strings.HasPrefix(c.Endpoint, "http://") || strings.HasPrefix(c.Endpoint, "https://")) {
64+
if !strings.HasPrefix(c.Endpoint, "http://") && !strings.HasPrefix(c.Endpoint, "https://") {
6565
c.Endpoint = "http://" + c.Endpoint
6666
}
6767

store/awsrds/store_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func TestStoreValidation(t *testing.T) {
2222
}
2323

2424
testCases := []struct {
25-
description string
26-
fields map[string]interface{}
2725
expectedErr error
26+
fields map[string]interface{}
27+
description string
2828
}{
2929
{
3030
description: "missing endpoint",
@@ -108,13 +108,15 @@ func TestStoreValidation(t *testing.T) {
108108
}
109109

110110
// If we have a pointer to an error we need to compare error strings
111-
if reflect.ValueOf(testCase.expectedErr).Kind() == reflect.Ptr && err.Error() != testCase.expectedErr.Error() {
111+
if reflect.ValueOf(testCase.expectedErr).Kind() == reflect.Ptr &&
112+
err.Error() != testCase.expectedErr.Error() {
112113
t.Fatalf("expected '%v' but got '%v' instead", testCase.expectedErr, err)
113114

114115
return
115116
}
116117

117-
if reflect.ValueOf(testCase.expectedErr).Kind() != reflect.Ptr && err != testCase.expectedErr {
118+
if reflect.ValueOf(testCase.expectedErr).Kind() != reflect.Ptr &&
119+
err != testCase.expectedErr {
118120
t.Fatalf("expected '%T' but got '%T' instead", testCase.expectedErr, err)
119121
}
120122
})
@@ -206,6 +208,7 @@ func TestStoreCachesCredentials(t *testing.T) {
206208
// NOTE: This is hacky as hell but necessary because the rdsutil.BuildAuthToken has a hard-coded
207209
// 15 minute expiration for each signed token. To ensure we don't repeatedly generate the same signing
208210
// token we need to wind the clock forward past the 15 minute window.
211+
// See https://github.com/aws/aws-sdk-go-v2/blob/main/feature/rds/auth/connect.go#L86
209212
var patch *monkey.PatchGuard
210213

211214
patch = monkey.Patch(time.Now, func() time.Time {
@@ -236,6 +239,10 @@ func TestStoreCachesCredentials(t *testing.T) {
236239
}
237240

238241
if password == refreshedCreds.GetPassword() {
239-
t.Fatal("cached password and refreshed password were the same but expected them not to be", password, refreshedCreds.GetPassword())
242+
t.Fatal(
243+
"cached password and refreshed password were the same but expected them not to be",
244+
password,
245+
refreshedCreds.GetPassword(),
246+
)
240247
}
241248
}

store/vault/example/helpers.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
8391
func 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

store/vault/vaulttest/vault.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
vaultclient "github.com/hashicorp/vault-client-go"
9-
"github.com/testcontainers/testcontainers-go"
109
"github.com/testcontainers/testcontainers-go/modules/vault"
1110
)
1211

@@ -22,10 +21,13 @@ type TokenCarryingClient struct {
2221
func CreateTestVault(ctx context.Context) (*TokenCarryingClient, *vault.VaultContainer, error) {
2322
rootToken := RandString(tokenLength)
2423

25-
vaultContainer, err := vault.RunContainer(ctx, vault.WithToken(rootToken), vault.WithInitCommand(
26-
"auth enable kubernetes", // Enable the kubernetes auth method
27-
),
28-
testcontainers.WithImage("hashicorp/vault:1.15.4"),
24+
vaultContainer, err := vault.Run(
25+
ctx,
26+
"hashicorp/vault:1.15.4",
27+
vault.WithToken(rootToken),
28+
vault.WithInitCommand(
29+
"auth enable kubernetes", // Enable the kubernetes auth method
30+
),
2931
)
3032
if err != nil {
3133
return nil, nil, err

0 commit comments

Comments
 (0)