diff --git a/.gitignore b/.gitignore index 315f68452603204db8d098e3322ade96cafe939f..f56e44c3b03efd1c1274d3c9b34922f967cb0e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,6 @@ ### IDE .idea -*.iml .vscode -.clangd -.cache -.clwb -.ijwb - -###go.sum -*.sum ### output dir **/output/* @@ -22,50 +14,9 @@ .project *.prefs -### ignore all `build` dir inside pkg or tools -functionsystem/pkg/*/**/build/ - ### ninja files .ninja_* build.ninja -### build -build/ - -### resource -resource/ - -### functionsystem build cache -functionsystem/build/CMakeFiles -functionsystem/build/lib -functionsystem/build/bin -functionsystem/build/src -functionsystem/build/tests -functionsystem/build/*.txt -functionsystem/build/cmake* -functionsystem/build/*cmake -functionsystem/build/build.ninja -functionsystem/build/compile_commands.json -functionsystem/output/ - -### litebus build cache -common/litebus/build/ -common/litebus/test/ssl_utils/ -### logs build cache -common/utils/logs/build/ -### metrics build cache -common/utils/metrics/build/ - -### generated files -functionsystem/src/common/utils/version.h - ### copied files -common/utils/proto/pb/posix/*.pb.* -common/utils/proto/posix/common.proto -common/utils/proto/posix/core_service.proto -common/utils/proto/posix/runtime_rpc.proto -common/utils/proto/posix/runtime_service.proto -common/utils/proto/posix/affinity.proto - -### package cache -.build +functionsystem/src/common/proto/* \ No newline at end of file diff --git a/functionsystem/apps/cli/.gitignore b/functionsystem/apps/cli/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8f0f6e3d656cbe7ebc7ef2980dac668317426057 --- /dev/null +++ b/functionsystem/apps/cli/.gitignore @@ -0,0 +1,29 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Code coverage profiles and other test artifacts +*.out +coverage.* +*.coverprofile +profile.cov + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go file +go.work +go.work.sum + +# env file +.env + +# Editor/IDE +.idea/ +.vscode/ diff --git a/functionsystem/cmd/cli/main.go b/functionsystem/apps/cli/cmd/main.go similarity index 96% rename from functionsystem/cmd/cli/main.go rename to functionsystem/apps/cli/cmd/main.go index d83da3ddfc03d95d321ebe11b6c5daaf401fde33..d51c5445f522862fe3a70719bb742673853ad016 100644 --- a/functionsystem/cmd/cli/main.go +++ b/functionsystem/apps/cli/cmd/main.go @@ -20,7 +20,7 @@ package main import ( "os" - "functionsystem/pkg/cli/cmd" + "cli/internal" ) const errorExitCode = 1 diff --git a/functionsystem/pkg/cli/build/build.go b/functionsystem/apps/cli/constant/build.go similarity index 67% rename from functionsystem/pkg/cli/build/build.go rename to functionsystem/apps/cli/constant/build.go index 0677b194cff2c7c2dcb241d3a06682fe980bec96..d65d4fa03151a88cd63d37f4e04a4e458a406dcf 100644 --- a/functionsystem/pkg/cli/build/build.go +++ b/functionsystem/apps/cli/constant/build.go @@ -15,18 +15,13 @@ */ // Package build is build info of cli -package build - -// Version is version of cli, it is dynamically set by the Makefile. -var Version = Dev - -// CustomizeVer is build time of cli, it is dynamically set by the Makefile. -var CustomizeVer = "" - -// Date is build time of cli, it is dynamically set by the Makefile. -var Date = "" // YYYY-MM-DD +package constant const ( - // Dev develop version - Dev = "DEV" + // Version is version of cli, it is dynamically set by the Makefile. + Version = "DEV" + // Date is build time of cli, it is dynamically set by the Makefile. + Date = "" + // CustomizeVer is build time of cli, it is dynamically set by the Makefile. + CustomizeVer = "" ) diff --git a/functionsystem/pkg/cli/constant/constants.go b/functionsystem/apps/cli/constant/constants.go similarity index 100% rename from functionsystem/pkg/cli/constant/constants.go rename to functionsystem/apps/cli/constant/constants.go diff --git a/functionsystem/go.mod b/functionsystem/apps/cli/go.mod similarity index 99% rename from functionsystem/go.mod rename to functionsystem/apps/cli/go.mod index c8db8e65fbdaa8e0a45372fcec1c11acb24d234f..03a31808c253c4c611c0b72120feb795497cf27a 100644 --- a/functionsystem/go.mod +++ b/functionsystem/apps/cli/go.mod @@ -1,4 +1,4 @@ -module functionsystem +module cli go 1.21.4 diff --git a/functionsystem/apps/cli/go.sum b/functionsystem/apps/cli/go.sum new file mode 100644 index 0000000000000000000000000000000000000000..95263f525ddbf6146a52df3f5ddf4f597670e22c --- /dev/null +++ b/functionsystem/apps/cli/go.sum @@ -0,0 +1,96 @@ +github.com/agiledragon/gomonkey v2.0.1+incompatible h1:DIQT3ZshgGz9pTwBddRSZWDutIRPx2d7UzmjzgWo9q0= +github.com/agiledragon/gomonkey v2.0.1+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.etcd.io/etcd/api/v3 v3.5.11 h1:B54KwXbWDHyD3XYAwprxNzTe7vlhR69LuBgZnMVvS7E= +go.etcd.io/etcd/api/v3 v3.5.11/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4= +go.etcd.io/etcd/client/pkg/v3 v3.5.11 h1:bT2xVspdiCj2910T0V+/KHcVKjkUrCZVtk8J2JF2z1A= +go.etcd.io/etcd/client/pkg/v3 v3.5.11/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4= +go.etcd.io/etcd/client/v3 v3.5.11 h1:ajWtgoNSZJ1gmS8k+icvPtqsqEav+iUorF7b0qozgUU= +go.etcd.io/etcd/client/v3 v3.5.11/go.mod h1:a6xQUEqFJ8vztO1agJh/KQKOMfFI8og52ZconzcDJwE= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +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/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +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= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= +google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +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.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/functionsystem/pkg/cli/cmd/root.go b/functionsystem/apps/cli/internal/root.go similarity index 89% rename from functionsystem/pkg/cli/cmd/root.go rename to functionsystem/apps/cli/internal/root.go index ddbe7797760af5bc069e7e614735db0dba88444f..9319a67c65e98f2f1a14adfbd931957d003eb337 100644 --- a/functionsystem/pkg/cli/cmd/root.go +++ b/functionsystem/apps/cli/internal/root.go @@ -23,12 +23,12 @@ import ( "github.com/spf13/cobra" - "functionsystem/pkg/cli/cmd/start" - "functionsystem/pkg/cli/cmd/status" - "functionsystem/pkg/cli/cmd/stop" - "functionsystem/pkg/cli/cmd/version" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" + "cli/constant" + "cli/internal/start" + "cli/internal/status" + "cli/internal/stop" + "cli/internal/version" + "cli/pkg/cmdio" ) // NewCmdRoot new root cmd diff --git a/functionsystem/pkg/cli/cmd/root_test.go b/functionsystem/apps/cli/internal/root_test.go similarity index 100% rename from functionsystem/pkg/cli/cmd/root_test.go rename to functionsystem/apps/cli/internal/root_test.go diff --git a/functionsystem/pkg/cli/cmd/start/yr_start.go b/functionsystem/apps/cli/internal/start/yr_start.go similarity index 99% rename from functionsystem/pkg/cli/cmd/start/yr_start.go rename to functionsystem/apps/cli/internal/start/yr_start.go index 4bb1ea8e511f899af555522297b7c6404cf968e6..e67e0d88d0b0ca1d26d984c584a550b0dc015dfd 100644 --- a/functionsystem/pkg/cli/cmd/start/yr_start.go +++ b/functionsystem/apps/cli/internal/start/yr_start.go @@ -36,10 +36,10 @@ import ( "github.com/spf13/cobra" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/utils" - "functionsystem/pkg/cli/utils/colorprint" + "cli/constant" + "cli/pkg/cmdio" + "cli/utils" + "cli/utils/colorprint" ) type yrStartOptions struct { diff --git a/functionsystem/pkg/cli/cmd/start/yr_start_test.go b/functionsystem/apps/cli/internal/start/yr_start_test.go similarity index 99% rename from functionsystem/pkg/cli/cmd/start/yr_start_test.go rename to functionsystem/apps/cli/internal/start/yr_start_test.go index ed9087b8e8654706364f101460d6a9d1f310e8be..a780e973a7c150aa74150cf6d7367cb9cb36756b 100644 --- a/functionsystem/pkg/cli/cmd/start/yr_start_test.go +++ b/functionsystem/apps/cli/internal/start/yr_start_test.go @@ -17,10 +17,10 @@ package start import ( + "cli/constant" "context" "errors" "fmt" - "functionsystem/pkg/cli/constant" "os" "os/exec" "path" @@ -28,8 +28,8 @@ import ( "testing" "time" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/utils" + "cli/pkg/cmdio" + "cli/utils" "github.com/agiledragon/gomonkey" . "github.com/smartystreets/goconvey/convey" diff --git a/functionsystem/pkg/cli/cmd/status/yr_status.go b/functionsystem/apps/cli/internal/status/yr_status.go similarity index 96% rename from functionsystem/pkg/cli/cmd/status/yr_status.go rename to functionsystem/apps/cli/internal/status/yr_status.go index eeab7ca3ed9247faa9ff28380e0b210b867810a3..ef9eceabe3f759e5e6ad26892d493c0edd6facbe 100644 --- a/functionsystem/pkg/cli/cmd/status/yr_status.go +++ b/functionsystem/apps/cli/internal/status/yr_status.go @@ -30,10 +30,10 @@ import ( "github.com/spf13/cobra" clientv3 "go.etcd.io/etcd/client/v3" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/utils" - "functionsystem/pkg/cli/utils/colorprint" + "cli/constant" + "cli/pkg/cmdio" + "cli/utils" + "cli/utils/colorprint" ) type yrStatusOptions struct { diff --git a/functionsystem/pkg/cli/cmd/stop/yr_stop.go b/functionsystem/apps/cli/internal/stop/yr_stop.go similarity index 97% rename from functionsystem/pkg/cli/cmd/stop/yr_stop.go rename to functionsystem/apps/cli/internal/stop/yr_stop.go index 1e416ff0fe1bec3d7f1ff4177eddd941ba761c26..441b0d74196a86ea100b9b6d46c83c8d8b47a94c 100644 --- a/functionsystem/pkg/cli/cmd/stop/yr_stop.go +++ b/functionsystem/apps/cli/internal/stop/yr_stop.go @@ -32,11 +32,11 @@ import ( "github.com/spf13/cobra" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/pkg/progress" - "functionsystem/pkg/cli/utils" - "functionsystem/pkg/cli/utils/colorprint" + "cli/constant" + "cli/pkg/cmdio" + "cli/pkg/progress" + "cli/utils" + "cli/utils/colorprint" ) type yrStopOptions struct { diff --git a/functionsystem/pkg/cli/cmd/stop/yr_stop_test.go b/functionsystem/apps/cli/internal/stop/yr_stop_test.go similarity index 96% rename from functionsystem/pkg/cli/cmd/stop/yr_stop_test.go rename to functionsystem/apps/cli/internal/stop/yr_stop_test.go index bbd8a5aa5557f2381dc9c7949e3e9f3cbeeeb9b3..5b73e866b9771cabef2e1fefa3687e384c336a3d 100644 --- a/functionsystem/pkg/cli/cmd/stop/yr_stop_test.go +++ b/functionsystem/apps/cli/internal/stop/yr_stop_test.go @@ -17,9 +17,9 @@ package stop import ( - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/utils" + "cli/constant" + "cli/pkg/cmdio" + "cli/utils" "github.com/agiledragon/gomonkey" "github.com/smartystreets/goconvey/convey" "os" diff --git a/functionsystem/pkg/cli/cmd/version/version.go b/functionsystem/apps/cli/internal/version/version.go similarity index 86% rename from functionsystem/pkg/cli/cmd/version/version.go rename to functionsystem/apps/cli/internal/version/version.go index 1f6e49a8721cc674333bf9adc7d63cf75c70a8ea..a1e5ccd8ce9f9ee337034b6347ae806fe821d18f 100644 --- a/functionsystem/pkg/cli/cmd/version/version.go +++ b/functionsystem/apps/cli/internal/version/version.go @@ -20,11 +20,10 @@ package version import ( "github.com/spf13/cobra" - "functionsystem/pkg/cli/build" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/cmdio" - "functionsystem/pkg/cli/utils" - "functionsystem/pkg/cli/utils/colorprint" + "cli/constant" + "cli/pkg/cmdio" + "cli/utils" + "cli/utils/colorprint" ) type options struct { @@ -41,7 +40,7 @@ var cmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { colorMap := []colorprint.StringColorInfo{ {Str: "CLI version: ", Color: colorprint.Colorless}, - {Str: build.Version, Color: colorprint.KeywordColor}, + {Str: constant.Version, Color: colorprint.KeywordColor}, {Str: ".\n", Color: colorprint.Colorless}, {Str: "Using yuanrong at: ", Color: colorprint.Colorless}, {Str: constant.YuanRongInstallationDir, Color: colorprint.Colorless}, diff --git a/functionsystem/pkg/cli/cmd/version/version_test.go b/functionsystem/apps/cli/internal/version/version_test.go similarity index 85% rename from functionsystem/pkg/cli/cmd/version/version_test.go rename to functionsystem/apps/cli/internal/version/version_test.go index 7eed761aba53a61172a7f66244456445372ad0db..42a859dedf5ea95e724205fc09e29c1a5816a43a 100644 --- a/functionsystem/pkg/cli/cmd/version/version_test.go +++ b/functionsystem/apps/cli/internal/version/version_test.go @@ -23,10 +23,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "functionsystem/pkg/cli/build" - "functionsystem/pkg/cli/constant" - "functionsystem/pkg/cli/pkg/test" - "functionsystem/pkg/cli/utils/colorprint" + "cli/constant" + "cli/pkg/test" + "cli/utils/colorprint" ) func TestInitVersionCMD(t *testing.T) { @@ -47,8 +46,8 @@ func TestInitVersionCMD(t *testing.T) { } for _, tt := range testCases { t.Run(tt.name, func(t *testing.T) { - p := gomonkey.ApplyGlobalVar(&build.Version, tt.version) - p.ApplyGlobalVar(&build.Date, tt.buildTime) + p := gomonkey.ApplyGlobalVar(&constant.Version, tt.version) + p.ApplyGlobalVar(&constant.Date, tt.buildTime) defer p.Reset() cio, mio := test.MockCmdIO() diff --git a/functionsystem/pkg/cli/pkg/cmdio/cmdio.go b/functionsystem/apps/cli/pkg/cmdio/cmdio.go similarity index 100% rename from functionsystem/pkg/cli/pkg/cmdio/cmdio.go rename to functionsystem/apps/cli/pkg/cmdio/cmdio.go diff --git a/functionsystem/pkg/cli/pkg/progress/progress.go b/functionsystem/apps/cli/pkg/progress/progress.go similarity index 100% rename from functionsystem/pkg/cli/pkg/progress/progress.go rename to functionsystem/apps/cli/pkg/progress/progress.go diff --git a/functionsystem/pkg/cli/pkg/test/cmdio.go b/functionsystem/apps/cli/pkg/test/cmdio.go similarity index 97% rename from functionsystem/pkg/cli/pkg/test/cmdio.go rename to functionsystem/apps/cli/pkg/test/cmdio.go index 2440593dcadef4f1a7fc9773a6d80a857f43ecb6..328ddb5b85c009411b5d1635b92dc6e80c74720d 100644 --- a/functionsystem/pkg/cli/pkg/test/cmdio.go +++ b/functionsystem/apps/cli/pkg/test/cmdio.go @@ -21,7 +21,7 @@ import ( "bytes" "io/ioutil" - "functionsystem/pkg/cli/pkg/cmdio" + "cli/pkg/cmdio" ) // CmdIO mock io of cmd diff --git a/functionsystem/pkg/cli/utils/cmd_args.go b/functionsystem/apps/cli/utils/cmd_args.go similarity index 100% rename from functionsystem/pkg/cli/utils/cmd_args.go rename to functionsystem/apps/cli/utils/cmd_args.go diff --git a/functionsystem/pkg/cli/utils/colorprint/ac.go b/functionsystem/apps/cli/utils/colorprint/ac.go similarity index 100% rename from functionsystem/pkg/cli/utils/colorprint/ac.go rename to functionsystem/apps/cli/utils/colorprint/ac.go diff --git a/functionsystem/pkg/cli/utils/colorprint/colorprint.go b/functionsystem/apps/cli/utils/colorprint/colorprint.go similarity index 100% rename from functionsystem/pkg/cli/utils/colorprint/colorprint.go rename to functionsystem/apps/cli/utils/colorprint/colorprint.go diff --git a/functionsystem/pkg/cli/utils/colorprint/colorprint_unix.go b/functionsystem/apps/cli/utils/colorprint/colorprint_unix.go similarity index 100% rename from functionsystem/pkg/cli/utils/colorprint/colorprint_unix.go rename to functionsystem/apps/cli/utils/colorprint/colorprint_unix.go diff --git a/functionsystem/pkg/cli/utils/colorprint/types.go b/functionsystem/apps/cli/utils/colorprint/types.go similarity index 100% rename from functionsystem/pkg/cli/utils/colorprint/types.go rename to functionsystem/apps/cli/utils/colorprint/types.go diff --git a/functionsystem/pkg/cli/utils/colorprint/types_unix.go b/functionsystem/apps/cli/utils/colorprint/types_unix.go similarity index 100% rename from functionsystem/pkg/cli/utils/colorprint/types_unix.go rename to functionsystem/apps/cli/utils/colorprint/types_unix.go diff --git a/functionsystem/pkg/cli/utils/file.go b/functionsystem/apps/cli/utils/file.go similarity index 100% rename from functionsystem/pkg/cli/utils/file.go rename to functionsystem/apps/cli/utils/file.go diff --git a/functionsystem/pkg/cli/utils/file_test.go b/functionsystem/apps/cli/utils/file_test.go similarity index 100% rename from functionsystem/pkg/cli/utils/file_test.go rename to functionsystem/apps/cli/utils/file_test.go diff --git a/functionsystem/pkg/cli/utils/localip.go b/functionsystem/apps/cli/utils/localip.go similarity index 100% rename from functionsystem/pkg/cli/utils/localip.go rename to functionsystem/apps/cli/utils/localip.go diff --git a/functionsystem/pkg/cli/utils/masterinfo.go b/functionsystem/apps/cli/utils/masterinfo.go similarity index 100% rename from functionsystem/pkg/cli/utils/masterinfo.go rename to functionsystem/apps/cli/utils/masterinfo.go diff --git a/functionsystem/pkg/cli/utils/memory.go b/functionsystem/apps/cli/utils/memory.go similarity index 100% rename from functionsystem/pkg/cli/utils/memory.go rename to functionsystem/apps/cli/utils/memory.go diff --git a/functionsystem/pkg/cli/utils/memory_test.go b/functionsystem/apps/cli/utils/memory_test.go similarity index 100% rename from functionsystem/pkg/cli/utils/memory_test.go rename to functionsystem/apps/cli/utils/memory_test.go diff --git a/functionsystem/pkg/cli/utils/raw.go b/functionsystem/apps/cli/utils/raw.go similarity index 100% rename from functionsystem/pkg/cli/utils/raw.go rename to functionsystem/apps/cli/utils/raw.go diff --git a/functionsystem/pkg/cli/utils/raw_test.go b/functionsystem/apps/cli/utils/raw_test.go similarity index 100% rename from functionsystem/pkg/cli/utils/raw_test.go rename to functionsystem/apps/cli/utils/raw_test.go diff --git a/functionsystem/pkg/cli/utils/reader.go b/functionsystem/apps/cli/utils/reader.go similarity index 100% rename from functionsystem/pkg/cli/utils/reader.go rename to functionsystem/apps/cli/utils/reader.go diff --git a/functionsystem/pkg/cli/utils/reader_test.go b/functionsystem/apps/cli/utils/reader_test.go similarity index 100% rename from functionsystem/pkg/cli/utils/reader_test.go rename to functionsystem/apps/cli/utils/reader_test.go diff --git a/functionsystem/pkg/cli/utils/symbollink.go b/functionsystem/apps/cli/utils/symbollink.go similarity index 100% rename from functionsystem/pkg/cli/utils/symbollink.go rename to functionsystem/apps/cli/utils/symbollink.go diff --git a/functionsystem/pkg/cli/utils/util.go b/functionsystem/apps/cli/utils/util.go similarity index 100% rename from functionsystem/pkg/cli/utils/util.go rename to functionsystem/apps/cli/utils/util.go diff --git a/functionsystem/pkg/cli/utils/util_test.go b/functionsystem/apps/cli/utils/util_test.go similarity index 100% rename from functionsystem/pkg/cli/utils/util_test.go rename to functionsystem/apps/cli/utils/util_test.go diff --git a/functionsystem/apps/iam_server/go.mod b/functionsystem/apps/iam_server/go.mod new file mode 100644 index 0000000000000000000000000000000000000000..42c31c164b1db5f8e819f3c81811e17778d390af --- /dev/null +++ b/functionsystem/apps/iam_server/go.mod @@ -0,0 +1,37 @@ +module iam_server + +go 1.24.1 + +require ( + github.com/gorilla/mux v1.8.1 + github.com/wolfbolin/gobo v0.1.0-beta.1 + go.etcd.io/etcd/client/v3 v3.5.13 +) + +require ( + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/getsentry/sentry-go v0.18.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect + go.etcd.io/etcd/api/v3 v3.5.13 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect + go.uber.org/multierr v1.10.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/grpc v1.59.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect +) diff --git a/functionsystem/build.sh b/functionsystem/build.sh deleted file mode 100644 index ea391452cac3a0173f1300a39dbbd9f340911475..0000000000000000000000000000000000000000 --- a/functionsystem/build.sh +++ /dev/null @@ -1,345 +0,0 @@ -#!/bin/bash -# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -x -set -e -set -o nounset -set -o pipefail - -readonly USAGE=" -Usage: bash build.sh [-h] [-r] [-C] [-m ] [-v ] [-j ] [-o ] [-S] - [-u off|build|run] [-M ] [-t ] [-c off/on/html] [-O on/off] - [-P 1/2] [-k] - -Options: - -r specifies build type to 'Release' mode, default 'Debug' mode. - -m compile the specific module, for example 'function_proxy', default is 'all' - -v YuanRong version - -V enable print ninja build verbose message - -o set the output path of the compilation result, default is './output'. - -j set the number of jobs run in parallel for compiling source code and compiling open source software, - default is the number of processor. - -C clear make history before building - -O building with observability - -h show usage - -T set path of third party, default is ./third_party - -P choose build part - -k do not check charts - -b enable print build object time trace - - For Debug Mode: - -S Use Sanitizers tools to detect bugs. Choose from off/address/thread/leak, - if set the value to 'address' enable AddressSanitizer, memory error detector - if set the value to 'thread' enable ThreadSanitizer, data race detector. - if set the value to 'memory' enable MemorySanitizer, a detector of uninitialized memory reads - default off. - - For LLT: - -c Build coverage, choose from: off/on/html, default: off. - -M Specifies the test suit name to run, all suits by default. - -t Specifies the testcase name to run, all testcases by default. - -u Compiling or running unit testcases, default off. Choose from: off/build/run. - Field 'off' indicates that testcases are not compiled and executed. - Field 'build' indicates that testcases are compiled but not run. - Field 'run' indicates that testcases are compiled and run. - - For tool: - -g generate code from proto file. - -Environment: -1) YR_OPENSOURCE_DIR: Specifies a directory to cache the opensource compilation result. - Cache the compilation result to speed up the compilation. Default: readlink -f BASE_DIR - -Example: -1) Compile a release version and export compilation result to the output directory. - $ bash build.sh -r -m function_proxy -o ./output -" -BASE_DIR=$( - cd "$(dirname "$0")" - pwd -) - -# test options -BUILD_LLT=OFF -RUN_LLT=OFF -BUILD_GCOV=OFF -GEN_LLT_REPORT=OFF -UT_EXECUTABLE="functionsystem_unit_test" -IT_EXECUTABLE="functionsystem_integration_test" -TEST_SUIT="*" -TEST_CASE="*" -# compile options - -YR_VERSION="yr-functionsystem-v0.0.1" -BUILD_TYPE=Debug -CLEAR_OUTPUT=OFF -SANITIZERS=OFF -MODULE='' -MODULE_LIST=("function_master" "function_proxy" "function_agent") -PROJECT_DIR="${BASE_DIR}" -BUILD_DIR="${BASE_DIR}/build" -OUTPUT_DIR="${BASE_DIR}/output" -YR_ROOT_DIR="${BASE_DIR}/.." -POSIX_DIR="${BASE_DIR}/src/common/proto/posix" -PACKAGE_OUTPUT_DIR="${YR_ROOT_DIR}/output" -FUNCTION_SYSTEM_PACKAGE_DIR="${YR_ROOT_DIR}/output/function_system" -FUNCTIONCORE_DIR="${YR_ROOT_DIR}/functioncore/" -SYM_OUTPUT_DIR="${YR_ROOT_DIR}/output/sym" -CPU_NUM="$(grep -c 'processor' /proc/cpuinfo)" -JOB_NUM="$(($(grep -c 'processor' /proc/cpuinfo) + 1))" -YR_OPENSOURCE_DIR="" -BUILD_RUNTIMES="all" -VERBOSE="" - -FUNCTION_SYSTEM_BUILD_TIME_TRACE="OFF" -JEMALLOC_PROF_ENABLE="OFF" - -BUILD_ROOT_DIR="$(readlink -f "${PROJECT_DIR}/..")" -BUILD_CONFIG_DIR="${BUILD_ROOT_DIR}/thirdparty" -THIRDPARTY_SRC_DIR="${BUILD_ROOT_DIR}/vendor/" -THIRDPARTY_INSTALL_DIR="${THIRDPARTY_SRC_DIR}/out" - -BUILD_FUNCTIONCORE="OFF" -FUNCTIONCORE_SRC_DIR="${YR_ROOT_DIR}/functionsystem" -FUNCTIONCORE_OUT_DIR="${YR_ROOT_DIR}/output/functioncore" -YUANRONG_DIR="${YR_ROOT_DIR}/output/function_system" - -# go module prepare -export GO111MODULE=on -export GONOSUMDB=* - -. "${YR_ROOT_DIR}"/tools/utils.sh - -if command -v ccache &> /dev/null -then - ccache -p - ccache -z -fi - -usage_cpp() { - echo -e "$USAGE" -} - -function check_number() { - number_check='^([0-9]+)$' - if [[ "$1" =~ ${number_check} ]]; then - return 0 - else - log_error "Invalid value $1 for option -$2" - log_warning "${USAGE}" - exit 1 - fi -} - -function check_module() { - if [[ "${MODULE_LIST[*]}" =~ $1 ]]; then - return 0 - fi - log_error "Invalid module name $1 for option -m" - log_info "Valid module list: ${MODULE_LIST}" - return 1 -} - -function check_posix() { - log_info "Start check posix at ${POSIX_DIR}" - mkdir -p ${POSIX_DIR} - cp -f ${YR_ROOT_DIR}/proto/inner/*.proto ${POSIX_DIR} - cp -f ${YR_ROOT_DIR}/proto/posix/*.proto ${POSIX_DIR} -} - -function strip_symbols() { - local src_dir="$1" - local dest_dir="$2" - if [[ ! -d "${dest_dir}" ]]; then - mkdir -p "${dest_dir}" - fi - - for file in ${src_dir}/*; do - local type - type="$(file -b --mime-type ${file} | sed 's|/.*||')" - if [[ ! -L "${file}" ]] && [[ ! -d "${file}" ]] && [[ "x${type}" != "xtext" ]]; then - strip_file_symbols ${file} ${dest_dir} - fi - done -} - -function strip_file_symbols() { - local file="$1" - local dest_dir="$2" - echo "---- start to strip ${file}" - local basename - basename=$(basename "${file}") - objcopy --only-keep-debug "${file}" "${dest_dir}/${basename}.sym" - objcopy --add-gnu-debuglink="${dest_dir}/${basename}.sym" "${file}" - objcopy --strip-all "${file}" -} - -function functioncore_compile() { - log_info "functioncore build" - if [ ! -d "${FUNCTIONCORE_SRC_DIR}" ]; then - log_warning "functioncore is not existed, skip it" - return 0 - fi - cd "${FUNCTIONCORE_SRC_DIR}" && go mod tidy - set +e - GIT_BRANCH=$(git symbolic-ref --short -q HEAD) - GIT_HASH=$(git log -1 "--pretty=format:[%H][%aI]") - set -e - log_info "version:${YR_VERSION} branch:${GIT_BRANCH} commitID:${GIT_HASH}" - export GIT_HASH - export GIT_BRANCH - export YR_VERSION - - bash build_golang.sh linux || die "cli module build failed" - CLI_NAME="yr" bash build_golang.sh linux || die "cli module build failed" - - log_info "functioncore build successfully" -} - -while getopts 'yghrxVbm:v:o:j:S:Cc:u:t:M:d:T:s:R:P:p:k' opt; do - case "$opt" in - v) - VERSION="${OPTARG}" - YR_VERSION="yr-functionsystem-v${VERSION}" - ;; - V) - VERBOSE="-v" - ;; - r) - BUILD_TYPE=Release - ;; - o) - OUTPUT_DIR=$(realpath -m "${OPTARG}") - ;; - j) - check_number "${OPTARG}" j - if [ ${OPTARG} -gt $(($CPU_NUM * 2)) ]; then - log_warning "The -j $OPTARG is over the max logical cpu count($CPU_NUM) * 2" - fi - JOB_NUM="${OPTARG}" - ;; - h) - usage_cpp - exit 0 - ;; - S) - BUILD_TYPE=Debug - SANITIZERS="${OPTARG}" # Debug工具 - ;; - C) - CLEAR_OUTPUT=ON - ;; - c) - if [ "X${OPTARG}" = "Xoff" ]; then - log_info "Coverage reports is disabled" - elif [ "X${OPTARG}" = "Xon" ]; then - BUILD_GCOV=ON - elif [ "X${OPTARG}" = "Xhtml" ]; then - BUILD_GCOV=ON - GEN_LLT_REPORT=ON - else - log_error "Invalid value ${OPTARG} for option -c, choose from off/on/html" - log_info "${USAGE}" - exit 1 - fi - ;; - p) - JEMALLOC_PROF_ENABLE=${OPTARG} - ;; - M) - TEST_SUIT=${OPTARG} - ;; - t) - TEST_CASE=${OPTARG} - ;; - u) - if [ "X${OPTARG}" = "Xoff" ]; then - log_info "LLT is disabled" - elif [ "X${OPTARG}" = "Xbuild" ]; then - BUILD_LLT=ON - elif [ "X${OPTARG}" = "Xrun" ]; then - BUILD_LLT=ON - RUN_LLT=ON - else - log_error "Invalid value ${OPTARG} for option -u, choose from off/build/run" - log_info "${USAGE}" - exit 1 - fi - ;; - b) - FUNCTION_SYSTEM_BUILD_TIME_TRACE=ON - log_info "cmake build time trace is enabled" - ;; - y) - BUILD_FUNCTIONCORE=ON - log_info "build functioncore" - ;; - *) - log_error "Invalid command" - usage_cpp - exit 1 - ;; - esac -done - -log_info "Begin to build, Build-Type:${BUILD_TYPE} Enable-LLT:${BUILD_LLT} Sanitizers:${SANITIZERS}" - -if [ X"${BUILD_FUNCTIONCORE}" == X"ON" ]; then - functioncore_compile -fi - - -if [ "$BUILD_TYPE" != "Debug" ]; then - [ ! -d "${OUTPUT_DIR}/functionsystem_SYM" ] && mkdir -p "${OUTPUT_DIR}/functionsystem_SYM" - rm -rf "${OUTPUT_DIR}/functionsystem_SYM/*" - strip_symbols "$OUTPUT_DIR"/bin "${OUTPUT_DIR}/functionsystem_SYM" - strip_symbols "$OUTPUT_DIR"/lib "${OUTPUT_DIR}/functionsystem_SYM" -fi - -# copy function system output -# TODO 全是脚本耦合,待优化 -# OUTPUT_DIR = functionsystem/output -# FUNCTION_SYSTEM_PACKAGE_DIR = ./output/function_system -mkdir -p "${FUNCTION_SYSTEM_PACKAGE_DIR}"/bin "${FUNCTION_SYSTEM_PACKAGE_DIR}"/lib "${FUNCTION_SYSTEM_PACKAGE_DIR}"/deploy "${FUNCTION_SYSTEM_PACKAGE_DIR}"/config -cp -ar "$OUTPUT_DIR"/bin/* "${FUNCTION_SYSTEM_PACKAGE_DIR}"/bin - -cp -ar "$OUTPUT_DIR"/lib/* "${FUNCTION_SYSTEM_PACKAGE_DIR}"/lib - -# 复制部署文件 -cp -ar "${YR_ROOT_DIR}"/scripts/deploy/function_system/* "${FUNCTION_SYSTEM_PACKAGE_DIR}"/deploy - -# 复制可观测配置 -cp -ar "${YR_ROOT_DIR}"/scripts/config/metrics/metrics_config.json "${FUNCTION_SYSTEM_PACKAGE_DIR}"/config/ - -# clean and create output dir -[[ -d "${YUANRONG_DIR}"/third_party ]] && rm -rf "${YUANRONG_DIR}"/third_party -mkdir -p "${YUANRONG_DIR}"/third_party/etcd -cp "$BUILD_DIR"/etcd/bin/etcd "${YUANRONG_DIR}"/third_party/etcd -cp "$BUILD_DIR"/etcd/bin/etcdctl "${YUANRONG_DIR}"/third_party/etcd -cp "${YR_ROOT_DIR}"/scripts/deploy/third_party/health_check.sh "${YUANRONG_DIR}"/third_party/ -cp "${YR_ROOT_DIR}"/scripts/deploy/third_party/install.sh "${YUANRONG_DIR}"/third_party/ -cp "${YR_ROOT_DIR}"/scripts/deploy/third_party/utils.sh "${YUANRONG_DIR}"/third_party/ -find "${YUANRONG_DIR}"/third_party/ -type f -exec chmod 550 {} \; - -if [ "$BUILD_TYPE" != "Debug" ]; then - rm -rf "${SYM_OUTPUT_DIR}/functionsystem_SYM" - cp -ar "${OUTPUT_DIR}/functionsystem_SYM" "${SYM_OUTPUT_DIR}/" - tar -czf "${PACKAGE_OUTPUT_DIR}"/sym.tar.gz -C "${SYM_OUTPUT_DIR}/" . - rm -rf "${SYM_OUTPUT_DIR}/" -fi - -rm -f "${PACKAGE_OUTPUT_DIR}"/${YR_VERSION}.tar.gz -cd ${PACKAGE_OUTPUT_DIR} -tar -czf "${PACKAGE_OUTPUT_DIR}"/${YR_VERSION}.tar.gz function_system -cd ${YR_ROOT_DIR} \ No newline at end of file diff --git a/functionsystem/build_golang.sh b/functionsystem/build_golang.sh deleted file mode 100644 index ee5ebe3afbf71aa0220ba5efbc47ec84f60ae891..0000000000000000000000000000000000000000 --- a/functionsystem/build_golang.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -BASE_DIR=$(cd "$(dirname "$0")"; pwd) -PROJECT_DIR="${BASE_DIR}/pkg/cli" -OUTPUT_DIR="${BASE_DIR}/../output/function_system/cli" -TARGET_OS=$1 -CLI_NAME=${CLI_NAME:-"yr"} -PLATFORM_NAME=${PLATFORM_NAME:-"OpenYuanrong"} - -BUILD_DATE=$(date -u "+%Y%m%d%H%M%S") -VERSION=$YR_VERSION -if [ -z "$VERSION" ]; then - VERSION="DEV" -fi - -FLAGS='-X functionsystem/pkg/cli/build.Version='${VERSION}' -X functionsystem/pkg/cli/build.Date='${BUILD_DATE}' -X functionsystem/pkg/cli/constant.CliName='${CLI_NAME}' -X functionsystem/pkg/cli/constant.PlatformName='${PLATFORM_NAME}' -X functionsystem/pkg/cli/build.CustomizeVer='${CLI_NAME}' -linkmode=external -extldflags "-fPIC -fstack-protector-strong -Wl,-z,now,-z,relro,-z,noexecstack,-s -Wall -Werror"' - -MODE='-buildmode=pie' - -function build_linux() { - CC='gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2' go build -buildmode=pie -ldflags "${FLAGS}" -o \ - build/_output/bin/${CLI_NAME} ../../cmd/cli/main.go - ls -l build/_output/bin/${CLI_NAME} -} - -function build_windows() { - if ! CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "${FLAGS}" \ - -o build/_output/bin/"${CLI_NAME}".exe ../../cmd/cli/main.go; then - log_error "Failed to build "${CLI_NAME}".exe!!!" - return 1 - fi - return 0 -} - -cd "${PROJECT_DIR}" || die "${PROJECT_DIR} not exist" - -# clean -rm -rf build/_output -rm -fr build/cli/usr/local/cli/bin/"${CLI_NAME}" - -cd "${PROJECT_DIR}" -mkdir -p build/_output/bin -mkdir -p build/_output/pkg -mkdir -p build/cli/usr/local/cli/bin -if [ "${TARGET_OS}" = "linux" ]; then - build_linux -elif [ "${TARGET_OS}" = "windows" ]; then - build_windows -else - build_linux - build_windows -fi -rm -fr build/cli/usr/local/cli/bin/"${CLI_NAME}" -cp build/_output/bin/"${CLI_NAME}" build/cli/usr/local/cli/bin/ -tar -cf build/_output/pkg/cli.tar -C ../../cmd/cli install.sh -C "${PROJECT_DIR}"/build/cli/usr/local cli - -mkdir -p "${OUTPUT_DIR}" -cp -ar build/_output/* "${OUTPUT_DIR}"/ - -exit 0 diff --git a/functionsystem/cmd/cli/install.sh b/functionsystem/cmd/cli/install.sh deleted file mode 100644 index 120787e9a61ece5b3e9bfcaa13bbeaed455854d4..0000000000000000000000000000000000000000 --- a/functionsystem/cmd/cli/install.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu -set -o pipefail - -install_dir=~/.cli -CLI_NAME="" - -# clear and remove cli -[ -d "${install_dir}" ] && rm -rf ${install_dir} -mkdir -p ${install_dir} - -files=$(ls ./cli/bin) -for filename in $files; do - if [[ "$filename" != *"exe" ]]; then - CLI_NAME=$filename - fi - break -done - -if [ -z "$CLI_NAME" ]; then - echo "there is no incorrect cli installation file" - exit 1 -fi - -# install cli -cp -r ./cli/* ${install_dir} -if [ ! -d ~/bin ]; then - mkdir ~/bin -fi - -ln -sf ${install_dir}/bin/"${CLI_NAME}" ~/bin/"${CLI_NAME}" - -echo -e "The CLI is installed successfully." -exit 0 diff --git a/functionsystem/dist/README.md b/functionsystem/dist/README.md deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/functionsystem/docs/overview.md b/functionsystem/docs/overview.md deleted file mode 100644 index ad55bf907804b69a114e4cd432fdacc585f3878e..0000000000000000000000000000000000000000 --- a/functionsystem/docs/overview.md +++ /dev/null @@ -1,46 +0,0 @@ -# 概述 - -

openYuanrong:单机编程体验,分布式运行性能

-
-
- -::::{grid} 2 -:gutter: 3 3 4 5 - -:::{grid-item-card} 入门 -:link: overview-getting-started -:link-type: ref -:text-align: center -::: -:::{grid-item-card} 安装 openYuanrong -:link: overview-installation -:link-type: ref -:text-align: center -::: -:::: - -::::{grid} 3 -:gutter: 3 3 4 5 - -:::{grid-item-card} -**了解使用案例** -^^^ -openYuanrong 可作为 AI 智算的基础设施,用于开发 AI 推理、强化学习等应用,也可作为通用计算的基础设施,开发大数据分析、HPC 等应用。 -+++ -[使用案例](./use_cases/index.md) -::: -:::{grid-item-card} -**开发分布式应用** -^^^ -openYuanrong 以函数为开发粒度,提供多语言函数编程接口,快速构建和运行分布式应用。 -+++ -[多语言函数编程接口](./multi_language_function_programming_interface/index.md) -::: -:::{grid-item-card} -**部署工作负载** -^^^ -openYuanrong 支持在单机上部署和运行,用于学习和开发,生产时可无缝扩展到大型集群。 -+++ -[部署 openYuanrong](./deploy/index.md) -::: -:::: diff --git a/functionsystem/pkg/cli/README.md b/functionsystem/pkg/cli/README.md deleted file mode 100644 index 9b51956b962aa5a0fe297588c26246f46367875c..0000000000000000000000000000000000000000 --- a/functionsystem/pkg/cli/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Cli - -## 代码目录结构 - -- cmd 命令行命令 - - version 查看命令版本命令 -- constant 公共常量配置、命令行配置 -- pkg 对外接口 - - cmdio 命令行 io - - progress 函数部署进度 api - - test 用于单元测试 -- utils 工具方法 - -## 本地编码环境配置 - -```sh -export GO111MODULE=on -export GOPROXY="direct" -export GONOSUMDB=* -``` - -## 编译二进制 - -linux: - -```sh -cd ../../../build/ -sh build.sh -m cli -``` diff --git a/scripts/basic_build.sh b/scripts/basic_build.sh deleted file mode 100644 index 7eca42dc8f25ab42a1487bc54a1ed03df12ea4f0..0000000000000000000000000000000000000000 --- a/scripts/basic_build.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -BASE_DIR=$( - cd "$(dirname "$0")" - pwd -) -YR_ROOT_DIR="${BASE_DIR}/../" -YUANRONG_DIR="${YR_ROOT_DIR}/output/function_system" -BUILD_DIR="$YR_ROOT_DIR"/functionsystem/build - -[[ ! -f "${YR_ROOT_DIR}/tools/utils.sh" ]] && echo "${YR_ROOT_DIR}/tools/utils.sh is not exist" && exit 1 -. ${YR_ROOT_DIR}/tools/utils.sh - -function build_etcd() -{ - # Check if etcd and etcdctl already exist - if [[ -f "${YUANRONG_DIR}/third_party/etcd/etcd" && -f "${YUANRONG_DIR}/third_party/etcd/etcdctl" ]]; then - log_info "etcd and etcdctl already built, skipping build." - return - fi - - log_info "---- build etcd ----" - export GO111MODULE=on - export GONOSUMDB=* - - [ -d "$BUILD_DIR"/etcd ] && rm -rf "$BUILD_DIR"/etcd - mkdir -p "$BUILD_DIR" - cp -ar "${YR_ROOT_DIR}"/vendor/src/etcd "$BUILD_DIR" - cd "$BUILD_DIR"/etcd - go get github.com/myitcv/gobin - go install github.com/myitcv/gobin - export GO_LDFLAGS='-linkmode=external -extldflags "-fstack-protector-strong -Wl,-z,now,-z,relro,-z,noexecstack,-s -Wall -Werror"' - export GO_BUILD_FLAGS='-buildmode=pie' - git apply "${BASE_DIR}"/deploy/third_party/etcd.patch - go mod edit -replace=go.uber.org/zap=go.uber.org/zap@v1.24.0 - go mod tidy - cd "$BUILD_DIR"/etcd/server - go mod edit -replace=go.uber.org/zap=go.uber.org/zap@v1.24.0 - go mod tidy - cd "$BUILD_DIR"/etcd/etcdctl - go mod edit -replace=go.uber.org/zap=go.uber.org/zap@v1.24.0 - go mod tidy - cd "$BUILD_DIR"/etcd/etcdutl - go mod edit -replace=go.uber.org/zap=go.uber.org/zap@v1.24.0 - go mod tidy - cd "$BUILD_DIR"/etcd/ - bash build.sh - - log_info "---- build etcd success ----" -} - -build_etcd diff --git a/scripts/deploy/function_system/install.sh b/scripts/deploy/function_system/install.sh index 20528f1d9add26ecc2e0f0bcae4648832d92771b..df35630dfa4bc7d7ceeff424dd0505eab599ac61 100644 --- a/scripts/deploy/function_system/install.sh +++ b/scripts/deploy/function_system/install.sh @@ -15,10 +15,10 @@ FUNCTION_SYSTEM_DEPLOY_DIR=$(dirname "$(readlink -f "$0")") if [ -n "${BASE_DIR}" ]; then - FUNCTION_SYSTEM_DEPLOY_DIR=${BASE_DIR}/../../function_system/deploy + FUNCTION_SYSTEM_DEPLOY_DIR=${BASE_DIR}/../../functionsystem/deploy fi FUNCTION_SYSTEM_DIR=$(readlink -m "${FUNCTION_SYSTEM_DEPLOY_DIR}/..") -DATA_SYSTEM_DIR=$(readlink -m "${FUNCTION_SYSTEM_DIR}/../data_system") +DATA_SYSTEM_DIR=$(readlink -m "${FUNCTION_SYSTEM_DIR}/../datasystem") RUNTIME_HOME_DIR=$(readlink -m "${FUNCTION_SYSTEM_DIR}/../runtime") if [ -d "${FUNCTION_SYSTEM_DIR}/../pattern/pattern_faas" ]; then PATTERN_FAAS_HOME_DIR=$(readlink -m "${FUNCTION_SYSTEM_DIR}/../pattern/pattern_faas") diff --git a/scripts/deploy/third_party/etcd.patch b/scripts/deploy/third_party/etcd.patch deleted file mode 100644 index 1f4413747f06f7086ec95e161f07a7d5573ab3fe..0000000000000000000000000000000000000000 --- a/scripts/deploy/third_party/etcd.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/build.sh -+++ b/build.sh -@@ -17,5 +17,5 @@ - # Set GO_LDFLAGS="-s" for building without symbols for debugging. - # shellcheck disable=SC2206 - GO_LDFLAGS=(${GO_LDFLAGS:-} "-X=${VERSION_SYMBOL}=${GIT_SHA}") --GO_BUILD_ENV=("CGO_ENABLED=0" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS:-}" "GOOS=${GOOS}" "GOARCH=${GOARCH}") -+GO_BUILD_ENV=("CGO_ENABLED=1" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS:-}" "CGO_CFLAGS=-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong -fPIE" "GOOS=${GOOS}" "GOARCH=${GOARCH}") - - # enable/disable failpoints \ No newline at end of file diff --git a/scripts/executor/compile/__init__.py b/scripts/executor/compile/__init__.py index 89ec708bf2254b9a20a68456935a46dfcd54de10..622a44126016c9490ee449c229903b7eb721db6e 100644 --- a/scripts/executor/compile/__init__.py +++ b/scripts/executor/compile/__init__.py @@ -2,4 +2,7 @@ # Copyright (c) 2025 Huawei Technologies Co., Ltd from .compile_cpp import compile_gtest -from .compile_cpp import compile_binary \ No newline at end of file +from .compile_cpp import compile_binary +from .compile_go import compile_golang +from .compile_go import compile_etcd +from .compile_go import compile_cli \ No newline at end of file diff --git a/scripts/executor/compile/compile_cpp.py b/scripts/executor/compile/compile_cpp.py index 23b76f4a76f5ef01ab81a7e2af2c61f5fe783515..908e623fee7f675d3c3f5bbb9c46adb49e892ae4 100644 --- a/scripts/executor/compile/compile_cpp.py +++ b/scripts/executor/compile/compile_cpp.py @@ -13,8 +13,8 @@ def compile_gtest(root_dir, job_num): compile_functionsystem(root_dir, job_num, build_type="Debug", gtest=True) -def compile_binary(root_dir, job_num, version): - compile_functionsystem(root_dir, job_num, build_type="Release", version=version) +def compile_binary(root_dir, job_num, version, build_type="Release"): + compile_functionsystem(root_dir, job_num, build_type=build_type, version=version) def compile_functionsystem(root_dir, job_num, version="0.0.0", build_type="Debug", @@ -26,9 +26,11 @@ def compile_functionsystem(root_dir, job_num, version="0.0.0", build_type="Debug inner_proto = os.path.join(root_dir, "proto", "inner") posix_proto = os.path.join(root_dir, "proto", "posix") cpp_proto_dir = os.path.join(root_dir, "functionsystem", "src", "common", "proto", "posix") + if os.path.exists(cpp_proto_dir): + shutil.rmtree(cpp_proto_dir) os.makedirs(cpp_proto_dir, exist_ok=True) - copy_proto_folder(inner_proto, cpp_proto_dir) - copy_proto_folder(posix_proto, cpp_proto_dir) + shutil.copytree(inner_proto, cpp_proto_dir, copy_function=shutil.copy2, dirs_exist_ok=True) + shutil.copytree(posix_proto, cpp_proto_dir, copy_function=shutil.copy2, dirs_exist_ok=True) # 使用 CMake 创建 Ninja 构建清单 root_dir = os.path.abspath(root_dir) # Git根目录 @@ -84,8 +86,3 @@ def version_name(version): def bool2switch(b: bool): return "ON" if b else "OFF" - -def copy_proto_folder(src, dst): - for proto_file in os.listdir(src): - if proto_file.endswith(".proto"): - shutil.copy(os.path.join(src, proto_file), dst) \ No newline at end of file diff --git a/scripts/executor/compile/compile_go.py b/scripts/executor/compile/compile_go.py new file mode 100644 index 0000000000000000000000000000000000000000..7f0ffce6024613714e143bcd70d4ced63e62e152 --- /dev/null +++ b/scripts/executor/compile/compile_go.py @@ -0,0 +1,52 @@ +# coding=UTF-8 +# Copyright (c) 2025 Huawei Technologies Co., Ltd +import os +import json + +import utils + +log = utils.stream_logger() + + +def compile_cli(root_path): + app_path = os.path.join(root_path, "functionsystem", "apps", "cli") + main_path = os.path.join(app_path, "cmd", "main.go") + output_path = os.path.join(root_path, "functionsystem", "output", "bin") + compile_golang(app_path, "yr", main_path, output_path) + + +def compile_golang(app_path, app_name, main_path, output_path, + go_ldflags="-s -w", cgo_enabled=False): + """ + 在 app_path 路径下编译 main_path 到 output_path/app_name + """ + build_env = os.environ.copy() + build_env["CGO_ENABLED"] = "1" if cgo_enabled else "0" + bin_path = os.path.join(output_path, app_name) + log.info(f"Build golang app[{app_name}] to {bin_path}.") + log.info(f"Go build ldflags: {go_ldflags}") + log.info(f"Go build env: {json.dumps(build_env)}") + utils.sync_command( + cmd=[ + "go", "build", + "-o", bin_path, + "-trimpath", + "-ldflags", go_ldflags, + main_path + ], + cwd=app_path, + env=build_env + ) + log.info(f"Build golang app[{app_name}] success") + +def compile_etcd(vendor_path): + etcd_path = os.path.join(vendor_path, "src", "etcd") + etcd_bin_path = os.path.join(etcd_path, "bin") + if os.path.exists(etcd_bin_path): + log.warning("Skip ETCD compilation. Compilation product already exists") + return + # 原地编译ETCD + utils.sync_command( + ["bash", "build.sh"], + cwd=os.path.join(etcd_path) + ) \ No newline at end of file diff --git a/scripts/executor/make_functionsystem.py b/scripts/executor/make_functionsystem.py index 2974ecb3109016f2cb016f07ce15a7236103ca3a..dd445dded41a424c170b024d1b854f02f4b61abb 100644 --- a/scripts/executor/make_functionsystem.py +++ b/scripts/executor/make_functionsystem.py @@ -29,9 +29,15 @@ def parser_args(): help="Set the number of jobs for compile") build_parser.add_argument("-v", "--version", type=str, default="0.0.0", help="Set the version for function system build") + build_parser.add_argument("--build_type", type=str, default="Release", + help="Set program compilation mode(Debug/Release). Default: Release") build_parser.set_defaults(func=lambda func_args: tasks.run_build(ROOT_DIR, func_args)) # 清理缓存执行参数 clean_parser = subparsers.add_parser("clean", help="Clean all build artifacts and caches") + clean_parser.add_argument("--skip_vendor", type=bool, default=True, + help="Skip clean vendor build cache and installed files") + clean_parser.add_argument("--skip_change", type=bool, default=True, + help="Skip clean all code change and the files that ignored by git") clean_parser.set_defaults(func=lambda func_args: tasks.run_clean(ROOT_DIR, func_args)) # 测试用例执行参数 test_parser = subparsers.add_parser("test", help="Run tests for function system") @@ -49,6 +55,13 @@ def parser_args(): test_parser.add_argument("-p", "--print_logs", type=bool, default=True, help="Set whether to print test case standard output. Default: True") test_parser.set_defaults(func=lambda func_args: tasks.run_test(ROOT_DIR, func_args)) + # 打包函数系统构建产物 + pack_parser = subparsers.add_parser("pack", help="Copy and package all compiled products of function system") + pack_parser.add_argument("-v", "--version", type=str, default="0.0.0", + help="Set the version for function system package") + pack_parser.add_argument("--pack_type", type=str, default="Release", + help="Set program package mode(Debug/Release). Default: Release") + pack_parser.set_defaults(func=lambda func_args: tasks.run_pack(ROOT_DIR, func_args)) args = parser.parse_args() return parser, args diff --git a/scripts/executor/tasks/__init__.py b/scripts/executor/tasks/__init__.py index 5e4b83a6aab7275e7f98e5c0fda749d3e6531c0c..ede73c9b85fa7a625b8935602b38679fae533202 100644 --- a/scripts/executor/tasks/__init__.py +++ b/scripts/executor/tasks/__init__.py @@ -1,12 +1,11 @@ #!/usr/bin/env python3 # coding=UTF-8 # Copyright (c) 2025 Huawei Technologies Co., Ltd -from .build_task import run_build from .download_vendor import download_vendor -from .clean_task import run_clean - from .test_task import run_test - +from .pack_task import run_pack +from .clean_task import run_clean +from .build_task import run_build from .run_code_gate import run_code_gate diff --git a/scripts/executor/tasks/build_task.py b/scripts/executor/tasks/build_task.py index 87f6931fdc17d37f2b230f3fafb7b2c5a6ee4dd3..5c961a6a9ada7073e79b3731a8b5d6f3d78b366d 100644 --- a/scripts/executor/tasks/build_task.py +++ b/scripts/executor/tasks/build_task.py @@ -1,8 +1,10 @@ +# coding=UTF-8 # Copyright (c) 2025 Huawei Technologies Co., Ltd import os import json import utils import tasks +import shutil import compile log = utils.stream_logger() @@ -12,7 +14,8 @@ def run_build(root_dir, cmd_args): args = { "root_dir": root_dir, "job_num": cmd_args.job_num, - "version": cmd_args.version + "version": cmd_args.version, + "build_type": cmd_args.build_type.capitalize(), # 设置为首字母大写 } if args['job_num'] > (os.cpu_count() or 1) * 2: log.warning(f"The -j {args['job_num']} is over the max logical cpu count({os.cpu_count()}) * 2") @@ -27,25 +30,35 @@ def run_build(root_dir, cmd_args): def compile_vendor(args): print(args['root_dir'], args['job_num']) + vendor_path = os.path.join(args['root_dir'], "vendor") # 根据下载清单下载第三方依赖 tasks.download_vendor( - config_path=os.path.join(args['root_dir'], "vendor", "VendorList.csv"), - download_path=os.path.join(args['root_dir'], "vendor", "src") + config_path=os.path.join(vendor_path, "VendorList.csv"), + download_path=os.path.join(vendor_path, "src") ) - + # 编译三方件依赖 + compile.compile_etcd(vendor_path) utils.sync_command( ["cmake", "-B", "build"], - cwd=os.path.join(args['root_dir'], "vendor") + cwd=os.path.join(vendor_path) ) utils.sync_command( ["cmake", "--build", "build", "--parallel", str(args['job_num'])], - cwd=os.path.join(args['root_dir'], "vendor") - ) - utils.sync_command( - ["bash", "basic_build.sh"], - cwd=os.path.join(args['root_dir'], "scripts") + cwd=os.path.join(vendor_path) ) + # 引入二方件产物 + install_datasystem(vendor_path) + + +def install_datasystem(vendor_path): + linux_dist = utils.get_linux_distribution() + datasystem_sdk_path = os.path.join(vendor_path, "src", "datasystem", "sdk") + datasystem_install_path = os.path.join(vendor_path, "output", linux_dist, "Install", "datasystem", "sdk") + if os.path.exists(datasystem_install_path): + log.warning("Datasystem install path is exist. Skip to copy files.") + return + shutil.copytree(datasystem_sdk_path, datasystem_install_path, copy_function=shutil.copy2) def compile_logs(args): @@ -73,10 +86,8 @@ def compile_metrics(args): def compile_functionsystem(root_dir, args): - cwd = os.path.join(args['root_dir'], "functionsystem") log.info("Start to compile functionsystem") - compile.compile_binary(root_dir, args["job_num"], args["version"]) - utils.sync_command( - ["bash", "build.sh", "-y", "-j", str(args['job_num']), "-v", args['version']], - cwd=cwd - ) + # 编译 CPP 程序 + compile.compile_binary(root_dir, args["job_num"], args["version"], args["build_type"]) + # 编译 CLI 程序 + compile.compile_cli(root_dir) diff --git a/scripts/executor/tasks/clean_task.py b/scripts/executor/tasks/clean_task.py index 4d54d9ce5aac5c031463f8e15b4865104d2e4e87..bb5ffd68a314e416ce1847fd496717437c14fc91 100644 --- a/scripts/executor/tasks/clean_task.py +++ b/scripts/executor/tasks/clean_task.py @@ -1,15 +1,45 @@ # coding=UTF-8 # Copyright (c) 2025 Huawei Technologies Co., Ltd +import os.path -import os import utils -import tasks +import shutil log = utils.stream_logger() -def run_clean(ROOT_DIR, args): +def run_clean(root_dir, args): + args = { + "root_dir": root_dir, + "skip_vendor": args.skip_vendor, + "skip_change": args.skip_change, + } log.info("Start to clean vendor cache and component build cache") - utils.sync_command(["git", "clean", "-dffx"], cwd=ROOT_DIR) - utils.sync_command(["git", "submodule", "foreach", "--recursive", "git clean -dffx"], cwd=ROOT_DIR) + vendor_path = os.path.join(root_dir, "vendor") + common_path = os.path.join(root_dir, "common") + source_path = os.path.join(root_dir, "functionsystem") + if not args["skip_vendor"]: + vendor_list = [ + os.path.join(vendor_path, "build"), + os.path.join(vendor_path, "output"), + os.path.join(vendor_path, "src", "etcd", "bin"), + ] + for folder in vendor_list: + shutil.rmtree(folder, ignore_errors=True) + + if not args["skip_change"]: + utils.sync_command(["git", "clean", "-dffx"], cwd=root_dir) + + output_list = [ + os.path.join(source_path, "build"), + os.path.join(source_path, "output"), + os.path.join(common_path, "logs", "build"), + os.path.join(common_path, "logs", "output"), + os.path.join(common_path, "litebus", "build"), + os.path.join(common_path, "litebus", "output"), + os.path.join(common_path, "metrics", "build"), + os.path.join(common_path, "metrics", "output"), + ] + for folder in output_list: + shutil.rmtree(folder, ignore_errors=True) \ No newline at end of file diff --git a/scripts/executor/tasks/download_vendor.py b/scripts/executor/tasks/download_vendor.py index 5838f9da3b0751fa2057e4a87d00b6a0da0167a1..3c901cda5597f22813b02bf4a56965214137de7f 100644 --- a/scripts/executor/tasks/download_vendor.py +++ b/scripts/executor/tasks/download_vendor.py @@ -6,12 +6,13 @@ import utils import hashlib import argparse import urllib.request +from urllib.parse import urlparse log = utils.stream_logger() def download_vendor(config_path, download_path): - """主函数""" + """下载并解压依赖""" config_path = os.path.abspath(config_path) if not os.path.exists(config_path): raise FileNotFoundError(f"Configuration file not found: {config_path}") @@ -23,21 +24,31 @@ def download_vendor(config_path, download_path): configs = list(reader) # name, version, module, repo, sha256 for config in configs: + repo_parsed = urlparse(config['repo']) archive_name = config['repo'].split('/')[-1] package_name = archive_name.replace(".tar.gz", "").replace(".tar", "").replace(".zip", "") - archive_path = os.path.join(download_path, archive_name) # vendor/xxx-vvv.zip - vendor_path = os.path.join(download_path, config['name']) # vendor/xxx + archive_path = os.path.join(download_path, archive_name) # vendor/src/xxx-vvv.zip + vendor_path = os.path.join(download_path, config['name']) # vendor/src/xxx if os.path.exists(vendor_path): log.info(f"Dependency {config['name']}-{config['version']} already exists, skipping download and extraction") continue - log.info(f"Downloading {config['name']}-{config['version']} with checksum: {config['sha256']} from source: {config['repo']}") - download_zipfile(package_name, config['repo'], archive_path) - verify_checksum(package_name, archive_path, config['sha256']) - extract_name = utils.extract_file(archive_path, download_path) - package_path = os.path.join(download_path, extract_name) # vendor/xxx-vvv - os.rename(package_path, vendor_path) + if repo_parsed.scheme == "file": + # 直接解压指定压缩包 + log.info(f"Extracting {config['name']}-{config['version']} with local file: {repo_parsed.path}") + log.warning(f"Skip local file[{archive_name}] hash verification") + extract_name = utils.extract_file(archive_path, download_path) + package_path = os.path.join(download_path, extract_name) # vendor/src/xxx-vvv + os.rename(package_path, vendor_path) + else: + # 通过网络下载压缩包 + log.info(f"Downloading {config['name']}-{config['version']} with checksum: {config['sha256']} from source: {config['repo']}") + download_zipfile(package_name, config['repo'], archive_path) + verify_checksum(package_name, archive_path, config['sha256']) + extract_name = utils.extract_file(archive_path, download_path) + package_path = os.path.join(download_path, extract_name) # vendor/src/xxx-vvv + os.rename(package_path, vendor_path) return 0 diff --git a/scripts/executor/tasks/pack_task.py b/scripts/executor/tasks/pack_task.py new file mode 100644 index 0000000000000000000000000000000000000000..b4529f8bde676ba4e3464c3163278c13618d03f2 --- /dev/null +++ b/scripts/executor/tasks/pack_task.py @@ -0,0 +1,128 @@ +# coding=UTF-8 +# Copyright (c) 2025 Huawei Technologies Co., Ltd +import json +import utils +import shutil +import os.path + +log = utils.stream_logger() + + +def run_pack(root_dir, cmd_args): + args = { + "root_dir": root_dir, + "version": cmd_args.version, + "pack_type": cmd_args.pack_type.capitalize(), # 设置为首字母大写 + } + log.info(f"Start to package function system output with args: {json.dumps(args)}") + renew_output(root_dir) + pack_metrics(args) + pack_functionsystem(args) + + +def renew_output(root_dir): + # 创建输出文件夹 + output_dir = os.path.join(root_dir, "output") # ./functionsystem/output + if os.path.exists(output_dir): + log.warning(f"Removing product output folder: {output_dir}") + shutil.rmtree(output_dir) + os.makedirs(output_dir) + + +def pack_functionsystem(args): + root_dir = args['root_dir'] + pack_base_dir = os.path.join(root_dir, "output", "functionsystem") # ./output/functionsystem + + # 拷贝二进制 bin 产物 + # CPP编译产物目录 ./functionsystem/output/bin + # GO编译产物目录 暂无 + # 打包产物目录 ./output/functionsystem/bin + log.info("Copy function system binary products") + bin_src_path = os.path.join(root_dir, "functionsystem", "output", "bin") + bin_dst_path = os.path.join(pack_base_dir, "bin") + shutil.copytree(bin_src_path, bin_dst_path, copy_function=shutil.copy2) + + # 拷贝动态库 lib 产物 + log.info("Copy function system library products") + lib_src_path = os.path.join(root_dir, "functionsystem", "output", "lib") + lib_dst_path = os.path.join(pack_base_dir, "lib") + shutil.copytree(lib_src_path, lib_dst_path, copy_function=shutil.copy2, symlinks=True) + + # CPP程序去符号 + if args['pack_type'] == "Release": + log.info("Remove debug symbols from compiled products") + remove_cpp_symbol(pack_base_dir) + + # 拷贝系统部署配置 + log.info("Copy function system deploy package") + deploy_src_path = os.path.join(root_dir, "scripts", "deploy") + deploy_dst_path = os.path.join(pack_base_dir, "deploy") + shutil.copytree(deploy_src_path, deploy_dst_path, copy_function=shutil.copy2) + + # 拷贝部署配置文件 + log.info("Copy function system config files") + config_src_path = os.path.join(root_dir, "scripts", "config") + config_dst_path = os.path.join(pack_base_dir, "config") + shutil.copytree(config_src_path, config_dst_path, copy_function=shutil.copy2) + + # 拷贝ETCD二进制 + log.info("Copy etcd binary to vendor folder") + etcd_bin_path = os.path.join(root_dir, "vendor", "src", "etcd", "bin") + etcd_dst_path = os.path.join(pack_base_dir, "deploy", "vendor", "etcd") + shutil.copytree(etcd_bin_path, etcd_dst_path, copy_function=shutil.copy2) + + # 生成压缩包 + tar_name = f"yr-functionsystem-v{args['version']}.tar.gz" + tarfile = os.path.join(root_dir, "output", tar_name) + archive_output(tar_name, tarfile, pack_base_dir) + + +def remove_cpp_symbol(pack_base_dir): + bin_dir = os.path.join(pack_base_dir, "bin") + sym_dir = os.path.join(pack_base_dir, "sym") + if not os.path.exists(sym_dir): + os.makedirs(sym_dir) + + for file in os.listdir(bin_dir): + file_path = os.path.join(bin_dir, file) + basename = os.path.splitext(file)[0] + sym_file = os.path.join(sym_dir, f"{basename}.sym") + log.info(f"Remove cpp file[{basename}] symbol to [{sym_file}]") + utils.sync_command(["objcopy", "--only-keep-debug", file_path, sym_file]) + utils.sync_command(["objcopy", "--add-gnu-debuglink", sym_file, file_path]) + utils.sync_command(["objcopy", "--strip-all", file_path]) + + +def pack_metrics(args): + root_dir = args['root_dir'] + pack_base_dir = os.path.join(root_dir, "output", "metrics") # ./output/metrics + + # 拷贝配置文件 + log.info("Copy metrics config files") + config_src_path = os.path.join(root_dir, "scripts", "config", "metrics") + config_dst_path = os.path.join(pack_base_dir, "config") + shutil.copytree(config_src_path, config_dst_path, copy_function=shutil.copy2) + + # 拷贝头文件 + log.info("Copy metrics include files") + include_src_path = os.path.join(root_dir, "common", "metrics", "output", "include") + include_dst_path = os.path.join(pack_base_dir, "include") + shutil.copytree(include_src_path, include_dst_path, copy_function=shutil.copy2) + + # 拷贝 lib 库 + log.info("Copy metrics library products") + lib_src_path = os.path.join(root_dir, "common", "metrics", "output", "lib") + lib_dst_path = os.path.join(pack_base_dir, "lib") + shutil.copytree(lib_src_path, lib_dst_path, copy_function=shutil.copy2, symlinks=True) + + # 生成压缩包 + tar_name = f"metrics.tar.gz" + tarfile = os.path.join(root_dir, "output", tar_name) + archive_output(tar_name, tarfile, pack_base_dir) + + +def archive_output(tar_name, tarfile, pack_base_dir): + log.info(f"Packaging function system compression package to {tarfile}") + utils.archive_tar(tarfile, pack_base_dir) + tar_file_size = os.path.getsize(tarfile) + log.info(f"The size of the product[{tar_name}] is {tar_file_size / (1024 * 1024):.2f}MiB") diff --git a/scripts/executor/utils/__init__.py b/scripts/executor/utils/__init__.py index 4494979e94c86e57c7ea684a9f669173d4d1d62f..a51451568d9a7a36b8dc32eb9dea0ab0b159e4dc 100644 --- a/scripts/executor/utils/__init__.py +++ b/scripts/executor/utils/__init__.py @@ -11,6 +11,7 @@ from .process import sync_command from .process import exec_command from .process import pipe_command -from .extract import extract_file -from .extract import extract_tar -from .extract import extract_zip \ No newline at end of file +from .archive import extract_file +from .archive import extract_tar +from .archive import extract_zip +from .archive import archive_tar \ No newline at end of file diff --git a/scripts/executor/utils/extract.py b/scripts/executor/utils/archive.py similarity index 82% rename from scripts/executor/utils/extract.py rename to scripts/executor/utils/archive.py index 9e8bf0d7b6193ac457aedb908370e737bf177798..617d312b9383e8da9be69186f39f9a37d7be65ea 100644 --- a/scripts/executor/utils/extract.py +++ b/scripts/executor/utils/archive.py @@ -53,3 +53,14 @@ def _is_symlink(info): """检查 ZIP 条目是否为符号链接""" mode = (info.external_attr >> 16) & 0xFFFF return stat.S_IFMT(mode) == stat.S_IFLNK + + +def archive_tar(tarfile_path: str, archive_path): + """压缩指定文件夹到压缩文件""" + mod = "w" + if tarfile_path.endswith(".tar.gz"): + mod = "w:gz" + base_path = os.path.basename(os.path.abspath(archive_path)) + tar_ref = tarfile.open(tarfile_path, mod) + tar_ref.add(archive_path, arcname=base_path) + tar_ref.close() diff --git a/scripts/executor/utils/process.py b/scripts/executor/utils/process.py index 0468bd17dccbe42899e5830d8076f2546f0b8606..42989f88fde7323b8ba6f1193b7f5115d39be295 100644 --- a/scripts/executor/utils/process.py +++ b/scripts/executor/utils/process.py @@ -8,17 +8,19 @@ import subprocess log = utils.stream_logger() -def sync_command(cmd: list[str], cwd: str = None): +def sync_command(cmd: list[str], cwd: str = None, env: dict[str, str] = None): """ 在指定路径同步执行命令,不返回任何信息 注意:不能打印cmd,因为cmd可能包含敏感信息或用户输入的参数,打印可能导致信息泄露。 :param cmd: 可执行命令路径 :param cwd: 命令的参数 + :param env: 执行的环境变量 """ log.info(f"Executing command[{cmd[0]}] in {cwd if cwd else os.getcwd()}") subprocess.run( cmd, cwd=cwd, + env=env, text=True, check=True ) diff --git a/scripts/executor/utils/tools.py b/scripts/executor/utils/tools.py index 646217cfc94f075861f9bf279b4ec90e2ee7ff40..b60feec4014b4ffa8c8e2dab85f10dbcadfd2d18 100644 --- a/scripts/executor/utils/tools.py +++ b/scripts/executor/utils/tools.py @@ -1,6 +1,7 @@ # coding=UTF-8 # Copyright (c) 2025 Huawei Technologies Co., Ltd import os +import shutil from typing import Tuple diff --git a/vendor/VendorList.csv b/vendor/VendorList.csv index 4d6e7023eec55100536c202ae736c45416996293..d6e5f9c2791e06673720ca8eb2c906d19ad7a2a8 100644 --- a/vendor/VendorList.csv +++ b/vendor/VendorList.csv @@ -1,7 +1,7 @@ name,version,module,repo,sha256 abseil-cpp,20240722.0,functionsystem,https://gitee.com/mirrors/abseil-cpp/repository/archive/20240722.0.zip,104dead3edd7b67ddeb70c37578245130d6118efad5dad4b618d7e26a5331f55 c-ares,1.19.1,functionsystem,https://gitee.com/mirrors/c-ares/repository/archive/cares-1_19_1.zip,edcaac184aff0e6b6eb7b9ede7a55f36c7fc04085d67fecff2434779155dd8ce -etcd,v3.5.11,functionsystem,https://gitee.com/mirrors/etcd/repository/archive/v3.5.11.zip,7af745a2bf75c7b04f9b168b85deb35fb73d30d60f751046564b54dbd483277a +etcd,v3.5.24,functionsystem,https://gitee.com/mirrors/etcd/repository/archive/v3.5.24.zip,cd1ee896fcdae1679dbed946fc61f799de51460121ff8ac0687bc39063f87123 gogo-protobuf,v1.3.2,functionsystem,https://gitee.com/mirrors_gogo/protobuf/repository/archive/v1.3.2.zip,11e863712289bf1e6ba86239b5b896704bb63815bee8710e5032daf63fd9efe7 grpc,v1.65.4,runtime;functionsystem,https://gitee.com/mirrors/grpc/repository/archive/v1.65.4.tar.gz,dd60131b74bd1ecb3ffd29a31a6d68d6bb009106bd22c4be140e40f5d2baf2f6 jemalloc,5.3.0,functionsystem,https://gitee.com/mirrors/jemalloc/repository/archive/5.3.0.zip,fcd383b168b72904f777e500631996366a633d1c40714f1601b7e739eb054613 @@ -14,7 +14,8 @@ yaml-cpp,0.8.0,functionsystem,https://gitee.com/mirrors/yaml-cpp/repository/arch zlib,v1.3.1,functionsystem;metrics;logs,https://gitee.com/mirrors/zlib/repository/archive/v1.3.1.tar.gz,4208eb8a8ba5703831123b06c9bbadf780e678a9972eb00ecce57e6f87b30f36 grpc-gateway,v1.16.0,functionsystem,https://gitee.com/mirrors/grpc-gateway/repository/archive/v1.16.0.zip,0c85be2911500fabace8caffe3cfafd335a75844135aa2f5b58ea4d693ffb2ae libboundscheck,v1.1.16,runtime;litebus;functionsystem;metrics,https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.16.zip,5119bda1ee96440c1a45e23f0cb8b079cc6697e052c4a78f27d0869f84ba312b -curl,8.8.0,litebus,https://gitee.com/mirrors/curl/repository/archive/curl-8_8_0.zip,73c70c94f487c5ae26f9f27094249e40bb1667ae6c0406a75c3b11f86f0c1128 +curl,8.8.0,litebus,https://gitee.com/mirrors/curl/repository/archive/curl-8_8_0.zip,479697e261e6db6ad438d9eaff1b517161a0bc4450e5d195e4478ccdcae673b8 gtest_1_12_1,release-1.12.1,litebus;functionsystem;metrics;logs,https://gitee.com/mirrors/googletest/repository/archive/release-1.12.1.zip,4f1037f17462dbcc4d715f2fc8212c03431ad06e7a4b73bb49b3f534a13b21f1 gtest_1_10_0,release-1.10.0,functionsystem,https://gitee.com/mirrors/googletest/repository/archive/release-1.10.0.zip,db55081e6b5a5f820d052f8d37e0d29835dd5a2bd5b8d4d50590b7834f9abfae -huaweicloud-sdk-c-obs,v3.24.3,functionsystem,https://gitee.com/mirrors/huaweicloud-sdk-c-obs/repository/archive/v3.24.3.zip,ed744c92494d2d7fd171e776abfef627ac7bdd0e24910a207e83d3887cafb2bd \ No newline at end of file +huaweicloud-sdk-c-obs,v3.24.3,functionsystem,https://gitee.com/mirrors/huaweicloud-sdk-c-obs/repository/archive/v3.24.3.zip,ed744c92494d2d7fd171e776abfef627ac7bdd0e24910a207e83d3887cafb2bd +datasystem,0.0.0,functionsystem,file://localhost/vendor/src/yr-datasystem.tar.gz, \ No newline at end of file diff --git a/vendor/patches/etcd_pb.patch b/vendor/patches/etcd_pb.patch deleted file mode 100644 index d5be92422511c5c5c66b877c8070a2f95a7bdbde..0000000000000000000000000000000000000000 --- a/vendor/patches/etcd_pb.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --color -Npur etcd-3.5.0-old/api/etcdserverpb/rpc.proto etcd-3.5.0/api/etcdserverpb/rpc.proto ---- etcd-3.5.0-old/api/etcdserverpb/rpc.proto 2021-06-16 05:34:52.000000000 +0800 -+++ etcd-3.5.0/api/etcdserverpb/rpc.proto 2022-08-01 16:10:49.559459777 +0800 -@@ -2,8 +2,8 @@ syntax = "proto3"; - package etcdserverpb; - - import "gogoproto/gogo.proto"; --import "etcd/api/mvccpb/kv.proto"; --import "etcd/api/authpb/auth.proto"; -+import "kv.proto"; -+import "auth.proto"; - - // for grpc-gateway - import "google/api/annotations.proto"; -diff --color -Npur etcd-3.5.0-old/server/etcdserver/api/v3election/v3electionpb/v3election.proto etcd-3.5.0/server/etcdserver/api/v3election/v3electionpb/v3election.proto ---- etcd-3.5.0-old/server/etcdserver/api/v3election/v3electionpb/v3election.proto 2021-06-16 05:34:52.000000000 +0800 -+++ etcd-3.5.0/server/etcdserver/api/v3election/v3electionpb/v3election.proto 2022-08-01 16:11:57.767456176 +0800 -@@ -2,8 +2,8 @@ syntax = "proto3"; - package v3electionpb; - - import "gogoproto/gogo.proto"; --import "etcd/api/etcdserverpb/rpc.proto"; --import "etcd/api/mvccpb/kv.proto"; -+import "rpc.proto"; -+import "kv.proto"; - - // for grpc-gateway - import "google/api/annotations.proto"; -diff --color -Npur etcd-3.5.0-old/server/etcdserver/api/v3lock/v3lockpb/v3lock.proto etcd-3.5.0/server/etcdserver/api/v3lock/v3lockpb/v3lock.proto ---- etcd-3.5.0-old/server/etcdserver/api/v3lock/v3lockpb/v3lock.proto 2021-06-16 05:34:52.000000000 +0800 -+++ etcd-3.5.0/server/etcdserver/api/v3lock/v3lockpb/v3lock.proto 2022-08-01 16:12:29.867454481 +0800 -@@ -2,7 +2,7 @@ syntax = "proto3"; - package v3lockpb; - - import "gogoproto/gogo.proto"; --import "etcd/api/etcdserverpb/rpc.proto"; -+import "rpc.proto"; - - // for grpc-gateway - import "google/api/annotations.proto";