Skip to content

Commit 98db3f0

Browse files
Fixes #63 - Upgrade dependencies and go version (#66)
* Fixes #63 - Upgrade dependencies and go version Signed-off-by: Ricardo Zanini <zanini@redhat.com> * Fix CVE-2022-27191 Signed-off-by: Ricardo Zanini <zanini@redhat.com> Signed-off-by: Ricardo Zanini <zanini@redhat.com>
1 parent 8fd2e70 commit 98db3f0

File tree

11 files changed

+107
-197
lines changed

11 files changed

+107
-197
lines changed

.github/workflows/Go-SDK-PR-Check.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,30 @@ on:
2323
branches:
2424
- main
2525
env:
26-
GO_VERSION: 1.14
27-
GOLANGLINT_CI_VERSION: v1.45.2
26+
GO_VERSION: 1.19
2827
jobs:
2928
basic_checks:
3029
name: Basic Checks
3130
runs-on: ubuntu-latest
3231
steps:
3332
- name: Checkout Code
34-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3534
- name: Setup Go ${{ env.GO_VERSION }}
36-
uses: actions/setup-go@v2
35+
uses: actions/setup-go@v3
3736
with:
3837
go-version: ${{ env.GO_VERSION }}
3938
id: go
4039
- name: Cache dependencies
41-
uses: actions/cache@v2
40+
uses: actions/cache@v3
4241
with:
43-
path: ~/go/pkg/mod/cache
44-
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
42+
path: |
43+
~/.cache/go-build
44+
~/go/pkg/mod
45+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
4546
restore-keys: |
46-
${{ runner.os }}-go-cache-
47+
${{ runner.os }}-go-
4748
- name: Cache tools
48-
uses: actions/cache@v2
49+
uses: actions/cache@v3
4950
with:
5051
path: ~/go/bin
5152
key: ${{ runner.os }}-go-tools-${{ hashFiles('**/tools.sum') }}
@@ -62,9 +63,9 @@ jobs:
6263
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|tools.mod\|tools.sum' || :)
6364
[[ -z "$changed_files" ]] || (printf "Some files are not formatted properly: \n$changed_files\n Did you run 'make test' before sending the PR?" && exit 1)
6465
- name: Check lint
65-
uses: golangci/golangci-lint-action@v2
66+
uses: golangci/golangci-lint-action@v3
6667
with:
67-
version: ${{ env.GOLANGLINT_CI_VERSION }}
68+
version: latest
6869
- name: Install cover
6970
run: go get -modfile=tools.mod golang.org/x/tools/cmd/cover
7071
- name: Validate codcov yaml file

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ fmt:
77
@go fmt ./...
88

99
lint:
10-
@command -v golint > /dev/null || go install -modfile=tools.mod -v golang.org/x/lint/golint
1110
@command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin"
1211
make addheaders
1312
make fmt

go.mod

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
module github.com/serverlessworkflow/sdk-go/v2
22

3-
go 1.15
3+
go 1.19
44

55
require (
6-
github.com/stretchr/testify v1.6.1
7-
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
8-
gopkg.in/go-playground/validator.v8 v8.18.2
9-
k8s.io/apimachinery v0.21.0
10-
sigs.k8s.io/yaml v1.2.0
6+
github.com/go-playground/validator/v10 v10.11.0
7+
github.com/stretchr/testify v1.7.0
8+
k8s.io/apimachinery v0.25.0
9+
sigs.k8s.io/yaml v1.3.0
10+
)
11+
12+
require (
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/go-logr/logr v1.2.3 // indirect
15+
github.com/go-playground/locales v0.14.0 // indirect
16+
github.com/go-playground/universal-translator v0.18.0 // indirect
17+
github.com/gogo/protobuf v1.3.2 // indirect
18+
github.com/google/gofuzz v1.1.0 // indirect
19+
github.com/leodido/go-urn v1.2.1 // indirect
20+
github.com/pmezard/go-difflib v1.0.0 // indirect
21+
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect
22+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
23+
golang.org/x/text v0.3.7 // indirect
24+
gopkg.in/yaml.v2 v2.4.0 // indirect
25+
gopkg.in/yaml.v3 v3.0.1 // indirect
26+
k8s.io/klog/v2 v2.70.1 // indirect
27+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
1128
)

go.sum

Lines changed: 48 additions & 152 deletions
Large diffs are not rendered by default.

hack/go-lint.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
golint ./... | tee -a golint_errors
17-
if [ -s golint_errors ] ; then
18-
code=1
19-
fi
20-
rm -f golint_errors
21-
golangci-lint run ./... --enable golint --timeout 2m0s
22-
23-
exit ${code:0}
16+
golangci-lint run ./... --timeout 2m0s

model/auth.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ package model
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
val "github.com/serverlessworkflow/sdk-go/v2/validator"
21-
"gopkg.in/go-playground/validator.v8"
2220
"reflect"
21+
22+
validator "github.com/go-playground/validator/v10"
23+
val "github.com/serverlessworkflow/sdk-go/v2/validator"
2324
)
2425

