Skip to content

Commit f855dc6

Browse files
authored
Merge pull request #48 from Flowpack/upgrade
Upgrade to Go 1.24
2 parents d7fdf27 + 335b12f commit f855dc6

File tree

14 files changed

+217
-235
lines changed

14 files changed

+217
-235
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
name: Set up Go
3232
uses: actions/setup-go@v4
3333
with:
34-
go-version: '1.20'
34+
go-version: '1.24'
3535
-
3636
name: Run GoReleaser
3737
uses: goreleaser/goreleaser-action@v2

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ jobs:
1616
- name: Install Go
1717
uses: actions/setup-go@v4
1818
with:
19-
go-version: '1.20'
19+
go-version: '1.24'
2020
- name: Run linters
21-
uses: golangci/golangci-lint-action@v3
21+
uses: golangci/golangci-lint-action@v8
2222
with:
23-
version: v1.52
23+
version: v2.1.6
2424

2525
test:
2626
strategy:
2727
matrix:
28-
go-version: [ '1.20', '1.19', '1.18']
28+
go-version: [ '1.24' ]
2929
platform: [ 'ubuntu-latest' ]
3030
runs-on: ${{ matrix.platform }}
3131
steps:
@@ -47,7 +47,7 @@ jobs:
4747
if: success()
4848
uses: actions/setup-go@v4
4949
with:
50-
go-version: '1.20'
50+
go-version: '1.24'
5151
- name: Checkout code
5252
uses: actions/checkout@v2
5353
- name: Calc coverage

app/app.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package app
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78
"net/http"
@@ -15,7 +16,6 @@ import (
1516
"github.com/apex/log"
1617
logfmt_handler "github.com/apex/log/handlers/logfmt"
1718
text_handler "github.com/apex/log/handlers/text"
18-
"github.com/friendsofgo/errors"
1919
"github.com/go-chi/chi/v5/middleware"
2020
"github.com/go-chi/jwtauth/v5"
2121
"github.com/joho/godotenv"
@@ -143,22 +143,24 @@ func loadDotenv(c *cli.Context) error {
143143
for _, envFile := range envFiles {
144144
err := loadEnvFile(envFile)
145145
if err != nil {
146-
return errors.Wrapf(err, "loading env file %s", envFile)
146+
return fmt.Errorf("loading env file %s: %w", envFile, err)
147147
}
148148
}
149149
}
150150
return nil
151151
}
152152

