From c10a388a439b3bd8f37dd687aa0ad04c7922894f Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Mon, 23 Sep 2024 17:37:38 +0200 Subject: [PATCH] chore: move core in ledger/pkg --- components/ledger/Earthfile | 2 - components/ledger/go.mod | 3 -- .../internal/api/v1/controllers_accounts.go | 3 +- .../internal/api/v2/controllers_accounts.go | 3 +- components/ledger/internal/machine/account.go | 2 +- components/ledger/internal/machine/asset.go | 2 +- components/ledger/internal/posting.go | 4 +- .../ledger/pkg}/core/accounts/account_test.go | 0 .../ledger/pkg}/core/accounts/accounts.go | 0 .../ledger/pkg}/core/assets/asset.go | 0 .../internal/storage/migrations_v1.x.go | 2 - ee/wallets/Earthfile | 2 +- ee/wallets/go.mod | 6 +-- ee/wallets/pkg/credit.go | 2 +- ee/wallets/pkg/debit.go | 3 +- ee/wallets/pkg/subject.go | 2 +- libs/Earthfile | 1 - libs/core/.golangci.yml | 43 ------------------- libs/core/Earthfile | 32 -------------- libs/core/go.mod | 11 ----- libs/core/go.sum | 10 ----- tests/integration/go.mod | 2 - 22 files changed, 15 insertions(+), 120 deletions(-) rename {libs => components/ledger/pkg}/core/accounts/account_test.go (100%) rename {libs => components/ledger/pkg}/core/accounts/accounts.go (100%) rename {libs => components/ledger/pkg}/core/assets/asset.go (100%) delete mode 100644 libs/core/.golangci.yml delete mode 100644 libs/core/Earthfile delete mode 100644 libs/core/go.mod delete mode 100644 libs/core/go.sum diff --git a/components/ledger/Earthfile b/components/ledger/Earthfile index fdeb746cee..4bac74fc00 100644 --- a/components/ledger/Earthfile +++ b/components/ledger/Earthfile @@ -7,8 +7,6 @@ IMPORT .. AS components FROM core+base-image sources: - WORKDIR src - COPY (stack+sources/out --LOCATION=libs/core) /src/libs/core WORKDIR /src/components/ledger COPY go.mod go.sum . COPY --dir internal pkg cmd . diff --git a/components/ledger/go.mod b/components/ledger/go.mod index ad758c17e3..eb84228d61 100644 --- a/components/ledger/go.mod +++ b/components/ledger/go.mod @@ -6,8 +6,6 @@ toolchain go1.22.7 replace github.com/formancehq/stack/ledger/client => ./pkg/client -replace github.com/formancehq/stack/libs/core => ../../libs/core - require ( github.com/ThreeDotsLabs/watermill v1.3.7 github.com/alitto/pond v1.9.2 @@ -15,7 +13,6 @@ require ( github.com/bluele/gcache v0.0.2 github.com/formancehq/go-libs v1.7.1 github.com/formancehq/stack/ledger/client v0.0.0-00010101000000-000000000000 - github.com/formancehq/stack/libs/core v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/cors v1.2.1 github.com/google/go-cmp v0.6.0 diff --git a/components/ledger/internal/api/v1/controllers_accounts.go b/components/ledger/internal/api/v1/controllers_accounts.go index 0856acd82d..1a0514a308 100644 --- a/components/ledger/internal/api/v1/controllers_accounts.go +++ b/components/ledger/internal/api/v1/controllers_accounts.go @@ -9,12 +9,13 @@ import ( "strconv" "strings" + "github.com/formancehq/ledger/pkg/core/accounts" + "github.com/go-chi/chi/v5" storageerrors "github.com/formancehq/ledger/internal/storage/sqlutils" "github.com/formancehq/go-libs/pointer" - "github.com/formancehq/stack/libs/core/accounts" "github.com/formancehq/go-libs/bun/bunpaginate" "github.com/formancehq/ledger/internal/api/backend" diff --git a/components/ledger/internal/api/v2/controllers_accounts.go b/components/ledger/internal/api/v2/controllers_accounts.go index 5322d6ff95..0a363d6b4d 100644 --- a/components/ledger/internal/api/v2/controllers_accounts.go +++ b/components/ledger/internal/api/v2/controllers_accounts.go @@ -6,12 +6,13 @@ import ( "net/http" "net/url" + "github.com/formancehq/ledger/pkg/core/accounts" + "github.com/go-chi/chi/v5" storageerrors "github.com/formancehq/ledger/internal/storage/sqlutils" "github.com/formancehq/go-libs/pointer" - "github.com/formancehq/stack/libs/core/accounts" sharedapi "github.com/formancehq/go-libs/api" "github.com/formancehq/go-libs/bun/bunpaginate" diff --git a/components/ledger/internal/machine/account.go b/components/ledger/internal/machine/account.go index 9ba1fa77c9..bf98e74b3c 100644 --- a/components/ledger/internal/machine/account.go +++ b/components/ledger/internal/machine/account.go @@ -3,7 +3,7 @@ package machine import ( "fmt" - "github.com/formancehq/stack/libs/core/accounts" + "github.com/formancehq/ledger/pkg/core/accounts" ) type AccountAddress string diff --git a/components/ledger/internal/machine/asset.go b/components/ledger/internal/machine/asset.go index 853539aefc..ceb03ac659 100644 --- a/components/ledger/internal/machine/asset.go +++ b/components/ledger/internal/machine/asset.go @@ -3,7 +3,7 @@ package machine import ( "fmt" - "github.com/formancehq/stack/libs/core/assets" + "github.com/formancehq/ledger/pkg/core/assets" ) type Asset string diff --git a/components/ledger/internal/posting.go b/components/ledger/internal/posting.go index 3f2f96e5c1..6a48194a89 100644 --- a/components/ledger/internal/posting.go +++ b/components/ledger/internal/posting.go @@ -5,8 +5,8 @@ import ( "encoding/json" "math/big" - "github.com/formancehq/stack/libs/core/accounts" - "github.com/formancehq/stack/libs/core/assets" + "github.com/formancehq/ledger/pkg/core/accounts" + "github.com/formancehq/ledger/pkg/core/assets" "github.com/pkg/errors" ) diff --git a/libs/core/accounts/account_test.go b/components/ledger/pkg/core/accounts/account_test.go similarity index 100% rename from libs/core/accounts/account_test.go rename to components/ledger/pkg/core/accounts/account_test.go diff --git a/libs/core/accounts/accounts.go b/components/ledger/pkg/core/accounts/accounts.go similarity index 100% rename from libs/core/accounts/accounts.go rename to components/ledger/pkg/core/accounts/accounts.go diff --git a/libs/core/assets/asset.go b/components/ledger/pkg/core/assets/asset.go similarity index 100% rename from libs/core/assets/asset.go rename to components/ledger/pkg/core/assets/asset.go diff --git a/components/payments/internal/storage/migrations_v1.x.go b/components/payments/internal/storage/migrations_v1.x.go index d52016f13c..2b9e50a988 100644 --- a/components/payments/internal/storage/migrations_v1.x.go +++ b/components/payments/internal/storage/migrations_v1.x.go @@ -1052,8 +1052,6 @@ func fixExpandingChangelogs(ctx context.Context, tx bun.Tx) error { return err } - fmt.Println("Processing", len(metadata), "metadata") - if len(metadata) == 0 { break } diff --git a/ee/wallets/Earthfile b/ee/wallets/Earthfile index 672ba425a5..fcc3516de0 100644 --- a/ee/wallets/Earthfile +++ b/ee/wallets/Earthfile @@ -9,7 +9,7 @@ FROM core+base-image sources: WORKDIR src - COPY (stack+sources/out --LOCATION=libs/core) libs/core + COPY (stack+sources/out --LOCATION=components/ledger) components/ledger COPY --pass-args (releases+sdk-generate/go) /src/releases/sdks/go WORKDIR /src/ee/wallets COPY go.* . diff --git a/ee/wallets/go.mod b/ee/wallets/go.mod index 6e831b44d1..4736ca3c27 100644 --- a/ee/wallets/go.mod +++ b/ee/wallets/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.7 require ( github.com/formancehq/formance-sdk-go/v2 v2.0.0-00010101000000-000000000000 github.com/formancehq/go-libs v1.7.1 - github.com/formancehq/stack/libs/core v0.0.0-00010101000000-000000000000 + github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/render v1.0.3 github.com/google/uuid v1.6.0 @@ -89,6 +89,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/formancehq/stack/libs/core => ../../libs/core - replace github.com/formancehq/formance-sdk-go/v2 => ../../releases/sdks/go + +replace github.com/formancehq/ledger => ../../components/ledger diff --git a/ee/wallets/pkg/credit.go b/ee/wallets/pkg/credit.go index 88b45e5df8..98478e2960 100644 --- a/ee/wallets/pkg/credit.go +++ b/ee/wallets/pkg/credit.go @@ -4,7 +4,7 @@ import ( "math/big" "net/http" - "github.com/formancehq/stack/libs/core/assets" + "github.com/formancehq/ledger/pkg/core/assets" "github.com/formancehq/go-libs/time" diff --git a/ee/wallets/pkg/debit.go b/ee/wallets/pkg/debit.go index c10499d92b..e73532d380 100644 --- a/ee/wallets/pkg/debit.go +++ b/ee/wallets/pkg/debit.go @@ -4,8 +4,7 @@ import ( "math/big" "net/http" - "github.com/formancehq/stack/libs/core/assets" - + "github.com/formancehq/ledger/pkg/core/assets" "github.com/formancehq/go-libs/time" "github.com/formancehq/go-libs/metadata" diff --git a/ee/wallets/pkg/subject.go b/ee/wallets/pkg/subject.go index 03934fae8f..d4c3898e0e 100644 --- a/ee/wallets/pkg/subject.go +++ b/ee/wallets/pkg/subject.go @@ -3,7 +3,7 @@ package wallet import ( "fmt" - "github.com/formancehq/stack/libs/core/accounts" + "github.com/formancehq/ledger/pkg/core/accounts" ) const ( diff --git a/libs/Earthfile b/libs/Earthfile index 396ad4b92b..6b0b403b2f 100644 --- a/libs/Earthfile +++ b/libs/Earthfile @@ -6,5 +6,4 @@ IMPORT .. AS stack run: LOCALLY ARG --required TARGET - BUILD ./core+$TARGET BUILD ./events+$TARGET diff --git a/libs/core/.golangci.yml b/libs/core/.golangci.yml deleted file mode 100644 index 5cafc8d3d0..0000000000 --- a/libs/core/.golangci.yml +++ /dev/null @@ -1,43 +0,0 @@ -allow-parallel-runners: true -run: - timeout: 5m -linters: - disable-all: true - enable: - - gofmt - - goimports - - unused - - gosec -linters-settings: - gosec: - # To select a subset of rules to run. - # Available rules: https://github.com/securego/gosec#available-rules - includes: - - G103 # Audit the use of unsafe block - - G104 # Audit errors not checked - - G106 # Audit the use of ssh.InsecureIgnoreHostKey - - G108 # Profiling endpoint automatically exposed on /debug/pprof - - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 - - G110 # Potential DoS vulnerability via decompression bomb - - G111 # Potential directory traversal - - G112 # Potential slowloris attack -# - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G203 # Use of unescaped data in HTML templates - - G204 # Audit use of command execution - - G301 # Poor file permissions used when creating a directory - - G302 # Poor file permissions used with chmod - - G303 # Creating tempfile using a predictable path - - G304 # File path provided as taint input - - G305 # File traversal when extracting zip/tar archive - - G306 # Poor file permissions used when writing to a new file - - G307 # Poor file permissions used when creating a file with os.Create - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G403 # Ensure minimum RSA key length of 2048 bits - - G501 # Import blocklist: crypto/md5 - - G502 # Import blocklist: crypto/des - - G503 # Import blocklist: crypto/rc4 - - G504 # Import blocklist: net/http/cgi - - G505 # Import blocklist: crypto/sha1 - - G602 # Slice access out of bounds \ No newline at end of file diff --git a/libs/core/Earthfile b/libs/core/Earthfile deleted file mode 100644 index cf512fcca9..0000000000 --- a/libs/core/Earthfile +++ /dev/null @@ -1,32 +0,0 @@ -VERSION 0.8 - -IMPORT github.com/formancehq/earthly:tags/v0.15.0 AS core -IMPORT ../.. AS stack - -FROM core+base-image - -sources: - COPY . /src - WORKDIR src - SAVE ARTIFACT /src - -tidy: - FROM core+builder-image - COPY (+sources/*) /src - WORKDIR /src - DO --pass-args stack+GO_TIDY - SAVE ARTIFACT go.* AS LOCAL ./ - -lint: - FROM core+builder-image - COPY (+sources/*) /src - WORKDIR /src - COPY --pass-args +tidy/go.* . - DO --pass-args stack+GO_LINT - SAVE ARTIFACT * AS LOCAL ./ - -pre-commit: - WAIT - BUILD --pass-args +tidy - END - BUILD --pass-args +lint \ No newline at end of file diff --git a/libs/core/go.mod b/libs/core/go.mod deleted file mode 100644 index 272293a577..0000000000 --- a/libs/core/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module github.com/formancehq/stack/libs/core - -go 1.21.0 - -require github.com/stretchr/testify v1.9.0 - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/libs/core/go.sum b/libs/core/go.sum deleted file mode 100644 index 60ce688a04..0000000000 --- a/libs/core/go.sum +++ /dev/null @@ -1,10 +0,0 @@ -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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tests/integration/go.mod b/tests/integration/go.mod index 6493c3af37..8c9c4ce672 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -94,7 +94,6 @@ require ( github.com/fatih/structs v1.1.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/formancehq/payments/genericclient v0.0.0-00010101000000-000000000000 // indirect - github.com/formancehq/stack/libs/core v0.0.0-00010101000000-000000000000 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/get-momo/atlar-v1-go-client v1.2.1 // indirect github.com/gibson042/canonicaljson-go v1.0.3 // indirect @@ -280,7 +279,6 @@ replace ( github.com/formancehq/payments/genericclient => ../../components/payments/cmd/connectors/internal/connectors/generic/client/generated github.com/formancehq/reconciliation => ../../ee/reconciliation github.com/formancehq/search => ../../ee/search - github.com/formancehq/stack/libs/core => ../../libs/core github.com/formancehq/stack/libs/events => ../../libs/events github.com/formancehq/wallets => ../../ee/wallets github.com/formancehq/webhooks => ../../ee/webhooks