Skip to content

Commit f181e1c

Browse files
authored
update deps, remove old errors and replace ioutils (#48)
1 parent c719a8b commit f181e1c

File tree

9 files changed

+211
-191
lines changed

9 files changed

+211
-191
lines changed

go.mod

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/Masterminds/squirrel v1.5.0
77
github.com/ghodss/yaml v1.0.0
88
github.com/gogo/status v1.1.0
9-
github.com/golang/protobuf v1.5.2 // indirect
109
github.com/google/go-cmp v0.5.6
1110
github.com/google/uuid v1.2.0
1211
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
@@ -16,19 +15,14 @@ require (
1615
github.com/lib/pq v1.10.2
1716
github.com/lopezator/migrator v0.3.0
1817
github.com/metal-stack/metal-lib v0.8.0
19-
github.com/metal-stack/security v0.5.3
18+
github.com/metal-stack/security v0.6.0
2019
github.com/metal-stack/v v1.0.3
21-
github.com/pkg/errors v0.9.1
22-
github.com/prometheus/client_golang v1.10.0
23-
github.com/spf13/cobra v1.1.3
24-
github.com/spf13/viper v1.7.1
20+
github.com/prometheus/client_golang v1.11.0
21+
github.com/spf13/cobra v1.2.1
22+
github.com/spf13/viper v1.8.1
2523
github.com/stretchr/testify v1.7.0
26-
github.com/testcontainers/testcontainers-go v0.11.0
27-
go.uber.org/zap v1.17.0
28-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
29-
google.golang.org/grpc v1.38.0
30-
google.golang.org/protobuf v1.26.0
24+
github.com/testcontainers/testcontainers-go v0.11.1
25+
go.uber.org/zap v1.18.1
26+
google.golang.org/grpc v1.39.0
27+
google.golang.org/protobuf v1.27.1
3128
)
32-
33-
// required because by default viper depends on etcd v3.3.10 which has a corrupt sum
34-
replace github.com/coreos/etcd => github.com/coreos/etcd v3.3.18+incompatible

go.sum

Lines changed: 186 additions & 158 deletions
Large diffs are not rendered by default.

pkg/client/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"crypto/tls"
66
"crypto/x509"
7+
"errors"
78
"fmt"
8-
"io/ioutil"
9+
"os"
910

1011
"github.com/metal-stack/masterdata-api/pkg/auth"
11-
"github.com/pkg/errors"
1212
"google.golang.org/grpc"
1313
"google.golang.org/grpc/credentials"
1414

@@ -41,7 +41,7 @@ func NewClient(ctx context.Context, hostname string, port int, certFile string,
4141
}
4242

4343
if caFile != "" {
44-
ca, err := ioutil.ReadFile(caFile)
44+
ca, err := os.ReadFile(caFile)
4545
if err != nil {
4646
return nil, fmt.Errorf("could not read ca certificate: %w", err)
4747
}
@@ -76,7 +76,7 @@ func NewClient(ctx context.Context, hostname string, port int, certFile string,
7676
// Set up the credentials for the connection.
7777
perRPCHMACAuthenticator, err := auth.NewHMACAuther(logger, hmacKey, auth.EditUser)
7878
if err != nil {
79-
return nil, errors.Wrap(err, "failed to create hmac-authenticator")
79+
return nil, fmt.Errorf("failed to create hmac-authenticator: %w", err)
8080
}
8181

8282
opts := []grpc.DialOption{

pkg/datastore/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"io/ioutil"
7+
"os"
88
"path"
99
"path/filepath"
1010
"reflect"
@@ -61,7 +61,7 @@ func splitYamlDocs(doc string) []string {
6161

6262
// processConfig processes all yaml docs contained in the given file
6363
func (ds *Datastore) processConfig(file string) error {
64-
yaml, err := ioutil.ReadFile(file)
64+
yaml, err := os.ReadFile(file)
6565
if err != nil {
6666
return err
6767
}

pkg/datastore/dberrors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package datastore
22

33
import (
4+
"errors"
5+
46
"github.com/lib/pq"
5-
"github.com/pkg/errors"
67
)
78

89
// OptimisticLockError indicates that the operation could not be executed because the dataset to update has changed in the meantime.

pkg/datastore/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package datastore
33
import (
44
"context"
55
"database/sql"
6+
"errors"
67
"fmt"
78
"reflect"
89
"time"
@@ -13,7 +14,6 @@ import (
1314
"github.com/google/uuid"
1415
"github.com/jmoiron/sqlx"
1516
v1 "github.com/metal-stack/masterdata-api/api/v1"
16-
"github.com/pkg/errors"
1717
"go.uber.org/zap"
1818

1919
// import for sqlx to use postgres driver
@@ -198,7 +198,7 @@ func (ds *Datastore) Update(ctx context.Context, ve VersionedJSONEntity) error {
198198

199199
err := ds.Get(ctx, id, existingVE)
200200
if err != nil {
201-
return errors.Errorf("update - no entity of type:%s with id:%s found", jsonField, id)
201+
return fmt.Errorf("update - no entity of type:%s with id:%s found", jsonField, id)
202202
}
203203

204204
if ve.GetMeta().GetVersion() < existingVE.GetMeta().GetVersion() {

pkg/datastore/postgres_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func TestUpdate(t *testing.T) {
352352
}
353353
err = ds.Update(ctx, tcr1)
354354
assert.Error(t, err)
355-
assert.EqualError(t, err, "entity of type:tenant has no id, cannot update: meta:{} name:\"ctenant\" description:\"C Tenant\"")
355+
assert.EqualError(t, err, "entity of type:tenant has no id, cannot update: meta:{} name:\"ctenant\" description:\"C Tenant\"")
356356

357357
// tenant with id is not found
358358
tcr1 = &v1.Tenant{

pkg/gen/genscanvaluer.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ import (
1414
"flag"
1515
"fmt"
1616
"go/format"
17-
"io/ioutil"
1817
"log"
1918
"os"
2019
"path/filepath"
2120
"strings"
2221
"text/template"
2322

24-
errs "github.com/pkg/errors"
2523
"go.uber.org/zap"
2624
)
2725

@@ -72,7 +70,7 @@ func main() {
7270
baseName := fmt.Sprintf("%s%s", *typeName, defaultFilenameSuffix)
7371
outputName = filepath.Join(dir, strings.ToLower(baseName))
7472
}
75-
err = ioutil.WriteFile(outputName, src, 0644)
73+
err = os.WriteFile(outputName, src, 0644)
7674
if err != nil {
7775
log.Fatal("error writing output", zap.Error(err))
7876
}
@@ -92,11 +90,11 @@ func (g *Generator) generate(packageName, typeName string) error {
9290

9391
tmpl, err := template.New("sv").Parse(svTemplate)
9492
if err != nil {
95-
return errs.Wrapf(err, "error parsing template %s", svTemplate)
93+
return fmt.Errorf("error parsing template %s error: %w", svTemplate, err)
9694
}
9795
stmpl, err := template.New("sv").Parse(schemaTemplate)
9896
if err != nil {
99-
return errs.Wrapf(err, "error parsing template %s", schemaTemplate)
97+
return fmt.Errorf("error parsing template %s error: %w", schemaTemplate, err)
10098
}
10199

102100
info := map[string]string{
@@ -109,15 +107,15 @@ func (g *Generator) generate(packageName, typeName string) error {
109107
var renderedBytesSchema bytes.Buffer
110108
err = stmpl.Execute(&renderedBytesSchema, info)
111109
if err != nil {
112-
return errs.Wrap(err, "error rendering template")
110+
return fmt.Errorf("error rendering template: %w", err)
113111
}
114112

115113
info["schema"] = fmt.Sprintf("`%s`", renderedBytesSchema.String())
116114

117115
var renderedBytes bytes.Buffer
118116
err = tmpl.Execute(&renderedBytes, info)
119117
if err != nil {
120-
return errs.Wrap(err, "error rendering template")
118+
return fmt.Errorf("error rendering template: %w", err)
121119
}
122120

123121
g.Printf("%s", renderedBytes.String())

server/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/tls"
55
"crypto/x509"
66
"fmt"
7-
"io/ioutil"
87
"net"
98
"net/http"
109
_ "net/http/pprof" //nolint:gosec
@@ -123,7 +122,7 @@ func run() {
123122

124123
if caFile != "" {
125124
logger.Info("using ca", zap.String("ca", caFile))
126-
ca, err := ioutil.ReadFile(caFile)
125+
ca, err := os.ReadFile(caFile)
127126
if err != nil {
128127
logger.Fatal("could not read ca certificate", zap.Error(err))
129128
}

0 commit comments

Comments
 (0)