Skip to content

Commit ba40614

Browse files
committed
chore: bump Go version to 1.24 and golangci-lint
1 parent d47c465 commit ba40614

21 files changed

+108
-72
lines changed

.github/workflows/golangci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414

1515
- name: Setup Go
1616
uses: actions/setup-go@v5
1717
with:
18-
go-version: 1.23.x
18+
go-version: 1.24.x
1919

2020
- run: go mod vendor
2121

2222
- name: Run golangci-lint
23-
uses: golangci/golangci-lint-action@v6
23+
uses: golangci/golangci-lint-action@v8
2424
with:
25-
version: v1.61
25+
version: v2.4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
name: Set up Go
2929
uses: actions/setup-go@v5
3030
with:
31-
go-version: '1.23'
31+
go-version: '1.24'
3232
-
3333
name: Import GPG key
3434
id: import_gpg

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@v5
2626
with:
27-
go-version: '1.23'
27+
go-version: '1.24'
2828

2929
- name: test
3030
run: make test

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: "2"
2+
13
run:
24
timeout: 5m
35

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/terraform-providers/terraform-provider-postgresql
22

3-
go 1.23.0
3+
go 1.24.0
44

5-
toolchain go1.23.2
5+
toolchain go1.24.2
66

77
require (
88
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1

postgresql/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (c *Client) Connect() (*DBConnection, error) {
302302
}
303303
if err != nil {
304304
errString := strings.Replace(err.Error(), c.config.Password, "XXXX", 2)
305-
return nil, fmt.Errorf("Error connecting to PostgreSQL server %s (scheme: %s): %s", c.config.Host, c.config.Scheme, errString)
305+
return nil, fmt.Errorf("error connecting to PostgreSQL server %s (scheme: %s): %s", c.config.Host, c.config.Scheme, errString)
306306
}
307307

308308
// We don't want to retain connection
@@ -365,17 +365,17 @@ func openImpersonatedGCPDBConnection(ctx context.Context, dsn string, targetServ
365365
Scopes: []string{"https://www.googleapis.com/auth/sqlservice.admin"},
366366
})
367367
if err != nil {
368-
return nil, fmt.Errorf("Error creating token source with service account impersonation of %s: %w", targetServiceAccountEmail, err)
368+
return nil, fmt.Errorf("error creating token source with service account impersonation of %s: %w", targetServiceAccountEmail, err)
369369
}
370370
client, err := gcp.NewHTTPClient(gcp.DefaultTransport(), ts)
371371
if err != nil {
372-
return nil, fmt.Errorf("Error creating HTTP client with service account impersonation of %s: %w", targetServiceAccountEmail, err)
372+
return nil, fmt.Errorf("error creating HTTP client with service account impersonation of %s: %w", targetServiceAccountEmail, err)
373373
}
374374
certSource := cloudsql.NewCertSourceWithIAM(client, ts)
375375
opener := gcppostgres.URLOpener{CertSource: certSource}
376376
dbURL, err := url.Parse(dsn)
377377
if err != nil {
378-
return nil, fmt.Errorf("Error parsing connection string: %w", err)
378+
return nil, fmt.Errorf("error parsing connection string: %w", err)
379379
}
380380
return opener.OpenPostgresURL(ctx, dbURL)
381381
}

postgresql/data_source_postgresql_schemas.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package postgresql
22

33
import (
44
"fmt"
5+
"log"
56
"strconv"
67
"strings"
78

@@ -103,7 +104,11 @@ func dataSourcePostgreSQLSchemasRead(db *DBConnection, d *schema.ResourceData) e
103104
if err != nil {
104105
return err
105106
}
106-
defer rows.Close()
107+
defer func() {
108+
if err := rows.Close(); err != nil {
109+
log.Printf("error closing rows: %v", err)
110+
}
111+
}()
107112

108113
schemas := []string{}
109114
for rows.Next() {

postgresql/data_source_postgresql_sequences.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package postgresql
22

33
import (
44
"fmt"
5+
"log"
56
"strings"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -102,7 +103,11 @@ func dataSourcePostgreSQLSequencesRead(db *DBConnection, d *schema.ResourceData)
102103
if err != nil {
103104
return err
104105
}
105-
defer rows.Close()
106+
defer func() {
107+
if err := rows.Close(); err != nil {
108+
log.Printf("error closing rows: %v", err)
109+
}
110+
}()
106111

107112
sequences := make([]interface{}, 0)
108113
for rows.Next() {

postgresql/data_source_postgresql_tables.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package postgresql
22

33
import (
44
"fmt"
5+
"log"
56
"strings"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -110,7 +111,11 @@ func dataSourcePostgreSQLTablesRead(db *DBConnection, d *schema.ResourceData) er
110111
if err != nil {
111112
return err
112113
}
113-
defer rows.Close()
114+
defer func() {
115+
if err := rows.Close(); err != nil {
116+
log.Printf("error closing rows: %v\n", err)
117+
}
118+
}()
114119

115120
tables := make([]interface{}, 0)
116121
for rows.Next() {

postgresql/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func grantRoleMembership(db QueryAble, role, member string) (bool, error) {
107107

108108
sql := fmt.Sprintf("GRANT %s TO %s", pq.QuoteIdentifier(role), pq.QuoteIdentifier(member))
109109
if _, err := db.Exec(sql); err != nil {
110-
return false, fmt.Errorf("Error granting role %s to %s: %w", role, member, err)
110+
return false, fmt.Errorf("error granting role %s to %s: %w", role, member, err)
111111
}
112112
return true, nil
113113
}
@@ -131,7 +131,7 @@ func revokeRoleMembership(db QueryAble, role, member string) (bool, error) {
131131

132132
sql := fmt.Sprintf("REVOKE %s FROM %s", pq.QuoteIdentifier(role), pq.QuoteIdentifier(member))
133133
if _, err := db.Exec(sql); err != nil {
134-
return false, fmt.Errorf("Error revoking role %s from %s: %w", role, member, err)
134+
return false, fmt.Errorf("error revoking role %s from %s: %w", role, member, err)
135135
}
136136
return true, nil
137137
}

0 commit comments

Comments
 (0)