2526
func init() {
2627
val.GetValidator().RegisterStructValidation(AuthDefinitionsStructLevelValidation, AuthDefinitions{})
2728
}
2829

2930
// AuthDefinitionsStructLevelValidation custom validator for unique name of the auth methods
30-
func AuthDefinitionsStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) {
31-
authDefs := structLevel.CurrentStruct.Interface().(AuthDefinitions)
31+
func AuthDefinitionsStructLevelValidation(structLevel validator.StructLevel) {
32+
authDefs := structLevel.Current().Interface().(AuthDefinitions)
3233
dict := map[string]bool{}
3334
if authDefs.Defs != nil && len(authDefs.Defs) > 1 {
3435
for _, a := range authDefs.Defs {
3536
if !dict[a.Name] {
3637
dict[a.Name] = true
3738
} else {
38-
structLevel.ReportError(reflect.ValueOf(a.Name), "Name", "name", "reqnameunique")
39+
structLevel.ReportError(reflect.ValueOf(a.Name), "Name", "name", "reqnameunique", "")
3940
}
4041
}
4142
}

model/event.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package model
1717
import (
1818
"reflect"
1919

20+
validator "github.com/go-playground/validator/v10"
2021
val "github.com/serverlessworkflow/sdk-go/v2/validator"
21-
"gopkg.in/go-playground/validator.v8"
2222
)
2323

2424
const (
@@ -33,11 +33,11 @@ func init() {
3333
}
3434

3535
// EventStructLevelValidation custom validator for event kind consumed
36-
func EventStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) {
37-
event := structLevel.CurrentStruct.Interface().(Event)
36+
func EventStructLevelValidation(structLevel validator.StructLevel) {
37+
event := structLevel.Current().Interface().(Event)
3838

3939
if event.Kind == EventKindConsumed && len(event.Type) == 0 {
40-
structLevel.ReportError(reflect.ValueOf(event.Type), "Type", "type", "reqtypeconsumed")
40+
structLevel.ReportError(reflect.ValueOf(event.Type), "Type", "type", "reqtypeconsumed", "")
4141
}
4242
}
4343

model/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package model
1717
import (
1818
"bytes"
1919
"encoding/json"
20-
"io/ioutil"
2120
"net/http"
21+
"os"
2222
"path/filepath"
2323
"strings"
2424
)
@@ -46,7 +46,7 @@ func getBytesFromFile(s string) (b []byte, err error) {
4646
} else if s, err = filepath.Abs(s); err != nil {
4747
return nil, err
4848
}
49-
if b, err = ioutil.ReadFile(filepath.Clean(s)); err != nil {
49+
if b, err = os.ReadFile(filepath.Clean(s)); err != nil {
5050
return nil, err
5151
}
5252
return b, nil

parser/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package parser
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
"github.com/serverlessworkflow/sdk-go/v2/validator"
21-
"io/ioutil"
2220
"os"
2321
"path/filepath"
2422
"strings"
2523

24+
"github.com/serverlessworkflow/sdk-go/v2/validator"
25+
2626
"github.com/serverlessworkflow/sdk-go/v2/model"
2727
"sigs.k8s.io/yaml"
2828
)
@@ -61,7 +61,7 @@ func FromFile(path string) (*model.Workflow, error) {
6161
if err := checkFilePath(path); err != nil {
6262
return nil, err
6363
}
64-
fileBytes, err := ioutil.ReadFile(filepath.Clean(path))
64+
fileBytes, err := os.ReadFile(filepath.Clean(path))
6565
if err != nil {
6666
return nil, err
6767
}

parser/parser_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package parser
1616

1717
import (
18-
"io/ioutil"
18+
"os"
1919
"path/filepath"
2020
"testing"
2121

@@ -25,7 +25,7 @@ import (
2525

2626
func TestBasicValidation(t *testing.T) {
2727
rootPath := "./testdata/workflows"
28-
files, err := ioutil.ReadDir(rootPath)
28+
files, err := os.ReadDir(rootPath)
2929
assert.NoError(t, err)
3030
for _, file := range files {
3131
if !file.IsDir() {
@@ -37,9 +37,10 @@ func TestBasicValidation(t *testing.T) {
3737
}
3838
}
3939
}
40+
4041
func TestCustomValidators(t *testing.T) {
4142
rootPath := "./testdata/workflows/witherrors"
42-
files, err := ioutil.ReadDir(rootPath)
43+
files, err := os.ReadDir(rootPath)
4344
assert.NoError(t, err)
4445
for _, file := range files {
4546
if !file.IsDir() {

validator/validator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414

1515
package validator
1616

17-
import "gopkg.in/go-playground/validator.v8"
17+
import (
18+
validator "github.com/go-playground/validator/v10"
19+
)
1820

1921
// TODO: expose a better validation message. See: https://pkg.go.dev/gopkg.in/go-playground/validator.v8#section-documentation
2022

2123
var validate *validator.Validate
2224

2325
func init() {
24-
validate = validator.New(&validator.Config{TagName: "validate"})
26+
validate = validator.New()
2527
}
2628

2729
// GetValidator gets the default validator.Validate reference

0 commit comments

Comments
 (0)