From 81101314767fe250f9e62b0ed6582b0d1853c0e4 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Thu, 31 Mar 2022 14:53:11 -0300 Subject: [PATCH 1/6] Update golang lint in CI to 1.43.0 (#57) * Update golang lint in CI * Update Go-SDK-PR-Check.yaml --- .github/workflows/Go-SDK-PR-Check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Go-SDK-PR-Check.yaml b/.github/workflows/Go-SDK-PR-Check.yaml index 9a9d012..621f3c6 100644 --- a/.github/workflows/Go-SDK-PR-Check.yaml +++ b/.github/workflows/Go-SDK-PR-Check.yaml @@ -24,7 +24,7 @@ on: - main env: GO_VERSION: 1.14 - GOLANGLINT_CI_VERSION: v1.33.0 + GOLANGLINT_CI_VERSION: v1.45.2 jobs: basic_checks: name: Basic Checks From 387b8decbaa280b86e682765463f1d8aff9d57b7 Mon Sep 17 00:00:00 2001 From: Davide Salerno Date: Thu, 31 Mar 2022 21:33:16 +0200 Subject: [PATCH 2/6] Support multiple Auths (#56) Signed-off-by: Davide Salerno --- go.sum | 1 + model/auth.go | 65 ++++++++++++- model/workflow.go | 2 +- parser/parser_test.go | 46 ++++++++- .../applicationrequest.multiauth.json | 96 +++++++++++++++++++ .../applicationrequest.authdupl.json | 96 +++++++++++++++++++ 6 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 parser/testdata/workflows/applicationrequest.multiauth.json create mode 100644 parser/testdata/workflows/witherrors/applicationrequest.authdupl.json diff --git a/go.sum b/go.sum index 9e83c46..4d623de 100644 --- a/go.sum +++ b/go.sum @@ -141,6 +141,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= diff --git a/model/auth.go b/model/auth.go index f87dccf..f11949c 100644 --- a/model/auth.go +++ b/model/auth.go @@ -17,8 +17,35 @@ package model import ( "encoding/json" "fmt" + val "github.com/serverlessworkflow/sdk-go/v2/validator" + "gopkg.in/go-playground/validator.v8" + "reflect" ) +func init() { + val.GetValidator().RegisterStructValidation(AuthDefinitionsStructLevelValidation, AuthDefinitions{}) +} + +// AuthDefinitionsStructLevelValidation custom validator for unique name of the auth methods +func AuthDefinitionsStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) { + authDefs := structLevel.CurrentStruct.Interface().(AuthDefinitions) + dict := map[string]bool{} + if authDefs.Defs != nil && len(authDefs.Defs) > 1 { + for _, a := range authDefs.Defs { + if !dict[a.Name] { + dict[a.Name] = true + } else { + structLevel.ReportError(reflect.ValueOf(a.Name), "Name", "name", "reqnameunique") + } + } + } +} + +// AuthDefinitions used to define authentication information applied to resources defined in the operation property of function definitions +type AuthDefinitions struct { + Defs []Auth +} + // AuthType ... type AuthType string @@ -60,7 +87,43 @@ type Auth struct { Properties AuthProperties `json:"properties" validate:"required"` } -// UnmarshalJSON ... +// UnmarshalJSON implements json.Unmarshaler +func (a *AuthDefinitions) UnmarshalJSON(b []byte) error { + if len(b) == 0 { + return fmt.Errorf("no bytes to unmarshal") + } + // See if we can guess based on the first character + switch b[0] { + case '{': + return a.unmarshalSingle(b) + case '[': + return a.unmarshalMany(b) + } + return nil +} + +func (a *AuthDefinitions) unmarshalSingle(data []byte) error { + var auth Auth + err := json.Unmarshal(data, &auth) + if err != nil { + return err + } + a.Defs = []Auth{auth} + return nil +} + +func (a *AuthDefinitions) unmarshalMany(data []byte) error { + var auths []Auth + err := json.Unmarshal(data, &auths) + if err != nil { + return err + } + + a.Defs = auths + return nil +} + +// UnmarshalJSON Auth definition func (a *Auth) UnmarshalJSON(data []byte) error { auth := make(map[string]json.RawMessage) if err := json.Unmarshal(data, &auth); err != nil { diff --git a/model/workflow.go b/model/workflow.go index a00653b..b0506c1 100644 --- a/model/workflow.go +++ b/model/workflow.go @@ -89,7 +89,7 @@ type BaseWorkflow struct { // Auth definitions can be used to define authentication information that should be applied to resources defined in the operation // property of function definitions. It is not used as authentication information for the function invocation, // but just to access the resource containing the function invocation information. - Auth *Auth `json:"auth,omitempty"` + Auth AuthDefinitions `json:"auth,omitempty"` } // Workflow base definition diff --git a/parser/parser_test.go b/parser/parser_test.go index 9ab240c..673a167 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -37,6 +37,17 @@ func TestBasicValidation(t *testing.T) { } } } +func TestCustomValidators(t *testing.T) { + rootPath := "./testdata/workflows/witherrors" + files, err := ioutil.ReadDir(rootPath) + assert.NoError(t, err) + for _, file := range files { + if !file.IsDir() { + _, err := FromFile(filepath.Join(rootPath, file.Name())) + assert.Error(t, err) + } + } +} func TestFromFile(t *testing.T) { files := map[string]func(*testing.T, *model.Workflow){ @@ -113,11 +124,40 @@ func TestFromFile(t *testing.T) { assert.NotEmpty(t, operationState.Actions) assert.Equal(t, "startApplicationWorkflowId", operationState.Actions[0].SubFlowRef.WorkflowID) assert.NotNil(t, w.Auth) - assert.Equal(t, "testAuth", w.Auth.Name) - assert.Equal(t, model.AuthTypeBearer, w.Auth.Scheme) - bearerProperties := w.Auth.Properties.(*model.BearerAuthProperties).Token + assert.NotNil(t, w.Auth.Defs) + assert.Equal(t, len(w.Auth.Defs), 1) + assert.Equal(t, "testAuth", w.Auth.Defs[0].Name) + assert.Equal(t, model.AuthTypeBearer, w.Auth.Defs[0].Scheme) + bearerProperties := w.Auth.Defs[0].Properties.(*model.BearerAuthProperties).Token assert.Equal(t, "test_token", bearerProperties) }, + "./testdata/workflows/applicationrequest.multiauth.json": func(t *testing.T, w *model.Workflow) { + assert.IsType(t, &model.DataBasedSwitchState{}, w.States[0]) + eventState := w.States[0].(*model.DataBasedSwitchState) + assert.NotNil(t, eventState) + assert.NotEmpty(t, eventState.DataConditions) + assert.IsType(t, &model.TransitionDataCondition{}, eventState.DataConditions[0]) + assert.Equal(t, "TimeoutRetryStrategy", w.Retries[0].Name) + assert.Equal(t, "CheckApplication", w.Start.StateName) + assert.IsType(t, &model.OperationState{}, w.States[1]) + operationState := w.States[1].(*model.OperationState) + assert.NotNil(t, operationState) + assert.NotEmpty(t, operationState.Actions) + assert.Equal(t, "startApplicationWorkflowId", operationState.Actions[0].SubFlowRef.WorkflowID) + assert.NotNil(t, w.Auth) + assert.NotNil(t, w.Auth.Defs) + assert.Equal(t, len(w.Auth.Defs), 2) + assert.Equal(t, "testAuth", w.Auth.Defs[0].Name) + assert.Equal(t, model.AuthTypeBearer, w.Auth.Defs[0].Scheme) + bearerProperties := w.Auth.Defs[0].Properties.(*model.BearerAuthProperties).Token + assert.Equal(t, "test_token", bearerProperties) + assert.Equal(t, "testAuth2", w.Auth.Defs[1].Name) + assert.Equal(t, model.AuthTypeBasic, w.Auth.Defs[1].Scheme) + basicProperties := w.Auth.Defs[1].Properties.(*model.BasicAuthProperties) + assert.Equal(t, "test_user", basicProperties.Username) + assert.Equal(t, "test_pwd", basicProperties.Password) + + }, "./testdata/workflows/applicationrequest.rp.json": func(t *testing.T, w *model.Workflow) { assert.IsType(t, &model.DataBasedSwitchState{}, w.States[0]) eventState := w.States[0].(*model.DataBasedSwitchState) diff --git a/parser/testdata/workflows/applicationrequest.multiauth.json b/parser/testdata/workflows/applicationrequest.multiauth.json new file mode 100644 index 0000000..b1bf69c --- /dev/null +++ b/parser/testdata/workflows/applicationrequest.multiauth.json @@ -0,0 +1,96 @@ +{ + "id": "applicantrequest", + "version": "1.0", + "name": "Applicant Request Decision Workflow", + "description": "Determine if applicant request is valid", + "start": "CheckApplication", + "specVersion": "0.7", + "auth": [ + { + "name": "testAuth", + "scheme": "bearer", + "properties": { + "token": "test_token" + } + }, + { + "name": "testAuth2", + "scheme": "basic", + "properties": { + "username": "test_user", + "password": "test_pwd" + } + } + ] + , + "functions": [ + { + "name": "sendRejectionEmailFunction", + "operation": "http://myapis.org/applicationapi.json#emailRejection" + } + ], + "retries": [ + { + "name": "TimeoutRetryStrategy", + "delay": "PT1M", + "maxAttempts": "5" + } + ], + "states": [ + { + "name": "CheckApplication", + "type": "switch", + "dataConditions": [ + { + "condition": "{{ $.applicants[?(@.age >= 18)] }}", + "transition": { + "nextState": "StartApplication" + } + }, + { + "condition": "{{ $.applicants[?(@.age < 18)] }}", + "transition": { + "nextState": "RejectApplication" + } + } + ], + "default": { + "transition": { + "nextState": "RejectApplication" + } + } + }, + { + "name": "StartApplication", + "type": "operation", + "actions": [ + { + "subFlowRef": { + "workflowId": "startApplicationWorkflowId" + } + } + ], + "end": { + "terminate": true + } + }, + { + "name": "RejectApplication", + "type": "operation", + "actionMode": "sequential", + "actions": [ + { + "functionRef": { + "refName": "sendRejectionEmailFunction", + "parameters": { + "applicant": "{{ $.applicant }}" + } + } + } + ], + "end": { + "terminate": true + } + } + ] +} \ No newline at end of file diff --git a/parser/testdata/workflows/witherrors/applicationrequest.authdupl.json b/parser/testdata/workflows/witherrors/applicationrequest.authdupl.json new file mode 100644 index 0000000..30f75cd --- /dev/null +++ b/parser/testdata/workflows/witherrors/applicationrequest.authdupl.json @@ -0,0 +1,96 @@ +{ + "id": "applicantrequest", + "version": "1.0", + "name": "Applicant Request Decision Workflow", + "description": "Determine if applicant request is valid", + "start": "CheckApplication", + "specVersion": "0.7", + "auth": [ + { + "name": "testAuth", + "scheme": "bearer", + "properties": { + "token": "test_token" + } + }, + { + "name": "testAuth", + "scheme": "basic", + "properties": { + "username": "test_user", + "password": "test_pwd" + } + } + ] + , + "functions": [ + { + "name": "sendRejectionEmailFunction", + "operation": "http://myapis.org/applicationapi.json#emailRejection" + } + ], + "retries": [ + { + "name": "TimeoutRetryStrategy", + "delay": "PT1M", + "maxAttempts": "5" + } + ], + "states": [ + { + "name": "CheckApplication", + "type": "switch", + "dataConditions": [ + { + "condition": "{{ $.applicants[?(@.age >= 18)] }}", + "transition": { + "nextState": "StartApplication" + } + }, + { + "condition": "{{ $.applicants[?(@.age < 18)] }}", + "transition": { + "nextState": "RejectApplication" + } + } + ], + "default": { + "transition": { + "nextState": "RejectApplication" + } + } + }, + { + "name": "StartApplication", + "type": "operation", + "actions": [ + { + "subFlowRef": { + "workflowId": "startApplicationWorkflowId" + } + } + ], + "end": { + "terminate": true + } + }, + { + "name": "RejectApplication", + "type": "operation", + "actionMode": "sequential", + "actions": [ + { + "functionRef": { + "refName": "sendRejectionEmailFunction", + "parameters": { + "applicant": "{{ $.applicant }}" + } + } + } + ], + "end": { + "terminate": true + } + } + ] +} \ No newline at end of file From 7e3a7ca844fde2dbe858a0c60a7d68df46b83bcb Mon Sep 17 00:00:00 2001 From: "whitesource-bolt-for-github[bot]" <42819689+whitesource-bolt-for-github[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 14:53:46 -0300 Subject: [PATCH 3/6] Add .whitesource configuration file (#58) Co-authored-by: whitesource-bolt-for-github[bot] <42819689+whitesource-bolt-for-github[bot]@users.noreply.github.com> --- .whitesource | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .whitesource diff --git a/.whitesource b/.whitesource new file mode 100644 index 0000000..0d7ea09 --- /dev/null +++ b/.whitesource @@ -0,0 +1,13 @@ +{ + "scanSettings": { + "baseBranches": [] + }, + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure", + "displayMode": "diff" + }, + "issueSettings": { + "minSeverityLevel": "LOW", + "issueType": "DEPENDENCY" + } +} \ No newline at end of file From 8fd2e70d6155ac194ed16e7d40bb1b0e63ca4405 Mon Sep 17 00:00:00 2001 From: globalflea Date: Mon, 15 Aug 2022 20:17:56 +0800 Subject: [PATCH 4/6] Changed Retry.Multiplier, OnError.Transition, OnError.End to pointer (#49) * Changed Multiplier to pointer * Changed Transition & End to pointers --- model/retry.go | 2 +- model/workflow.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/model/retry.go b/model/retry.go index 7a3990a..5f232af 100644 --- a/model/retry.go +++ b/model/retry.go @@ -30,7 +30,7 @@ type Retry struct { // Static value by which the delay increases during each attempt (ISO 8601 time format) Increment string `json:"increment,omitempty"` // Numeric value, if specified the delay between retries is multiplied by this value. - Multiplier floatstr.Float32OrString `json:"multiplier,omitempty" validate:"omitempty,min=0"` + Multiplier *floatstr.Float32OrString `json:"multiplier,omitempty" validate:"omitempty,min=1"` // Maximum number of retry attempts. MaxAttempts intstr.IntOrString `json:"maxAttempts" validate:"required"` // If float type, maximum amount of random time added or subtracted from the delay between each retry relative to total delay (between 0 and 1). If string type, absolute maximum amount of random time added or subtracted from the delay between each retry (ISO 8601 duration format) diff --git a/model/workflow.go b/model/workflow.go index b0506c1..489eebf 100644 --- a/model/workflow.go +++ b/model/workflow.go @@ -483,9 +483,9 @@ type OnError struct { // ErrorRefs References one or more workflow error definitions. Used if errorRef is not used ErrorRefs []string `json:"errorRefs,omitempty"` // Transition to next state to handle the error. If retryRef is defined, this transition is taken only if retries were unsuccessful. - Transition Transition `json:"transition,omitempty"` + Transition *Transition `json:"transition,omitempty"` // End workflow execution in case of this error. If retryRef is defined, this ends workflow only if retries were unsuccessful. - End End `json:"end,omitempty"` + End *End `json:"end,omitempty"` } // OnEvents ... From 98db3f0808d14c71abd1ba621022f884b70f4b20 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Mon, 29 Aug 2022 12:21:34 -0300 Subject: [PATCH 5/6] Fixes #63 - Upgrade dependencies and go version (#66) * Fixes #63 - Upgrade dependencies and go version Signed-off-by: Ricardo Zanini * Fix CVE-2022-27191 Signed-off-by: Ricardo Zanini Signed-off-by: Ricardo Zanini --- .github/workflows/Go-SDK-PR-Check.yaml | 23 +-- Makefile | 1 - go.mod | 29 +++- go.sum | 200 ++++++------------------- hack/go-lint.sh | 9 +- model/auth.go | 11 +- model/event.go | 8 +- model/util.go | 4 +- parser/parser.go | 6 +- parser/parser_test.go | 7 +- validator/validator.go | 6 +- 11 files changed, 107 insertions(+), 197 deletions(-) diff --git a/.github/workflows/Go-SDK-PR-Check.yaml b/.github/workflows/Go-SDK-PR-Check.yaml index 621f3c6..8226f60 100644 --- a/.github/workflows/Go-SDK-PR-Check.yaml +++ b/.github/workflows/Go-SDK-PR-Check.yaml @@ -23,29 +23,30 @@ on: branches: - main env: - GO_VERSION: 1.14 - GOLANGLINT_CI_VERSION: v1.45.2 + GO_VERSION: 1.19 jobs: basic_checks: name: Basic Checks runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ env.GO_VERSION }} id: go - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: - path: ~/go/pkg/mod/cache - key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }} + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-cache- + ${{ runner.os }}-go- - name: Cache tools - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/go/bin key: ${{ runner.os }}-go-tools-${{ hashFiles('**/tools.sum') }} @@ -62,9 +63,9 @@ jobs: changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|tools.mod\|tools.sum' || :) [[ -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) - name: Check lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: - version: ${{ env.GOLANGLINT_CI_VERSION }} + version: latest - name: Install cover run: go get -modfile=tools.mod golang.org/x/tools/cmd/cover - name: Validate codcov yaml file diff --git a/Makefile b/Makefile index ae9d1f2..826475e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ fmt: @go fmt ./... lint: - @command -v golint > /dev/null || go install -modfile=tools.mod -v golang.org/x/lint/golint @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" make addheaders make fmt diff --git a/go.mod b/go.mod index ca7f252..88d4311 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,28 @@ module github.com/serverlessworkflow/sdk-go/v2 -go 1.15 +go 1.19 require ( - github.com/stretchr/testify v1.6.1 - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/go-playground/validator.v8 v8.18.2 - k8s.io/apimachinery v0.21.0 - sigs.k8s.io/yaml v1.2.0 + github.com/go-playground/validator/v10 v10.11.0 + github.com/stretchr/testify v1.7.0 + k8s.io/apimachinery v0.25.0 + sigs.k8s.io/yaml v1.3.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/klog/v2 v2.70.1 // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect ) diff --git a/go.sum b/go.sum index 4d623de..830ed38 100644 --- a/go.sum +++ b/go.sum @@ -1,153 +1,79 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= -github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= +github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d h1:3qF+Z8Hkrw9sOhrFHti9TlB1Hkac1x+DNRkv0XQiFjo= +golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -155,52 +81,22 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/apimachinery v0.21.0 h1:3Fx+41if+IRavNcKOz09FwEXDBG6ORh6iMsTSelhkMA= -k8s.io/apimachinery v0.21.0/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY= -k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.8.0 h1:Q3gmuM9hKEjefWFFYF0Mat+YyFJvsUyYuwyNNJ5C9Ts= -k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU= +k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0= +k8s.io/klog/v2 v2.70.1 h1:7aaoSdahviPmR+XkS7FyxlkkXs6tHISSG03RxleQAVQ= +k8s.io/klog/v2 v2.70.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/hack/go-lint.sh b/hack/go-lint.sh index 8e70331..a9c0251 100755 --- a/hack/go-lint.sh +++ b/hack/go-lint.sh @@ -13,11 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -golint ./... | tee -a golint_errors -if [ -s golint_errors ] ; then - code=1 -fi -rm -f golint_errors -golangci-lint run ./... --enable golint --timeout 2m0s - -exit ${code:0} \ No newline at end of file +golangci-lint run ./... --timeout 2m0s diff --git a/model/auth.go b/model/auth.go index f11949c..60e9aa1 100644 --- a/model/auth.go +++ b/model/auth.go @@ -17,9 +17,10 @@ package model import ( "encoding/json" "fmt" - val "github.com/serverlessworkflow/sdk-go/v2/validator" - "gopkg.in/go-playground/validator.v8" "reflect" + + validator "github.com/go-playground/validator/v10" + val "github.com/serverlessworkflow/sdk-go/v2/validator" ) func init() { @@ -27,15 +28,15 @@ func init() { } // AuthDefinitionsStructLevelValidation custom validator for unique name of the auth methods -func AuthDefinitionsStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) { - authDefs := structLevel.CurrentStruct.Interface().(AuthDefinitions) +func AuthDefinitionsStructLevelValidation(structLevel validator.StructLevel) { + authDefs := structLevel.Current().Interface().(AuthDefinitions) dict := map[string]bool{} if authDefs.Defs != nil && len(authDefs.Defs) > 1 { for _, a := range authDefs.Defs { if !dict[a.Name] { dict[a.Name] = true } else { - structLevel.ReportError(reflect.ValueOf(a.Name), "Name", "name", "reqnameunique") + structLevel.ReportError(reflect.ValueOf(a.Name), "Name", "name", "reqnameunique", "") } } } diff --git a/model/event.go b/model/event.go index 0154428..cf44d99 100644 --- a/model/event.go +++ b/model/event.go @@ -17,8 +17,8 @@ package model import ( "reflect" + validator "github.com/go-playground/validator/v10" val "github.com/serverlessworkflow/sdk-go/v2/validator" - "gopkg.in/go-playground/validator.v8" ) const ( @@ -33,11 +33,11 @@ func init() { } // EventStructLevelValidation custom validator for event kind consumed -func EventStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) { - event := structLevel.CurrentStruct.Interface().(Event) +func EventStructLevelValidation(structLevel validator.StructLevel) { + event := structLevel.Current().Interface().(Event) if event.Kind == EventKindConsumed && len(event.Type) == 0 { - structLevel.ReportError(reflect.ValueOf(event.Type), "Type", "type", "reqtypeconsumed") + structLevel.ReportError(reflect.ValueOf(event.Type), "Type", "type", "reqtypeconsumed", "") } } diff --git a/model/util.go b/model/util.go index edf12e9..1cfd08b 100644 --- a/model/util.go +++ b/model/util.go @@ -17,8 +17,8 @@ package model import ( "bytes" "encoding/json" - "io/ioutil" "net/http" + "os" "path/filepath" "strings" ) @@ -46,7 +46,7 @@ func getBytesFromFile(s string) (b []byte, err error) { } else if s, err = filepath.Abs(s); err != nil { return nil, err } - if b, err = ioutil.ReadFile(filepath.Clean(s)); err != nil { + if b, err = os.ReadFile(filepath.Clean(s)); err != nil { return nil, err } return b, nil diff --git a/parser/parser.go b/parser/parser.go index 2d52d67..fe9972d 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -17,12 +17,12 @@ package parser import ( "encoding/json" "fmt" - "github.com/serverlessworkflow/sdk-go/v2/validator" - "io/ioutil" "os" "path/filepath" "strings" + "github.com/serverlessworkflow/sdk-go/v2/validator" + "github.com/serverlessworkflow/sdk-go/v2/model" "sigs.k8s.io/yaml" ) @@ -61,7 +61,7 @@ func FromFile(path string) (*model.Workflow, error) { if err := checkFilePath(path); err != nil { return nil, err } - fileBytes, err := ioutil.ReadFile(filepath.Clean(path)) + fileBytes, err := os.ReadFile(filepath.Clean(path)) if err != nil { return nil, err } diff --git a/parser/parser_test.go b/parser/parser_test.go index 673a167..0b91a25 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -15,7 +15,7 @@ package parser import ( - "io/ioutil" + "os" "path/filepath" "testing" @@ -25,7 +25,7 @@ import ( func TestBasicValidation(t *testing.T) { rootPath := "./testdata/workflows" - files, err := ioutil.ReadDir(rootPath) + files, err := os.ReadDir(rootPath) assert.NoError(t, err) for _, file := range files { if !file.IsDir() { @@ -37,9 +37,10 @@ func TestBasicValidation(t *testing.T) { } } } + func TestCustomValidators(t *testing.T) { rootPath := "./testdata/workflows/witherrors" - files, err := ioutil.ReadDir(rootPath) + files, err := os.ReadDir(rootPath) assert.NoError(t, err) for _, file := range files { if !file.IsDir() { diff --git a/validator/validator.go b/validator/validator.go index 50af1ac..fbff15f 100644 --- a/validator/validator.go +++ b/validator/validator.go @@ -14,14 +14,16 @@ package validator -import "gopkg.in/go-playground/validator.v8" +import ( + validator "github.com/go-playground/validator/v10" +) // TODO: expose a better validation message. See: https://pkg.go.dev/gopkg.in/go-playground/validator.v8#section-documentation var validate *validator.Validate func init() { - validate = validator.New(&validator.Config{TagName: "validate"}) + validate = validator.New() } // GetValidator gets the default validator.Validate reference From c6596fdef5734569b362040b176ac6ca1f6c6554 Mon Sep 17 00:00:00 2001 From: Andres Mijares Date: Mon, 29 Aug 2022 11:34:00 -0400 Subject: [PATCH 6/6] Fixes workflow event states unmarshalling methods (#65) * clear mapState after next loop iteraction * signed commit * signed commit * added unit test for both events at once --- .gitignore | 3 +- model/workflow.go | 3 +- parser/parser_test.go | 6 ++ .../workflows/eventbaseddataandswitch.sw.json | 100 ++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 parser/testdata/workflows/eventbaseddataandswitch.sw.json diff --git a/.gitignore b/.gitignore index aef41c5..036f9f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin .idea -*.out \ No newline at end of file +*.out +.vscode \ No newline at end of file diff --git a/model/workflow.go b/model/workflow.go index 489eebf..986e497 100644 --- a/model/workflow.go +++ b/model/workflow.go @@ -117,7 +117,7 @@ func (w *Workflow) UnmarshalJSON(data []byte) error { } w.States = make([]State, len(rawStates)) - var mapState map[string]interface{} + mapState := map[string]interface{}{} for i, rawState := range rawStates { if err := json.Unmarshal(rawState, &mapState); err != nil { return err @@ -130,6 +130,7 @@ func (w *Workflow) UnmarshalJSON(data []byte) error { return err } w.States[i] = state + mapState = map[string]interface{}{} } if _, ok := workflowMap["events"]; ok { if err := json.Unmarshal(workflowMap["events"], &w.Events); err != nil { diff --git a/parser/parser_test.go b/parser/parser_test.go index 0b91a25..2bdbfa6 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -64,6 +64,12 @@ func TestFromFile(t *testing.T) { assert.NotNil(t, w.States[0].(*model.OperationState).Actions[0].FunctionRef) assert.Equal(t, "greetingFunction", w.States[0].(*model.OperationState).Actions[0].FunctionRef.RefName) }, + "./testdata/workflows/eventbaseddataandswitch.sw.json": func(t *testing.T, w *model.Workflow) { + assert.Equal(t, "Start", w.States[0].GetName()) + assert.Equal(t, "CheckVisaStatus", w.States[1].GetName()) + assert.IsType(t, &model.DataBasedSwitchState{}, w.States[0]) + assert.IsType(t, &model.EventBasedSwitchState{}, w.States[1]) + }, "./testdata/workflows/eventbasedgreeting.sw.json": func(t *testing.T, w *model.Workflow) { assert.Equal(t, "GreetingEvent", w.Events[0].Name) assert.IsType(t, &model.EventState{}, w.States[0]) diff --git a/parser/testdata/workflows/eventbaseddataandswitch.sw.json b/parser/testdata/workflows/eventbaseddataandswitch.sw.json new file mode 100644 index 0000000..58482be --- /dev/null +++ b/parser/testdata/workflows/eventbaseddataandswitch.sw.json @@ -0,0 +1,100 @@ +{ + "id": "eventbaseddataandswitch", + "version": "1.0", + "name": "Event Based Switch Transitions", + "description": "Event Based Switch Transitions with Event Database Condition", + "specVersion": "0.7", + "start": { + "stateName": "Start" + }, + "events": [ + { + "name": "visaApprovedEvent", + "type": "VisaApproved", + "source": "visaCheckSource" + }, + { + "name": "visaRejectedEvent", + "type": "VisaRejected", + "source": "visaCheckSource" + } + ], + "states": [ + { + "name": "Start", + "type": "switch", + "dataConditions": [ + { + "condition": "${ true }", + "transition": "CheckVisaStatus" + } + ] + }, + { + "name": "CheckVisaStatus", + "type": "switch", + "eventConditions": [ + { + "eventRef": "visaApprovedEvent", + "transition": { + "nextState": "HandleApprovedVisa" + } + }, + { + "eventRef": "visaRejectedEvent", + "transition": { + "nextState": "HandleRejectedVisa" + } + } + ], + "eventTimeout": "PT1H", + "defaultCondition": { + "transition": { + "nextState": "HandleNoVisaDecision" + } + } + }, + { + "name": "HandleApprovedVisa", + "type": "operation", + "actions": [ + { + "subFlowRef": { + "workflowId": "handleApprovedVisaWorkflowID" + } + } + ], + "end": { + "terminate": true + } + }, + { + "name": "HandleRejectedVisa", + "type": "operation", + "actions": [ + { + "subFlowRef": { + "workflowId": "handleRejectedVisaWorkflowID" + } + } + ], + "end": { + "terminate": true + } + }, + { + "name": "HandleNoVisaDecision", + "type": "operation", + "actions": [ + { + "subFlowRef": { + "workflowId": "handleNoVisaDecisionWorkfowId" + } + } + ], + "end": { + "terminate": true + } + } + ] +} \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy