diff --git a/.gitignore b/.gitignore index b55a950..9e82b91 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ bin/ tmp/ /pkgdash +*.sqlite diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..88dc99d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: build +build: + go build -o bin/app -mod=readonly ./main.go + +.PHONY: test +test: + go test -v ./... -race -cover + +.PHONY: lint +lint: + # Install the binary release of golangci-lint + # https://github.com/golangci/golangci-lint#install + golangci-lint run \ No newline at end of file diff --git a/main.go b/cmd/script/main.go similarity index 97% rename from main.go rename to cmd/script/main.go index e039cfa..424e11e 100644 --- a/main.go +++ b/cmd/script/main.go @@ -15,7 +15,7 @@ import ( "github.com/go-git/go-git/v5/plumbing/filemode" "github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/storage/memory" - flagconfig "go.unistack.org/micro-config-flag/v4" + flagconfig "go.unistack.org/micro-config-flag/v3" "go.unistack.org/micro/v4/config" "go.unistack.org/micro/v4/logger" "golang.org/x/mod/modfile" @@ -65,7 +65,7 @@ func main() { cloneOpts.Depth = 1 } - if err := cloneOpts.Validate(); err != nil { + if err = cloneOpts.Validate(); err != nil { logger.Fatal(ctx, err) } diff --git a/go.mod b/go.mod index 21ffeb8..edfc01c 100644 --- a/go.mod +++ b/go.mod @@ -8,18 +8,17 @@ require ( github.com/golang-migrate/migrate/v4 v4.15.1 github.com/google/uuid v1.3.0 github.com/jackc/pgtype v1.14.0 + github.com/lib/pq v1.10.2 + github.com/mattn/go-sqlite3 v1.14.16 github.com/pkg/errors v0.9.1 go.unistack.org/cms-service v0.0.1 - go.unistack.org/micro-client-http/v3 v3.9.3 - go.unistack.org/micro-config-flag/v4 v4.0.1 - go.unistack.org/micro-proto/v3 v3.3.1 + go.unistack.org/micro-client-http/v4 v4.0.1 + go.unistack.org/micro-config-flag/v3 v3.8.9 go.unistack.org/micro-proto/v4 v4.0.1 - go.unistack.org/micro-server-http/v3 v3.11.6 go.unistack.org/micro-server-http/v4 v4.0.8 go.unistack.org/micro/v4 v4.0.6 go.unistack.org/protoc-gen-go-micro/v4 v4.0.5 golang.org/x/mod v0.12.0 - golang.org/x/net v0.12.0 golang.org/x/sync v0.3.0 google.golang.org/protobuf v1.31.0 ) @@ -38,18 +37,18 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic v0.6.9 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.1.0 // indirect github.com/iancoleman/strcase v0.2.0 // indirect - github.com/imdario/mergo v0.3.16 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.14.0 // indirect - github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect + github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530 // indirect + github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.2 // indirect + github.com/jackc/pgproto3/v2 v2.1.1 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v4 v4.18.1 // indirect + github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c // indirect github.com/jackc/pgx/v5 v5.3.1 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect @@ -59,27 +58,29 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/sergi/go-diff v1.3.1 // indirect + github.com/sergi/go-diff v1.1.0 // indirect github.com/sijms/go-ora/v2 v2.6.7 // indirect github.com/skeema/knownhosts v1.2.0 // indirect github.com/spf13/afero v1.3.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.unistack.org/cms-api-proto v0.0.5 // indirect + go.uber.org/atomic v1.6.0 // indirect + go.unistack.org/cms-api-proto v0.0.4 // indirect go.unistack.org/micro-broker-service/v3 v3.8.2 // indirect go.unistack.org/micro-codec-yaml/v3 v3.10.0 // indirect go.unistack.org/micro-config-env/v3 v3.8.5 // indirect go.unistack.org/micro-config-file/v3 v3.8.3 // indirect - go.unistack.org/micro-config-flag/v3 v3.8.9 // indirect go.unistack.org/micro-config-service/v3 v3.8.1 // indirect - go.unistack.org/micro/v3 v3.10.24 // indirect + go.unistack.org/micro-proto/v3 v3.3.1 // indirect + go.unistack.org/micro-server-http/v3 v3.11.6 // indirect + go.unistack.org/micro/v3 v3.10.18 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect + golang.org/x/net v0.12.0 // indirect golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect golang.org/x/tools v0.11.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect - google.golang.org/grpc v1.57.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.54.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 76df0aa..b5b5053 100644 --- a/go.sum +++ b/go.sum @@ -559,14 +559,12 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -581,8 +579,8 @@ github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= -github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= @@ -597,12 +595,10 @@ github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530 h1:dUJ578zuPEsXjtzOfEF0q9zDAfljJ9oFnTHcQaNkccw= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.14.0 h1:vrbA9Ud87g6JdFWkHTJXppVce58qPIdP7N8y0Ml/A7Q= -github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= +github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451 h1:WAvSpGf7MsFuzAtK4Vk7R4EVe+liW4x83r4oWu0WHKw= github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= -github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw= -github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -619,9 +615,8 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1: github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.0.7/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0= -github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= @@ -643,9 +638,8 @@ github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXg github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c h1:Dznn52SgVIVst9UyOT9brctYUgxs+CvVfPaC3jKrA50= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0= -github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE= github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU= github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -653,7 +647,6 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= @@ -750,6 +743,7 @@ github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vq github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -894,8 +888,8 @@ github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfF github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= @@ -942,8 +936,6 @@ github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -951,10 +943,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1016,9 +1005,8 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -1026,14 +1014,14 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.unistack.org/cms-api-proto v0.0.5 h1:c5tTAP8RvJAkjkeYFmPhcx9k/NEE5Dfo0GDhwL5c530= -go.unistack.org/cms-api-proto v0.0.5/go.mod h1:t5+6CxtaK1CxOv8fG/UJvj911K8+e9d86AHymNR6wDA= +go.unistack.org/cms-api-proto v0.0.4 h1:YFlnlr/rB0IadPiPhBC2B6/U9e4NLgkNvXTsgbu4bcw= +go.unistack.org/cms-api-proto v0.0.4/go.mod h1:t5+6CxtaK1CxOv8fG/UJvj911K8+e9d86AHymNR6wDA= go.unistack.org/cms-service v0.0.1 h1:XKKZqjQD3ViPGRzjadnVX94wQlKcWxompZac9YTeTjw= go.unistack.org/cms-service v0.0.1/go.mod h1:3apbDEEgmoPfnPRpzgN40fCqbn/BdfXDk/Hvly8+bGk= go.unistack.org/micro-broker-service/v3 v3.8.2 h1:K30wBLsoLO0WbD9rhPi8S8asU9pfes/M2X9tX9HLr24= go.unistack.org/micro-broker-service/v3 v3.8.2/go.mod h1:qTlBl4vdJSl66SFIjdjOWFWKO0BFQ2ImbwiPCti/H8M= -go.unistack.org/micro-client-http/v3 v3.9.3 h1:5AicVsSwzAbIa1mpi99g5JhhDakUkgMV6e4F/Xyu3jI= -go.unistack.org/micro-client-http/v3 v3.9.3/go.mod h1:3zB0iVaYhG/xi0r/YvyTE422dOOOx1PAaiWlD2GSBlM= +go.unistack.org/micro-client-http/v4 v4.0.1 h1:XPE/BCLaVDrvAuAUHw3o8VelLut+OOIw3SSQ2R4L4Ig= +go.unistack.org/micro-client-http/v4 v4.0.1/go.mod h1:ghKvUXvm+TY9C3ntAiIxQAS1nInLuKBLP4SG9U2jpB4= go.unistack.org/micro-codec-yaml/v3 v3.10.0 h1:cnNiWQZ3F+jsCX9DhEHBdIw8CjBItxb+TrKGGdlQ8F8= go.unistack.org/micro-codec-yaml/v3 v3.10.0/go.mod h1:UzwC3QZZ6+PgKSudlGZNLkugXzOFkp3sxhs/CctEwBY= go.unistack.org/micro-config-env/v3 v3.8.5 h1:k0BKpQflJ9mutzK//VcYw4XAKlKHTvg2GtkHTrEjbko= @@ -1042,8 +1030,6 @@ go.unistack.org/micro-config-file/v3 v3.8.3 h1:yoAyDtmWutlUkVgFUtc7JhwCX7H/2Jz0n go.unistack.org/micro-config-file/v3 v3.8.3/go.mod h1:dl+MQ27/P41+hINmSrZFltDSDYP1y2LItIDYb2jHFog= go.unistack.org/micro-config-flag/v3 v3.8.9 h1:I4eoJVV28CpxQvQ63TJ1fqK5JcV1gHmOZPveT2Vl5Iw= go.unistack.org/micro-config-flag/v3 v3.8.9/go.mod h1:eWI90dcZh5AOhkd83fF0KY17ea/DZPebkJ8K61yky+8= -go.unistack.org/micro-config-flag/v4 v4.0.1 h1:oYmNZrFDnARyi6toFFJ9cfIZQkZ4nNp5As+UYiIhBgM= -go.unistack.org/micro-config-flag/v4 v4.0.1/go.mod h1:EYBZUMCqEXs092hB5hhMCALduXMOg76VRuNdzlvV3aU= go.unistack.org/micro-config-service/v3 v3.8.1 h1:Q+RPWCb88VGz5+EQUx45Xeysf+Mon9Q2IvqCF3e8LZM= go.unistack.org/micro-config-service/v3 v3.8.1/go.mod h1:KdZJEuYwninyT04ysFkgEQa3OaMRa0kSQVPQHlumQoA= go.unistack.org/micro-proto/v3 v3.3.1 h1:nQ0MtWvP2G3QrpOgawVOPhpZZYkq6umTGDqs8FxJYIo= @@ -1055,8 +1041,8 @@ go.unistack.org/micro-server-http/v3 v3.11.6/go.mod h1:phNG9aosjbneXvZxEVaVQI+NH go.unistack.org/micro-server-http/v4 v4.0.8 h1:49ZoZTAcRCZpoVH9D6CKzp7It6AEuvffJJaurgFIrms= go.unistack.org/micro-server-http/v4 v4.0.8/go.mod h1:p55E0T8dthtOQC4bwzYpRSlky2Pd9xrUbJxPOu3opTI= go.unistack.org/micro/v3 v3.10.14/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q= -go.unistack.org/micro/v3 v3.10.24 h1:gIi4r0vUSpNLs+uRb4KKEXBLkE8iNp6ZnJsI5FV42j0= -go.unistack.org/micro/v3 v3.10.24/go.mod h1:aywPekJP0n07xvmDgj+Si3VPmQzGMfj6tkHk/6kjXhU= +go.unistack.org/micro/v3 v3.10.18 h1:iz193N8eZKGrKPXuX6XMsGIRHMqdvUaZSfb9mzwlUYM= +go.unistack.org/micro/v3 v3.10.18/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q= go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk= go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk= go.unistack.org/protoc-gen-go-micro/v4 v4.0.5 h1:1QTAN51nkQ3uAX0yxH1Ypti1ErghGN1goPA0D6Vnq9c= @@ -1088,7 +1074,6 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= @@ -1546,8 +1531,8 @@ google.golang.org/genproto v0.0.0-20210721163202-f1cecdd8b78a/go.mod h1:ob2IJxKr google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1577,8 +1562,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= 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= diff --git a/handler/handlers.go b/handler/handlers.go index 5573dca..85f3496 100644 --- a/handler/handlers.go +++ b/handler/handlers.go @@ -2,15 +2,20 @@ package handler import ( "context" + "encoding/json" + "io" "net/http" + "net/url" cmsstorage "go.unistack.org/cms-service/storage" "go.unistack.org/micro/v4" "go.unistack.org/micro/v4/errors" "go.unistack.org/unistack-org/pkgdash/config" - "go.unistack.org/unistack-org/pkgdash/models" pb "go.unistack.org/unistack-org/pkgdash/proto" + cligit "go.unistack.org/unistack-org/pkgdash/service/client_git" "go.unistack.org/unistack-org/pkgdash/storage" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" ) type Handler struct { @@ -18,6 +23,11 @@ type Handler struct { store storage.Storage writer writer + protojson.MarshalOptions + protojson.UnmarshalOptions + + git cligit.Client + chanUrl chan *pb.AddPackageReq } func (h *Handler) ListPackage(w http.ResponseWriter, r *http.Request) { @@ -25,7 +35,7 @@ func (h *Handler) ListPackage(w http.ResponseWriter, r *http.Request) { logger := h.svc.Logger() logger.Debug(ctx, "Start getListPackage") - dbRsp, err := h.store.List(ctx) + dbRsp, err := h.store.ListPackage(ctx) if err != nil { logger.Errorf(ctx, "error db response: %v", err) h.writer.Response(ctx, w, err) @@ -33,18 +43,45 @@ func (h *Handler) ListPackage(w http.ResponseWriter, r *http.Request) { } rsp := new(pb.ListPackageRsp) - rsp.Packages = models.ListPackage(dbRsp).Mapping() + rsp.Packages = dbRsp.Decode() logger.Debug(ctx, "Success finish getListPackage") h.writer.Response(ctx, w, rsp) } -func (h *Handler) UpdateInfo(w http.ResponseWriter, r *http.Request) { +func (h *Handler) UpdatePackage(w http.ResponseWriter, r *http.Request) { ctx := r.Context() logger := h.svc.Logger() - logger.Debug(ctx, "Start UpdateInfo") + logger.Debug(ctx, "Start UpdatePackage") - // TODO + defer r.Body.Close() + all, err := io.ReadAll(r.Body) + if err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + req := new(pb.UpdatePackageReq) + if err = h.Unmarshal(all, req); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewUnmarshalError(err)) + return + } + + if err = req.Validate(); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewValidationError(err)) + return + } + + if err = h.store.UpdatePackage(ctx, req); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + logger.Debug(ctx, "Success finish UpdatePackage") } func (h *Handler) AddComment(w http.ResponseWriter, r *http.Request) { @@ -52,11 +89,129 @@ func (h *Handler) AddComment(w http.ResponseWriter, r *http.Request) { logger := h.svc.Logger() logger.Debug(ctx, "Start AddComment") - // TODO + defer r.Body.Close() + all, err := io.ReadAll(r.Body) + if err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + req := new(pb.AddCommentReq) + if err = h.Unmarshal(all, req); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewUnmarshalError(err)) + return + } + + if err = req.Validate(); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewValidationError(err)) + return + } + + if err = h.store.AddComment(ctx, req); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + logger.Debug(ctx, "Success finish addComment") } -func NewHandler(svc micro.Service, w writer) *Handler { - return &Handler{svc: svc, writer: w} +func (h *Handler) AddPackage(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + logger := h.svc.Logger() + logger.Debug(ctx, "Start AddPackage") + + defer r.Body.Close() + all, err := io.ReadAll(r.Body) + if err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + req := new(pb.AddPackageReq) + if err = h.Unmarshal(all, req); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewUnmarshalError(err)) + return + } + + if err = req.Validate(); err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewValidationError(err)) + return + } + + if h.git.IsClose() { + logger.Error(ctx, "chan is closed") + } else { + h.chanUrl <- req + } + + logger.Debug(ctx, "Success finish addPackage") +} + +func (h *Handler) GetModule(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + logger := h.svc.Logger() + logger.Debug(ctx, "Start GetModule") + + req := new(pb.GetModuleReq) + if err := URLValuesToProto(r.URL.Query(), req); err != nil { + logger.Errorf(ctx, "Required parameter missing: %v", err) + h.writer.Response(ctx, w, err) + return + } + + modules, err := h.store.GetModule(ctx, req) + if err != nil { + logger.Error(ctx, err) + h.writer.Response(ctx, w, NewInternalError(err)) + return + } + + rsp := &pb.GetModuleRsp{Modules: modules.Decode()} + h.writer.Response(ctx, w, rsp) + + logger.Debug(ctx, "Success finish getModule") +} + +func URLValuesToProto(vals url.Values, msg proto.Message) error { + params := make(map[string]interface{}) + var err error + for k, v := range vals { + if len(v) == 0 { + continue + } + switch k { + case "id[]": + params[k] = v + default: + params[k] = v[0] + } + } + b, err := json.Marshal(params) + if err != nil { + return NewUnmarshalError(err) + } + if err = protojson.Unmarshal(b, msg); err != nil { + return NewUnmarshalError(err) + } + return nil +} + +func NewHandler(svc micro.Service, w writer, client cligit.Client) *Handler { + h := &Handler{ + svc: svc, + writer: w, + git: client, + } + h.EmitUnpopulated = true + h.UseProtoNames = false + return h } func (h *Handler) Init(ctx context.Context) error { @@ -69,6 +224,8 @@ func (h *Handler) Init(ctx context.Context) error { return errors.New(config.ServiceName, "error init storage", 1) } + h.chanUrl = h.git.Run(ctx, st) + h.store = st return nil diff --git a/handler/middleware.go b/handler/middleware.go new file mode 100644 index 0000000..df99f45 --- /dev/null +++ b/handler/middleware.go @@ -0,0 +1,21 @@ +package handler + +import "net/http" + +func Methods(m string, next http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, req *http.Request) { + if req.Method != m { + http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) + return + } + + switch req.Method { + case http.MethodPost: + w.WriteHeader(http.StatusCreated) + case http.MethodPut: + w.WriteHeader(http.StatusNoContent) + } + + next.ServeHTTP(w, req) + } +} diff --git a/handler/writer.go b/handler/writer.go index 42684b4..b04eb96 100644 --- a/handler/writer.go +++ b/handler/writer.go @@ -4,10 +4,9 @@ import ( "context" "net/http" + "github.com/pkg/errors" "go.unistack.org/micro/v4/logger" pb "go.unistack.org/unistack-org/pkgdash/proto" - - "github.com/pkg/errors" ) type encoder interface { @@ -19,6 +18,7 @@ type writer interface { Response(ctx context.Context, rw http.ResponseWriter, value interface{}) } +// nolint type stackTracer interface { StackTrace() errors.StackTrace } diff --git a/internal/modproxy.go b/internal/modproxy.go index c3d306e..6cebcb0 100644 --- a/internal/modproxy.go +++ b/internal/modproxy.go @@ -282,7 +282,7 @@ func Updates(opt UpdateOptions) { return nil }) } - group.Wait() + _ = group.Wait() }() for u := range ch { if opt.OnUpdate != nil { diff --git a/models/entities.go b/models/entities.go index 3711af4..e9e2d52 100644 --- a/models/entities.go +++ b/models/entities.go @@ -7,38 +7,39 @@ import ( ) type Package struct { - ID int64 `db:"id"` // package id - Name string `db:"name"` // service name, last component path - URL string `db:"url"` // scm url - Modules []Module `db:"modules"` // parsed go.mod modules - Issues []Issue `db:"issues"` // issues list - Comments []int64 `db:"comments"` + ID uint64 `db:"id" json:"id"` // package id + Name string `db:"name" json:"name"` // service name, last component path + URL string `db:"url" json:"url"` // scm url + Modules []uint64 `db:"modules" json:"modules"` // parsed go.mod modules + Issues []uint64 `db:"issues" json:"issues,omitempty"` // issues list + Comments []uint64 `db:"comments" json:"comments,omitempty"` } type Module struct { - ID int64 `db:"id"` - Name string `db:"name"` // module name - Version string `db:"version"` // module - Package int64 `db:"package"` + ID uint64 `db:"id"` + Name string `db:"name"` // module name + Version string `db:"version"` // module + Package uint64 `db:"package"` + LastVersion string `db:"last_version"` } type Issue struct { - ID int64 `db:"id"` - Status int64 `db:"status"` + ID uint64 `db:"id"` + Status uint64 `db:"status"` Desc string `db:"desc"` Package int64 `db:"package"` Modules []int64 `db:"modules"` } type Comment struct { - ID int64 `db:"id"` - Text string `db:"value"` - Created pgtype.Date `db:"created"` - Updated pgtype.Date `db:"updated"` + ID uint64 `db:"id" json:"id"` + Text string `db:"value" json:"text"` + Created pgtype.Date `db:"created" json:"created"` + Updated pgtype.Date `db:"updated" json:"updated,omitempty"` } type Dashboard struct { - ID int64 `db:"id"` - Uuid uuid.UUID `db:"uuid"` - Package int64 `db:"package"` + ID uint64 `db:"id"` + Uuid uuid.UUID `db:"uuid"` + Packages []uint64 `db:"package"` } diff --git a/models/mapping.go b/models/mapping.go index 2745cab..c03226b 100644 --- a/models/mapping.go +++ b/models/mapping.go @@ -6,8 +6,39 @@ import ( type ListPackage []*Package -func (l ListPackage) Mapping() []*pb.Package { +func (l ListPackage) Decode() []*pb.Package { result := make([]*pb.Package, 0, len(l)) + for i := range l { + temp := &pb.Package{ + Id: l[i].ID, + Name: l[i].Name, + Url: l[i].URL, + Modules: l[i].Modules, + Issues: l[i].Issues, + Comments: l[i].Comments, + } + + result = append(result, temp) + } + + return result +} + +type ListModule []*Module + +func (l ListModule) Decode() []*pb.Module { + result := make([]*pb.Module, 0, len(l)) + for i := range l { + temp := &pb.Module{ + Id: l[i].ID, + Name: l[i].Name, + Version: l[i].Version, + LastVersion: l[i].LastVersion, + } + + result = append(result, temp) + } + return result } diff --git a/proto/docker_generate/Dockerfile b/proto/docker_generate/Dockerfile new file mode 100644 index 0000000..24e0cd6 --- /dev/null +++ b/proto/docker_generate/Dockerfile @@ -0,0 +1,43 @@ +FROM golang:1.19-bullseye + +RUN mkdir /build +WORKDIR /build + +RUN apt-get update && apt-get -y install --no-install-recommends protobuf-compiler libprotobuf-dev + +ENV PATH=${PATH}:${GOBIN} + +ENV GEN_VALIDATE=github.com/envoyproxy/protoc-gen-validate@v1.0.2 +ENV GOOGLEAPIS=github.com/google/googleapis@v0.0.0-20200324113624-36c0febd0fa7 +ENV GRPC_GATEWAY=github.com/grpc-ecosystem/grpc-gateway@v1.16.0 + +RUN go install ${GEN_VALIDATE} + +RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0 && \ + go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.16.0 && \ + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + +RUN go install go.unistack.org/protoc-gen-go-micro/v3@latest + +RUN go mod init proto +RUN go get ${GOOGLEAPIS} && \ + go get ${GRPC_GATEWAY} && \ + go get google.golang.org/grpc@v1.57.0 && \ + go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway && \ + go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 && \ + go get google.golang.org/protobuf/cmd/protoc-gen-go && \ + go get go.unistack.org/micro-proto/v3@v3.3.1 + +CMD rm -rf go_generate && \ + protoc \ + --validate_out=lang=go:. \ + --go-micro_out=debug=true,components="micro|http":. \ + --go_out=. \ + --grpc-gateway_out=. \ + --proto_path=/go/pkg/mod/go.unistack.org/micro-proto/v3@v3.3.1 \ + -I=./ \ + -I=/usr/include \ + -I=/go/pkg/mod/${GEN_VALIDATE} \ + -I=/go/pkg/mod/${GOOGLEAPIS} \ + -I=/go/pkg/mod/${GRPC_GATEWAY} \ + ./*.proto diff --git a/proto/docker_generate/Makefile b/proto/docker_generate/Makefile new file mode 100644 index 0000000..cac80f5 --- /dev/null +++ b/proto/docker_generate/Makefile @@ -0,0 +1,7 @@ +#New version of proto Makefile and Dockerfile can be found +#at https://qcm-git.mbrd.ru/service-platform/examples/makefile + +.PHONY: proto +proto: + docker build -t proto:latest . + docker run --rm --name=proto -v `pwd`:/build proto:latest \ No newline at end of file diff --git a/proto/docker_generate/dashboard.proto b/proto/docker_generate/dashboard.proto new file mode 100644 index 0000000..e6a9588 --- /dev/null +++ b/proto/docker_generate/dashboard.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package proto; + +option go_package = "./go_generate;go_generate"; + +import "validate/validate.proto"; + + +message ErrorRsp { + Error error = 1 [json_name = "error"]; +} + +message Error { + string code = 1 [json_name = "code"]; + string title = 2 [json_name = "title"]; + string uuid = 3 [json_name = "uuid"]; + string details = 4 [json_name = "details"]; +} + +message Package { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; + string name = 2 [(validate.rules).string.min_len = 1]; + string url = 3 [(validate.rules).string.min_len = 1]; + repeated Module modules = 4; + repeated Issue issues = 5; +}; + +message Module { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; + string name = 2 [(validate.rules).string.min_len = 1]; + string version = 3 [(validate.rules).string.min_len = 1]; + uint64 package = 4 [(validate.rules).uint64.gt = 0]; +} + +message Issue { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; + uint64 status = 2 [(validate.rules).uint64.gt = 0]; + string desc = 3 [(validate.rules).string.min_len = 1]; + uint64 package = 4 [(validate.rules).uint64.gt = 0]; + repeated uint64 modules = 5; +} + +message Comment { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; + uint64 package = 2 [(validate.rules).uint64.gt = 0]; + string text = 3; + uint64 created = 4 [(validate.rules).uint64.gt = 0]; + uint64 updated = 5 [(validate.rules).uint64.gt = 0]; +} + +message ListPackageReq {} +message ListPackageRsp{ + repeated Package packages = 1; +} + +message UpdateInfoPackageRsp { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; +} +message UpdateInfoPackageReq { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; +} + +message CommentRsp { + uint64 idPackage = 1 [(validate.rules).uint64.gt = 0]; + string text = 2; +} + +message CommentReq { + uint64 id = 1 [(validate.rules).uint64.gt = 0]; +} \ No newline at end of file diff --git a/proto/docker_generate/restService.proto b/proto/docker_generate/restService.proto new file mode 100644 index 0000000..d3205fa --- /dev/null +++ b/proto/docker_generate/restService.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package proto; + +option go_package = "./go_generate;go_generate"; + +import "dashboard.proto"; +import "google/api/annotations.proto"; +import "protoc-gen-swagger/options/annotations.proto"; + +option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { + info: { + title: "service-platform/product-services/mts-money/gateway-proto", + version: "0"; + }; + consumes: "application/json"; + produces: "application/json"; +}; + +service DashboardService { + rpc ListPackage(ListPackageReq) returns (ListPackageRsp) { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = { + operation_id: "ListPackage"; + responses: { + key: "default"; + value: { + description: "Error response"; + schema: { + json_schema: { + ref: ".go_generate.ErrorRsp"; + } + } + } + } + }; + option (google.api.http) = { + get: "/listPackage"; + }; + }; + rpc UpdateInfo(UpdateInfoPackageRsp) returns (UpdateInfoPackageReq) {}; + rpc AddComment(CommentRsp) returns (CommentReq) {}; +}; \ No newline at end of file diff --git a/proto/generate.sh b/proto/generate.sh new file mode 100755 index 0000000..d841b96 --- /dev/null +++ b/proto/generate.sh @@ -0,0 +1,14 @@ +#!/bin/sh -ex + + PROTO_ARGS=" \ +--proto_path=$(go list -f '{{ .Dir }}' -m github.com/envoyproxy/protoc-gen-validate) \ +--proto_path=$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) \ +--go_out=paths=source_relative:go_generate \ +--go-micro_out=module=go.unistack.org/unistack-org/pkgdash/proto/go_generate,components=micro|http,standalone=true:./micro \ +--validate_out=paths=source_relative,lang=go:go_generate +" + +find . -not \( -name "*.sh" -or -name "*.proto" -or -name "generate.go" -or -name "Dockerfile" -or -name "Makefile" \) -delete +mkdir -p micro go_generate && \ +protoc -I. $PROTO_ARGS ./*.proto || \ +find . -not \( -name "*.sh" -or -name "*.proto" -or -name "generate.go" -or -name "Dockerfile" -or -name "Makefile" \) -delete \ No newline at end of file diff --git a/proto/pkgdash.pb.go b/proto/pkgdash.pb.go index 0de4fd3..49d7953 100644 --- a/proto/pkgdash.pb.go +++ b/proto/pkgdash.pb.go @@ -9,12 +9,10 @@ package pkgdashpb import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" _ "go.unistack.org/micro-proto/v4/api" - _ "go.unistack.org/micro-proto/v4/openapiv2" _ "go.unistack.org/micro-proto/v4/openapiv3" - _ "go.unistack.org/micro-proto/v4/tag" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/wrapperspb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) @@ -149,11 +147,12 @@ type Package struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` - Modules []*Module `protobuf:"bytes,4,rep,name=modules,proto3" json:"modules,omitempty"` - Issues []*Issue `protobuf:"bytes,5,rep,name=issues,proto3" json:"issues,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + Modules []uint64 `protobuf:"varint,4,rep,packed,name=modules,proto3" json:"modules,omitempty"` + Issues []uint64 `protobuf:"varint,5,rep,packed,name=issues,proto3" json:"issues,omitempty"` + Comments []uint64 `protobuf:"varint,6,rep,packed,name=comments,proto3" json:"comments,omitempty"` } func (x *Package) Reset() { @@ -209,29 +208,37 @@ func (x *Package) GetUrl() string { return "" } -func (x *Package) GetModules() []*Module { +func (x *Package) GetModules() []uint64 { if x != nil { return x.Modules } return nil } -func (x *Package) GetIssues() []*Issue { +func (x *Package) GetIssues() []uint64 { if x != nil { return x.Issues } return nil } +func (x *Package) GetComments() []uint64 { + if x != nil { + return x.Comments + } + return nil +} + type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` - Package uint64 `protobuf:"varint,4,opt,name=package,proto3" json:"package,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + Package uint64 `protobuf:"varint,4,opt,name=package,proto3" json:"package,omitempty"` + LastVersion string `protobuf:"bytes,5,opt,name=last_version,json=lastVersion,proto3" json:"last_version,omitempty"` } func (x *Module) Reset() { @@ -294,6 +301,13 @@ func (x *Module) GetPackage() uint64 { return 0 } +func (x *Module) GetLastVersion() string { + if x != nil { + return x.LastVersion + } + return "" +} + type Issue struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -537,16 +551,20 @@ func (x *ListPackageRsp) GetPackages() []*Package { return nil } -type UpdateInfoPackageRsp struct { +type UpdatePackageReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id *wrapperspb.UInt64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Url *wrapperspb.StringValue `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + Modules []uint64 `protobuf:"varint,4,rep,packed,name=modules,proto3" json:"modules,omitempty"` + Issues []uint64 `protobuf:"varint,5,rep,packed,name=issues,proto3" json:"issues,omitempty"` } -func (x *UpdateInfoPackageRsp) Reset() { - *x = UpdateInfoPackageRsp{} +func (x *UpdatePackageReq) Reset() { + *x = UpdatePackageReq{} if protoimpl.UnsafeEnabled { mi := &file_pkgdash_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -554,13 +572,13 @@ func (x *UpdateInfoPackageRsp) Reset() { } } -func (x *UpdateInfoPackageRsp) String() string { +func (x *UpdatePackageReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateInfoPackageRsp) ProtoMessage() {} +func (*UpdatePackageReq) ProtoMessage() {} -func (x *UpdateInfoPackageRsp) ProtoReflect() protoreflect.Message { +func (x *UpdatePackageReq) ProtoReflect() protoreflect.Message { mi := &file_pkgdash_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -572,19 +590,47 @@ func (x *UpdateInfoPackageRsp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateInfoPackageRsp.ProtoReflect.Descriptor instead. -func (*UpdateInfoPackageRsp) Descriptor() ([]byte, []int) { +// Deprecated: Use UpdatePackageReq.ProtoReflect.Descriptor instead. +func (*UpdatePackageReq) Descriptor() ([]byte, []int) { return file_pkgdash_proto_rawDescGZIP(), []int{8} } -func (x *UpdateInfoPackageRsp) GetId() uint64 { +func (x *UpdatePackageReq) GetId() *wrapperspb.UInt64Value { if x != nil { return x.Id } - return 0 + return nil } -type UpdateInfoPackageReq struct { +func (x *UpdatePackageReq) GetName() *wrapperspb.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *UpdatePackageReq) GetUrl() *wrapperspb.StringValue { + if x != nil { + return x.Url + } + return nil +} + +func (x *UpdatePackageReq) GetModules() []uint64 { + if x != nil { + return x.Modules + } + return nil +} + +func (x *UpdatePackageReq) GetIssues() []uint64 { + if x != nil { + return x.Issues + } + return nil +} + +type UpdatePackageRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -592,8 +638,8 @@ type UpdateInfoPackageReq struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *UpdateInfoPackageReq) Reset() { - *x = UpdateInfoPackageReq{} +func (x *UpdatePackageRsp) Reset() { + *x = UpdatePackageRsp{} if protoimpl.UnsafeEnabled { mi := &file_pkgdash_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -601,13 +647,13 @@ func (x *UpdateInfoPackageReq) Reset() { } } -func (x *UpdateInfoPackageReq) String() string { +func (x *UpdatePackageRsp) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateInfoPackageReq) ProtoMessage() {} +func (*UpdatePackageRsp) ProtoMessage() {} -func (x *UpdateInfoPackageReq) ProtoReflect() protoreflect.Message { +func (x *UpdatePackageRsp) ProtoReflect() protoreflect.Message { mi := &file_pkgdash_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -619,12 +665,12 @@ func (x *UpdateInfoPackageReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateInfoPackageReq.ProtoReflect.Descriptor instead. -func (*UpdateInfoPackageReq) Descriptor() ([]byte, []int) { +// Deprecated: Use UpdatePackageRsp.ProtoReflect.Descriptor instead. +func (*UpdatePackageRsp) Descriptor() ([]byte, []int) { return file_pkgdash_proto_rawDescGZIP(), []int{9} } -func (x *UpdateInfoPackageReq) GetId() uint64 { +func (x *UpdatePackageRsp) GetId() uint64 { if x != nil { return x.Id } @@ -686,16 +732,17 @@ func (x *CommentReq) GetText() string { return "" } -type CommentRsp struct { +type AddCommentReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + IdPackage *wrapperspb.UInt64Value `protobuf:"bytes,1,opt,name=idPackage,proto3" json:"idPackage,omitempty"` + Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` } -func (x *CommentRsp) Reset() { - *x = CommentRsp{} +func (x *AddCommentReq) Reset() { + *x = AddCommentReq{} if protoimpl.UnsafeEnabled { mi := &file_pkgdash_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -703,13 +750,13 @@ func (x *CommentRsp) Reset() { } } -func (x *CommentRsp) String() string { +func (x *AddCommentReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CommentRsp) ProtoMessage() {} +func (*AddCommentReq) ProtoMessage() {} -func (x *CommentRsp) ProtoReflect() protoreflect.Message { +func (x *AddCommentReq) ProtoReflect() protoreflect.Message { mi := &file_pkgdash_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -721,126 +768,426 @@ func (x *CommentRsp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CommentRsp.ProtoReflect.Descriptor instead. -func (*CommentRsp) Descriptor() ([]byte, []int) { +// Deprecated: Use AddCommentReq.ProtoReflect.Descriptor instead. +func (*AddCommentReq) Descriptor() ([]byte, []int) { return file_pkgdash_proto_rawDescGZIP(), []int{11} } -func (x *CommentRsp) GetId() uint64 { +func (x *AddCommentReq) GetIdPackage() *wrapperspb.UInt64Value { + if x != nil { + return x.IdPackage + } + return nil +} + +func (x *AddCommentReq) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +type AddCommentRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *AddCommentRsp) Reset() { + *x = AddCommentRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_pkgdash_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddCommentRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddCommentRsp) ProtoMessage() {} + +func (x *AddCommentRsp) ProtoReflect() protoreflect.Message { + mi := &file_pkgdash_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddCommentRsp.ProtoReflect.Descriptor instead. +func (*AddCommentRsp) Descriptor() ([]byte, []int) { + return file_pkgdash_proto_rawDescGZIP(), []int{12} +} + +func (x *AddCommentRsp) GetId() uint64 { if x != nil { return x.Id } return 0 } +type AddPackageReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Modules []uint64 `protobuf:"varint,3,rep,packed,name=modules,proto3" json:"modules,omitempty"` +} + +func (x *AddPackageReq) Reset() { + *x = AddPackageReq{} + if protoimpl.UnsafeEnabled { + mi := &file_pkgdash_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPackageReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPackageReq) ProtoMessage() {} + +func (x *AddPackageReq) ProtoReflect() protoreflect.Message { + mi := &file_pkgdash_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPackageReq.ProtoReflect.Descriptor instead. +func (*AddPackageReq) Descriptor() ([]byte, []int) { + return file_pkgdash_proto_rawDescGZIP(), []int{13} +} + +func (x *AddPackageReq) GetName() *wrapperspb.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *AddPackageReq) GetUrl() *wrapperspb.StringValue { + if x != nil { + return x.Url + } + return nil +} + +func (x *AddPackageReq) GetModules() []uint64 { + if x != nil { + return x.Modules + } + return nil +} + +type AddPackageRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AddPackageRsp) Reset() { + *x = AddPackageRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_pkgdash_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPackageRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPackageRsp) ProtoMessage() {} + +func (x *AddPackageRsp) ProtoReflect() protoreflect.Message { + mi := &file_pkgdash_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPackageRsp.ProtoReflect.Descriptor instead. +func (*AddPackageRsp) Descriptor() ([]byte, []int) { + return file_pkgdash_proto_rawDescGZIP(), []int{14} +} + +type GetModuleReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []uint64 `protobuf:"varint,1,rep,packed,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetModuleReq) Reset() { + *x = GetModuleReq{} + if protoimpl.UnsafeEnabled { + mi := &file_pkgdash_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetModuleReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetModuleReq) ProtoMessage() {} + +func (x *GetModuleReq) ProtoReflect() protoreflect.Message { + mi := &file_pkgdash_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetModuleReq.ProtoReflect.Descriptor instead. +func (*GetModuleReq) Descriptor() ([]byte, []int) { + return file_pkgdash_proto_rawDescGZIP(), []int{15} +} + +func (x *GetModuleReq) GetId() []uint64 { + if x != nil { + return x.Id + } + return nil +} + +type GetModuleRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Modules []*Module `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` +} + +func (x *GetModuleRsp) Reset() { + *x = GetModuleRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_pkgdash_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetModuleRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetModuleRsp) ProtoMessage() {} + +func (x *GetModuleRsp) ProtoReflect() protoreflect.Message { + mi := &file_pkgdash_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetModuleRsp.ProtoReflect.Descriptor instead. +func (*GetModuleRsp) Descriptor() ([]byte, []int) { + return file_pkgdash_proto_rawDescGZIP(), []int{16} +} + +func (x *GetModuleRsp) GetModules() []*Module { + if x != nil { + return x.Modules + } + return nil +} + var File_pkgdash_proto protoreflect.FileDescriptor var file_pkgdash_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, - 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x74, 0x61, 0x67, 0x2f, 0x74, - 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x30, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x73, 0x70, 0x12, 0x24, 0x0a, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, - 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x22, 0x5f, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x73, 0x22, 0xad, 0x01, 0x0a, 0x07, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x73, + 0x70, 0x12, 0x24, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x5f, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0xa8, 0x01, 0x0a, 0x07, 0x50, 0x61, 0x63, + 0x6b, 0x61, 0x67, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x03, 0x75, 0x72, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, + 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, + 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, 0x52, + 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x22, 0xb0, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x17, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, + 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, + 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x2a, 0x0a, 0x0c, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9b, 0x01, 0x0a, 0x05, 0x49, 0x73, 0x73, 0x75, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, - 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x75, 0x72, - 0x6c, 0x12, 0x29, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x4d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x06, - 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, - 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x52, 0x06, 0x69, 0x73, - 0x73, 0x75, 0x65, 0x73, 0x22, 0x84, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, - 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, - 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, - 0x20, 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x05, - 0x49, 0x73, 0x73, 0x75, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1b, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x64, 0x65, 0x73, 0x63, 0x12, 0x21, 0x0a, 0x07, - 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, - 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x9f, 0x01, 0x0a, 0x07, 0x43, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, - 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, - 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x21, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, - 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, - 0x20, 0x00, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x22, 0x10, 0x0a, 0x0e, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x22, 0x3e, 0x0a, - 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, - 0x2c, 0x0a, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0x2f, 0x0a, - 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2f, - 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, - 0x3b, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x19, 0x0a, - 0x03, 0x70, 0x6b, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, - 0x02, 0x20, 0x00, 0x52, 0x03, 0x70, 0x6b, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x25, 0x0a, 0x0a, - 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, - 0x02, 0x69, 0x64, 0x32, 0xb0, 0x03, 0x0a, 0x0e, 0x50, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, - 0x17, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x3f, 0xaa, 0x84, 0x9e, 0x03, 0x26, 0x2a, - 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, 0x17, 0x0a, 0x15, - 0x12, 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0e, 0x12, 0x0c, 0x2f, 0x76, 0x31, - 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x91, 0x01, 0x0a, 0x0a, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, - 0x73, 0x68, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, - 0x68, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x45, 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, 0x0a, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x17, 0x0a, 0x15, 0x12, 0x13, 0x0a, - 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, - 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x15, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x01, 0x2a, 0x12, 0x86, 0x01, - 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x70, - 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x22, 0x4e, 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, 0x0a, 0x41, - 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x17, 0x0a, 0x15, 0x12, 0x13, 0x0a, - 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, - 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x1e, 0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x7b, 0x70, 0x6b, 0x67, 0x7d, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x3a, 0x01, 0x2a, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, + 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, + 0x20, 0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x65, + 0x73, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, + 0x01, 0x52, 0x04, 0x64, 0x65, 0x73, 0x63, 0x12, 0x21, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, + 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x73, 0x22, 0x9f, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, + 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x07, 0x70, 0x61, 0x63, + 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, + 0x02, 0x20, 0x00, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, + 0x12, 0x21, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x07, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x22, 0x10, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x22, 0x3e, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, + 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x12, 0x2c, 0x0a, 0x08, 0x70, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, + 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x08, + 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xf2, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x36, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, + 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3a, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x38, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, + 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x73, 0x22, 0x2b, 0x0a, + 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, + 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, + 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, 0x3b, 0x0a, 0x0a, 0x43, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x19, 0x0a, 0x03, 0x70, 0x6b, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x03, + 0x70, 0x6b, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x69, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x43, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x44, 0x0a, 0x09, 0x69, 0x64, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, + 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, + 0x02, 0x10, 0x01, 0x52, 0x09, 0x69, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, + 0x78, 0x74, 0x22, 0x28, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, + 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, 0x22, 0x9f, 0x01, 0x0a, + 0x0d, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x3a, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x03, 0x75, 0x72, + 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, + 0x03, 0x75, 0x72, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x0f, + 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, + 0x1e, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, + 0x39, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x12, + 0x29, 0x0a, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0f, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x32, 0xa9, 0x05, 0x0a, 0x0e, 0x50, + 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x80, 0x01, + 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x17, 0x2e, + 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, + 0x3f, 0xaa, 0x84, 0x9e, 0x03, 0x26, 0x2a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x42, 0x17, 0x0a, 0x15, 0x12, 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, + 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, + 0x01, 0x0e, 0x12, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, + 0x12, 0x8c, 0x01, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, + 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x45, 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, + 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x17, 0x0a, 0x15, 0x12, + 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x15, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, + 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x01, 0x2a, 0x12, + 0x8c, 0x01, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, + 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, + 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x73, 0x70, 0x22, 0x4e, + 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x74, 0x42, 0x17, 0x0a, 0x15, 0x12, 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, + 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x1e, + 0x22, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x7b, 0x70, + 0x6b, 0x67, 0x7d, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x3a, 0x01, 0x2a, 0x12, 0x7e, + 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x16, 0x2e, 0x70, + 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x41, + 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x73, 0x70, 0x22, 0x40, 0xaa, 0x84, + 0x9e, 0x03, 0x25, 0x2a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, + 0x17, 0x0a, 0x15, 0x12, 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x10, 0x22, 0x0b, + 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x76, + 0x0a, 0x09, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x70, 0x6b, + 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x47, 0x65, 0x74, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x22, 0x3b, 0xaa, 0x84, 0x9e, 0x03, 0x24, + 0x2a, 0x09, 0x47, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0x17, 0x0a, 0x15, 0x12, + 0x13, 0x0a, 0x11, 0x2e, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0c, 0x12, 0x0a, 0x2f, 0x76, 0x31, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x6b, 0x67, 0x64, 0x61, 0x73, 0x68, 0x70, 0x62, 0x62, 0x06, @@ -859,37 +1206,53 @@ func file_pkgdash_proto_rawDescGZIP() []byte { return file_pkgdash_proto_rawDescData } -var file_pkgdash_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_pkgdash_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_pkgdash_proto_goTypes = []interface{}{ - (*ErrorRsp)(nil), // 0: pkgdash.ErrorRsp - (*Error)(nil), // 1: pkgdash.Error - (*Package)(nil), // 2: pkgdash.Package - (*Module)(nil), // 3: pkgdash.Module - (*Issue)(nil), // 4: pkgdash.Issue - (*Comment)(nil), // 5: pkgdash.Comment - (*ListPackageReq)(nil), // 6: pkgdash.ListPackageReq - (*ListPackageRsp)(nil), // 7: pkgdash.ListPackageRsp - (*UpdateInfoPackageRsp)(nil), // 8: pkgdash.UpdateInfoPackageRsp - (*UpdateInfoPackageReq)(nil), // 9: pkgdash.UpdateInfoPackageReq - (*CommentReq)(nil), // 10: pkgdash.CommentReq - (*CommentRsp)(nil), // 11: pkgdash.CommentRsp + (*ErrorRsp)(nil), // 0: pkgdash.ErrorRsp + (*Error)(nil), // 1: pkgdash.Error + (*Package)(nil), // 2: pkgdash.Package + (*Module)(nil), // 3: pkgdash.Module + (*Issue)(nil), // 4: pkgdash.Issue + (*Comment)(nil), // 5: pkgdash.Comment + (*ListPackageReq)(nil), // 6: pkgdash.ListPackageReq + (*ListPackageRsp)(nil), // 7: pkgdash.ListPackageRsp + (*UpdatePackageReq)(nil), // 8: pkgdash.UpdatePackageReq + (*UpdatePackageRsp)(nil), // 9: pkgdash.UpdatePackageRsp + (*CommentReq)(nil), // 10: pkgdash.CommentReq + (*AddCommentReq)(nil), // 11: pkgdash.AddCommentReq + (*AddCommentRsp)(nil), // 12: pkgdash.AddCommentRsp + (*AddPackageReq)(nil), // 13: pkgdash.AddPackageReq + (*AddPackageRsp)(nil), // 14: pkgdash.AddPackageRsp + (*GetModuleReq)(nil), // 15: pkgdash.GetModuleReq + (*GetModuleRsp)(nil), // 16: pkgdash.GetModuleRsp + (*wrapperspb.UInt64Value)(nil), // 17: google.protobuf.UInt64Value + (*wrapperspb.StringValue)(nil), // 18: google.protobuf.StringValue } var file_pkgdash_proto_depIdxs = []int32{ 1, // 0: pkgdash.ErrorRsp.error:type_name -> pkgdash.Error - 3, // 1: pkgdash.Package.modules:type_name -> pkgdash.Module - 4, // 2: pkgdash.Package.issues:type_name -> pkgdash.Issue - 2, // 3: pkgdash.ListPackageRsp.packages:type_name -> pkgdash.Package - 6, // 4: pkgdash.PkgdashService.ListPackage:input_type -> pkgdash.ListPackageReq - 9, // 5: pkgdash.PkgdashService.UpdateInfo:input_type -> pkgdash.UpdateInfoPackageReq - 10, // 6: pkgdash.PkgdashService.AddComment:input_type -> pkgdash.CommentReq - 7, // 7: pkgdash.PkgdashService.ListPackage:output_type -> pkgdash.ListPackageRsp - 8, // 8: pkgdash.PkgdashService.UpdateInfo:output_type -> pkgdash.UpdateInfoPackageRsp - 11, // 9: pkgdash.PkgdashService.AddComment:output_type -> pkgdash.CommentRsp - 7, // [7:10] is the sub-list for method output_type - 4, // [4:7] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 2, // 1: pkgdash.ListPackageRsp.packages:type_name -> pkgdash.Package + 17, // 2: pkgdash.UpdatePackageReq.id:type_name -> google.protobuf.UInt64Value + 18, // 3: pkgdash.UpdatePackageReq.name:type_name -> google.protobuf.StringValue + 18, // 4: pkgdash.UpdatePackageReq.url:type_name -> google.protobuf.StringValue + 17, // 5: pkgdash.AddCommentReq.idPackage:type_name -> google.protobuf.UInt64Value + 18, // 6: pkgdash.AddPackageReq.name:type_name -> google.protobuf.StringValue + 18, // 7: pkgdash.AddPackageReq.url:type_name -> google.protobuf.StringValue + 3, // 8: pkgdash.GetModuleRsp.modules:type_name -> pkgdash.Module + 6, // 9: pkgdash.PkgdashService.ListPackage:input_type -> pkgdash.ListPackageReq + 8, // 10: pkgdash.PkgdashService.UpdatePackage:input_type -> pkgdash.UpdatePackageReq + 11, // 11: pkgdash.PkgdashService.AddComment:input_type -> pkgdash.AddCommentReq + 13, // 12: pkgdash.PkgdashService.AddPackage:input_type -> pkgdash.AddPackageReq + 15, // 13: pkgdash.PkgdashService.GetModule:input_type -> pkgdash.GetModuleReq + 7, // 14: pkgdash.PkgdashService.ListPackage:output_type -> pkgdash.ListPackageRsp + 9, // 15: pkgdash.PkgdashService.UpdatePackage:output_type -> pkgdash.UpdatePackageRsp + 12, // 16: pkgdash.PkgdashService.AddComment:output_type -> pkgdash.AddCommentRsp + 14, // 17: pkgdash.PkgdashService.AddPackage:output_type -> pkgdash.AddPackageRsp + 16, // 18: pkgdash.PkgdashService.GetModule:output_type -> pkgdash.GetModuleRsp + 14, // [14:19] is the sub-list for method output_type + 9, // [9:14] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_pkgdash_proto_init() } @@ -995,7 +1358,7 @@ func file_pkgdash_proto_init() { } } file_pkgdash_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateInfoPackageRsp); i { + switch v := v.(*UpdatePackageReq); i { case 0: return &v.state case 1: @@ -1007,7 +1370,7 @@ func file_pkgdash_proto_init() { } } file_pkgdash_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateInfoPackageReq); i { + switch v := v.(*UpdatePackageRsp); i { case 0: return &v.state case 1: @@ -1031,7 +1394,67 @@ func file_pkgdash_proto_init() { } } file_pkgdash_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommentRsp); i { + switch v := v.(*AddCommentReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkgdash_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddCommentRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkgdash_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPackageReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkgdash_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPackageRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkgdash_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetModuleReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkgdash_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetModuleRsp); i { case 0: return &v.state case 1: @@ -1049,7 +1472,7 @@ func file_pkgdash_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pkgdash_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/pkgdash.pb.validate.go b/proto/pkgdash.pb.validate.go index 2f3a080..240bf79 100644 --- a/proto/pkgdash.pb.validate.go +++ b/proto/pkgdash.pb.validate.go @@ -321,74 +321,6 @@ func (m *Package) validate(all bool) error { errors = append(errors, err) } - for idx, item := range m.GetModules() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PackageValidationError{ - field: fmt.Sprintf("Modules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PackageValidationError{ - field: fmt.Sprintf("Modules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PackageValidationError{ - field: fmt.Sprintf("Modules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetIssues() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PackageValidationError{ - field: fmt.Sprintf("Issues[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PackageValidationError{ - field: fmt.Sprintf("Issues[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PackageValidationError{ - field: fmt.Sprintf("Issues[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - if len(errors) > 0 { return PackageMultiError(errors) } @@ -530,6 +462,17 @@ func (m *Module) validate(all bool) error { errors = append(errors, err) } + if utf8.RuneCountInString(m.GetLastVersion()) < 1 { + err := ModuleValidationError{ + field: "LastVersion", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + if len(errors) > 0 { return ModuleMultiError(errors) } @@ -1122,32 +1065,32 @@ var _ interface { ErrorName() string } = ListPackageRspValidationError{} -// Validate checks the field values on UpdateInfoPackageRsp with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *UpdateInfoPackageRsp) Validate() error { +// Validate checks the field values on UpdatePackageReq with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *UpdatePackageReq) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on UpdateInfoPackageRsp with the rules +// ValidateAll checks the field values on UpdatePackageReq with the rules // defined in the proto definition for this message. If any rules are // violated, the result is a list of violation errors wrapped in -// UpdateInfoPackageRspMultiError, or nil if none found. -func (m *UpdateInfoPackageRsp) ValidateAll() error { +// UpdatePackageReqMultiError, or nil if none found. +func (m *UpdatePackageReq) ValidateAll() error { return m.validate(true) } -func (m *UpdateInfoPackageRsp) validate(all bool) error { +func (m *UpdatePackageReq) validate(all bool) error { if m == nil { return nil } var errors []error - if m.GetId() <= 0 { - err := UpdateInfoPackageRspValidationError{ + if m.GetId() == nil { + err := UpdatePackageReqValidationError{ field: "Id", - reason: "value must be greater than 0", + reason: "value is required", } if !all { return err @@ -1155,19 +1098,128 @@ func (m *UpdateInfoPackageRsp) validate(all bool) error { errors = append(errors, err) } + if all { + switch v := interface{}(m.GetId()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetId()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Id", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetName() == nil { + err := UpdatePackageReqValidationError{ + field: "Name", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetName()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetUrl() == nil { + err := UpdatePackageReqValidationError{ + field: "Url", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUrl()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { - return UpdateInfoPackageRspMultiError(errors) + return UpdatePackageReqMultiError(errors) } return nil } -// UpdateInfoPackageRspMultiError is an error wrapping multiple validation -// errors returned by UpdateInfoPackageRsp.ValidateAll() if the designated -// constraints aren't met. -type UpdateInfoPackageRspMultiError []error +// UpdatePackageReqMultiError is an error wrapping multiple validation errors +// returned by UpdatePackageReq.ValidateAll() if the designated constraints +// aren't met. +type UpdatePackageReqMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m UpdateInfoPackageRspMultiError) Error() string { +func (m UpdatePackageReqMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1176,11 +1228,11 @@ func (m UpdateInfoPackageRspMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m UpdateInfoPackageRspMultiError) AllErrors() []error { return m } +func (m UpdatePackageReqMultiError) AllErrors() []error { return m } -// UpdateInfoPackageRspValidationError is the validation error returned by -// UpdateInfoPackageRsp.Validate if the designated constraints aren't met. -type UpdateInfoPackageRspValidationError struct { +// UpdatePackageReqValidationError is the validation error returned by +// UpdatePackageReq.Validate if the designated constraints aren't met. +type UpdatePackageReqValidationError struct { field string reason string cause error @@ -1188,24 +1240,22 @@ type UpdateInfoPackageRspValidationError struct { } // Field function returns field value. -func (e UpdateInfoPackageRspValidationError) Field() string { return e.field } +func (e UpdatePackageReqValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e UpdateInfoPackageRspValidationError) Reason() string { return e.reason } +func (e UpdatePackageReqValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e UpdateInfoPackageRspValidationError) Cause() error { return e.cause } +func (e UpdatePackageReqValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e UpdateInfoPackageRspValidationError) Key() bool { return e.key } +func (e UpdatePackageReqValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e UpdateInfoPackageRspValidationError) ErrorName() string { - return "UpdateInfoPackageRspValidationError" -} +func (e UpdatePackageReqValidationError) ErrorName() string { return "UpdatePackageReqValidationError" } // Error satisfies the builtin error interface -func (e UpdateInfoPackageRspValidationError) Error() string { +func (e UpdatePackageReqValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1217,14 +1267,14 @@ func (e UpdateInfoPackageRspValidationError) Error() string { } return fmt.Sprintf( - "invalid %sUpdateInfoPackageRsp.%s: %s%s", + "invalid %sUpdatePackageReq.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = UpdateInfoPackageRspValidationError{} +var _ error = UpdatePackageReqValidationError{} var _ interface { Field() string @@ -1232,24 +1282,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = UpdateInfoPackageRspValidationError{} +} = UpdatePackageReqValidationError{} -// Validate checks the field values on UpdateInfoPackageReq with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *UpdateInfoPackageReq) Validate() error { +// Validate checks the field values on UpdatePackageRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *UpdatePackageRsp) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on UpdateInfoPackageReq with the rules +// ValidateAll checks the field values on UpdatePackageRsp with the rules // defined in the proto definition for this message. If any rules are // violated, the result is a list of violation errors wrapped in -// UpdateInfoPackageReqMultiError, or nil if none found. -func (m *UpdateInfoPackageReq) ValidateAll() error { +// UpdatePackageRspMultiError, or nil if none found. +func (m *UpdatePackageRsp) ValidateAll() error { return m.validate(true) } -func (m *UpdateInfoPackageReq) validate(all bool) error { +func (m *UpdatePackageRsp) validate(all bool) error { if m == nil { return nil } @@ -1257,7 +1307,7 @@ func (m *UpdateInfoPackageReq) validate(all bool) error { var errors []error if m.GetId() <= 0 { - err := UpdateInfoPackageReqValidationError{ + err := UpdatePackageRspValidationError{ field: "Id", reason: "value must be greater than 0", } @@ -1268,18 +1318,18 @@ func (m *UpdateInfoPackageReq) validate(all bool) error { } if len(errors) > 0 { - return UpdateInfoPackageReqMultiError(errors) + return UpdatePackageRspMultiError(errors) } return nil } -// UpdateInfoPackageReqMultiError is an error wrapping multiple validation -// errors returned by UpdateInfoPackageReq.ValidateAll() if the designated -// constraints aren't met. -type UpdateInfoPackageReqMultiError []error +// UpdatePackageRspMultiError is an error wrapping multiple validation errors +// returned by UpdatePackageRsp.ValidateAll() if the designated constraints +// aren't met. +type UpdatePackageRspMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m UpdateInfoPackageReqMultiError) Error() string { +func (m UpdatePackageRspMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1288,11 +1338,11 @@ func (m UpdateInfoPackageReqMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m UpdateInfoPackageReqMultiError) AllErrors() []error { return m } +func (m UpdatePackageRspMultiError) AllErrors() []error { return m } -// UpdateInfoPackageReqValidationError is the validation error returned by -// UpdateInfoPackageReq.Validate if the designated constraints aren't met. -type UpdateInfoPackageReqValidationError struct { +// UpdatePackageRspValidationError is the validation error returned by +// UpdatePackageRsp.Validate if the designated constraints aren't met. +type UpdatePackageRspValidationError struct { field string reason string cause error @@ -1300,24 +1350,22 @@ type UpdateInfoPackageReqValidationError struct { } // Field function returns field value. -func (e UpdateInfoPackageReqValidationError) Field() string { return e.field } +func (e UpdatePackageRspValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e UpdateInfoPackageReqValidationError) Reason() string { return e.reason } +func (e UpdatePackageRspValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e UpdateInfoPackageReqValidationError) Cause() error { return e.cause } +func (e UpdatePackageRspValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e UpdateInfoPackageReqValidationError) Key() bool { return e.key } +func (e UpdatePackageRspValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e UpdateInfoPackageReqValidationError) ErrorName() string { - return "UpdateInfoPackageReqValidationError" -} +func (e UpdatePackageRspValidationError) ErrorName() string { return "UpdatePackageRspValidationError" } // Error satisfies the builtin error interface -func (e UpdateInfoPackageReqValidationError) Error() string { +func (e UpdatePackageRspValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1329,14 +1377,14 @@ func (e UpdateInfoPackageReqValidationError) Error() string { } return fmt.Sprintf( - "invalid %sUpdateInfoPackageReq.%s: %s%s", + "invalid %sUpdatePackageRsp.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = UpdateInfoPackageReqValidationError{} +var _ error = UpdatePackageRspValidationError{} var _ interface { Field() string @@ -1344,7 +1392,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = UpdateInfoPackageReqValidationError{} +} = UpdatePackageRspValidationError{} // Validate checks the field values on CommentReq with the rules defined in the // proto definition for this message. If any rules are violated, the first @@ -1457,32 +1505,32 @@ var _ interface { ErrorName() string } = CommentReqValidationError{} -// Validate checks the field values on CommentRsp with the rules defined in the -// proto definition for this message. If any rules are violated, the first +// Validate checks the field values on AddCommentReq with the rules defined in +// the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. -func (m *CommentRsp) Validate() error { +func (m *AddCommentReq) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on CommentRsp with the rules defined in -// the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in CommentRspMultiError, or +// ValidateAll checks the field values on AddCommentReq with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddCommentReqMultiError, or // nil if none found. -func (m *CommentRsp) ValidateAll() error { +func (m *AddCommentReq) ValidateAll() error { return m.validate(true) } -func (m *CommentRsp) validate(all bool) error { +func (m *AddCommentReq) validate(all bool) error { if m == nil { return nil } var errors []error - if m.GetId() <= 0 { - err := CommentRspValidationError{ - field: "Id", - reason: "value must be greater than 0", + if m.GetIdPackage() == nil { + err := AddCommentReqValidationError{ + field: "IdPackage", + reason: "value is required", } if !all { return err @@ -1490,18 +1538,50 @@ func (m *CommentRsp) validate(all bool) error { errors = append(errors, err) } + if all { + switch v := interface{}(m.GetIdPackage()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIdPackage()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddCommentReqValidationError{ + field: "IdPackage", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Text + if len(errors) > 0 { - return CommentRspMultiError(errors) + return AddCommentReqMultiError(errors) } return nil } -// CommentRspMultiError is an error wrapping multiple validation errors -// returned by CommentRsp.ValidateAll() if the designated constraints aren't met. -type CommentRspMultiError []error +// AddCommentReqMultiError is an error wrapping multiple validation errors +// returned by AddCommentReq.ValidateAll() if the designated constraints +// aren't met. +type AddCommentReqMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m CommentRspMultiError) Error() string { +func (m AddCommentReqMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -1510,11 +1590,11 @@ func (m CommentRspMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m CommentRspMultiError) AllErrors() []error { return m } +func (m AddCommentReqMultiError) AllErrors() []error { return m } -// CommentRspValidationError is the validation error returned by -// CommentRsp.Validate if the designated constraints aren't met. -type CommentRspValidationError struct { +// AddCommentReqValidationError is the validation error returned by +// AddCommentReq.Validate if the designated constraints aren't met. +type AddCommentReqValidationError struct { field string reason string cause error @@ -1522,22 +1602,22 @@ type CommentRspValidationError struct { } // Field function returns field value. -func (e CommentRspValidationError) Field() string { return e.field } +func (e AddCommentReqValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e CommentRspValidationError) Reason() string { return e.reason } +func (e AddCommentReqValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e CommentRspValidationError) Cause() error { return e.cause } +func (e AddCommentReqValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e CommentRspValidationError) Key() bool { return e.key } +func (e AddCommentReqValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e CommentRspValidationError) ErrorName() string { return "CommentRspValidationError" } +func (e AddCommentReqValidationError) ErrorName() string { return "AddCommentReqValidationError" } // Error satisfies the builtin error interface -func (e CommentRspValidationError) Error() string { +func (e AddCommentReqValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1549,14 +1629,14 @@ func (e CommentRspValidationError) Error() string { } return fmt.Sprintf( - "invalid %sCommentRsp.%s: %s%s", + "invalid %sAddCommentReq.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = CommentRspValidationError{} +var _ error = AddCommentReqValidationError{} var _ interface { Field() string @@ -1564,4 +1644,622 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = CommentRspValidationError{} +} = AddCommentReqValidationError{} + +// Validate checks the field values on AddCommentRsp with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AddCommentRsp) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AddCommentRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddCommentRspMultiError, or +// nil if none found. +func (m *AddCommentRsp) ValidateAll() error { + return m.validate(true) +} + +func (m *AddCommentRsp) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := AddCommentRspValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return AddCommentRspMultiError(errors) + } + return nil +} + +// AddCommentRspMultiError is an error wrapping multiple validation errors +// returned by AddCommentRsp.ValidateAll() if the designated constraints +// aren't met. +type AddCommentRspMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AddCommentRspMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AddCommentRspMultiError) AllErrors() []error { return m } + +// AddCommentRspValidationError is the validation error returned by +// AddCommentRsp.Validate if the designated constraints aren't met. +type AddCommentRspValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AddCommentRspValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AddCommentRspValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AddCommentRspValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AddCommentRspValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AddCommentRspValidationError) ErrorName() string { return "AddCommentRspValidationError" } + +// Error satisfies the builtin error interface +func (e AddCommentRspValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAddCommentRsp.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AddCommentRspValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AddCommentRspValidationError{} + +// Validate checks the field values on AddPackageReq with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AddPackageReq) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AddPackageReq with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddPackageReqMultiError, or +// nil if none found. +func (m *AddPackageReq) ValidateAll() error { + return m.validate(true) +} + +func (m *AddPackageReq) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetName() == nil { + err := AddPackageReqValidationError{ + field: "Name", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetName()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetName()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddPackageReqValidationError{ + field: "Name", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetUrl() == nil { + err := AddPackageReqValidationError{ + field: "Url", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUrl()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUrl()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AddPackageReqValidationError{ + field: "Url", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return AddPackageReqMultiError(errors) + } + return nil +} + +// AddPackageReqMultiError is an error wrapping multiple validation errors +// returned by AddPackageReq.ValidateAll() if the designated constraints +// aren't met. +type AddPackageReqMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AddPackageReqMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AddPackageReqMultiError) AllErrors() []error { return m } + +// AddPackageReqValidationError is the validation error returned by +// AddPackageReq.Validate if the designated constraints aren't met. +type AddPackageReqValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AddPackageReqValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AddPackageReqValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AddPackageReqValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AddPackageReqValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AddPackageReqValidationError) ErrorName() string { return "AddPackageReqValidationError" } + +// Error satisfies the builtin error interface +func (e AddPackageReqValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAddPackageReq.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AddPackageReqValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AddPackageReqValidationError{} + +// Validate checks the field values on AddPackageRsp with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AddPackageRsp) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AddPackageRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AddPackageRspMultiError, or +// nil if none found. +func (m *AddPackageRsp) ValidateAll() error { + return m.validate(true) +} + +func (m *AddPackageRsp) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return AddPackageRspMultiError(errors) + } + return nil +} + +// AddPackageRspMultiError is an error wrapping multiple validation errors +// returned by AddPackageRsp.ValidateAll() if the designated constraints +// aren't met. +type AddPackageRspMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AddPackageRspMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AddPackageRspMultiError) AllErrors() []error { return m } + +// AddPackageRspValidationError is the validation error returned by +// AddPackageRsp.Validate if the designated constraints aren't met. +type AddPackageRspValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AddPackageRspValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AddPackageRspValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AddPackageRspValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AddPackageRspValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AddPackageRspValidationError) ErrorName() string { return "AddPackageRspValidationError" } + +// Error satisfies the builtin error interface +func (e AddPackageRspValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAddPackageRsp.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AddPackageRspValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AddPackageRspValidationError{} + +// Validate checks the field values on GetModuleReq with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *GetModuleReq) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetModuleReq with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetModuleReqMultiError, or +// nil if none found. +func (m *GetModuleReq) ValidateAll() error { + return m.validate(true) +} + +func (m *GetModuleReq) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetModuleReqMultiError(errors) + } + return nil +} + +// GetModuleReqMultiError is an error wrapping multiple validation errors +// returned by GetModuleReq.ValidateAll() if the designated constraints aren't met. +type GetModuleReqMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetModuleReqMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetModuleReqMultiError) AllErrors() []error { return m } + +// GetModuleReqValidationError is the validation error returned by +// GetModuleReq.Validate if the designated constraints aren't met. +type GetModuleReqValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetModuleReqValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetModuleReqValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetModuleReqValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetModuleReqValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetModuleReqValidationError) ErrorName() string { return "GetModuleReqValidationError" } + +// Error satisfies the builtin error interface +func (e GetModuleReqValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetModuleReq.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetModuleReqValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetModuleReqValidationError{} + +// Validate checks the field values on GetModuleRsp with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *GetModuleRsp) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetModuleRsp with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetModuleRspMultiError, or +// nil if none found. +func (m *GetModuleRsp) ValidateAll() error { + return m.validate(true) +} + +func (m *GetModuleRsp) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetModules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetModuleRspValidationError{ + field: fmt.Sprintf("Modules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetModuleRspMultiError(errors) + } + return nil +} + +// GetModuleRspMultiError is an error wrapping multiple validation errors +// returned by GetModuleRsp.ValidateAll() if the designated constraints aren't met. +type GetModuleRspMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetModuleRspMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetModuleRspMultiError) AllErrors() []error { return m } + +// GetModuleRspValidationError is the validation error returned by +// GetModuleRsp.Validate if the designated constraints aren't met. +type GetModuleRspValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetModuleRspValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetModuleRspValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetModuleRspValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetModuleRspValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetModuleRspValidationError) ErrorName() string { return "GetModuleRspValidationError" } + +// Error satisfies the builtin error interface +func (e GetModuleRspValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetModuleRsp.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetModuleRspValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetModuleRspValidationError{} diff --git a/proto/pkgdash.proto b/proto/pkgdash.proto index 74e214c..5336554 100644 --- a/proto/pkgdash.proto +++ b/proto/pkgdash.proto @@ -5,11 +5,9 @@ package pkgdash; option go_package = "go.unistack.org/unistack-org/pkgdash/proto;pkgdashpb"; import "api/annotations.proto"; -import "google/protobuf/wrappers.proto"; -import "openapiv2/annotations.proto"; import "openapiv3/annotations.proto"; -import "tag/tag.proto"; import "validate/validate.proto"; +import "google/protobuf/wrappers.proto"; service PkgdashService { rpc ListPackage(ListPackageReq) returns (ListPackageRsp) { @@ -25,7 +23,7 @@ service PkgdashService { get: "/v1/packages"; }; }; - rpc UpdateInfo(UpdateInfoPackageReq) returns (UpdateInfoPackageRsp) { + rpc UpdatePackage(UpdatePackageReq) returns (UpdatePackageRsp) { option (micro.openapiv3.openapiv3_operation) = { operation_id: "UpdateInfo"; responses: { @@ -39,7 +37,7 @@ service PkgdashService { body: "*"; }; }; - rpc AddComment(CommentReq) returns (CommentRsp) { + rpc AddComment(AddCommentReq) returns (AddCommentRsp) { option (micro.openapiv3.openapiv3_operation) = { operation_id: "AddComment"; responses: { @@ -53,6 +51,33 @@ service PkgdashService { body: "*"; }; }; + rpc AddPackage(AddPackageReq) returns (AddPackageRsp) { + option (micro.openapiv3.openapiv3_operation) = { + operation_id: "AddPackage"; + responses: { + default: { + reference: {_ref: ".pkgdash.ErrorRsp"}; + }; + }; + }; + option (micro.api.http) = { + post: "/v1/package"; + body: "*"; + }; + }; + rpc GetModule(GetModuleReq) returns (GetModuleRsp) { + option (micro.openapiv3.openapiv3_operation) = { + operation_id: "GetModule"; + responses: { + default: { + reference: {_ref: ".pkgdash.ErrorRsp"}; + }; + }; + }; + option (micro.api.http) = { + get: "/v1/module"; + }; + }; }; message ErrorRsp { @@ -70,8 +95,9 @@ message Package { uint64 id = 1 [(validate.rules).uint64.gt = 0]; string name = 2 [(validate.rules).string.min_len = 1]; string url = 3 [(validate.rules).string.min_len = 1]; - repeated Module modules = 4; - repeated Issue issues = 5; + repeated uint64 modules = 4; + repeated uint64 issues = 5; + repeated uint64 comments = 6; }; message Module { @@ -79,6 +105,7 @@ message Module { string name = 2 [(validate.rules).string.min_len = 1]; string version = 3 [(validate.rules).string.min_len = 1]; uint64 package = 4 [(validate.rules).uint64.gt = 0]; + string last_version = 5 [(validate.rules).string.min_len = 1]; } message Issue { @@ -102,10 +129,14 @@ message ListPackageRsp{ repeated Package packages = 1; } -message UpdateInfoPackageRsp { - uint64 id = 1 [(validate.rules).uint64.gt = 0]; +message UpdatePackageReq { + google.protobuf.UInt64Value id = 1 [(validate.rules).message.required = true]; + google.protobuf.StringValue name = 2 [(validate.rules).message.required = true]; + google.protobuf.StringValue url = 3 [(validate.rules).message.required = true]; + repeated uint64 modules = 4 ; + repeated uint64 issues = 5 ; } -message UpdateInfoPackageReq { +message UpdatePackageRsp { uint64 id = 1 [(validate.rules).uint64.gt = 0]; } @@ -114,6 +145,26 @@ message CommentReq { string text = 2; } -message CommentRsp { +message AddCommentReq { + google.protobuf.UInt64Value idPackage = 1 [(validate.rules).message.required = true]; + string text = 2; +} + +message AddCommentRsp { uint64 id = 1 [(validate.rules).uint64.gt = 0]; +} + +message AddPackageReq { + google.protobuf.StringValue name = 1 [(validate.rules).message.required = true]; + google.protobuf.StringValue url = 2 [(validate.rules).message.required = true]; + repeated uint64 modules = 3; +} + +message AddPackageRsp{} + +message GetModuleReq { + repeated uint64 id = 1 ; +} +message GetModuleRsp { + repeated Module modules = 1 ; } \ No newline at end of file diff --git a/proto/pkgdash_micro.pb.go b/proto/pkgdash_micro.pb.go index 60abb41..9b0632e 100644 --- a/proto/pkgdash_micro.pb.go +++ b/proto/pkgdash_micro.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: -// - protoc-gen-go-micro v3.10.4 +// - protoc-gen-go-micro v4.0.2 // - protoc v4.23.4 // source: pkgdash.proto @@ -8,7 +8,8 @@ package pkgdashpb import ( context "context" - client "go.unistack.org/micro/v3/client" + _ "go.unistack.org/micro/v4/client" + options "go.unistack.org/micro/v4/options" ) var ( @@ -16,13 +17,17 @@ var ( ) type PkgdashServiceClient interface { - ListPackage(ctx context.Context, req *ListPackageReq, opts ...client.CallOption) (*ListPackageRsp, error) - UpdateInfo(ctx context.Context, req *UpdateInfoPackageReq, opts ...client.CallOption) (*UpdateInfoPackageRsp, error) - AddComment(ctx context.Context, req *CommentReq, opts ...client.CallOption) (*CommentRsp, error) + ListPackage(ctx context.Context, req *ListPackageReq, opts ...options.Option) (*ListPackageRsp, error) + UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error) + AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error) + AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error) + GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error) } type PkgdashServiceServer interface { ListPackage(ctx context.Context, req *ListPackageReq, rsp *ListPackageRsp) error - UpdateInfo(ctx context.Context, req *UpdateInfoPackageReq, rsp *UpdateInfoPackageRsp) error - AddComment(ctx context.Context, req *CommentReq, rsp *CommentRsp) error + UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error + AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error + AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error + GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error } diff --git a/proto/pkgdash_micro_http.pb.go b/proto/pkgdash_micro_http.pb.go index 3312c9a..6f016ff 100644 --- a/proto/pkgdash_micro_http.pb.go +++ b/proto/pkgdash_micro_http.pb.go @@ -1,20 +1,21 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. -// protoc-gen-go-micro version: v3.10.4 +// protoc-gen-go-micro version: v4.0.2 // source: pkgdash.proto package pkgdashpb import ( context "context" - v31 "go.unistack.org/micro-client-http/v3" - v3 "go.unistack.org/micro-server-http/v3" - client "go.unistack.org/micro/v3/client" - server "go.unistack.org/micro/v3/server" + v41 "go.unistack.org/micro-client-http/v4" + v4 "go.unistack.org/micro-server-http/v4" + client "go.unistack.org/micro/v4/client" + options "go.unistack.org/micro/v4/options" + server "go.unistack.org/micro/v4/server" http "net/http" ) var ( - PkgdashServiceServerEndpoints = []v3.EndpointMetadata{ + PkgdashServiceServerEndpoints = []v4.EndpointMetadata{ { Name: "PkgdashService.ListPackage", Path: "/v1/packages", @@ -23,7 +24,7 @@ var ( Stream: false, }, { - Name: "PkgdashService.UpdateInfo", + Name: "PkgdashService.UpdatePackage", Path: "/v1/package/{id}", Method: "POST", Body: "*", @@ -36,6 +37,20 @@ var ( Body: "*", Stream: false, }, + { + Name: "PkgdashService.AddPackage", + Path: "/v1/package", + Method: "POST", + Body: "*", + Stream: false, + }, + { + Name: "PkgdashService.GetModule", + Path: "/v1/module", + Method: "GET", + Body: "", + Stream: false, + }, } ) @@ -48,15 +63,15 @@ func NewPkgdashServiceClient(name string, c client.Client) PkgdashServiceClient return &pkgdashServiceClient{c: c, name: name} } -func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *ListPackageReq, opts ...client.CallOption) (*ListPackageRsp, error) { +func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *ListPackageReq, opts ...options.Option) (*ListPackageRsp, error) { errmap := make(map[string]interface{}, 1) errmap["default"] = &ErrorRsp{} opts = append(opts, - v31.ErrorMap(errmap), + v41.ErrorMap(errmap), ) opts = append(opts, - v31.Method(http.MethodGet), - v31.Path("/v1/packages"), + v41.Method(http.MethodGet), + v41.Path("/v1/packages"), ) rsp := &ListPackageRsp{} err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.ListPackage", req), rsp, opts...) @@ -66,37 +81,37 @@ func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *ListPackage return rsp, nil } -func (c *pkgdashServiceClient) UpdateInfo(ctx context.Context, req *UpdateInfoPackageReq, opts ...client.CallOption) (*UpdateInfoPackageRsp, error) { +func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePackageReq, opts ...options.Option) (*UpdatePackageRsp, error) { errmap := make(map[string]interface{}, 1) errmap["default"] = &ErrorRsp{} opts = append(opts, - v31.ErrorMap(errmap), + v41.ErrorMap(errmap), ) opts = append(opts, - v31.Method(http.MethodPost), - v31.Path("/v1/package/{id}"), - v31.Body("*"), + v41.Method(http.MethodPost), + v41.Path("/v1/package/{id}"), + v41.Body("*"), ) - rsp := &UpdateInfoPackageRsp{} - err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.UpdateInfo", req), rsp, opts...) + rsp := &UpdatePackageRsp{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.UpdatePackage", req), rsp, opts...) if err != nil { return nil, err } return rsp, nil } -func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *CommentReq, opts ...client.CallOption) (*CommentRsp, error) { +func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *AddCommentReq, opts ...options.Option) (*AddCommentRsp, error) { errmap := make(map[string]interface{}, 1) errmap["default"] = &ErrorRsp{} opts = append(opts, - v31.ErrorMap(errmap), + v41.ErrorMap(errmap), ) opts = append(opts, - v31.Method(http.MethodPost), - v31.Path("/v1/package/{pkg}/comment"), - v31.Body("*"), + v41.Method(http.MethodPost), + v41.Path("/v1/package/{pkg}/comment"), + v41.Body("*"), ) - rsp := &CommentRsp{} + rsp := &AddCommentRsp{} err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddComment", req), rsp, opts...) if err != nil { return nil, err @@ -104,6 +119,43 @@ func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *CommentReq, return rsp, nil } +func (c *pkgdashServiceClient) AddPackage(ctx context.Context, req *AddPackageReq, opts ...options.Option) (*AddPackageRsp, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &ErrorRsp{} + opts = append(opts, + v41.ErrorMap(errmap), + ) + opts = append(opts, + v41.Method(http.MethodPost), + v41.Path("/v1/package"), + v41.Body("*"), + ) + rsp := &AddPackageRsp{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddPackage", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq, opts ...options.Option) (*GetModuleRsp, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &ErrorRsp{} + opts = append(opts, + v41.ErrorMap(errmap), + ) + opts = append(opts, + v41.Method(http.MethodGet), + v41.Path("/v1/module"), + ) + rsp := &GetModuleRsp{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.GetModule", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type pkgdashServiceServer struct { PkgdashServiceServer } @@ -112,25 +164,35 @@ func (h *pkgdashServiceServer) ListPackage(ctx context.Context, req *ListPackage return h.PkgdashServiceServer.ListPackage(ctx, req, rsp) } -func (h *pkgdashServiceServer) UpdateInfo(ctx context.Context, req *UpdateInfoPackageReq, rsp *UpdateInfoPackageRsp) error { - return h.PkgdashServiceServer.UpdateInfo(ctx, req, rsp) +func (h *pkgdashServiceServer) UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error { + return h.PkgdashServiceServer.UpdatePackage(ctx, req, rsp) } -func (h *pkgdashServiceServer) AddComment(ctx context.Context, req *CommentReq, rsp *CommentRsp) error { +func (h *pkgdashServiceServer) AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error { return h.PkgdashServiceServer.AddComment(ctx, req, rsp) } +func (h *pkgdashServiceServer) AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error { + return h.PkgdashServiceServer.AddPackage(ctx, req, rsp) +} + +func (h *pkgdashServiceServer) GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error { + return h.PkgdashServiceServer.GetModule(ctx, req, rsp) +} + func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts ...server.HandlerOption) error { type pkgdashService interface { ListPackage(ctx context.Context, req *ListPackageReq, rsp *ListPackageRsp) error - UpdateInfo(ctx context.Context, req *UpdateInfoPackageReq, rsp *UpdateInfoPackageRsp) error - AddComment(ctx context.Context, req *CommentReq, rsp *CommentRsp) error + UpdatePackage(ctx context.Context, req *UpdatePackageReq, rsp *UpdatePackageRsp) error + AddComment(ctx context.Context, req *AddCommentReq, rsp *AddCommentRsp) error + AddPackage(ctx context.Context, req *AddPackageReq, rsp *AddPackageRsp) error + GetModule(ctx context.Context, req *GetModuleReq, rsp *GetModuleRsp) error } type PkgdashService struct { pkgdashService } h := &pkgdashServiceServer{sh} var nopts []server.HandlerOption - nopts = append(nopts, v3.HandlerEndpoints(PkgdashServiceServerEndpoints)) + nopts = append(nopts, v4.HandlerEndpoints(PkgdashServiceServerEndpoints)) return s.Handle(s.NewHandler(&PkgdashService{h}, append(nopts, opts...)...)) } diff --git a/service/client_git/client.go b/service/client_git/client.go new file mode 100644 index 0000000..870cd0d --- /dev/null +++ b/service/client_git/client.go @@ -0,0 +1,218 @@ +package client_git + +import ( + "context" + "fmt" + "io" + "net/url" + "os" + "sort" + "strings" + + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing/filemode" + "github.com/go-git/go-git/v5/plumbing/object" + "github.com/go-git/go-git/v5/storage/memory" + "github.com/pkg/errors" + "go.unistack.org/micro/v4/logger" + "go.unistack.org/unistack-org/pkgdash/internal" + "go.unistack.org/unistack-org/pkgdash/models" + pb "go.unistack.org/unistack-org/pkgdash/proto" + "go.unistack.org/unistack-org/pkgdash/storage" + "golang.org/x/mod/modfile" + "golang.org/x/mod/module" +) + +type Client interface { + Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq + IsClose() bool + Done() <-chan struct{} +} + +type client struct { + worker chan *pb.AddPackageReq + closed bool + lock chan struct{} +} + +func NewClient(cap uint) Client { + return &client{ + make(chan *pb.AddPackageReq, cap), + false, + make(chan struct{}), + } +} + +func (c *client) Run(ctx context.Context, st storage.Storage) chan *pb.AddPackageReq { + go func() { + defer close(c.worker) + for { + select { + case data := <-c.worker: + go func() { + runner(ctx, st, data) + }() + case <-ctx.Done(): + logger.Info(ctx, ctx.Err()) + return + } + } + }() + + return c.worker +} + +func (c *client) IsClose() bool { + return c.closed +} + +// Done for locked goroutine +func (c *client) Done() <-chan struct{} { + return c.lock +} + +func runner(ctx context.Context, st storage.Storage, req *pb.AddPackageReq) { + modules, err := getGoModule(ctx, req.Url.Value) + if err != nil { + logger.Error(ctx, err) + return + } + + logger.Infof(ctx, "success get list mod", modules) + + if req.Modules, err = st.InsertButchModules(ctx, modules); err != nil { + logger.Error(ctx, err) + return + } + + if err = st.AddPackage(ctx, req); err != nil { + logger.Error(ctx, err) + } +} + +func getGoModule(ctx context.Context, gitUrl string) ([]models.Module, error) { + u, err := url.Parse(gitUrl) + if err != nil { + logger.Fatal(ctx, err) + } + + var rev string + if idx := strings.Index(u.Path, "@"); idx > 0 { + rev = u.Path[idx+1:] + } + + cloneOpts := &git.CloneOptions{ + URL: gitUrl, + Progress: os.Stdout, + } + + if len(rev) == 0 { + cloneOpts.SingleBranch = true + cloneOpts.Depth = 1 + } + + if err = cloneOpts.Validate(); err != nil { + return nil, err + } + + repo, err := git.CloneContext(ctx, memory.NewStorage(), nil, cloneOpts) + if err != nil { + return nil, err + } + + ref, err := repo.Head() + if err != nil { + return nil, fmt.Errorf("failed to get head: %v", err) + } + + commit, err := repo.CommitObject(ref.Hash()) + if err != nil { + return nil, fmt.Errorf("failed to get commit: %v", err) + } + + tree, err := commit.Tree() + if err != nil { + return nil, err + } + + unique := make(map[string]models.Module) + var mvs []module.Version + err = tree.Files().ForEach(func(file *object.File) error { + if file == nil { + err = errors.New("file pointer is nil") + logger.Error(ctx, err) + return err + } + + switch file.Mode { + case filemode.Regular: + if strings.HasSuffix(file.Name, "go.mod") { + if mvs, err = Direct(file); err != nil { + return err + } + for i := range mvs { + unique[mvs[i].Path] = models.Module{ + Name: mvs[i].Path, + Version: mvs[i].Version, + LastVersion: mvs[i].Version, + } + } + internal.Updates(internal.UpdateOptions{ + Pre: false, + Major: false, + Cached: false, + Modules: mvs, + OnUpdate: func(u internal.Update) { + if u.Err != nil { + logger.Errorf(ctx, "%s: failed: %v\n", u.Module.Path, u.Err) + } else { + val := unique[u.Module.Path] + val.LastVersion = u.Version + unique[u.Module.Path] = val + } + }, + }) + } + } + return nil + }) + + result := make([]models.Module, 0, len(unique)) + for _, v := range unique { + result = append(result, v) + } + + sort.Slice(result, func(i, j int) bool { + return result[i].Name < result[j].Name + }) + + return result, err +} + +func Direct(file *object.File) ([]module.Version, error) { + r, err := file.Reader() + if err != nil { + return nil, err + } + defer r.Close() + data, err := io.ReadAll(r) + if err != nil { + return nil, err + } + modfile, err := modfile.ParseLax("go.mod", data, nil) + if err != nil { + return nil, err + } + var mods []module.Version + for _, req := range modfile.Require { + // if !req.Indirect { + mods = append(mods, req.Mod) + //} + } + /* + sort.Slice(mods, func(i, j int) bool { + return mods[i].Path < mods[j].Path + }) + */ + return mods, nil +} diff --git a/service/client_git/client_test.go b/service/client_git/client_test.go new file mode 100644 index 0000000..34551e8 --- /dev/null +++ b/service/client_git/client_test.go @@ -0,0 +1,86 @@ +package client_git + +import ( + "context" + "database/sql" + "fmt" + pb "go.unistack.org/unistack-org/pkgdash/proto" + "go.unistack.org/unistack-org/pkgdash/storage" + "go.unistack.org/unistack-org/pkgdash/storage/postgres" + "go.unistack.org/unistack-org/pkgdash/storage/sqlite" + "google.golang.org/protobuf/types/known/wrapperspb" + "testing" +) + +func TestClientPG(t *testing.T) { + dsn := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=disable", "test", "123", "localhost", "5432", "postgres") + conn, err := sql.Open("postgres", dsn) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + if err = conn.Ping(); err != nil { + t.Fatal(err) + } + + st, err := postgres.NewStorage(conn) + if err != nil { + t.Fatal(err) + } + + s, ok := st.(storage.Storage) + if !ok { + t.Fatal("typecast error") + } + + ctx, cancel := context.WithCancel(context.Background()) + _ = cancel + cli := NewClient(1) + + ch := cli.Run(ctx, s) + + data := &pb.AddPackageReq{ + Name: wrapperspb.String("test"), + Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"), + } + + ch <- data + + <-cli.Done() +} + +func TestClientLite(t *testing.T) { + conn, err := sql.Open("sqlite3", "../../identifier.sqlite") + if err != nil { + t.Fatal(err) + } + defer conn.Close() + if err = conn.Ping(); err != nil { + t.Fatal(err) + } + + st, err := sqlite.NewStorage(conn) + if err != nil { + t.Fatal(err) + } + + s, ok := st.(storage.Storage) + if !ok { + t.Fatal("typecast error") + } + + ctx, cancel := context.WithCancel(context.Background()) + _ = cancel + cli := NewClient(1) + + ch := cli.Run(ctx, s) + + data := &pb.AddPackageReq{ + Name: wrapperspb.String("test"), + Url: wrapperspb.String("https://github.com/dantedenis/service_history.git"), + } + + ch <- data + + <-cli.Done() +} diff --git a/service/service.go b/service/service.go index d7a57a7..64e76a2 100644 --- a/service/service.go +++ b/service/service.go @@ -12,16 +12,16 @@ import ( "go.unistack.org/micro/v4/logger" "go.unistack.org/micro/v4/options" "go.unistack.org/micro/v4/register" - microuter "go.unistack.org/micro/v4/router" + "go.unistack.org/micro/v4/server" intcfg "go.unistack.org/unistack-org/pkgdash/config" "go.unistack.org/unistack-org/pkgdash/handler" "go.unistack.org/unistack-org/pkgdash/handler/encoders" + "go.unistack.org/unistack-org/pkgdash/service/client_git" "go.unistack.org/unistack-org/pkgdash/storage" ) func NewService(ctx context.Context) (micro.Service, error) { var reg register.Register - var router microuter.Router if ctx == nil { ctx = context.Background() @@ -30,25 +30,11 @@ func NewService(ctx context.Context) (micro.Service, error) { cfg := intcfg.NewConfig() cs := cmsservice.NewConfigLocal(cfg) - if r, ok := register.FromContext(ctx); ok && r != nil { - reg = r - } else { - reg = register.NewRegister() - } - if r, ok := microuter.FromContext(ctx); ok && r != nil { - router = r - } else { - router = microuter.NewRouter() - } - mgsrv := httpsrv.NewServer( options.Register(reg), ) svc := micro.NewService( - micro.Server(mgsrv), - micro.Register(reg), - micro.Router(router), micro.Config(cs...), ) @@ -57,21 +43,21 @@ func NewService(ctx context.Context) (micro.Service, error) { logger.Fatalf(ctx, "failed init writer: %v", err) } - h := handler.NewHandler(svc, writer) + h := handler.NewHandler(svc, writer, client_git.NewClient(5)) - if err := svc.Init( + if err = svc.Init( micro.AfterStart(func(_ context.Context) error { return h.Init(svc.Options().Context) }), micro.BeforeStart(func(ctx context.Context) error { - if err := config.Load(ctx, cs, config.LoadOverride(true)); err != nil { + if err = config.Load(ctx, cs, config.LoadOverride(true)); err != nil { return err } - if err := config.Validate(ctx, cfg); err != nil { + if err = config.Validate(ctx, cfg); err != nil { return err } - if err := svc.Init( + if err = svc.Init( micro.Name(cfg.Service.Name), micro.Version(cfg.Service.Version), ); err != nil { @@ -81,7 +67,7 @@ func NewService(ctx context.Context) (micro.Service, error) { if err := svc.Server("http").Init( options.Address(cfg.App.Address), options.Name(cfg.Service.Name), - options.Version(cfg.Service.Version), + server.Version(cfg.Service.Version), ); err != nil { return err } @@ -131,9 +117,11 @@ func NewService(ctx context.Context) (micro.Service, error) { mux := http.NewServeMux() - mux.HandleFunc("/listPackage", h.ListPackage) - mux.HandleFunc("/updateInfo", h.UpdateInfo) - mux.HandleFunc("/addComment", h.AddComment) + mux.HandleFunc("/listPackage", handler.Methods(http.MethodGet, h.ListPackage)) + mux.HandleFunc("/updatePackage", handler.Methods(http.MethodPost, h.UpdatePackage)) + mux.HandleFunc("/addComment", handler.Methods(http.MethodPut, h.AddComment)) + mux.HandleFunc("/addPackage", handler.Methods(http.MethodPost, h.AddPackage)) + mux.HandleFunc("/getModule", handler.Methods(http.MethodGet, h.GetModule)) if err = svc.Server().Handle(svc.Server().NewHandler(mux)); err != nil { logger.Fatalf(ctx, "failed to register handler: %v", err) diff --git a/storage/migrations/postgres/000001_init_schema.up.sql b/storage/migrations/postgres/000001_init_schema.up.sql index 02c4ecc..2e7fdd1 100644 --- a/storage/migrations/postgres/000001_init_schema.up.sql +++ b/storage/migrations/postgres/000001_init_schema.up.sql @@ -1,12 +1,12 @@ create table if not exists dashboard ( id serial not null unique primary key , - "uniq_id" uuid not null unique default gen_random_uuid() , - package integer + "uuid" uuid not null unique default gen_random_uuid() , + package integer[] default '{}'::integer[] ); create table if not exists comment ( id serial not null unique primary key , - text text , + "text" text , created timestamp not null default current_timestamp , updated timestamp ); @@ -14,13 +14,14 @@ create table if not exists comment ( create table if not exists module ( id serial not null unique primary key , name varchar not null , - version varchar not null + version varchar not null , + last_version varchar not null ); create table if not exists issue ( id serial not null unique primary key , --package integer references package(id) , - modules integer[] , + modules integer[] default '{}'::integer[], status integer default 0 , "desc" varchar ); @@ -29,9 +30,10 @@ create table if not exists package ( id serial not null unique primary key , name varchar not null , url varchar , - modules integer[] , - issues integer[] , - comments integer[] + modules integer[] default '{}'::integer[], + issues integer[] default '{}'::integer[], + comments integer[] default '{}'::integer[] ); +create unique index module_info on module(name, version); diff --git a/storage/migrations/sqlite/000001_init_schema.down.sql b/storage/migrations/sqlite/000001_init_schema.down.sql new file mode 100644 index 0000000..b9ce01f --- /dev/null +++ b/storage/migrations/sqlite/000001_init_schema.down.sql @@ -0,0 +1,5 @@ +drop table if exists dashboard ; +drop table if exists package ; +drop table if exists module ; +drop table if exists issue ; +drop table if exists comment; \ No newline at end of file diff --git a/storage/migrations/sqlite/000001_init_schema.up.sql b/storage/migrations/sqlite/000001_init_schema.up.sql new file mode 100644 index 0000000..8893211 --- /dev/null +++ b/storage/migrations/sqlite/000001_init_schema.up.sql @@ -0,0 +1,38 @@ +create table if not exists dashboard ( + id integer primary key autoincrement not null , + "uuid" uuid not null unique , + package integer[] default '{}' +); + +create table if not exists comment ( + id integer primary key autoincrement not null , + "text" text , + created timestamp not null default current_timestamp , + updated timestamp +); + +create table if not exists module ( + id integer primary key autoincrement not null , + name varchar not null , + version varchar not null , + last_version varchar not null +); + +create table if not exists issue ( + id serial not null unique primary key , + --package integer references package(id) , + modules integer[] default '[]', + status integer default 0 , + "desc" varchar +); + +create table if not exists package ( + id integer primary key autoincrement not null , + name varchar not null , + url varchar , + modules integer[] default '[]', + issues integer[] default '[]', + comments integer[] default '[]' +); + + diff --git a/storage/postgres/queries.go b/storage/postgres/queries.go index accfcad..aa0e3c8 100644 --- a/storage/postgres/queries.go +++ b/storage/postgres/queries.go @@ -2,6 +2,27 @@ package postgres const ( queryListPackage = ` -select * from package; +select + id, + name, + url, + comments + --modules, + --issues, + from package; +` + queryAddComment = ` +with insert_comm as ( + insert into comment(text) values ($1) returning id +) +update package set comments = array_append(comments, (select * from insert_comm)) where id=$2; +` + queryAddPackage = ` +insert into package(name, url, modules) values ($1, $2, $3); +` + queryInsMsgGetIDs = ` +insert into module(name, version, last_version) values +%s +returning id; ` ) diff --git a/storage/postgres/storage.go b/storage/postgres/storage.go index dfe5875..75ce5f9 100644 --- a/storage/postgres/storage.go +++ b/storage/postgres/storage.go @@ -1,14 +1,21 @@ package postgres import ( + "context" "database/sql" "embed" "errors" - "go.unistack.org/unistack-org/pkgdash/config" + "fmt" + pb "go.unistack.org/unistack-org/pkgdash/proto" + "strings" "github.com/golang-migrate/migrate/v4" - "github.com/golang-migrate/migrate/v4/database/pgx" + mpgx "github.com/golang-migrate/migrate/v4/database/pgx" "github.com/golang-migrate/migrate/v4/source/iofs" + "github.com/lib/pq" + "go.unistack.org/micro/v4/logger" + "go.unistack.org/unistack-org/pkgdash/config" + "go.unistack.org/unistack-org/pkgdash/models" ) const ( @@ -31,8 +38,8 @@ func NewStorageFS(fs embed.FS) func(*sql.DB) (interface{}, error) { } func (s *Postgres) MigrateUp() error { - driver, err := pgx.WithInstance(s.db, &pgx.Config{ - MigrationsTable: pgx.DefaultMigrationsTable, + driver, err := mpgx.WithInstance(s.db, &mpgx.Config{ + MigrationsTable: mpgx.DefaultMigrationsTable, DatabaseName: config.ServiceName, }) if err != nil { @@ -57,8 +64,8 @@ func (s *Postgres) MigrateUp() error { } func (s *Postgres) MigrateDown() error { - driver, err := pgx.WithInstance(s.db, &pgx.Config{ - MigrationsTable: pgx.DefaultMigrationsTable, + driver, err := mpgx.WithInstance(s.db, &mpgx.Config{ + MigrationsTable: mpgx.DefaultMigrationsTable, DatabaseName: config.ServiceName, }) if err != nil { @@ -81,3 +88,150 @@ func (s *Postgres) MigrateDown() error { return nil } + +func (s *Postgres) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error { + panic("need implement") +} + +func (s *Postgres) ListPackage(ctx context.Context) (models.ListPackage, error) { + rows, err := s.db.QueryContext(ctx, queryListPackage) + if err != nil { + return nil, err + } + + defer func() { + if err = rows.Close(); err != nil { + return + } + err = rows.Err() + }() + + result := make([]*models.Package, 0) + for rows.Next() { + tmp := &models.Package{} + if err = rows.Scan( + &tmp.ID, + &tmp.Name, + &tmp.URL, + pq.Array(&tmp.Comments), + ); err != nil { + return nil, err + } + } + + return result, err +} + +func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return err + } + + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddComment: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value) + if err != nil { + return err + } + + if aff, affErr := res.RowsAffected(); err != nil { + err = affErr + } else if aff == 0 { + err = errors.New("rows affected is 0") + } + + return err +} + +func (s *Postgres) AddPackage(ctx context.Context, req *pb.AddPackageReq) error { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return err + } + + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddPackage: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules)) + if err != nil { + return err + } + + if aff, affErr := res.RowsAffected(); err != nil { + err = affErr + } else if aff == 0 { + err = errors.New("rows affected is 0") + } + + return err +} + +func (s *Postgres) InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddPackage: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + query := generateQuery(req) + + rows, err := tx.QueryContext(ctx, query) + if err != nil { + return nil, err + } + defer func() { + if err = rows.Close(); err != nil { + return + } + err = rows.Err() + }() + + result := make([]uint64, 0) + for rows.Next() { + tmp := uint64(0) + if err = rows.Scan(&tmp); err != nil { + return nil, err + } + + result = append(result, tmp) + } + + return result, err +} + +func generateQuery(rsp []models.Module) string { + const pattern = `%c('%s', '%s', '%s')` + build := strings.Builder{} + comma := ' ' + for i := range rsp { + str := fmt.Sprintf(pattern, comma, rsp[i].Name, rsp[i].Version, rsp[i].LastVersion) + build.WriteString(str) + comma = ',' + } + + return fmt.Sprintf(queryInsMsgGetIDs, build.String()) +} diff --git a/storage/postgres/storage_test.go b/storage/postgres/storage_test.go new file mode 100644 index 0000000..2fcbd67 --- /dev/null +++ b/storage/postgres/storage_test.go @@ -0,0 +1,37 @@ +package postgres + +import ( + "fmt" + "go.unistack.org/unistack-org/pkgdash/models" + "testing" +) + +func TestGenerate(t *testing.T) { + m := []models.Module{ + { + ID: 1, + Name: "test", + Version: "1.2.3", + Package: 2, + LastVersion: "23.31", + }, + { + ID: 1, + Name: "321test", + Version: "1.3", + Package: 4, + LastVersion: "2111.31", + }, + { + ID: 1, + Name: "testabcd", + Version: "1.2.3", + Package: 2, + LastVersion: "153453.31", + }, + } + + str := generateQuery(m) + + fmt.Println(str) +} diff --git a/storage/sqlite/quries.go b/storage/sqlite/quries.go new file mode 100644 index 0000000..2b6922b --- /dev/null +++ b/storage/sqlite/quries.go @@ -0,0 +1,32 @@ +package sqlite + +const ( + queryListPackage = ` +select + id, + name, + url, + comments + --modules, + --issues, + from package; +` + queryAddComment = ` +insert into comment(text) values ($1) ; +update package +set comments = json_insert(comments, '$[#]', ( select last_insert_rowid() as id from comment )) +where id = $2 ; +` + queryAddPackage = ` +insert into package(name, url, modules) values ($1, $2, $3); +` + queryInsMsgGetIDs = ` +insert into module(name, version, last_version) values +%s +returning id; +` + queryGetModule = ` +select id, name, version, last_version from module +where id in %s ; +` +) diff --git a/storage/sqlite/storage.go b/storage/sqlite/storage.go new file mode 100644 index 0000000..84354aa --- /dev/null +++ b/storage/sqlite/storage.go @@ -0,0 +1,286 @@ +package sqlite + +import ( + "context" + "database/sql" + "embed" + "errors" + "fmt" + "strings" + + "github.com/golang-migrate/migrate/v4" + "github.com/golang-migrate/migrate/v4/database/sqlite" + "github.com/golang-migrate/migrate/v4/source/iofs" + "github.com/lib/pq" + _ "github.com/mattn/go-sqlite3" + "go.unistack.org/micro/v4/logger" + "go.unistack.org/unistack-org/pkgdash/config" + "go.unistack.org/unistack-org/pkgdash/models" + pb "go.unistack.org/unistack-org/pkgdash/proto" +) + +const ( + pathMigration = `migrations/sqlite` +) + +type Sqlite struct { + db *sql.DB + fs embed.FS +} + +func NewStorage(db *sql.DB) (interface{}, error) { + return &Sqlite{db: db}, nil +} + +func NewStorageFS(fs embed.FS) func(*sql.DB) (interface{}, error) { + return func(db *sql.DB) (interface{}, error) { + return &Sqlite{db: db, fs: fs}, nil + } +} + +func (s *Sqlite) MigrateUp() error { + driver, err := sqlite.WithInstance(s.db, &sqlite.Config{ + MigrationsTable: sqlite.DefaultMigrationsTable, + DatabaseName: config.ServiceName, + }) + if err != nil { + return err + } + source, err := iofs.New(s.fs, pathMigration) + if err != nil { + return err + } + + // TODO: pass own logger + m, err := migrate.NewWithInstance("fs", source, config.ServiceName, driver) + if err != nil { + return err + } + + if err = m.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) { + return err + } + + return nil +} + +func (s *Sqlite) MigrateDown() error { + driver, err := sqlite.WithInstance(s.db, &sqlite.Config{ + MigrationsTable: sqlite.DefaultMigrationsTable, + DatabaseName: config.ServiceName, + }) + if err != nil { + return err + } + source, err := iofs.New(s.fs, pathMigration) + if err != nil { + return err + } + + // TODO: pass own logger + m, err := migrate.NewWithInstance("fs", source, config.ServiceName, driver) + if err != nil { + return err + } + + if err = m.Down(); err != nil && !errors.Is(err, migrate.ErrNoChange) { + return err + } + + return nil +} + +func (s *Sqlite) UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error { + panic("need implement") +} + +func (s *Sqlite) ListPackage(ctx context.Context) (models.ListPackage, error) { + rows, err := s.db.QueryContext(ctx, queryListPackage) + if err != nil { + return nil, err + } + + defer func() { + if err = rows.Close(); err != nil { + return + } + err = rows.Err() + }() + + result := make([]*models.Package, 0) + for rows.Next() { + tmp := &models.Package{} + if err = rows.Scan( + &tmp.ID, + &tmp.Name, + &tmp.URL, + pq.Array(&tmp.Comments), + ); err != nil { + return nil, err + } + } + + return result, err +} + +func (s *Sqlite) AddComment(ctx context.Context, req *pb.AddCommentReq) error { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return err + } + + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddComment: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value) + if err != nil { + return err + } + + if aff, affErr := res.RowsAffected(); err != nil { + err = affErr + } else if aff == 0 { + err = errors.New("rows affected is 0") + } + + return err +} + +func (s *Sqlite) AddPackage(ctx context.Context, req *pb.AddPackageReq) error { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return err + } + + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddPackage: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules)) + if err != nil { + return err + } + + if aff, affErr := res.RowsAffected(); err != nil { + err = affErr + } else if aff == 0 { + err = errors.New("rows affected is 0") + } + + return err +} + +func (s *Sqlite) InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + if rollbackErr := tx.Rollback(); rollbackErr != nil { + logger.Errorf(ctx, "AddPackage: unable to rollback: %v", rollbackErr) + } + } else { + err = tx.Commit() + } + }() + + query := generateQuery(req) + + rows, err := tx.QueryContext(ctx, query) + if err != nil { + return nil, err + } + defer func() { + if err = rows.Close(); err != nil { + return + } + err = rows.Err() + }() + + result := make([]uint64, 0) + for rows.Next() { + tmp := uint64(0) + if err = rows.Scan(&tmp); err != nil { + return nil, err + } + + result = append(result, tmp) + } + + return result, err +} + +func (s *Sqlite) GetModule(ctx context.Context, req *pb.GetModuleReq) (result models.ListModule, err error) { + query := "" + if len(req.Id) < 1 { + query = fmt.Sprintf(queryGetModule, "() or 1=1") + } else { + query = fmt.Sprintf(queryGetModule, generateArrayIneq(len(req.Id))) + } + + rows, err := s.db.QueryContext(ctx, query, convertSliceUInt(req.Id...)...) + if err != nil { + return nil, err + } + defer func() { + if err = rows.Close(); err != nil { + return + } + err = rows.Err() + }() + + for rows.Next() { + tmp := &models.Module{} + if err = rows.Scan( + &tmp.ID, + &tmp.Name, + &tmp.Version, + &tmp.LastVersion, + ); err != nil { + return nil, err + } + + result = append(result, tmp) + } + + return result, err +} + +func convertSliceUInt(arg ...uint64) []interface{} { + result := make([]interface{}, 0, len(arg)) + for i := range arg { + result = append(result, arg[i]) + } + return result +} + +func generateQuery(rsp []models.Module) string { + const pattern = `%c('%s', '%s', '%s')` + build := strings.Builder{} + comma := ' ' + for i := range rsp { + str := fmt.Sprintf(pattern, comma, rsp[i].Name, rsp[i].Version, rsp[i].LastVersion) + build.WriteString(str) + comma = ',' + } + + return fmt.Sprintf(queryInsMsgGetIDs, build.String()) +} + +func generateArrayIneq(count int) string { + return "(?" + strings.Repeat(",?", count-1) + ")" +} diff --git a/storage/storage.go b/storage/storage.go index 9328115..70b60c1 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -4,27 +4,33 @@ import ( "context" "database/sql" "embed" - "go.unistack.org/unistack-org/pkgdash/models" - "go.unistack.org/unistack-org/pkgdash/storage/postgres" cmsstorage "go.unistack.org/cms-service/storage" + "go.unistack.org/unistack-org/pkgdash/models" + pb "go.unistack.org/unistack-org/pkgdash/proto" + "go.unistack.org/unistack-org/pkgdash/storage/postgres" + "go.unistack.org/unistack-org/pkgdash/storage/sqlite" ) //go:embed migrations var fs embed.FS -var ( - storages = cmsstorage.NewStorageInterface() -) +var storages = cmsstorage.NewStorageInterface() func init() { storages.RegisterStorage("postgres", postgres.NewStorageFS(fs)) + storages.RegisterStorage("sqlite", sqlite.NewStorageFS(fs)) } type Storage interface { cmsstorage.Migrator - List(ctx context.Context) ([]*models.Package, error) + ListPackage(ctx context.Context) (models.ListPackage, error) + UpdatePackage(ctx context.Context, req *pb.UpdatePackageReq) error + AddComment(ctx context.Context, req *pb.AddCommentReq) error + AddPackage(ctx context.Context, req *pb.AddPackageReq) error + InsertButchModules(ctx context.Context, req []models.Module) ([]uint64, error) + GetModule(ctx context.Context, req *pb.GetModuleReq) (models.ListModule, error) } func NewStorage(name string, db *sql.DB) (interface{}, error) { diff --git a/storage/storage_test.go b/storage/storage_test.go new file mode 100644 index 0000000..2b4769e --- /dev/null +++ b/storage/storage_test.go @@ -0,0 +1,42 @@ +package storage + +import ( + "context" + "database/sql" + "fmt" + pb "go.unistack.org/unistack-org/pkgdash/proto" + "go.unistack.org/unistack-org/pkgdash/storage/sqlite" + "testing" +) + +func TestGetModule(t *testing.T) { + conn, err := sql.Open("sqlite3", "/Users/devstigneev_local/GolandProjects/unistack/pkgdash/identifier.sqlite") + if err != nil { + t.Fatal(err) + } + defer conn.Close() + if err = conn.Ping(); err != nil { + t.Fatal(err) + } + + st, err := sqlite.NewStorage(conn) + if err != nil { + t.Fatal(err) + } + + s, ok := st.(Storage) + if !ok { + t.Fatal("typecast error") + } + + req := &pb.GetModuleReq{ + Id: []uint64{1, 2, 5, 40}, + } + + module, err := s.GetModule(context.Background(), req) + if err != nil { + t.Fatal(err) + } + + fmt.Println(module) +}