153-
func loadEnvFile(file string) error {
153+
func loadEnvFile(file string) (err error) {
154154
f, err := os.Open(file)
155155
if os.IsNotExist(err) {
156156
// Ignore not existing dotenv files
157157
return nil
158158
} else if err != nil {
159159
return err
160160
}
161-
defer f.Close()
161+
defer func(f *os.File) {
162+
err = errors.Join(err, f.Close())
163+
}(f)
162164

163165
log.
164166
Debugf("Loading env from %q", file)
@@ -186,7 +188,7 @@ func appAction(c *cli.Context) error {
186188

187189
defs, err := definition.LoadRecursively(filepath.Join(c.String("path"), c.String("pattern")))
188190
if err != nil {
189-
return errors.Wrap(err, "loading definitions")
191+
return fmt.Errorf("loading definitions: %w", err)
190192
}
191193

192194
log.
@@ -197,12 +199,12 @@ func appAction(c *cli.Context) error {
197199

198200
outputStore, err := taskctl.NewOutputStore(path.Join(c.String("data"), "logs"))
199201
if err != nil {
200-
return errors.Wrap(err, "building output store")
202+
return fmt.Errorf("building output store: %w", err)
201203
}
202204

203205
dataStore, err := store.NewJSONDataStore(path.Join(c.String("data")))
204206
if err != nil {
205-
return errors.Wrap(err, "building pipeline runner store")
207+
return fmt.Errorf("building pipeline runner store: %w", err)
206208
}
207209

208210
// How signals are handled:

config/config.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package config
22

33
import (
4+
"errors"
5+
"fmt"
46
"os"
57

68
"github.com/apex/log"
7-
"github.com/friendsofgo/errors"
89
"gopkg.in/yaml.v2"
910

1011
"github.com/Flowpack/prunner/helper"
@@ -22,18 +23,18 @@ func (c Config) validate() error {
2223
}
2324
const minJWTSecretLength = 16
2425
if len(c.JWTSecret) < minJWTSecretLength {
25-
return errors.Errorf("jwt_secret must be at least %d characters long", minJWTSecretLength)
26+
return fmt.Errorf("jwt_secret must be at least %d characters long", minJWTSecretLength)
2627
}
2728

2829
return nil
2930
}
3031

31-
func LoadOrCreateConfig(configPath string, cliConfig Config) (*Config, error) {
32+
func LoadOrCreateConfig(configPath string, cliConfig Config) (c *Config, err error) {
3233
if err := cliConfig.validate(); err == nil {
3334
log.Debug("Using config from CLI")
3435
return &cliConfig, nil
3536
} else if err != ErrMissingJWTSecret {
36-
return nil, errors.Wrap(err, "invalid CLI config")
37+
return nil, fmt.Errorf("invalid CLI config: %w", err)
3738
}
3839

3940
log.Debugf("Reading config from %s", configPath)
@@ -42,43 +43,47 @@ func LoadOrCreateConfig(configPath string, cliConfig Config) (*Config, error) {
4243
log.Infof("No config found, creating file at %s", configPath)
4344
return createDefaultConfig(configPath)
4445
} else if err != nil {
45-
return nil, errors.Wrap(err, "opening config file")
46+
return nil, fmt.Errorf("opening config file: %w", err)
4647
}
47-
defer f.Close()
48+
defer func(f *os.File) {
49+
err = errors.Join(err, f.Close())
50+
}(f)
4851

49-
c := new(Config)
52+
c = new(Config)
5053

5154
err = yaml.NewDecoder(f).Decode(c)
5255
if err != nil {
53-
return nil, errors.Wrap(err, "decoding config")
56+
return nil, fmt.Errorf("decoding config: %w", err)
5457
}
5558

5659
err = c.validate()
5760
if err != nil {
58-
return nil, errors.Wrap(err, "invalid config")
61+
return nil, fmt.Errorf("invalid config: %w", err)
5962
}
6063

6164
return c, nil
6265
}
6366

64-
func createDefaultConfig(configPath string) (*Config, error) {
67+
func createDefaultConfig(configPath string) (c *Config, err error) {
6568
f, err := os.Create(configPath)
6669
if err != nil {
67-
return nil, errors.Wrap(err, "creating config file")
70+
return nil, fmt.Errorf("creating config file: %w", err)
6871
}
69-
defer f.Close()
72+
defer func(f *os.File) {
73+
err = errors.Join(err, f.Close())
74+
}(f)
7075

7176
jwtSecret, err := helper.GenerateRandomString(32)
7277
if err != nil {
73-
return nil, errors.Wrap(err, "generating random string")
78+
return nil, fmt.Errorf("generating random string: %w", err)
7479
}
75-
c := &Config{
80+
c = &Config{
7681
JWTSecret: jwtSecret,
7782
}
7883

7984
err = yaml.NewEncoder(f).Encode(c)
8085
if err != nil {
81-
return nil, errors.Wrap(err, "encoding config")
86+
return nil, fmt.Errorf("encoding config: %w", err)
8287
}
8388

8489
return c, nil

definition/loader.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package definition
22

33
import (
4+
"errors"
5+
"fmt"
46
"os"
57
"sort"
68

7-
"github.com/friendsofgo/errors"
89
"github.com/mattn/go-zglob"
910
"gopkg.in/yaml.v2"
1011
)
1112

1213
func LoadRecursively(pattern string) (*PipelinesDef, error) {
1314
matches, err := zglob.GlobFollowSymlinks(pattern)
1415
if err != nil {
15-
return nil, errors.Wrap(err, "finding files with glob")
16+
return nil, fmt.Errorf("finding files with glob: %w", err)
1617
}
1718

1819
// Make globbing deterministic
@@ -25,36 +26,38 @@ func LoadRecursively(pattern string) (*PipelinesDef, error) {
2526
for _, path := range matches {
2627
err = pipelinesDef.Load(path)
2728
if err != nil {
28-
return nil, errors.Wrapf(err, "loading %s", path)
29+
return nil, fmt.Errorf("loading %s: %w", path, err)
2930
}
3031
}
3132

3233
return pipelinesDef, nil
3334
}
3435

35-
func (d *PipelinesDef) Load(path string) error {
36+
func (d *PipelinesDef) Load(path string) (err error) {
3637
f, err := os.Open(path)
3738
if err != nil {
38-
return errors.Wrap(err, "opening file")
39+
return fmt.Errorf("opening file: %w", err)
3940
}
40-
defer f.Close()
41+
defer func(f *os.File) {
42+
err = errors.Join(err, f.Close())
43+
}(f)
4144

4245
var localDef PipelinesDef
4346

4447
err = yaml.NewDecoder(f).Decode(&localDef)
4548
if err != nil {
46-
return errors.Wrap(err, "decoding YAML")
49+
return fmt.Errorf("decoding YAML: %w", err)
4750
}
4851
localDef.setDefaults()
4952

5053
for pipelineName, pipelineDef := range localDef.Pipelines {
5154
if p, exists := d.Pipelines[pipelineName]; exists {
52-
return errors.Errorf("pipeline %q was already declared in %s", pipelineName, p.SourcePath)
55+
return fmt.Errorf("pipeline %q was already declared in %s", pipelineName, p.SourcePath)
5356
}
5457

55-
err := pipelineDef.validate()
58+
err = pipelineDef.validate()
5659
if err != nil {
57-
return errors.Wrapf(err, "invalid pipeline definition %q", pipelineName)
60+
return fmt.Errorf("invalid pipeline definition %q: %w", pipelineName, err)
5861
}
5962

6063
pipelineDef.SourcePath = path

definition/pipelines.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (d *PipelinesDef) Validate() error {
198198
return nil
199199
}
200200

201-
func (d PipelinesDef) Equals(otherDefs PipelinesDef) bool {
201+
func (d *PipelinesDef) Equals(otherDefs PipelinesDef) bool {
202202
if len(d.Pipelines) != len(otherDefs.Pipelines) {
203203
return false
204204
}

go.mod

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,54 @@
11
module github.com/Flowpack/prunner
22

3-
go 1.18
3+
go 1.24
44

55
require (
66
github.com/apex/log v1.9.0
77
github.com/friendsofgo/errors v0.9.2
8-
github.com/go-chi/chi/v5 v5.0.7
9-
github.com/go-chi/jwtauth/v5 v5.0.2
10-
github.com/gofrs/uuid v4.2.0+incompatible
11-
github.com/joho/godotenv v1.4.0
8+
github.com/go-chi/chi/v5 v5.2.1
9+
github.com/go-chi/jwtauth/v5 v5.3.3
10+
github.com/gofrs/uuid v4.4.0+incompatible
11+
github.com/joho/godotenv v1.5.1
1212
github.com/json-iterator/go v1.1.12
1313
github.com/liamylian/jsontime/v2 v2.0.0
14-
github.com/mattn/go-isatty v0.0.14
15-
github.com/mattn/go-zglob v0.0.3
16-
github.com/stretchr/testify v1.7.1
14+
github.com/mattn/go-isatty v0.0.20
15+
github.com/mattn/go-zglob v0.0.6
16+
github.com/stretchr/testify v1.10.0
1717
github.com/taskctl/taskctl v1.3.1-0.20210426182424-d8747985c906
18-
github.com/urfave/cli/v2 v2.4.0
18+
github.com/urfave/cli/v2 v2.27.6
1919
gopkg.in/yaml.v2 v2.4.0
20-
mvdan.cc/sh/v3 v3.6.0
20+
mvdan.cc/sh/v3 v3.11.0
2121
)
2222

2323
require (
24-
github.com/briandowns/spinner v1.18.1 // indirect
25-
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
24+
github.com/briandowns/spinner v1.23.2 // indirect
25+
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
2626
github.com/davecgh/go-spew v1.1.1 // indirect
27-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
28-
github.com/fatih/color v1.13.0 // indirect
29-
github.com/go-logfmt/logfmt v0.5.1 // indirect
30-
github.com/goccy/go-json v0.9.6 // indirect
31-
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
32-
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
27+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
28+
github.com/fatih/color v1.18.0 // indirect
29+
github.com/go-logfmt/logfmt v0.6.0 // indirect
30+
github.com/goccy/go-json v0.10.5 // indirect
31+
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
3332
github.com/lestrrat-go/httpcc v1.0.1 // indirect
33+
github.com/lestrrat-go/httprc v1.0.6 // indirect
3434
github.com/lestrrat-go/iter v1.0.2 // indirect
35-
github.com/lestrrat-go/jwx v1.2.21 // indirect
36-
github.com/lestrrat-go/option v1.0.0 // indirect
35+
github.com/lestrrat-go/jwx/v2 v2.1.6 // indirect
36+
github.com/lestrrat-go/option v1.0.1 // indirect
3737
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
38-
github.com/mattn/go-colorable v0.1.12 // indirect
38+
github.com/mattn/go-colorable v0.1.14 // indirect
3939
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4040
github.com/modern-go/reflect2 v1.0.2 // indirect
4141
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
4242
github.com/pkg/errors v0.9.1 // indirect
4343
github.com/pmezard/go-difflib v1.0.0 // indirect
4444
github.com/russross/blackfriday/v2 v2.1.0 // indirect
45-
github.com/sirupsen/logrus v1.8.1 // indirect
46-
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
47-
golang.org/x/sync v0.1.0 // indirect
48-
golang.org/x/sys v0.3.0 // indirect
49-
golang.org/x/term v0.3.0 // indirect
50-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
45+
github.com/segmentio/asm v1.2.0 // indirect
46+
github.com/sirupsen/logrus v1.9.3 // indirect
47+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
48+
golang.org/x/crypto v0.39.0 // indirect
49+
golang.org/x/sys v0.33.0 // indirect
50+
golang.org/x/term v0.32.0 // indirect
51+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
5152
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
52-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
53+
gopkg.in/yaml.v3 v3.0.1 // indirect
5354
)

0 commit comments

Comments
 (0)