From a71dd10757c246349fc81427c0461dc516a0b60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Fri, 22 Jul 2022 11:11:34 -0400 Subject: [PATCH 01/95] Initial commit --- .gitignore | 15 ++++ LICENSE | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 3 files changed, 217 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66fd13c --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..054c90e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# CasaOS-UserService \ No newline at end of file From e2b617e5100cede63e49c51e33dc53e7592abcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Thu, 4 Aug 2022 19:14:53 -0400 Subject: [PATCH 02/95] (#1) - refactored User service from IceWhaleTech/CasaOS as first modularized service --- .gitignore | 5 + Makefile | 31 + README.md | 4 +- build/etc/casaos/user-service.conf | 9 + .../system/casaos-user-service.service | 12 + go.mod | 47 ++ go.sum | 172 +++++ main.go | 86 +++ middleware/gin.go | 61 ++ model/sys_common.go | 19 + model/system_model/verify_information.go | 16 + pkg/config/config.go | 15 + pkg/config/init.go | 52 ++ pkg/sqlite/db.go | 59 ++ pkg/utils/encryption/md5_helper.go | 21 + pkg/utils/file/file.go | 146 ++++ pkg/utils/file/image.go | 182 +++++ pkg/utils/random/random.go | 24 + route/route.go | 64 ++ route/v1/user.go | 679 ++++++++++++++++++ service/model/o_user.go | 30 + service/service.go | 39 + service/user.go | 98 +++ 23 files changed, 1870 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 build/etc/casaos/user-service.conf create mode 100644 build/usr/lib/systemd/system/casaos-user-service.service create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 middleware/gin.go create mode 100644 model/sys_common.go create mode 100644 model/system_model/verify_information.go create mode 100644 pkg/config/config.go create mode 100644 pkg/config/init.go create mode 100644 pkg/sqlite/db.go create mode 100644 pkg/utils/encryption/md5_helper.go create mode 100644 pkg/utils/file/file.go create mode 100644 pkg/utils/file/image.go create mode 100644 pkg/utils/random/random.go create mode 100644 route/route.go create mode 100644 route/v1/user.go create mode 100644 service/model/o_user.go create mode 100644 service/service.go create mode 100644 service/user.go diff --git a/.gitignore b/.gitignore index 66fd13c..b32b330 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# IDE +.vscode/ +target/ +__debug_bin diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3c7f77a --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +APP_NAME = casaos-user-service +APP_NAME_SHORT = user-service + +TARGET_DIR = target +BUILD_DIR = $(TARGET_DIR)/build + +INSTALL_ROOT = / + +all: $(TARGET_DIR) + +$(BUILD_DIR): clean + mkdir -pv $(BUILD_DIR)/usr/bin + +$(APP_NAME): $(BUILD_DIR) + go build -v -o $(BUILD_DIR)/usr/bin/$(APP_NAME) + +$(TARGET_DIR): $(APP_NAME) + cp -rv build $(TARGET_DIR) + +clean: + rm -rfv $(TARGET_DIR) + +install: + cp -rv $(BUILD_DIR)/* $(INSTALL_ROOT) + systemctl enable --now $(APP_NAME).service + +uninstall: + systemctl disable --now $(APP_NAME).service + rm -v $(INSTALL_ROOT)/etc/casaos/$(APP_NAME_SHORT).conf + rm -v $(INSTALL_ROOT)/usr/bin/$(APP_NAME) + rm -v $(INSTALL_ROOT)/usr/lib/systemd/system/$(APP_NAME).service diff --git a/README.md b/README.md index 054c90e..1c61cb4 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# CasaOS-UserService \ No newline at end of file +# CasaOS-UserService + +User Service provides user management functionalities to CasaOS. diff --git a/build/etc/casaos/user-service.conf b/build/etc/casaos/user-service.conf new file mode 100644 index 0000000..a146555 --- /dev/null +++ b/build/etc/casaos/user-service.conf @@ -0,0 +1,9 @@ +[common] +RuntimePath=/var/run/casaos + +[app] +LogPath = /var/log/casaos +LogSaveName = user-service +LogFileExt = log +DBPath = /var/lib/casaos +UserDataPath = /var/lib/casaos diff --git a/build/usr/lib/systemd/system/casaos-user-service.service b/build/usr/lib/systemd/system/casaos-user-service.service new file mode 100644 index 0000000..4a46e82 --- /dev/null +++ b/build/usr/lib/systemd/system/casaos-user-service.service @@ -0,0 +1,12 @@ +[Unit] +After=casaos-gateway.service +ConditionFileNotEmpty=/etc/casaos/user-service.conf +Description=CasaOS User Service + +[Service] +ExecStart=/usr/bin/casaos-user-service -c /etc/casaos/user-service.conf +PIDFile=/var/run/casaos/user-service.pid +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d60fed9 --- /dev/null +++ b/go.mod @@ -0,0 +1,47 @@ +module github.com/IceWhaleTech/CasaOS-UserService + +go 1.18 + +require ( + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc + github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b + github.com/gin-contrib/gzip v0.0.6 + github.com/gin-gonic/gin v1.8.1 + github.com/satori/go.uuid v1.2.0 + github.com/tidwall/gjson v1.14.1 + go.uber.org/zap v1.21.0 + gopkg.in/ini.v1 v1.66.6 + gorm.io/driver/sqlite v1.3.6 + gorm.io/gorm v1.23.8 +) + +require ( + github.com/benbjohnson/clock v1.3.0 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-playground/validator/v10 v10.11.0 // indirect + github.com/goccy/go-json v0.9.10 // indirect + github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-sqlite3 v1.14.14 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/ugorji/go/codec v1.2.7 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.8.0 // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect + golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3cb538d --- /dev/null +++ b/go.sum @@ -0,0 +1,172 @@ +github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc h1:PVQLOa4Ao9vmVDi8bontpDQct81oE4NQJ72XEuo/7PU= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc/go.mod h1:2WIgP2lnFQ/1TfCnXW00JJIKm3coLyV3WqAaTCAYY28= +github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b h1:IiMCqvGelQLGTX151gqVwrzoPQVJy8Q2JAvkhjiQ6tY= +github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b/go.mod h1:jcURlZtPPQJJvfIW4ZgDTtpFfak7bPTvKZUxWxf62M8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= +github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= +github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= +github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc= +github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= +github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= +github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +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.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= +github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= +golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8= +golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= +gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ= +gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMTgE= +gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= +gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= diff --git a/main.go b/main.go new file mode 100644 index 0000000..9680801 --- /dev/null +++ b/main.go @@ -0,0 +1,86 @@ +package main + +import ( + "flag" + "fmt" + "log" + "net" + "net/http" + + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/IceWhaleTech/CasaOS-Gateway/common" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/random" + "github.com/IceWhaleTech/CasaOS-UserService/route" + "github.com/IceWhaleTech/CasaOS-UserService/service" + "gorm.io/gorm" +) + +const localhost = "127.0.0.1" + +var ( + sqliteDB *gorm.DB + configFlag = flag.String("c", "", "config address") + dbFlag = flag.String("db", "", "db path") + resetUser = flag.Bool("ru", false, "reset user") + user = flag.String("user", "", "user name") +) + +func init() { + flag.Parse() + config.InitSetup(*configFlag) + + logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) + + if len(*dbFlag) == 0 { + *dbFlag = config.AppInfo.DBPath + "/db" + } + + sqliteDB = sqlite.GetDb(*dbFlag) + service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath) +} + +func main() { + r := route.InitRouter() + + if *resetUser { + if user == nil || len(*user) == 0 { + fmt.Println("user is empty") + return + } + userData := service.MyService.User().GetUserAllInfoByName(*user) + if userData.Id == 0 { + fmt.Println("user not exist") + return + } + password := random.RandomString(6, false) + userData.Password = encryption.GetMD5ByStr(password) + service.MyService.User().UpdateUserPassword(userData) + fmt.Println("User reset successful") + fmt.Println("UserName:" + userData.Username) + fmt.Println("Password:" + password) + return + } + + listener, err := net.Listen("tcp", net.JoinHostPort(localhost, "0")) + if err != nil { + panic(err) + } + + err = service.MyService.Gateway().CreateRoute(&common.Route{ + Path: "/v1/users", + Target: "http://" + listener.Addr().String(), + }) + + if err != nil { + panic(err) + } + + log.Printf("user service listening on %s", listener.Addr().String()) + err = http.Serve(listener, r) + if err != nil { + panic(err) + } +} diff --git a/middleware/gin.go b/middleware/gin.go new file mode 100644 index 0000000..c273808 --- /dev/null +++ b/middleware/gin.go @@ -0,0 +1,61 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2021-10-08 10:29:08 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-07-22 11:06:07 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package middleware + +import ( + "fmt" + "net/http" + "strings" + + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/gin-gonic/gin" + "go.uber.org/zap" +) + +func Cors() gin.HandlerFunc { + return func(c *gin.Context) { + method := c.Request.Method + + c.Header("Access-Control-Allow-Origin", "*") + c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") + // 允许跨域设置可以返回其他子段,可以自定义字段 + c.Header("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,Language,Content-Type,Access-Control-Allow-Origin,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Connection,Host,Origin,Referer,User-Agent,X-Requested-With") + // 允许浏览器(客户端)可以解析的头部 (重要) + c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers") + // c.Writer.Header().Set("Access-Control-Allow-Headers", "Accept, Authorization, Content-Type, Content-Length, X-CSRF-Token, Token, session, Origin, Host, Connection, Accept-Encoding, Accept-Language, X-Requested-With") + // 设置缓存时间 + c.Header("Access-Control-Max-Age", "172800") + c.Header("Access-Control-Allow-Credentials", "true") + c.Set("Content-Type", "application/json") + //} + + // 允许类型校验 + if method == "OPTIONS" { + c.JSON(http.StatusOK, "ok!") + } + + defer func() { + if err := recover(); err != nil { + fmt.Println(err) + } + }() + + c.Next() + } +} + +func WriteLog() gin.HandlerFunc { + return func(c *gin.Context) { + if !strings.Contains(c.Request.URL.String(), "password") { + logger.Info("request:", zap.Any("path", c.Request.URL.String()), zap.Any("param", c.Params), zap.Any("query", c.Request.URL.Query()), zap.Any("method", c.Request.Method)) + c.Next() + } + } +} diff --git a/model/sys_common.go b/model/sys_common.go new file mode 100644 index 0000000..9d56b36 --- /dev/null +++ b/model/sys_common.go @@ -0,0 +1,19 @@ +package model + +type CommonModel struct { + RuntimePath string +} + +type APPModel struct { + LogPath string + LogSaveName string + LogFileExt string + UserDataPath string + DBPath string +} + +type Result struct { + Success int `json:"success" example:"200"` + Message string `json:"message" example:"ok"` + Data interface{} `json:"data" example:"返回结果"` +} diff --git a/model/system_model/verify_information.go b/model/system_model/verify_information.go new file mode 100644 index 0000000..7404202 --- /dev/null +++ b/model/system_model/verify_information.go @@ -0,0 +1,16 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2022-06-15 11:30:47 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-06-23 18:40:40 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package system_model + +type VerifyInformation struct { + RefreshToken string `json:"refresh_token"` + AccessToken string `json:"access_token"` + ExpiresAt int64 `json:"expires_at"` +} diff --git a/pkg/config/config.go b/pkg/config/config.go new file mode 100644 index 0000000..ed32f4b --- /dev/null +++ b/pkg/config/config.go @@ -0,0 +1,15 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2021-09-30 18:18:14 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-06-21 11:09:30 + * @FilePath: /CasaOS/pkg/config/config.go + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package config + +const ( + USERCONFIGURL = "/etc/casaos/casaos.conf" +) diff --git a/pkg/config/init.go b/pkg/config/init.go new file mode 100644 index 0000000..4045b32 --- /dev/null +++ b/pkg/config/init.go @@ -0,0 +1,52 @@ +package config + +import ( + "fmt" + "log" + "os" + + "github.com/IceWhaleTech/CasaOS-UserService/model" + "gopkg.in/ini.v1" +) + +// models with default values + +var CommonInfo = &model.CommonModel{ + RuntimePath: "/var/run/casaos", +} + +var AppInfo = &model.APPModel{ + DBPath: "/var/lib/casaos", + UserDataPath: "/var/lib/casaos", + LogPath: "/var/log/casaos", + LogSaveName: "user", + LogFileExt: "log", +} + +var Cfg *ini.File + +func InitSetup(config string) { + + var configDir = USERCONFIGURL + if len(config) > 0 { + configDir = config + } + + var err error + + Cfg, err = ini.Load(configDir) + if err != nil { + fmt.Printf("Fail to read file: %v", err) + os.Exit(1) + } + + mapTo("common", CommonInfo) + mapTo("app", AppInfo) +} + +func mapTo(section string, v interface{}) { + err := Cfg.Section(section).MapTo(v) + if err != nil { + log.Fatalf("Cfg.MapTo %s err: %v", section, err) + } +} diff --git a/pkg/sqlite/db.go b/pkg/sqlite/db.go new file mode 100644 index 0000000..114fe46 --- /dev/null +++ b/pkg/sqlite/db.go @@ -0,0 +1,59 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2022-05-13 18:15:46 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-07-11 18:10:53 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package sqlite + +import ( + "time" + + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" + model2 "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "go.uber.org/zap" + "gorm.io/driver/sqlite" + "gorm.io/gorm" +) + +var gdb *gorm.DB + +func GetDb(dbPath string) *gorm.DB { + if gdb != nil { + return gdb + } + // Refer https://github.com/go-sql-driver/mysql#dsn-data-source-name + // dsn := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8mb4&parseTime=True&loc=Local", m.User, m.PWD, m.IP, m.Port, m.DBName) + // db, err := gorm.Open(mysql2.Open(dsn), &gorm.Config{}) + file.IsNotExistMkDir(dbPath) + db, err := gorm.Open(sqlite.Open(dbPath+"/user.db"), &gorm.Config{}) + c, _ := db.DB() + c.SetMaxIdleConns(10) + c.SetMaxOpenConns(100) + c.SetConnMaxIdleTime(time.Second * 1000) + if err != nil { + logger.Error("sqlite connect error", zap.Any("db connect error", err)) + panic("sqlite connect error") + } + gdb = db + + db.Exec(`alter table o_user rename to old_user; + + create table o_users ( id integer primary key,username text,password text,role text,email text,nickname text,avatar text,description text,created_at datetime,updated_at datetime); + + insert into o_users select id,user_name,password,role,email,nick_name,avatar,description,created_at,updated_at from old_user; + + drop table old_user; + drop table o_user; + `) + + err = db.AutoMigrate(model2.UserDBModel{}) + if err != nil { + logger.Error("check or create db error", zap.Any("error", err)) + } + return db +} diff --git a/pkg/utils/encryption/md5_helper.go b/pkg/utils/encryption/md5_helper.go new file mode 100644 index 0000000..1a142e6 --- /dev/null +++ b/pkg/utils/encryption/md5_helper.go @@ -0,0 +1,21 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2022-06-14 14:33:25 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-06-14 14:33:49 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package encryption + +import ( + "crypto/md5" + "encoding/hex" +) + +func GetMD5ByStr(str string) string { + h := md5.New() + h.Write([]byte(str)) + return hex.EncodeToString(h.Sum(nil)) +} diff --git a/pkg/utils/file/file.go b/pkg/utils/file/file.go new file mode 100644 index 0000000..9948a07 --- /dev/null +++ b/pkg/utils/file/file.go @@ -0,0 +1,146 @@ +package file + +import ( + "io" + "io/ioutil" + "os" + "path" + "strings" +) + +// GetExt get the file ext +func GetExt(fileName string) string { + return path.Ext(fileName) +} + +func CheckNotExist(src string) bool { + _, err := os.Stat(src) + + return os.IsNotExist(err) +} + +// IsNotExistMkDir create a directory if it does not exist +func IsNotExistMkDir(src string) error { + if notExist := CheckNotExist(src); notExist { + if err := MkDir(src); err != nil { + return err + } + } + + return nil +} + +// MkDir create a directory +func MkDir(src string) error { + err := os.MkdirAll(src, os.ModePerm) + if err != nil { + return err + } + os.Chmod(src, 0777) + + return nil +} + +// IsNotExistMkDir create a directory if it does not exist +func IsNotExistCreateFile(src string) error { + if notExist := CheckNotExist(src); notExist { + if err := CreateFile(src); err != nil { + return err + } + } + + return nil +} + +func Exists(path string) bool { + _, err := os.Stat(path) //os.Stat获取文件信息 + if err != nil { + return os.IsExist(err) + } + return true +} + +func CreateFile(path string) error { + file, err := os.Create(path) + if err != nil { + return err + } + defer file.Close() + return nil +} + +func ReadFullFile(path string) []byte { + file, err := os.Open(path) + if err != nil { + return []byte("") + } + defer file.Close() + content, err := ioutil.ReadAll(file) + if err != nil { + return []byte("") + } + return content +} + +/** + * @description: + * @param {*} src + * @param {*} dst + * @param {string} style + * @return {*} + * @method: + * @router: + */ +func CopySingleFile(src, dst, style string) error { + var err error + var srcfd *os.File + var dstfd *os.File + var srcinfo os.FileInfo + + if Exists(dst) { + if style == "skip" { + return nil + } else { + os.Remove(dst) + } + } + + if srcfd, err = os.Open(src); err != nil { + return err + } + defer srcfd.Close() + + if dstfd, err = os.Create(dst); err != nil { + return err + } + defer dstfd.Close() + + if _, err = io.Copy(dstfd, srcfd); err != nil { + return err + } + if srcinfo, err = os.Stat(src); err != nil { + return err + } + return os.Chmod(dst, srcinfo.Mode()) +} + +func WriteToPath(data []byte, path, name string) error { + fullPath := path + if strings.HasSuffix(path, "/") { + fullPath += name + } else { + fullPath += "/" + name + } + IsNotExistCreateFile(fullPath) + file, err := os.OpenFile(fullPath, + os.O_WRONLY|os.O_TRUNC|os.O_CREATE, + 0666, + ) + if err != nil { + return err + } + defer file.Close() + _, err = file.Write(data) + + return err +} diff --git a/pkg/utils/file/image.go b/pkg/utils/file/image.go new file mode 100644 index 0000000..105a59e --- /dev/null +++ b/pkg/utils/file/image.go @@ -0,0 +1,182 @@ +package file + +import ( + "errors" + "net/http" + "os" + "path/filepath" + "strings" +) + +func ImageExtArray() []string { + + ext := []string{ + "ase", + "art", + "bmp", + "blp", + "cd5", + "cit", + "cpt", + "cr2", + "cut", + "dds", + "dib", + "djvu", + "egt", + "exif", + "gif", + "gpl", + "grf", + "icns", + "ico", + "iff", + "jng", + "jpeg", + "jpg", + "jfif", + "jp2", + "jps", + "lbm", + "max", + "miff", + "mng", + "msp", + "nitf", + "ota", + "pbm", + "pc1", + "pc2", + "pc3", + "pcf", + "pcx", + "pdn", + "pgm", + "PI1", + "PI2", + "PI3", + "pict", + "pct", + "pnm", + "pns", + "ppm", + "psb", + "psd", + "pdd", + "psp", + "px", + "pxm", + "pxr", + "qfx", + "raw", + "rle", + "sct", + "sgi", + "rgb", + "int", + "bw", + "tga", + "tiff", + "tif", + "vtf", + "xbm", + "xcf", + "xpm", + "3dv", + "amf", + "ai", + "awg", + "cgm", + "cdr", + "cmx", + "dxf", + "e2d", + "egt", + "eps", + "fs", + "gbr", + "odg", + "svg", + "stl", + "vrml", + "x3d", + "sxd", + "v2d", + "vnd", + "wmf", + "emf", + "art", + "xar", + "png", + "webp", + "jxr", + "hdp", + "wdp", + "cur", + "ecw", + "iff", + "lbm", + "liff", + "nrrd", + "pam", + "pcx", + "pgf", + "sgi", + "rgb", + "rgba", + "bw", + "int", + "inta", + "sid", + "ras", + "sun", + "tga", + } + + return ext +} + +/** +* @description:get a image's ext +* @param {string} path "file path" +* @return {string} ext "file ext" +* @return {error} err "error info" + */ +func GetImageExt(p string) (string, error) { + file, err := os.Open(p) + if err != nil { + return "", err + } + + buff := make([]byte, 512) + + _, err = file.Read(buff) + + if err != nil { + return "", err + } + + filetype := http.DetectContentType(buff) + + ext := ImageExtArray() + + for i := 0; i < len(ext); i++ { + if strings.Contains(ext[i], filetype[6:]) { + return ext[i], nil + } + } + + return "", errors.New("invalid image type") +} + +func GetImageExtByName(p string) (string, error) { + + extArr := ImageExtArray() + ext := filepath.Ext(p) + for i := 0; i < len(extArr); i++ { + if strings.Contains(ext, extArr[i]) { + return extArr[i], nil + } + } + return "", errors.New("invalid image type") +} diff --git a/pkg/utils/random/random.go b/pkg/utils/random/random.go new file mode 100644 index 0000000..6909cad --- /dev/null +++ b/pkg/utils/random/random.go @@ -0,0 +1,24 @@ +package random + +import ( + "math/rand" + "time" +) + +func RandomString(n int, onlyLetter bool) string { + + var letters []rune + + if onlyLetter { + letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + } else { + letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + } + + b := make([]rune, n) + rand.Seed(time.Now().UnixNano()) + for i := range b { + b[i] = letters[rand.Intn(len(letters))] + } + return string(b) +} diff --git a/route/route.go b/route/route.go new file mode 100644 index 0000000..a58ed6c --- /dev/null +++ b/route/route.go @@ -0,0 +1,64 @@ +package route + +import ( + "os" + + "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" + "github.com/IceWhaleTech/CasaOS-UserService/middleware" + v1 "github.com/IceWhaleTech/CasaOS-UserService/route/v1" + "github.com/gin-contrib/gzip" + "github.com/gin-gonic/gin" +) + +func InitRouter() *gin.Engine { + r := gin.Default() + r.Use(middleware.Cors()) + r.Use(middleware.WriteLog()) + r.Use(gzip.Gzip(gzip.DefaultCompression)) + + // check if environment variable is set + if ginMode, success := os.LookupEnv("GIN_MODE"); success { + gin.SetMode(ginMode) + } else { + gin.SetMode(gin.ReleaseMode) + } + + r.POST("/v1/users/register", v1.PostUserRegister) + r.POST("/v1/users/login", v1.PostUserLogin) + r.GET("/v1/users/name", v1.GetUserAllUsername) // all/name + r.POST("/v1/users/refresh", v1.PostUserRefreshToken) + // No short-term modifications + r.GET("/v1/users/image", v1.GetUserImage) + + r.GET("/v1/users/status", v1.GetUserStatus) // init/check + + v1Group := r.Group("/v1") + + v1Group.Use(jwt.JWT()) + { + v1UsersGroup := v1Group.Group("/users") + v1UsersGroup.Use() + { + v1UsersGroup.GET("/current", v1.GetUserInfo) + v1UsersGroup.PUT("/current", v1.PutUserInfo) + v1UsersGroup.PUT("/current/password", v1.PutUserPassword) + + v1UsersGroup.GET("/current/custom/:key", v1.GetUserCustomConf) + v1UsersGroup.POST("/current/custom/:key", v1.PostUserCustomConf) + v1UsersGroup.DELETE("/current/custom/:key", v1.DeleteUserCustomConf) + + v1UsersGroup.POST("/current/image/:key", v1.PostUserUploadImage) + v1UsersGroup.PUT("/current/image/:key", v1.PutUserImage) + // v1UserGroup.POST("/file/image/:key", v1.PostUserFileImage) + v1UsersGroup.DELETE("/current/image", v1.DeleteUserImage) + + // v1UserGroup.PUT("/avatar", v1.PutUserAvatar) + // v1UserGroup.GET("/avatar", v1.GetUserAvatar) + v1UsersGroup.DELETE("/:id", v1.DeleteUser) + v1UsersGroup.GET("/:username", v1.GetUserInfoByUsername) + v1UsersGroup.DELETE("", v1.DeleteUserAll) + } + } + + return r +} diff --git a/route/v1/user.go b/route/v1/user.go new file mode 100644 index 0000000..1ab5077 --- /dev/null +++ b/route/v1/user.go @@ -0,0 +1,679 @@ +package v1 + +import ( + json2 "encoding/json" + "io/ioutil" + "net/http" + url2 "net/url" + "os" + "path" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" + "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" + "github.com/IceWhaleTech/CasaOS-UserService/model" + "github.com/IceWhaleTech/CasaOS-UserService/model/system_model" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" + model2 "github.com/IceWhaleTech/CasaOS-UserService/service/model" + uuid "github.com/satori/go.uuid" + "github.com/tidwall/gjson" + + "github.com/IceWhaleTech/CasaOS-UserService/service" + "github.com/gin-gonic/gin" +) + +// @Summary register user +// @Router /user/register/ [post] +func PostUserRegister(c *gin.Context) { + json := make(map[string]string) + c.ShouldBind(&json) + + username := json["username"] + pwd := json["password"] + key := json["key"] + if _, ok := service.UserRegisterHash[key]; !ok { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.KEY_NOT_EXIST, Message: common_err.GetMsg(common_err.KEY_NOT_EXIST)}) + return + } + + if len(username) == 0 || len(pwd) == 0 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + if len(pwd) < 6 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.PWD_IS_TOO_SIMPLE, Message: common_err.GetMsg(common_err.PWD_IS_TOO_SIMPLE)}) + return + } + oldUser := service.MyService.User().GetUserInfoByUserName(username) + if oldUser.Id > 0 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.USER_EXIST, Message: common_err.GetMsg(common_err.USER_EXIST)}) + return + } + + user := model2.UserDBModel{} + user.Username = username + user.Password = encryption.GetMD5ByStr(pwd) + user.Role = "admin" + + user = service.MyService.User().CreateUser(user) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)}) + return + } + file.MkDir(config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id)) + delete(service.UserRegisterHash, key) + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)}) +} + +// @Summary login +// @Produce application/json +// @Accept application/json +// @Tags user +// @Param user_name query string true "User name" +// @Param pwd query string true "password" +// @Success 200 {string} string "ok" +// @Router /user/login [post] +func PostUserLogin(c *gin.Context) { + json := make(map[string]string) + c.ShouldBind(&json) + + username := json["username"] + + password := json["password"] + // check params is empty + if len(username) == 0 || len(password) == 0 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{ + Success: common_err.CLIENT_ERROR, + Message: common_err.GetMsg(common_err.INVALID_PARAMS), + }) + return + } + user := service.MyService.User().GetUserAllInfoByName(username) + if user.Id == 0 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + if user.Password != encryption.GetMD5ByStr(password) { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.PWD_INVALID, Message: common_err.GetMsg(common_err.PWD_INVALID)}) + return + } + token := system_model.VerifyInformation{} + token.AccessToken = jwt.GetAccessToken(user.Username, user.Password, user.Id) + token.RefreshToken = jwt.GetRefreshToken(user.Username, user.Password, user.Id) + token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix() + data := make(map[string]interface{}, 2) + user.Password = "" + data["token"] = token + + // TODO:1 Database fields cannot be external + data["user"] = user + + c.JSON(common_err.SUCCESS, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: data, + }) +} + +// @Summary edit user head +// @Produce application/json +// @Accept multipart/form-data +// @Tags user +// @Param file formData file true "用户头像" +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /user/avatar [put] +func PutUserAvatar(c *gin.Context) { + id := c.GetHeader("user_id") + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + f, err := c.FormFile("file") + if err != nil { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: err.Error()}) + return + } + if len(user.Avatar) > 0 { + os.RemoveAll(config.AppInfo.UserDataPath + "/" + id + "/" + user.Avatar) + } + ext := filepath.Ext(f.Filename) + avatarPath := config.AppInfo.UserDataPath + "/" + id + "/avatar" + ext + c.SaveUploadedFile(f, avatarPath) + user.Avatar = avatarPath + service.MyService.User().UpdateUser(user) + c.JSON(http.StatusOK, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: user, + }) +} + +// @Summary edit user name +// @Produce application/json +// @Accept application/json +// @Tags user +// @Param old_name query string true "Old user name" +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /user/name/:id [put] +func PutUserInfo(c *gin.Context) { + id := c.GetHeader("user_id") + json := model2.UserDBModel{} + c.ShouldBind(&json) + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + if len(json.Username) > 0 { + u := service.MyService.User().GetUserInfoByUserName(json.Username) + if u.Id > 0 { + c.JSON(common_err.CLIENT_ERROR, + model.Result{Success: common_err.USER_EXIST, Message: common_err.GetMsg(common_err.USER_EXIST)}) + return + } + } + + if len(json.Email) == 0 { + json.Email = user.Email + } + if len(json.Avatar) == 0 { + json.Avatar = user.Avatar + } + if len(json.Role) == 0 { + json.Role = user.Role + } + if len(json.Description) == 0 { + json.Description = user.Description + } + if len(json.Nickname) == 0 { + json.Nickname = user.Nickname + } + service.MyService.User().UpdateUser(json) + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json}) +} + +// @Summary edit user password +// @Produce application/json +// @Accept application/json +// @Tags user +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /user/password/:id [put] +func PutUserPassword(c *gin.Context) { + id := c.GetHeader("user_id") + json := make(map[string]string) + c.ShouldBind(&json) + oldPwd := json["old_password"] + pwd := json["password"] + if len(oldPwd) == 0 || len(pwd) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + user := service.MyService.User().GetUserAllInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + if user.Password != encryption.GetMD5ByStr(oldPwd) { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.PWD_INVALID_OLD, Message: common_err.GetMsg(common_err.PWD_INVALID_OLD)}) + return + } + user.Password = encryption.GetMD5ByStr(pwd) + service.MyService.User().UpdateUserPassword(user) + user.Password = "" + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user}) +} + +// @Summary edit user nick +// @Produce application/json +// @Accept application/json +// @Tags user +// @Param nick_name query string false "nick name" +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /user/nick [put] +func PutUserNick(c *gin.Context) { + id := c.GetHeader("user_id") + json := make(map[string]string) + c.ShouldBind(&json) + Nickname := json["nick_name"] + if len(Nickname) == 0 { + c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(http.StatusOK, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + user.Nickname = Nickname + service.MyService.User().UpdateUser(user) + c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user}) +} + +// @Summary edit user description +// @Produce application/json +// @Accept multipart/form-data +// @Tags user +// @Param description formData string false "Description" +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /user/desc [put] +func PutUserDesc(c *gin.Context) { + id := c.GetHeader("user_id") + json := make(map[string]string) + c.ShouldBind(&json) + desc := json["description"] + if len(desc) == 0 { + c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(http.StatusOK, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + user.Description = desc + + service.MyService.User().UpdateUser(user) + + c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user}) +} + +// @Summary get user info +// @Produce application/json +// @Accept application/json +// @Tags user +// @Success 200 {string} string "ok" +// @Router /user/info/:id [get] +func GetUserInfo(c *gin.Context) { + id := c.GetHeader("user_id") + user := service.MyService.User().GetUserInfoById(id) + + c.JSON(common_err.SUCCESS, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: user, + }) +} + +/** + * @description: + * @param {*gin.Context} c + * @param {string} Username + * @return {*} + * @method: + * @router: + */ +func GetUserInfoByUsername(c *gin.Context) { + username := c.Param("username") + if len(username) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + user := service.MyService.User().GetUserInfoByUserName(username) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + + c.JSON(common_err.SUCCESS, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: user, + }) +} + +/** + * @description: get all Usernames + * @method:GET + * @router:/user/all/name + */ +func GetUserAllUsername(c *gin.Context) { + users := service.MyService.User().GetAllUserName() + names := []string{} + for _, v := range users { + names = append(names, v.Username) + } + c.JSON(common_err.SUCCESS, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: names, + }) +} + +/** + * @description:get custom file by user + * @param {path} name string "file name" + * @method: GET + * @router: /user/custom/:key + */ +func GetUserCustomConf(c *gin.Context) { + name := c.Param("key") + if len(name) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + id := c.GetHeader("user_id") + + user := service.MyService.User().GetUserInfoById(id) + // user := service.MyService.User().GetUserInfoByUsername(Username) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + filePath := config.AppInfo.UserDataPath + "/" + id + "/" + name + ".json" + + data := file.ReadFullFile(filePath) + if !gjson.ValidBytes(data) { + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: string(data)}) + return + } + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))}) +} + +/** + * @description:create or update custom conf by user + * @param {path} name string "file name" + * @method:POST + * @router:/user/custom/:key + */ +func PostUserCustomConf(c *gin.Context) { + name := c.Param("key") + if len(name) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + id := c.GetHeader("user_id") + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + data, _ := ioutil.ReadAll(c.Request.Body) + filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + + file.WriteToPath(data, filePath, name+".json") + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))}) +} + +/** + * @description: delete user custom config + * @param {path} key string + * @method:delete + * @router:/user/custom/:key + */ +func DeleteUserCustomConf(c *gin.Context) { + name := c.Param("key") + if len(name) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + id := c.GetHeader("user_id") + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + "/" + name + ".json" + err := os.Remove(filePath) + if err != nil { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)}) + return + } + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)}) +} + +/** + * @description: + * @param {path} id string "user id" + * @method:DELETE + * @router:/user/delete/:id + */ +func DeleteUser(c *gin.Context) { + id := c.Param("id") + service.MyService.User().DeleteUserById(id) + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: id}) +} + +/** + * @description:update user image + * @method:POST + * @router:/user/current/image/:key + */ +func PutUserImage(c *gin.Context) { + id := c.GetHeader("user_id") + json := make(map[string]string) + c.ShouldBind(&json) + + path := json["path"] + key := c.Param("key") + if len(path) == 0 || len(key) == 0 { + c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + if !file.Exists(path) { + c.JSON(http.StatusOK, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)}) + return + } + + _, err := file.GetImageExt(path) + if err != nil { + c.JSON(http.StatusOK, model.Result{Success: common_err.NOT_IMAGE, Message: common_err.GetMsg(common_err.NOT_IMAGE)}) + return + } + + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(http.StatusOK, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + fstat, _ := os.Stat(path) + if fstat.Size() > 10<<20 { + c.JSON(http.StatusOK, model.Result{Success: common_err.IMAGE_TOO_LARGE, Message: common_err.GetMsg(common_err.IMAGE_TOO_LARGE)}) + return + } + ext := file.GetExt(path) + filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + "/" + key + ext + file.CopySingleFile(path, filePath, "overwrite") + + data := make(map[string]string, 3) + data["path"] = filePath + data["file_name"] = key + ext + data["online_path"] = "/v1/users/image?path=" + filePath + c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data}) +} + +/** +* @description: +* @param {*gin.Context} c +* @param {file} file +* @param {string} key +* @param {string} type:avatar,background +* @return {*} +* @method: +* @router: + */ +func PostUserUploadImage(c *gin.Context) { + id := c.GetHeader("user_id") + f, err := c.FormFile("file") + key := c.Param("key") + t := c.PostForm("type") + if len(key) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + if err != nil { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: err.Error()}) + return + } + + _, err = file.GetImageExtByName(f.Filename) + if err != nil { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.NOT_IMAGE, Message: common_err.GetMsg(common_err.NOT_IMAGE)}) + return + } + ext := filepath.Ext(f.Filename) + user := service.MyService.User().GetUserInfoById(id) + + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + if t == "avatar" { + key = "avatar" + } + path := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + "/" + key + ext + + c.SaveUploadedFile(f, path) + data := make(map[string]string, 3) + data["path"] = path + data["file_name"] = key + ext + data["online_path"] = "/v1/users/image?path=" + path + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data}) +} + +/** + * @description: get current user's image + * @method:GET + * @router:/user/image/:id + */ +func GetUserImage(c *gin.Context) { + filePath := c.Query("path") + if len(filePath) == 0 { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + if !file.Exists(filePath) { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)}) + return + } + if !strings.Contains(filePath, config.AppInfo.UserDataPath) { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) + return + } + + fileTmp, _ := os.Open(filePath) + defer fileTmp.Close() + + fileName := path.Base(filePath) + + // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析 + c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(fileName)) + c.File(filePath) +} + +func DeleteUserImage(c *gin.Context) { + id := c.GetHeader("user_id") + path := c.Query("path") + if len(path) == 0 { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + if !file.Exists(path) { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)}) + return + } + if !strings.Contains(path, config.AppInfo.UserDataPath+"/"+strconv.Itoa(user.Id)) { + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) + return + } + os.Remove(path) + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)}) +} + +/** + * @description: + * @param {*gin.Context} c + * @param {string} refresh_token + * @return {*} + * @method: + * @router: + */ +func PostUserRefreshToken(c *gin.Context) { + js := make(map[string]string) + c.ShouldBind(&js) + refresh := js["refresh_token"] + claims, err := jwt.ParseToken(refresh, true) + if err != nil { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE), Data: err.Error()}) + return + } + if !claims.VerifyExpiresAt(time.Now(), true) || !claims.VerifyIssuer("refresh", true) { + c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)}) + return + } + newToken := jwt.GetAccessToken(claims.Username, claims.Password, claims.ID) + verifyInfo := system_model.VerifyInformation{} + verifyInfo.AccessToken = newToken + verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.Username, claims.Password, claims.ID) + verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix() + + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo}) +} + +func DeleteUserAll(c *gin.Context) { + service.MyService.User().DeleteAllUser() + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)}) +} + +// @Summary 检查是否进入引导状态 +// @Produce application/json +// @Accept application/json +// @Tags sys +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /sys/init/check [get] +func GetUserStatus(c *gin.Context) { + data := make(map[string]interface{}, 2) + + if service.MyService.User().GetUserCount() > 0 { + data["initialized"] = true + data["key"] = "" + } else { + key := uuid.NewV4().String() + service.UserRegisterHash[key] = key + data["key"] = key + data["initialized"] = false + } + c.JSON(common_err.SUCCESS, + model.Result{ + Success: common_err.SUCCESS, + Message: common_err.GetMsg(common_err.SUCCESS), + Data: data, + }) +} diff --git a/service/model/o_user.go b/service/model/o_user.go new file mode 100644 index 0000000..34b080b --- /dev/null +++ b/service/model/o_user.go @@ -0,0 +1,30 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2022-05-13 18:15:46 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-07-11 17:57:00 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package model + +import "time" + +//Soon to be removed +type UserDBModel struct { + Id int `gorm:"column:id;primary_key" json:"id"` + Username string `json:"username"` + Password string `json:"password,omitempty"` + Role string `json:"role"` + Email string `json:"email"` + Nickname string `json:"nickname"` + Avatar string `json:"avatar"` + Description string `json:"description"` + CreatedAt time.Time `gorm:"<-:create;autoCreateTime" json:"created_at,omitempty"` + UpdatedAt time.Time `gorm:"<-:create;<-:update;autoUpdateTime" json:"updated_at,omitempty"` +} + +func (p *UserDBModel) TableName() string { + return "o_users" +} diff --git a/service/service.go b/service/service.go new file mode 100644 index 0000000..8d7f9db --- /dev/null +++ b/service/service.go @@ -0,0 +1,39 @@ +package service + +import ( + gateway "github.com/IceWhaleTech/CasaOS-Gateway/common" + "gorm.io/gorm" +) + +var MyService Repository + +type Repository interface { + Gateway() gateway.ManagementService + User() UserService +} + +func NewService(db *gorm.DB, RuntimePath string) Repository { + + gatewayManagement, err := gateway.NewManagementService(RuntimePath) + if err != nil { + panic(err) + } + + return &store{ + gateway: gatewayManagement, + user: NewUserService(db), + } +} + +type store struct { + gateway gateway.ManagementService + user UserService +} + +func (c *store) Gateway() gateway.ManagementService { + return c.gateway +} + +func (c *store) User() UserService { + return c.user +} diff --git a/service/user.go b/service/user.go new file mode 100644 index 0000000..21d9148 --- /dev/null +++ b/service/user.go @@ -0,0 +1,98 @@ +/* + * @Author: LinkLeong link@icewhale.com + * @Date: 2022-03-18 11:40:55 + * @LastEditors: LinkLeong + * @LastEditTime: 2022-07-12 10:05:37 + * @Description: + * @Website: https://www.casaos.io + * Copyright (c) 2022 by icewhale, All Rights Reserved. + */ +package service + +import ( + "io" + "mime/multipart" + "os" + + "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "gorm.io/gorm" +) + +type UserService interface { + UpLoadFile(file multipart.File, name string) error + CreateUser(m model.UserDBModel) model.UserDBModel + GetUserCount() (userCount int64) + UpdateUser(m model.UserDBModel) + UpdateUserPassword(m model.UserDBModel) + GetUserInfoById(id string) (m model.UserDBModel) + GetUserAllInfoById(id string) (m model.UserDBModel) + GetUserAllInfoByName(userName string) (m model.UserDBModel) + DeleteUserById(id string) + DeleteAllUser() + GetUserInfoByUserName(userName string) (m model.UserDBModel) + GetAllUserName() (list []model.UserDBModel) +} + +var UserRegisterHash = make(map[string]string) + +type userService struct { + db *gorm.DB +} + +func (u *userService) DeleteAllUser() { + u.db.Where("1=1").Delete(&model.UserDBModel{}) +} +func (u *userService) DeleteUserById(id string) { + u.db.Where("id= ?", id).Delete(&model.UserDBModel{}) +} + +func (u *userService) GetAllUserName() (list []model.UserDBModel) { + u.db.Select("username").Find(&list) + return +} +func (u *userService) CreateUser(m model.UserDBModel) model.UserDBModel { + u.db.Create(&m) + return m +} + +func (u *userService) GetUserCount() (userCount int64) { + u.db.Find(&model.UserDBModel{}).Count(&userCount) + return +} + +func (u *userService) UpdateUser(m model.UserDBModel) { + u.db.Model(&m).Omit("password").Updates(&m) +} +func (u *userService) UpdateUserPassword(m model.UserDBModel) { + u.db.Model(&m).Update("password", m.Password) +} +func (u *userService) GetUserAllInfoById(id string) (m model.UserDBModel) { + u.db.Where("id= ?", id).First(&m) + return +} +func (u *userService) GetUserAllInfoByName(userName string) (m model.UserDBModel) { + u.db.Where("username= ?", userName).First(&m) + return +} +func (u *userService) GetUserInfoById(id string) (m model.UserDBModel) { + u.db.Select("username", "id", "role", "nickname", "description", "avatar", "email").Where("id= ?", id).First(&m) + return +} + +func (u *userService) GetUserInfoByUserName(userName string) (m model.UserDBModel) { + u.db.Select("username", "id", "role", "nickname", "description", "avatar", "email").Where("username= ?", userName).First(&m) + return +} + +//上传文件 +func (c *userService) UpLoadFile(file multipart.File, url string) error { + out, _ := os.OpenFile(url, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + defer out.Close() + io.Copy(out, file) + return nil +} + +//获取用户Service +func NewUserService(db *gorm.DB) UserService { + return &userService{db: db} +} From 7792496f2d32f26a57a9edc3366e9f534592412b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Sat, 6 Aug 2022 22:52:14 -0400 Subject: [PATCH 03/95] (#2) - added workflow for releasing --- .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yaml | 43 +++++++++++++++++++++++++++++++++ main.go | 45 +++++++++++++++++++++-------------- 4 files changed, 112 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9b14c37 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: goreleaser + +on: + push: + branches: + - main + tags: + - v*.*.* + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Fetch all tags + run: git fetch --force --tags + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} diff --git a/.gitignore b/.gitignore index b32b330..5ab2489 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ # IDE .vscode/ target/ +dist/ __debug_bin diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..8a57e2b --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,43 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +project_name: casaos-user-service +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy +builds: + - binary: build/usr/bin/casaos-user-service + env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + - arm + goarm: + - 7 +archives: + - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}" + replacements: + arm: arm-7 + files: + - build/**/* +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-snapshot" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +release: + github: + owner: IceWhaleTech + name: CasaOS-UserService + draft: true + prerelease: auto + mode: replace + name_template: "v{{ .Version }}" diff --git a/main.go b/main.go index 9680801..5a681bf 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "os" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-Gateway/common" @@ -15,21 +16,27 @@ import ( "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/random" "github.com/IceWhaleTech/CasaOS-UserService/route" "github.com/IceWhaleTech/CasaOS-UserService/service" - "gorm.io/gorm" ) -const localhost = "127.0.0.1" - -var ( - sqliteDB *gorm.DB - configFlag = flag.String("c", "", "config address") - dbFlag = flag.String("db", "", "db path") - resetUser = flag.Bool("ru", false, "reset user") - user = flag.String("user", "", "user name") +const ( + version = "0.3.5" + localhost = "127.0.0.1" ) func init() { + configFlag := flag.String("c", "", "config address") + dbFlag := flag.String("db", "", "db path") + resetUserFlag := flag.Bool("ru", false, "reset user") + userFlag := flag.String("user", "", "user name") + versionFlag := flag.Bool("v", false, "version") + flag.Parse() + + if *versionFlag { + fmt.Println(version) + os.Exit(0) + } + config.InitSetup(*configFlag) logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) @@ -38,31 +45,33 @@ func init() { *dbFlag = config.AppInfo.DBPath + "/db" } - sqliteDB = sqlite.GetDb(*dbFlag) + sqliteDB := sqlite.GetDb(*dbFlag) service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath) -} -func main() { - r := route.InitRouter() - - if *resetUser { - if user == nil || len(*user) == 0 { + if *resetUserFlag { + if userFlag == nil || len(*userFlag) == 0 { fmt.Println("user is empty") return } - userData := service.MyService.User().GetUserAllInfoByName(*user) + + userData := service.MyService.User().GetUserAllInfoByName(*userFlag) + if userData.Id == 0 { fmt.Println("user not exist") return } + password := random.RandomString(6, false) userData.Password = encryption.GetMD5ByStr(password) service.MyService.User().UpdateUserPassword(userData) fmt.Println("User reset successful") fmt.Println("UserName:" + userData.Username) fmt.Println("Password:" + password) - return } +} + +func main() { + r := route.InitRouter() listener, err := net.Listen("tcp", net.JoinHostPort(localhost, "0")) if err != nil { From 1d1a15a2217b4016806909e23371be60f7a94c9e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 7 Aug 2022 02:54:31 +0000 Subject: [PATCH 04/95] updated README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1c61cb4..c2c7dfd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # CasaOS-UserService +[![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) + User Service provides user management functionalities to CasaOS. From fe354dfa7f9b2dcfea53ea587c1c4eb17b7a1e2f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 7 Aug 2022 02:58:00 +0000 Subject: [PATCH 05/95] removed branch trigger from GitHub workflow --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b14c37..8b1f8f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,8 +2,6 @@ name: goreleaser on: push: - branches: - - main tags: - v*.*.* From c1272b4b30adf6d44aac0deafbeb015a1ea2057d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 7 Aug 2022 03:16:12 +0000 Subject: [PATCH 06/95] fixed goreleaser badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2c7dfd..adf413c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CasaOS-UserService -[![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) +[![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) User Service provides user management functionalities to CasaOS. From 52d38428b6b89bb89a7d33eff5c3a42a3d37f463 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 8 Aug 2022 16:46:43 +0000 Subject: [PATCH 07/95] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index adf413c..0c8a9e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CasaOS-UserService -[![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/IceWhaleTech/CasaOS-UserService.svg)](https://pkg.go.dev/github.com/IceWhaleTech/CasaOS-UserService) [![Go Report Card](https://goreportcard.com/badge/github.com/IceWhaleTech/CasaOS-UserService)](https://goreportcard.com/report/github.com/IceWhaleTech/CasaOS-UserService) [![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) User Service provides user management functionalities to CasaOS. From 0b66fd838f9aafb1f2a983fc8ef31ab423dca88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Fri, 12 Aug 2022 00:07:50 -0400 Subject: [PATCH 08/95] add migration from versions 0.3.3, 0.3.4, 0.3.5 (#3) --- .github/workflows/release.yml | 8 ++ .goreleaser.yaml | 71 +++++++++++++- ...-service.conf => user-service.conf.sample} | 0 .../script.d/01-migrate-user-service.sh | 9 ++ .../service.d/user-service/from-0.2.sh | 0 .../service.d/user-service/from-0.3.4.sh | 1 + .../service.d/user-service/from-0.3.sh | 0 .../setup/script.d/01-setup-user-service.sh | 4 + .../debian/bullseye/setup-user-service.sh | 1 + .../user-service/debian/setup-user-service.sh | 0 .../ubuntu/jammy/setup-user-service.sh | 1 + .../user-service/ubuntu/setup-user-service.sh | 1 + cmd/migration-tool/log.go | 37 +++++++ cmd/migration-tool/main.go | 90 +++++++++++++++++ cmd/migration-tool/migration-033-034-035.go | 97 +++++++++++++++++++ common/version.go | 3 + go.mod | 6 +- go.sum | 12 ++- pkg/config/config.go | 12 +-- pkg/config/init.go | 29 +++++- 20 files changed, 358 insertions(+), 24 deletions(-) rename build/etc/casaos/{user-service.conf => user-service.conf.sample} (100%) create mode 100644 build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh create mode 100644 build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh create mode 120000 build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh create mode 100644 build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh create mode 100644 build/usr/share/casaos/setup/script.d/01-setup-user-service.sh create mode 120000 build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh create mode 100644 build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh create mode 120000 build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh create mode 120000 build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh create mode 100644 cmd/migration-tool/log.go create mode 100644 cmd/migration-tool/main.go create mode 100644 cmd/migration-tool/migration-033-034-035.go create mode 100644 common/version.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b1f8f7..34cfef9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,14 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: + - + name: Install dependencies for cross-compiling + run: | + sudo apt update + sudo apt-get --no-install-recommends --yes install \ + libc6-dev-amd64-cross \ + gcc-10-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-10-arm-linux-gnueabihf libc6-dev-armhf-cross - name: Checkout uses: actions/checkout@v2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8a57e2b..67768d0 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,19 +6,84 @@ before: # You may remove this if you don't use go modules. - go mod tidy builds: - - binary: build/usr/bin/casaos-user-service + - id: casaos-user-service-amd64 + binary: build/usr/bin/casaos-user-service env: - - CGO_ENABLED=0 + - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc-10 goos: - linux goarch: - amd64 + - id: casaos-user-service-arm64 + binary: build/usr/bin/casaos-user-service + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc-10 + goos: + - linux + goarch: - arm64 + - id: casaos-user-service-arm-7 + binary: build/usr/bin/casaos-user-service + env: + - CGO_ENABLED=1 + - CC=arm-linux-gnueabihf-gcc-10 + goos: + - linux + goarch: + - arm + goarm: + - 7 + - id: casaos-user-service-migration-tool-amd64 + binary: build/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc-10 + goos: + - linux + goarch: + - amd64 + - id: casaos-user-service-migration-tool-arm64 + binary: build/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CGO_ENABLED=1 + - CC=aarch64-linux-gnu-gcc-10 + goos: + - linux + goarch: + - arm64 + - id: casaos-user-service-migration-tool-arm-7 + binary: build/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CGO_ENABLED=1 + - CC=arm-linux-gnueabihf-gcc-10 + goos: + - linux + goarch: - arm goarm: - 7 archives: - - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}" + - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-v{{ .Version }}" + id: casaos-user-service + builds: + - casaos-user-service-amd64 + - casaos-user-service-arm64 + - casaos-user-service-arm-7 + replacements: + arm: arm-7 + files: + - build/**/* + - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-migration-tool-v{{ .Version }}" + id: casaos-user-service-migration-tool + builds: + - casaos-user-service-migration-tool-amd64 + - casaos-user-service-migration-tool-arm64 + - casaos-user-service-migration-tool-arm-7 replacements: arm: arm-7 files: diff --git a/build/etc/casaos/user-service.conf b/build/etc/casaos/user-service.conf.sample similarity index 100% rename from build/etc/casaos/user-service.conf rename to build/etc/casaos/user-service.conf.sample diff --git a/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh b/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh new file mode 100644 index 0000000..0f61faa --- /dev/null +++ b/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +__get_existing_version() { + local version + + echo "$version" +} \ No newline at end of file diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh new file mode 100644 index 0000000..e69de29 diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh new file mode 120000 index 0000000..2c3a78b --- /dev/null +++ b/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh @@ -0,0 +1 @@ +from-0.3.sh \ No newline at end of file diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh new file mode 100644 index 0000000..e69de29 diff --git a/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh b/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh new file mode 100644 index 0000000..94ef7de --- /dev/null +++ b/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -e + diff --git a/build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh b/build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh new file mode 120000 index 0000000..d1f69f2 --- /dev/null +++ b/build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh @@ -0,0 +1 @@ +../setup-user-service.sh \ No newline at end of file diff --git a/build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh b/build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh new file mode 100644 index 0000000..e69de29 diff --git a/build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh b/build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh new file mode 120000 index 0000000..d1f69f2 --- /dev/null +++ b/build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh @@ -0,0 +1 @@ +../setup-user-service.sh \ No newline at end of file diff --git a/build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh b/build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh new file mode 120000 index 0000000..79d764b --- /dev/null +++ b/build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh @@ -0,0 +1 @@ +../debian/setup-user-service.sh \ No newline at end of file diff --git a/cmd/migration-tool/log.go b/cmd/migration-tool/log.go new file mode 100644 index 0000000..ed69983 --- /dev/null +++ b/cmd/migration-tool/log.go @@ -0,0 +1,37 @@ +package main + +import ( + "log" + "os" +) + +type Logger struct { + DebugMode bool + + _debug *log.Logger + _info *log.Logger + _error *log.Logger +} + +func NewLogger() *Logger { + return &Logger{ + DebugMode: false, + _debug: log.New(os.Stdout, "DEBUG: ", 0), + _info: log.New(os.Stdout, "", 0), + _error: log.New(os.Stderr, "ERROR: ", 0), + } +} + +func (l *Logger) Debug(format string, v ...interface{}) { + if l.DebugMode { + l._debug.Printf(format, v...) + } +} + +func (l *Logger) Info(format string, v ...interface{}) { + l._info.Printf(format, v...) +} + +func (l *Logger) Error(format string, v ...interface{}) { + l._error.Printf(format, v...) +} diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go new file mode 100644 index 0000000..62bcb30 --- /dev/null +++ b/cmd/migration-tool/main.go @@ -0,0 +1,90 @@ +package main + +import ( + "flag" + "fmt" + "os" + + interfaces "github.com/IceWhaleTech/CasaOS-Common" + "github.com/IceWhaleTech/CasaOS-Common/utils/systemctl" + "github.com/IceWhaleTech/CasaOS-UserService/common" +) + +const ( + userServiceConfigSampleFilePath = "/etc/casaos/user-service.conf.sample" + userServiceName = "casaos-user-service.service" +) + +var _logger *Logger + +func main() { + versionFlag := flag.Bool("v", false, "version") + debugFlag := flag.Bool("d", true, "debug") + forceFlag := flag.Bool("f", false, "force") + flag.Parse() + + if *versionFlag { + fmt.Println(common.Version) + os.Exit(0) + } + + _logger = NewLogger() + + if os.Getuid() != 0 { + _logger.Info("Root privileges are required to run this program.") + os.Exit(1) + } + + if *debugFlag { + _logger.DebugMode = true + } + + if !*forceFlag { + serviceEnabled, err := systemctl.IsServiceEnabled(userServiceName) + if err != nil { + _logger.Error("Failed to check if %s is enabled", userServiceName) + panic(err) + } + + if serviceEnabled { + _logger.Info("%s is already enabled. If migration is still needed, try with -f.", userServiceName) + os.Exit(1) + } + } + + migrationTools := []interfaces.MigrationTool{ + NewMigrationToolFor033_034_035(), + } + + var selectedMigrationTool interfaces.MigrationTool + + // look for the right migration tool matching current version + for _, tool := range migrationTools { + migrationNeeded, err := tool.IsMigrationNeeded() + if err != nil { + panic(err) + } + + if migrationNeeded { + selectedMigrationTool = tool + break + } + } + + if selectedMigrationTool == nil { + _logger.Info("No migration to proceed.") + return + } + + if err := selectedMigrationTool.PreMigrate(); err != nil { + panic(err) + } + + if err := selectedMigrationTool.Migrate(); err != nil { + panic(err) + } + + if err := selectedMigrationTool.PostMigrate(); err != nil { + panic(err) + } +} diff --git a/cmd/migration-tool/migration-033-034-035.go b/cmd/migration-tool/migration-033-034-035.go new file mode 100644 index 0000000..bcec2a5 --- /dev/null +++ b/cmd/migration-tool/migration-033-034-035.go @@ -0,0 +1,97 @@ +package main + +import ( + interfaces "github.com/IceWhaleTech/CasaOS-Common" + "github.com/IceWhaleTech/CasaOS-Common/utils/version" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" + "gopkg.in/ini.v1" +) + +type migrationTool struct{} + +func (u *migrationTool) IsMigrationNeeded() (bool, error) { + _logger.Info("Checking if migration is needed for CasaoS version between 0.3.3 and 0.3.5...") + + minorVersion, err := version.DetectMinorVersion() + if err != nil { + return false, err + } + + if minorVersion != 3 { + return false, nil + } + + // this is the best way to tell if CasaOS version is between 0.3.3 and 0.3.5 + isUserDataInDatabase, err := version.IsUserDataInDatabase() + if err != nil { + return false, err + } + + if !isUserDataInDatabase { + return false, nil + } + + return true, nil +} + +func (u *migrationTool) PreMigrate() error { + _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) + if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { + return err + } + return nil +} + +func (u *migrationTool) Migrate() error { + _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + // LogPath + logPath, err := legacyConfigFile.Section("app").GetKey("LogPath") + if err != nil { + return err + } + + // LogFileExt + logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt") + if err != nil { + return err + } + + // DBPath + dbPath, err := legacyConfigFile.Section("app").GetKey("DBPath") + if err != nil { + return err + } + + // UserDataPath + userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath") + if err != nil { + return err + } + + _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) + config.InitSetup(config.UserServiceConfigFilePath) + + config.AppInfo.LogPath = logPath.Value() + config.AppInfo.LogSaveName = logSaveName.Value() + config.AppInfo.LogFileExt = logFileExt.Value() + config.AppInfo.DBPath = dbPath.Value() + config.AppInfo.UserDataPath = userDataPath.Value() + + config.SaveSetup(config.UserServiceConfigFilePath) + + return nil +} + +func (u *migrationTool) PostMigrate() error { + return nil +} + +func NewMigrationToolFor033_034_035() interfaces.MigrationTool { + return &migrationTool{} +} diff --git a/common/version.go b/common/version.go new file mode 100644 index 0000000..f3f9408 --- /dev/null +++ b/common/version.go @@ -0,0 +1,3 @@ +package common + +const Version = "0.3.5" diff --git a/go.mod b/go.mod index d60fed9..291de40 100644 --- a/go.mod +++ b/go.mod @@ -3,25 +3,27 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.18 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426 github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.1 go.uber.org/zap v1.21.0 - gopkg.in/ini.v1 v1.66.6 + gopkg.in/ini.v1 v1.67.0 gorm.io/driver/sqlite v1.3.6 gorm.io/gorm v1.23.8 ) require ( github.com/benbjohnson/clock v1.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.0 // indirect github.com/goccy/go-json v0.9.10 // indirect + github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect diff --git a/go.sum b/go.sum index 3cb538d..3701484 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,13 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc h1:PVQLOa4Ao9vmVDi8bontpDQct81oE4NQJ72XEuo/7PU= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220804224534-081d69c201cc/go.mod h1:2WIgP2lnFQ/1TfCnXW00JJIKm3coLyV3WqAaTCAYY28= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426 h1:+Yc9qJ6AehudNsIRkoyTe8dmHiHDWsPF/QL7qk8Va6o= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b h1:IiMCqvGelQLGTX151gqVwrzoPQVJy8Q2JAvkhjiQ6tY= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b/go.mod h1:jcURlZtPPQJJvfIW4ZgDTtpFfak7bPTvKZUxWxf62M8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -28,6 +30,8 @@ github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4 github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc= github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -154,8 +158,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= -gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/config/config.go b/pkg/config/config.go index ed32f4b..70fbbe2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,15 +1,5 @@ -/* - * @Author: LinkLeong link@icewhale.com - * @Date: 2021-09-30 18:18:14 - * @LastEditors: LinkLeong - * @LastEditTime: 2022-06-21 11:09:30 - * @FilePath: /CasaOS/pkg/config/config.go - * @Description: - * @Website: https://www.casaos.io - * Copyright (c) 2022 by icewhale, All Rights Reserved. - */ package config const ( - USERCONFIGURL = "/etc/casaos/casaos.conf" + UserServiceConfigFilePath = "/etc/casaos/user-service.conf" ) diff --git a/pkg/config/init.go b/pkg/config/init.go index 4045b32..38d9f56 100644 --- a/pkg/config/init.go +++ b/pkg/config/init.go @@ -26,15 +26,14 @@ var AppInfo = &model.APPModel{ var Cfg *ini.File func InitSetup(config string) { - - var configDir = USERCONFIGURL + configFilePath := UserServiceConfigFilePath if len(config) > 0 { - configDir = config + configFilePath = config } var err error - Cfg, err = ini.Load(configDir) + Cfg, err = ini.Load(configFilePath) if err != nil { fmt.Printf("Fail to read file: %v", err) os.Exit(1) @@ -44,9 +43,31 @@ func InitSetup(config string) { mapTo("app", AppInfo) } +func SaveSetup(config string) { + reflectFrom("common", CommonInfo) + reflectFrom("app", AppInfo) + + configFilePath := UserServiceConfigFilePath + if len(config) > 0 { + configFilePath = config + } + + if err := Cfg.SaveTo(configFilePath); err != nil { + fmt.Printf("Fail to save file: %v", err) + os.Exit(1) + } +} + func mapTo(section string, v interface{}) { err := Cfg.Section(section).MapTo(v) if err != nil { log.Fatalf("Cfg.MapTo %s err: %v", section, err) } } + +func reflectFrom(section string, v interface{}) { + err := Cfg.Section(section).ReflectFrom(v) + if err != nil { + log.Fatalf("Cfg.ReflectFrom %s err: %v", section, err) + } +} From 2493e91ce86f9b15aeea0fdeffcb621294b90a42 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 12 Aug 2022 04:18:09 +0000 Subject: [PATCH 09/95] build fix --- cmd/migration-tool/migration-033-034-035.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/migration-tool/migration-033-034-035.go b/cmd/migration-tool/migration-033-034-035.go index bcec2a5..e7c83df 100644 --- a/cmd/migration-tool/migration-033-034-035.go +++ b/cmd/migration-tool/migration-033-034-035.go @@ -78,7 +78,6 @@ func (u *migrationTool) Migrate() error { config.InitSetup(config.UserServiceConfigFilePath) config.AppInfo.LogPath = logPath.Value() - config.AppInfo.LogSaveName = logSaveName.Value() config.AppInfo.LogFileExt = logFileExt.Value() config.AppInfo.DBPath = dbPath.Value() config.AppInfo.UserDataPath = userDataPath.Value() From 8b2af35f395fecac98ef6f9fe9d4a5c2ffd7e19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Mon, 15 Aug 2022 18:58:08 -0400 Subject: [PATCH 10/95] add incrementation migration logic (#4) --- .github/workflows/release.yml | 6 +- .goreleaser.yaml | 26 ++-- Makefile | 31 ---- .../script.d/02-migrate-user-service.sh | 138 ++++++++++++++++++ .../service.d/user-service/migration.list | 2 + .../setup/script.d/02-setup-user-service.sh | 54 +++++++ .../debian/bullseye/setup-user-service.sh | 0 .../user-service/debian/setup-user-service.sh | 25 ++++ .../ubuntu/jammy/setup-user-service.sh | 0 .../user-service/ubuntu/setup-user-service.sh | 0 .../etc/casaos/user-service.conf.sample | 0 .../system/casaos-user-service.service | 0 .../script.d/01-migrate-user-service.sh | 9 -- .../service.d/user-service/from-0.2.sh | 0 .../service.d/user-service/from-0.3.4.sh | 1 - .../service.d/user-service/from-0.3.sh | 0 .../setup/script.d/01-setup-user-service.sh | 4 - .../user-service/debian/setup-user-service.sh | 0 18 files changed, 235 insertions(+), 61 deletions(-) delete mode 100644 Makefile create mode 100644 build/scripts/migration/script.d/02-migrate-user-service.sh create mode 100644 build/scripts/migration/service.d/user-service/migration.list create mode 100755 build/scripts/setup/script.d/02-setup-user-service.sh rename build/{usr/share/casaos => scripts}/setup/service.d/user-service/debian/bullseye/setup-user-service.sh (100%) create mode 100644 build/scripts/setup/service.d/user-service/debian/setup-user-service.sh rename build/{usr/share/casaos => scripts}/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh (100%) rename build/{usr/share/casaos => scripts}/setup/service.d/user-service/ubuntu/setup-user-service.sh (100%) rename build/{ => sysroot}/etc/casaos/user-service.conf.sample (100%) rename build/{ => sysroot}/usr/lib/systemd/system/casaos-user-service.service (100%) delete mode 100644 build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh delete mode 100644 build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh delete mode 120000 build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh delete mode 100644 build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh delete mode 100644 build/usr/share/casaos/setup/script.d/01-setup-user-service.sh delete mode 100644 build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34cfef9..32d0e66 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ permissions: jobs: goreleaser: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Install dependencies for cross-compiling @@ -18,8 +18,8 @@ jobs: sudo apt update sudo apt-get --no-install-recommends --yes install \ libc6-dev-amd64-cross \ - gcc-10-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-10-arm-linux-gnueabihf libc6-dev-armhf-cross + gcc-11-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-11-arm-linux-gnueabihf libc6-dev-armhf-cross - name: Checkout uses: actions/checkout@v2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 67768d0..d742a3b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -7,28 +7,28 @@ before: - go mod tidy builds: - id: casaos-user-service-amd64 - binary: build/usr/bin/casaos-user-service + binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-10 + - CC=x86_64-linux-gnu-gcc-11 goos: - linux goarch: - amd64 - id: casaos-user-service-arm64 - binary: build/usr/bin/casaos-user-service + binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-10 + - CC=aarch64-linux-gnu-gcc-11 goos: - linux goarch: - arm64 - id: casaos-user-service-arm-7 - binary: build/usr/bin/casaos-user-service + binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-10 + - CC=arm-linux-gnueabihf-gcc-11 goos: - linux goarch: @@ -36,31 +36,31 @@ builds: goarm: - 7 - id: casaos-user-service-migration-tool-amd64 - binary: build/usr/bin/casaos-user-service-migration-tool + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-10 + - CC=x86_64-linux-gnu-gcc-11 goos: - linux goarch: - amd64 - id: casaos-user-service-migration-tool-arm64 - binary: build/usr/bin/casaos-user-service-migration-tool + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-10 + - CC=aarch64-linux-gnu-gcc-11 goos: - linux goarch: - arm64 - id: casaos-user-service-migration-tool-arm-7 - binary: build/usr/bin/casaos-user-service-migration-tool + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-10 + - CC=arm-linux-gnueabihf-gcc-11 goos: - linux goarch: @@ -87,7 +87,7 @@ archives: replacements: arm: arm-7 files: - - build/**/* + - build/sysroot/etc/**/* checksum: name_template: 'checksums.txt' snapshot: diff --git a/Makefile b/Makefile deleted file mode 100644 index 3c7f77a..0000000 --- a/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -APP_NAME = casaos-user-service -APP_NAME_SHORT = user-service - -TARGET_DIR = target -BUILD_DIR = $(TARGET_DIR)/build - -INSTALL_ROOT = / - -all: $(TARGET_DIR) - -$(BUILD_DIR): clean - mkdir -pv $(BUILD_DIR)/usr/bin - -$(APP_NAME): $(BUILD_DIR) - go build -v -o $(BUILD_DIR)/usr/bin/$(APP_NAME) - -$(TARGET_DIR): $(APP_NAME) - cp -rv build $(TARGET_DIR) - -clean: - rm -rfv $(TARGET_DIR) - -install: - cp -rv $(BUILD_DIR)/* $(INSTALL_ROOT) - systemctl enable --now $(APP_NAME).service - -uninstall: - systemctl disable --now $(APP_NAME).service - rm -v $(INSTALL_ROOT)/etc/casaos/$(APP_NAME_SHORT).conf - rm -v $(INSTALL_ROOT)/usr/bin/$(APP_NAME) - rm -v $(INSTALL_ROOT)/usr/lib/systemd/system/$(APP_NAME).service diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh new file mode 100644 index 0000000..52f5a77 --- /dev/null +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +set -e + +# functions +__is_version_gt() { + test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1" +} + +__is_migration_needed() { + local version1 + local version2 + + version1="${1}" + version2="${2}" + + if [ "${version1}" = "${version2}" ]; then + return 1 + fi + + if [ "CURRENT_VERSION_NOT_FOUND" = "${version1}" ]; then + return 1 + fi + + if [ "LEGACY_WITHOUT_VERSION" = "${version1}" ]; then + return 0 + fi + + __is_version_gt "${version2}" "${version1}" +} + +BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. +SOURCE_ROOT=${BUILD_PATH}/sysroot + +APP_NAME="casaos-user-service" +APP_NAME_FORMAL="CasaOS-UserService" +APP_NAME_SHORT="user-service" +APP_NAME_LEGACY="casaos" + +# check if migration is needed +SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin +SOURCE_BIN_FILE=${SOURCE_BIN_PATH}/${APP_NAME} + +CURRENT_BIN_PATH=/usr/bin +CURRENT_BIN_PATH_LEGACY=/usr/local/bin +CURRENT_BIN_FILE=${CURRENT_BIN_PATH}/${APP_NAME} +CURRENT_BIN_FILE_LEGACY=$(realpath -e ${CURRENT_BIN_PATH}/${APP_NAME_LEGACY} || realpath -e ${CURRENT_BIN_PATH_LEGACY}/${APP_NAME_LEGACY} || which ${APP_NAME_LEGACY} || echo CURRENT_BIN_FILE_LEGACY_NOT_FOUND) + +SOURCE_VERSION="$(${SOURCE_BIN_FILE} -v)" +CURRENT_VERSION="$(${CURRENT_BIN_FILE} -v || ${CURRENT_BIN_FILE_LEGACY} -v || (stat "${CURRENT_BIN_FILE_LEGACY}" > /dev/null && echo LEGACY_WITHOUT_VERSION) || echo CURRENT_VERSION_NOT_FOUND)" + +echo "CURRENT_VERSION: ${CURRENT_VERSION}" +echo "SOURCE_VERSION: ${SOURCE_VERSION}" + +NEED_MIGRATION=$(__is_migration_needed "${CURRENT_VERSION}" "${SOURCE_VERSION}" && echo "true" || echo "false") + +if [ "${NEED_MIGRATION}" = "false" ]; then + echo "✅ Migration is not needed." + exit 0 +fi + +MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} +MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list +MIGRATION_PATH=() + +CURRENT_VERSION_FOUND="false" + +while read -r VERSION_PAIR; do + if [ -z "${VERSION_PAIR}" ]; then + continue + fi + + VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1) + VER2=$(echo "${VERSION_PAIR}" | cut -d' ' -f2) + + if [ "v${CURRENT_VERSION}" = "${VER1// /}" ]; then + CURRENT_VERSION_FOUND="true" + fi + + if [ "${CURRENT_VERSION_FOUND}" = "true" ]; then + MIGRATION_PATH+=("${VER2// /}") + fi +done < "${MIGRATION_LIST_FILE}" + +if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then + echo "🟨 No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}" + exit 0 +fi + +ARCH="unknown" + +case $(uname -m) in + x86_64) + ARCH="amd64" + ;; + aarch64) + ARCH="arm64" + ;; + armv7l) + ARCH="arm-7" + ;; + *) + echo "Unsupported architecture" + exit 1 + ;; +esac + +pushd "${MIGRATION_SERVICE_DIR}" + +{ + for VER2 in "${MIGRATION_PATH[@]}"; do + MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + echo "Dowloading ${MIGRATION_TOOL_URL}..." + curl -sL -O "${MIGRATION_TOOL_URL}" + done +} || { + echo "🟥 Failed to download migration tools" + popd + exit 1 +} + +{ + for VER2 in "${MIGRATION_PATH[@]}"; do + MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + echo "Extracting ${MIGRATION_TOOL_FILE}..." + tar zxvf "${MIGRATION_TOOL_FILE}" + + MIGRATION_TOOL_PATH=build/sysroot/usr/bin/${APP_NAME}-migration-tool + echo "Running ${MIGRATION_TOOL_PATH}..." + ${MIGRATION_TOOL_PATH} + done +} || { + echo "🟥 Failed to extract and run migration tools" + popd + exit 1 +} + +popd diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list new file mode 100644 index 0000000..bc84e4a --- /dev/null +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -0,0 +1,2 @@ +LEGACY_WITHOUT_VERSION v0.3.6-alpha1 +v0.3.5 v0.3.6-alpha1 \ No newline at end of file diff --git a/build/scripts/setup/script.d/02-setup-user-service.sh b/build/scripts/setup/script.d/02-setup-user-service.sh new file mode 100755 index 0000000..3553c72 --- /dev/null +++ b/build/scripts/setup/script.d/02-setup-user-service.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. + +APP_NAME_SHORT=user-service + +__get_setup_script_directory_by_os_release() { + pushd "$(dirname "${BASH_SOURCE[0]}")/../service.d/${APP_NAME_SHORT}" >/dev/null + + { + # shellcheck source=/dev/null + { + source /etc/os-release + { + pushd "${ID}"/"${VERSION_CODENAME}" >/dev/null + } || { + pushd "${ID}" >/dev/null + } || { + pushd "${ID_LIKE}" >/dev/null + } || { + echo "Unsupported OS: ${ID} ${VERSION_CODENAME} (${ID_LIKE})" + exit 1 + } + + pwd + + popd >/dev/null + + } || { + echo "Unsupported OS: unknown" + exit 1 + } + + } + + popd >/dev/null +} + +SETUP_SCRIPT_DIRECTORY=$(__get_setup_script_directory_by_os_release) +SETUP_SCRIPT_FILENAME="setup-${APP_NAME_SHORT}.sh" + +SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}" + +{ + echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..." + $SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" +} || { + echo "🟥 ${SETUP_SCRIPT_FILENAME} failed." + exit 1 +} + +echo "✅ ${SETUP_SCRIPT_FILENAME} finished." diff --git a/build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh b/build/scripts/setup/service.d/user-service/debian/bullseye/setup-user-service.sh similarity index 100% rename from build/usr/share/casaos/setup/service.d/user-service/debian/bullseye/setup-user-service.sh rename to build/scripts/setup/service.d/user-service/debian/bullseye/setup-user-service.sh diff --git a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh new file mode 100644 index 0000000..0e5494f --- /dev/null +++ b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +APP_NAME="casaos-user-service" +APP_NAME_SHORT="user-service" + +# copy config files +CONF_PATH=/etc/casaos +CONF_FILE=${CONF_PATH}/${APP_NAME_SHORT}.conf +CONF_FILE_SAMPLE=${CONF_PATH}/${APP_NAME_SHORT}.conf.sample + +if [ ! -f "${CONF_FILE}" ]; then \ + echo "Initializing config file..." + cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"; \ +fi + +# enable and start service +systemctl daemon-reload + +echo "Enabling service..." +systemctl enable --force --no-ask-password "${APP_NAME}.service" + +echo "Starting service..." +systemctl start --force --no-ask-password "${APP_NAME}.service" diff --git a/build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh b/build/scripts/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh similarity index 100% rename from build/usr/share/casaos/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh rename to build/scripts/setup/service.d/user-service/ubuntu/jammy/setup-user-service.sh diff --git a/build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh b/build/scripts/setup/service.d/user-service/ubuntu/setup-user-service.sh similarity index 100% rename from build/usr/share/casaos/setup/service.d/user-service/ubuntu/setup-user-service.sh rename to build/scripts/setup/service.d/user-service/ubuntu/setup-user-service.sh diff --git a/build/etc/casaos/user-service.conf.sample b/build/sysroot/etc/casaos/user-service.conf.sample similarity index 100% rename from build/etc/casaos/user-service.conf.sample rename to build/sysroot/etc/casaos/user-service.conf.sample diff --git a/build/usr/lib/systemd/system/casaos-user-service.service b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service similarity index 100% rename from build/usr/lib/systemd/system/casaos-user-service.service rename to build/sysroot/usr/lib/systemd/system/casaos-user-service.service diff --git a/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh b/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh deleted file mode 100644 index 0f61faa..0000000 --- a/build/usr/share/casaos/migration/script.d/01-migrate-user-service.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e - -__get_existing_version() { - local version - - echo "$version" -} \ No newline at end of file diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.2.sh deleted file mode 100644 index e69de29..0000000 diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh deleted file mode 120000 index 2c3a78b..0000000 --- a/build/usr/share/casaos/migration/service.d/user-service/from-0.3.4.sh +++ /dev/null @@ -1 +0,0 @@ -from-0.3.sh \ No newline at end of file diff --git a/build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh b/build/usr/share/casaos/migration/service.d/user-service/from-0.3.sh deleted file mode 100644 index e69de29..0000000 diff --git a/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh b/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh deleted file mode 100644 index 94ef7de..0000000 --- a/build/usr/share/casaos/setup/script.d/01-setup-user-service.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -set -e - diff --git a/build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh b/build/usr/share/casaos/setup/service.d/user-service/debian/setup-user-service.sh deleted file mode 100644 index e69de29..0000000 From acdbb326bc445d6437c34bd38e49c01838689957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Mon, 22 Aug 2022 17:22:27 -0400 Subject: [PATCH 11/95] change to static linking when building so older Linux distributions are supported (#5) --- .github/workflows/release.yml | 4 +-- .goreleaser.yaml | 58 ++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32d0e66..f92f949 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,8 @@ jobs: sudo apt update sudo apt-get --no-install-recommends --yes install \ libc6-dev-amd64-cross \ - gcc-11-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-11-arm-linux-gnueabihf libc6-dev-armhf-cross + gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - name: Checkout uses: actions/checkout@v2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d742a3b..a39f536 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,7 +10,14 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-11 + - CC=x86_64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -19,7 +26,14 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-11 + - CC=aarch64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -28,19 +42,33 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-11 + - CC=arm-linux-gnueabihf-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: - arm goarm: - - 7 + - "7" - id: casaos-user-service-migration-tool-amd64 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-11 + - CC=x86_64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -50,7 +78,14 @@ builds: main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-11 + - CC=aarch64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -60,13 +95,20 @@ builds: main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-11 + - CC=arm-linux-gnueabihf-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: - arm goarm: - - 7 + - "7" archives: - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-v{{ .Version }}" id: casaos-user-service From 44780ac1b428c8ee5010c6ac3df86dbb5c2a0361 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 22 Aug 2022 21:33:25 +0000 Subject: [PATCH 12/95] bump version in migration.list --- build/scripts/migration/service.d/user-service/migration.list | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index bc84e4a..5e71955 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,2 +1,2 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha1 -v0.3.5 v0.3.6-alpha1 \ No newline at end of file +LEGACY_WITHOUT_VERSION v0.3.6-alpha2 +v0.3.5 v0.3.6-alpha2 \ No newline at end of file From 210aa979f5a40773a476f0b5b108a8091be45ac3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 24 Aug 2022 01:27:48 +0000 Subject: [PATCH 13/95] bump version --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 5a681bf..1ef7fa1 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ import ( ) const ( - version = "0.3.5" + version = "0.3.6" localhost = "127.0.0.1" ) From 8d9c3f987d536a3f207fd340a443ff5c93f57553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Tue, 23 Aug 2022 22:55:46 -0400 Subject: [PATCH 14/95] fix migration not working for LEGACY_WITHOUT_VERSION (#6) --- .../script.d/02-migrate-user-service.sh | 54 +++++++++++++------ .../service.d/user-service/migration.list | 2 +- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh index 52f5a77..629f4c3 100644 --- a/build/scripts/migration/script.d/02-migrate-user-service.sh +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -3,6 +3,23 @@ set -e # functions +__info() { + echo -e "🟩 ${1}" +} + +__info_done() { + echo -e "✅ ${1}" +} + +__warning() { + echo -e "🟨 ${1}" +} + +__error() { + echo "🟥 ${1}" + exit 1 +} + __is_version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1" } @@ -49,13 +66,13 @@ CURRENT_BIN_FILE_LEGACY=$(realpath -e ${CURRENT_BIN_PATH}/${APP_NAME_LEGACY} || SOURCE_VERSION="$(${SOURCE_BIN_FILE} -v)" CURRENT_VERSION="$(${CURRENT_BIN_FILE} -v || ${CURRENT_BIN_FILE_LEGACY} -v || (stat "${CURRENT_BIN_FILE_LEGACY}" > /dev/null && echo LEGACY_WITHOUT_VERSION) || echo CURRENT_VERSION_NOT_FOUND)" -echo "CURRENT_VERSION: ${CURRENT_VERSION}" -echo "SOURCE_VERSION: ${SOURCE_VERSION}" +__info_done "CURRENT_VERSION: ${CURRENT_VERSION}" +__info_done "SOURCE_VERSION: ${SOURCE_VERSION}" NEED_MIGRATION=$(__is_migration_needed "${CURRENT_VERSION}" "${SOURCE_VERSION}" && echo "true" || echo "false") if [ "${NEED_MIGRATION}" = "false" ]; then - echo "✅ Migration is not needed." + __info_done "Migration is not needed." exit 0 fi @@ -65,15 +82,22 @@ MIGRATION_PATH=() CURRENT_VERSION_FOUND="false" +# a VERSION_PAIR looks like "v0.3.5 v0.3.6-alpha2" +# +# - "v0.3.5" is the current version installed on this host +# - "v0.3.6-alpha2" is the version of the migration tool from GitHub while read -r VERSION_PAIR; do if [ -z "${VERSION_PAIR}" ]; then continue fi + # obtain "v0.3.5" from "v0.3.5 v0.3.6-alpha2" VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1) + + # obtain "v0.3.6-alpha2" from "v0.3.5 v0.3.6-alpha2" VER2=$(echo "${VERSION_PAIR}" | cut -d' ' -f2) - if [ "v${CURRENT_VERSION}" = "${VER1// /}" ]; then + if [ "v${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then CURRENT_VERSION_FOUND="true" fi @@ -83,7 +107,7 @@ while read -r VERSION_PAIR; do done < "${MIGRATION_LIST_FILE}" if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then - echo "🟨 No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}" + __warning "No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}" exit 0 fi @@ -100,8 +124,7 @@ case $(uname -m) in ARCH="arm-7" ;; *) - echo "Unsupported architecture" - exit 1 + __error "Unsupported architecture" ;; esac @@ -110,29 +133,30 @@ pushd "${MIGRATION_SERVICE_DIR}" { for VER2 in "${MIGRATION_PATH[@]}"; do MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz - echo "Dowloading ${MIGRATION_TOOL_URL}..." + __info "Dowloading ${MIGRATION_TOOL_URL}..." curl -sL -O "${MIGRATION_TOOL_URL}" done } || { - echo "🟥 Failed to download migration tools" popd - exit 1 + __error "Failed to download migration tools" } { for VER2 in "${MIGRATION_PATH[@]}"; do MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz - echo "Extracting ${MIGRATION_TOOL_FILE}..." - tar zxvf "${MIGRATION_TOOL_FILE}" + __info "Extracting ${MIGRATION_TOOL_FILE}..." + tar zxvf "${MIGRATION_TOOL_FILE}" || __error "Failed to extract ${MIGRATION_TOOL_FILE}" + + MIGRATION_SYSROOT_DIR=$(realpath -e "${MIGRATION_SERVICE_DIR}"/build/sysroot || __error "Failed to find sysroot directory for migration") + cp -rv "${MIGRATION_SYSROOT_DIR}"/* / || __error "Failed to copy sysroot directory for migration" MIGRATION_TOOL_PATH=build/sysroot/usr/bin/${APP_NAME}-migration-tool - echo "Running ${MIGRATION_TOOL_PATH}..." + __info "Running ${MIGRATION_TOOL_PATH}..." ${MIGRATION_TOOL_PATH} done } || { - echo "🟥 Failed to extract and run migration tools" popd - exit 1 + __error "Failed to extract and run migration tools" } popd diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 5e71955..7325ac3 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,2 +1,2 @@ LEGACY_WITHOUT_VERSION v0.3.6-alpha2 -v0.3.5 v0.3.6-alpha2 \ No newline at end of file +v0.3.5 v0.3.6-alpha2 From 5417c6b94bebec1471bd898d48d4eaafda61fd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Thu, 25 Aug 2022 17:36:24 -0400 Subject: [PATCH 15/95] use middlewares from CasaOS-Common (#7) --- go.mod | 2 +- go.sum | 4 ++-- main.go | 4 ++-- middleware/gin.go | 61 ----------------------------------------------- route/route.go | 2 +- 5 files changed, 6 insertions(+), 67 deletions(-) delete mode 100644 middleware/gin.go diff --git a/go.mod b/go.mod index 291de40..05836d3 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.18 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426 + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68 github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 diff --git a/go.sum b/go.sum index 3701484..9c54ed1 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426 h1:+Yc9qJ6AehudNsIRkoyTe8dmHiHDWsPF/QL7qk8Va6o= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811230555-229797f76426/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68 h1:KMFS0/08mKgZqsM8fd5If/1NOLwtIvi7dljFEkJCdSw= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b h1:IiMCqvGelQLGTX151gqVwrzoPQVJy8Q2JAvkhjiQ6tY= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b/go.mod h1:jcURlZtPPQJJvfIW4ZgDTtpFfak7bPTvKZUxWxf62M8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/main.go b/main.go index 1ef7fa1..e6f68b0 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "flag" "fmt" - "log" "net" "net/http" "os" @@ -16,6 +15,7 @@ import ( "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/random" "github.com/IceWhaleTech/CasaOS-UserService/route" "github.com/IceWhaleTech/CasaOS-UserService/service" + "go.uber.org/zap" ) const ( @@ -87,7 +87,7 @@ func main() { panic(err) } - log.Printf("user service listening on %s", listener.Addr().String()) + logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) err = http.Serve(listener, r) if err != nil { panic(err) diff --git a/middleware/gin.go b/middleware/gin.go deleted file mode 100644 index c273808..0000000 --- a/middleware/gin.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * @Author: LinkLeong link@icewhale.com - * @Date: 2021-10-08 10:29:08 - * @LastEditors: LinkLeong - * @LastEditTime: 2022-07-22 11:06:07 - * @Description: - * @Website: https://www.casaos.io - * Copyright (c) 2022 by icewhale, All Rights Reserved. - */ -package middleware - -import ( - "fmt" - "net/http" - "strings" - - "github.com/IceWhaleTech/CasaOS-Common/utils/logger" - "github.com/gin-gonic/gin" - "go.uber.org/zap" -) - -func Cors() gin.HandlerFunc { - return func(c *gin.Context) { - method := c.Request.Method - - c.Header("Access-Control-Allow-Origin", "*") - c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") - // 允许跨域设置可以返回其他子段,可以自定义字段 - c.Header("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,Language,Content-Type,Access-Control-Allow-Origin,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Connection,Host,Origin,Referer,User-Agent,X-Requested-With") - // 允许浏览器(客户端)可以解析的头部 (重要) - c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers") - // c.Writer.Header().Set("Access-Control-Allow-Headers", "Accept, Authorization, Content-Type, Content-Length, X-CSRF-Token, Token, session, Origin, Host, Connection, Accept-Encoding, Accept-Language, X-Requested-With") - // 设置缓存时间 - c.Header("Access-Control-Max-Age", "172800") - c.Header("Access-Control-Allow-Credentials", "true") - c.Set("Content-Type", "application/json") - //} - - // 允许类型校验 - if method == "OPTIONS" { - c.JSON(http.StatusOK, "ok!") - } - - defer func() { - if err := recover(); err != nil { - fmt.Println(err) - } - }() - - c.Next() - } -} - -func WriteLog() gin.HandlerFunc { - return func(c *gin.Context) { - if !strings.Contains(c.Request.URL.String(), "password") { - logger.Info("request:", zap.Any("path", c.Request.URL.String()), zap.Any("param", c.Params), zap.Any("query", c.Request.URL.Query()), zap.Any("method", c.Request.Method)) - c.Next() - } - } -} diff --git a/route/route.go b/route/route.go index a58ed6c..127f67f 100644 --- a/route/route.go +++ b/route/route.go @@ -3,8 +3,8 @@ package route import ( "os" + "github.com/IceWhaleTech/CasaOS-Common/middleware" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" - "github.com/IceWhaleTech/CasaOS-UserService/middleware" v1 "github.com/IceWhaleTech/CasaOS-UserService/route/v1" "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" From 675ecb55f7456f8ef0e4afad3219e2ef61081b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Sun, 28 Aug 2022 20:40:51 -0400 Subject: [PATCH 16/95] add migration logic for 0.2.x (#8) --- .../service.d/user-service/migration.list | 4 +- .../etc/casaos/user-service.conf.sample | 2 +- cmd/migration-tool/main.go | 11 +- cmd/migration-tool/migration-033-034-035.go | 96 ------- cmd/migration-tool/migration_032_and_older.go | 191 ++++++++++++++ cmd/migration-tool/migration_033_034_035.go | 239 ++++++++++++++++++ common/version.go | 2 +- go.mod | 4 +- go.sum | 4 +- main.go | 2 +- 10 files changed, 445 insertions(+), 110 deletions(-) delete mode 100644 cmd/migration-tool/migration-033-034-035.go create mode 100644 cmd/migration-tool/migration_032_and_older.go create mode 100644 cmd/migration-tool/migration_033_034_035.go diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 7325ac3..0b2bdfa 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,2 +1,2 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha2 -v0.3.5 v0.3.6-alpha2 +LEGACY_WITHOUT_VERSION v0.3.6-alpha3 +v0.3.5 v0.3.6-alpha3 diff --git a/build/sysroot/etc/casaos/user-service.conf.sample b/build/sysroot/etc/casaos/user-service.conf.sample index a146555..1d2d1ba 100644 --- a/build/sysroot/etc/casaos/user-service.conf.sample +++ b/build/sysroot/etc/casaos/user-service.conf.sample @@ -5,5 +5,5 @@ RuntimePath=/var/run/casaos LogPath = /var/log/casaos LogSaveName = user-service LogFileExt = log -DBPath = /var/lib/casaos +DBPath = /var/lib/casaos/db UserDataPath = /var/lib/casaos diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go index 62bcb30..3e9271e 100644 --- a/cmd/migration-tool/main.go +++ b/cmd/migration-tool/main.go @@ -40,19 +40,20 @@ func main() { } if !*forceFlag { - serviceEnabled, err := systemctl.IsServiceEnabled(userServiceName) + isRunning, err := systemctl.IsServiceRunning(userServiceName) if err != nil { - _logger.Error("Failed to check if %s is enabled", userServiceName) + _logger.Error("Failed to check if %s is running", userServiceName) panic(err) } - if serviceEnabled { - _logger.Info("%s is already enabled. If migration is still needed, try with -f.", userServiceName) + if isRunning { + _logger.Info("%s is running. If migration is still needed, try with -f.", userServiceName) os.Exit(1) } } migrationTools := []interfaces.MigrationTool{ + NewMigrationToolFor032AndOlder(), NewMigrationToolFor033_034_035(), } @@ -85,6 +86,6 @@ func main() { } if err := selectedMigrationTool.PostMigrate(); err != nil { - panic(err) + _logger.Error("Migration succeeded, but post-migration failed: %s", err) } } diff --git a/cmd/migration-tool/migration-033-034-035.go b/cmd/migration-tool/migration-033-034-035.go deleted file mode 100644 index e7c83df..0000000 --- a/cmd/migration-tool/migration-033-034-035.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - interfaces "github.com/IceWhaleTech/CasaOS-Common" - "github.com/IceWhaleTech/CasaOS-Common/utils/version" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" - "gopkg.in/ini.v1" -) - -type migrationTool struct{} - -func (u *migrationTool) IsMigrationNeeded() (bool, error) { - _logger.Info("Checking if migration is needed for CasaoS version between 0.3.3 and 0.3.5...") - - minorVersion, err := version.DetectMinorVersion() - if err != nil { - return false, err - } - - if minorVersion != 3 { - return false, nil - } - - // this is the best way to tell if CasaOS version is between 0.3.3 and 0.3.5 - isUserDataInDatabase, err := version.IsUserDataInDatabase() - if err != nil { - return false, err - } - - if !isUserDataInDatabase { - return false, nil - } - - return true, nil -} - -func (u *migrationTool) PreMigrate() error { - _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) - if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { - return err - } - return nil -} - -func (u *migrationTool) Migrate() error { - _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - // LogPath - logPath, err := legacyConfigFile.Section("app").GetKey("LogPath") - if err != nil { - return err - } - - // LogFileExt - logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt") - if err != nil { - return err - } - - // DBPath - dbPath, err := legacyConfigFile.Section("app").GetKey("DBPath") - if err != nil { - return err - } - - // UserDataPath - userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath") - if err != nil { - return err - } - - _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) - config.InitSetup(config.UserServiceConfigFilePath) - - config.AppInfo.LogPath = logPath.Value() - config.AppInfo.LogFileExt = logFileExt.Value() - config.AppInfo.DBPath = dbPath.Value() - config.AppInfo.UserDataPath = userDataPath.Value() - - config.SaveSetup(config.UserServiceConfigFilePath) - - return nil -} - -func (u *migrationTool) PostMigrate() error { - return nil -} - -func NewMigrationToolFor033_034_035() interfaces.MigrationTool { - return &migrationTool{} -} diff --git a/cmd/migration-tool/migration_032_and_older.go b/cmd/migration-tool/migration_032_and_older.go new file mode 100644 index 0000000..3136cf9 --- /dev/null +++ b/cmd/migration-tool/migration_032_and_older.go @@ -0,0 +1,191 @@ +package main + +import ( + "os" + "path/filepath" + "strconv" + "strings" + "time" + + interfaces "github.com/IceWhaleTech/CasaOS-Common" + "github.com/IceWhaleTech/CasaOS-Common/utils/version" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" + "github.com/IceWhaleTech/CasaOS-UserService/service" + "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "gopkg.in/ini.v1" +) + +type migrationTool1 struct{} + +func (u *migrationTool1) IsMigrationNeeded() (bool, error) { + if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { + _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) + return false, nil + } + + majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion() + if err != nil { + if err == version.ErrLegacyVersionNotFound { + return false, nil + } + + return false, err + } + + if majorVersion != 0 { + return false, nil + } + + if minorVersion == 2 { + _logger.Info("Migration is needed for a CasaOS version 0.2.x...") + return true, nil + } + + if minorVersion == 3 && patchVersion < 2 { + _logger.Info("Migration is needed for a CasaOS version between 0.3.0 and 0.3.2...") + return true, nil + } + + return false, nil +} + +func (u *migrationTool1) PreMigrate() error { + _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) + if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { + return err + } + + extension := "." + time.Now().Format("20060102") + ".bak" + + _logger.Info("Creating a backup %s if it doesn't exist...", version.LegacyCasaOSConfigFilePath+extension) + return file.CopySingleFile(version.LegacyCasaOSConfigFilePath, version.LegacyCasaOSConfigFilePath+extension, "skip") +} + +func (u *migrationTool1) Migrate() error { + _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + migrateConfigurationFile1(legacyConfigFile) + + return migrateUser1(legacyConfigFile) +} + +func (u *migrationTool1) PostMigrate() error { + _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) + + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + legacyConfigFile.DeleteSection("user") + + return legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath) +} + +func NewMigrationToolFor032AndOlder() interfaces.MigrationTool { + return &migrationTool1{} +} + +func migrateConfigurationFile1(legacyConfigFile *ini.File) { + _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) + config.InitSetup(config.UserServiceConfigFilePath) + + // LogPath + if logPath, err := legacyConfigFile.Section("app").GetKey("LogPath"); err == nil { + _logger.Info("[app] LogPath = %s", logPath.Value()) + config.AppInfo.LogPath = logPath.Value() + } + + if logPath, err := legacyConfigFile.Section("app").GetKey("LogSavePath"); err == nil { + _logger.Info("[app] LogSavePath = %s", logPath.Value()) + config.AppInfo.LogPath = logPath.Value() + } + + // LogFileExt + if logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt"); err == nil { + _logger.Info("[app] LogFileExt = %s", logFileExt.Value()) + config.AppInfo.LogFileExt = logFileExt.Value() + } + + // UserDataPath + if userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath"); err == nil { + _logger.Info("[app] UserDataPath = %s", userDataPath.Value()) + config.AppInfo.UserDataPath = userDataPath.Value() + } + + _logger.Info("Saving %s...", config.UserServiceConfigFilePath) + config.SaveSetup(config.UserServiceConfigFilePath) +} + +func migrateUser1(legacyConfigFile *ini.File) error { + _logger.Info("Migrating user from configuration file to database...") + + user := model.UserDBModel{Role: "admin"} + + // UserName + if userName, err := legacyConfigFile.Section("user").GetKey("UserName"); err == nil { + _logger.Info("[user] UserName = %s", userName.Value()) + user.Username = userName.Value() + } + + // Email + if userEmail, err := legacyConfigFile.Section("user").GetKey("Email"); err == nil { + _logger.Info("[user] Email = %s", userEmail.Value()) + user.Email = userEmail.Value() + } + + // NickName + if userNickName, err := legacyConfigFile.Section("user").GetKey("NickName"); err == nil { + _logger.Info("[user] NickName = %s", userNickName.Value()) + user.Nickname = userNickName.Value() + } + + // Password + if userPassword, err := legacyConfigFile.Section("user").GetKey("PWD"); err == nil { + _logger.Info("[user] Password = %s", strings.Repeat("*", len(userPassword.Value()))) + user.Password = encryption.GetMD5ByStr(userPassword.Value()) + } + + newDB := sqlite.GetDb(config.AppInfo.DBPath) + userService := service.NewUserService(newDB) + + if len(user.Username) == 0 { + _logger.Info("No user found in legacy configuration file. Skipping...") + return nil + } + + if userService.GetUserInfoByUserName(user.Username).Id > 0 { + _logger.Info("User `%s` already exists in user database at %s. Skipping...", user.Username, config.AppInfo.DBPath) + return nil + } + + _logger.Info("Creating user %s in database at %s...", user.Username, config.AppInfo.DBPath) + user = userService.CreateUser(user) + if user.Id > 0 { + userPath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) + _logger.Info("Creating user data path: %s", userPath) + if err := file.MkDir(userPath); err != nil { + return err + } + + if legacyProjectPath, err := legacyConfigFile.Section("app").GetKey("ProjectPath"); err == nil { + appOrderJSONFile := filepath.Join(legacyProjectPath.Value(), "app_order.json") + + if _, err := os.Stat(appOrderJSONFile); err == nil { + _logger.Info("Moving %s to %s...", appOrderJSONFile, userPath) + if err := os.Rename(appOrderJSONFile, filepath.Join(userPath, "app_order.json")); err != nil { + return err + } + } + } + } + + return nil +} diff --git a/cmd/migration-tool/migration_033_034_035.go b/cmd/migration-tool/migration_033_034_035.go new file mode 100644 index 0000000..97bf9bb --- /dev/null +++ b/cmd/migration-tool/migration_033_034_035.go @@ -0,0 +1,239 @@ +package main + +import ( + "database/sql" + "os" + "path/filepath" + "time" + + interfaces "github.com/IceWhaleTech/CasaOS-Common" + "github.com/IceWhaleTech/CasaOS-Common/utils/version" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" + "github.com/IceWhaleTech/CasaOS-UserService/service" + "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "gopkg.in/ini.v1" +) + +type migrationTool2 struct{} + +func (u *migrationTool2) IsMigrationNeeded() (bool, error) { + if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { + _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) + return false, nil + } + + majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion() + if err != nil { + if err == version.ErrLegacyVersionNotFound { + return false, nil + } + + return false, err + } + + if majorVersion != 0 { + return false, nil + } + + if minorVersion != 3 { + return false, nil + } + + if patchVersion < 3 || patchVersion > 5 { + return false, nil + } + + // legacy version has to be between 0.3.3 and 0.3.5 + _logger.Info("Migration is needed for a CasaOS version between 0.3.3 and 0.3.5...") + return true, nil +} + +func (u *migrationTool2) PreMigrate() error { + _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) + if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { + return err + } + + extension := "." + time.Now().Format("20060102") + ".bak" + + _logger.Info("Creating a backup %s if it doesn't exist...", version.LegacyCasaOSConfigFilePath+extension) + if err := file.CopySingleFile(version.LegacyCasaOSConfigFilePath, version.LegacyCasaOSConfigFilePath+extension, "skip"); err != nil { + return err + } + + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + dbPath := legacyConfigFile.Section("app").Key("DBPath").String() + + dbFile := filepath.Join(dbPath, "db", "casaOS.db") + + _logger.Info("Creating a backup %s if it doesn't exist...", dbFile+extension) + if err := file.CopySingleFile(dbFile, dbFile+extension, "skip"); err != nil { + return err + } + + return nil +} + +func (u *migrationTool2) Migrate() error { + _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + migrateConfigurationFile2(legacyConfigFile) + + return migrateUser2(legacyConfigFile) +} + +func (u *migrationTool2) PostMigrate() error { + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) + if err != nil { + return err + } + + dbPath := legacyConfigFile.Section("app").Key("DBPath").String() + + dbFile := filepath.Join(dbPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + return err + } + + legacyDB, err := sql.Open("sqlite3", dbFile) + if err != nil { + return err + } + + defer legacyDB.Close() + + if tableExists, err := isTableExist(legacyDB, "o_users"); err != nil { + return err + } else if tableExists { + _logger.Info("Dropping `o_users` table in legacy database...") + + if _, err = legacyDB.Exec("DROP TABLE o_users"); err != nil { + _logger.Error("Failed to drop `o_users` table in legacy database: %s", err) + } + } + return nil +} + +func NewMigrationToolFor033_034_035() interfaces.MigrationTool { + return &migrationTool2{} +} + +func migrateConfigurationFile2(legacyConfigFile *ini.File) { + _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) + config.InitSetup(config.UserServiceConfigFilePath) + + // LogPath + if logPath, err := legacyConfigFile.Section("app").GetKey("LogPath"); err == nil { + _logger.Info("[app] LogPath = %s", logPath.Value()) + config.AppInfo.LogPath = logPath.Value() + } + + // LogFileExt + if logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt"); err == nil { + _logger.Info("[app] LogFileExt = %s", logFileExt.Value()) + config.AppInfo.LogFileExt = logFileExt.Value() + } + + // DBPath + if dbPath, err := legacyConfigFile.Section("app").GetKey("DBPath"); err == nil { + _logger.Info("[app] DBPath = %s", dbPath.Value()) + config.AppInfo.DBPath = dbPath.Value() + "/db" + } + + // UserDataPath + if userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath"); err == nil { + _logger.Info("[app] UserDataPath = %s", userDataPath.Value()) + config.AppInfo.UserDataPath = userDataPath.Value() + } + + _logger.Info("Saving %s...", config.UserServiceConfigFilePath) + config.SaveSetup(config.UserServiceConfigFilePath) +} + +func migrateUser2(legacyConfigFile *ini.File) error { + _logger.Info("Migrating user from legacy database to user database...") + + user := model.UserDBModel{Role: "admin"} + + dbPath := legacyConfigFile.Section("app").Key("DBPath").String() + + dbFile := filepath.Join(dbPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + return err + } + + legacyDB, err := sql.Open("sqlite3", dbFile) + if err != nil { + return err + } + + defer legacyDB.Close() + + if tableExists, err := isTableExist(legacyDB, "o_users"); err != nil { + return err + } else if !tableExists { + _logger.Info("Table `o_users` not found in legacy database. Skipping...") + return nil + } + + sqlStatement := "SELECT id, username, password, role, email, nickname, avatar, description, created_at FROM o_users ORDER BY id ASC" + + rows, err := legacyDB.Query(sqlStatement) + if err != nil { + return err + } + + defer rows.Close() + + newDB := sqlite.GetDb(config.AppInfo.DBPath) + userService := service.NewUserService(newDB) + + for rows.Next() { + if err := rows.Scan( + &user.Id, + &user.Username, + &user.Password, + &user.Role, + &user.Email, + &user.Nickname, + &user.Avatar, + &user.Description, + &user.CreatedAt, + ); err != nil { + return err + } + + if userService.GetUserAllInfoByName(user.Username).Id > 0 { + _logger.Info("User %s already exists in user database at %s, skipping...", user.Username, config.AppInfo.DBPath) + continue + } + + _logger.Info("Creating user %s in user database...", user.Username) + user = userService.CreateUser(user) + } + + return nil +} + +func isTableExist(legacyDB *sql.DB, tableName string) (bool, error) { + rows, err := legacyDB.Query("SELECT name FROM sqlite_master WHERE type='table' AND name= ?", tableName) + if err != nil { + return false, err + } + + defer rows.Close() + + return rows.Next(), nil +} diff --git a/common/version.go b/common/version.go index f3f9408..6564be8 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.3.5" +const Version = "0.3.6" diff --git a/go.mod b/go.mod index 05836d3..4a4e818 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/IceWhaleTech/CasaOS-UserService -go 1.18 +go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68 + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78 github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 diff --git a/go.sum b/go.sum index 9c54ed1..a0be9aa 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68 h1:KMFS0/08mKgZqsM8fd5If/1NOLwtIvi7dljFEkJCdSw= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220825191226-4519f1880f68/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78 h1:Cxy+bTjqpl0txx6gn2/D7O/E6G2SW5c6Ve7RXUin5K4= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b h1:IiMCqvGelQLGTX151gqVwrzoPQVJy8Q2JAvkhjiQ6tY= github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b/go.mod h1:jcURlZtPPQJJvfIW4ZgDTtpFfak7bPTvKZUxWxf62M8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/main.go b/main.go index e6f68b0..b179b77 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,7 @@ func init() { logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) if len(*dbFlag) == 0 { - *dbFlag = config.AppInfo.DBPath + "/db" + *dbFlag = config.AppInfo.DBPath } sqliteDB := sqlite.GetDb(*dbFlag) From 44ca8efc0d6955ec9432d25102e619b938ea1b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Tue, 30 Aug 2022 00:27:38 -0400 Subject: [PATCH 17/95] update CasaOS-Common (#9) --- .../service.d/user-service/migration.list | 4 +- go.mod | 16 +- go.sum | 430 +++++++++++++++++- 3 files changed, 442 insertions(+), 8 deletions(-) diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 0b2bdfa..9f0512d 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,2 +1,2 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha3 -v0.3.5 v0.3.6-alpha3 +LEGACY_WITHOUT_VERSION v0.3.6-alpha4 +v0.3.5 v0.3.6-alpha4 diff --git a/go.mod b/go.mod index 4a4e818..74619a2 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78 - github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6 + github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 @@ -18,6 +18,7 @@ require ( require ( github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect @@ -25,15 +26,25 @@ require ( github.com/goccy/go-json v0.9.10 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect + github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-sqlite3 v1.14.14 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.12.0 // indirect + github.com/subosito/gotenv v1.3.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect @@ -46,4 +57,5 @@ require ( google.golang.org/protobuf v1.28.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // 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 a0be9aa..2d22d6d 100644 --- a/go.sum +++ b/go.sum @@ -1,23 +1,83 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78 h1:Cxy+bTjqpl0txx6gn2/D7O/E6G2SW5c6Ve7RXUin5K4= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220829003259-cf7e89c30d78/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= -github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b h1:IiMCqvGelQLGTX151gqVwrzoPQVJy8Q2JAvkhjiQ6tY= -github.com/IceWhaleTech/CasaOS-Gateway v0.0.0-20220804231126-285796241a3b/go.mod h1:jcURlZtPPQJJvfIW4ZgDTtpFfak7bPTvKZUxWxf62M8= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6 h1:ICitt/XvD1oh3BTdQbzV95G48TFY/aiZr55iA8dMD8M= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4 h1:fSlA5kNBS/Q4D6bFWiNZTwUfsYQ5F/78vJLvUoowXao= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4/go.mod h1:8E5T8HJn2OUXz+KBZRD84CzwhBdCWsIBuQChZJ7XDwE= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -34,10 +94,70 @@ github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +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 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= @@ -45,6 +165,10 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -55,38 +179,63 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= +github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +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.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= +github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -96,7 +245,17 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -108,48 +267,300 @@ go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95a go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8= golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= @@ -162,6 +573,7 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -174,3 +586,13 @@ gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMT gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From 9afe211d90bb803a702f575e41184a216027d70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Wed, 31 Aug 2022 00:29:50 -0400 Subject: [PATCH 18/95] fix migration from 0.3.5.1 (#10) --- .../script.d/02-migrate-user-service.sh | 34 +++++++++--- .../service.d/user-service/migration.list | 5 +- cmd/migration-tool/main.go | 11 ++-- cmd/migration-tool/migration_032_and_older.go | 23 ++++++-- cmd/migration-tool/migration_033_034_035.go | 53 ++++++++++++++++--- go.mod | 14 ++++- go.sum | 33 ++++++++++-- main.go | 2 +- 8 files changed, 146 insertions(+), 29 deletions(-) diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh index 629f4c3..3e95f2a 100644 --- a/build/scripts/migration/script.d/02-migrate-user-service.sh +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -20,6 +20,17 @@ __error() { exit 1 } +__normalize_version() { + local version + if [ "${1::1}" = "v" ]; then + version="${1:1}" + else + version="${1}" + fi + + echo "$version" +} + __is_version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1" } @@ -28,8 +39,8 @@ __is_migration_needed() { local version1 local version2 - version1="${1}" - version2="${2}" + version1=$(__normalize_version "${1}") + version2=$(__normalize_version "${2}") if [ "${version1}" = "${version2}" ]; then return 1 @@ -76,7 +87,12 @@ if [ "${NEED_MIGRATION}" = "false" ]; then exit 0 fi -MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} +MIGRATION_SERVICE_DIR=${1} + +if [ -z "${MIGRATION_SERVICE_DIR}" ]; then + MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} +fi + MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list MIGRATION_PATH=() @@ -97,7 +113,7 @@ while read -r VERSION_PAIR; do # obtain "v0.3.6-alpha2" from "v0.3.5 v0.3.6-alpha2" VER2=$(echo "${VERSION_PAIR}" | cut -d' ' -f2) - if [ "v${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then + if [ "${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then CURRENT_VERSION_FOUND="true" fi @@ -132,6 +148,13 @@ pushd "${MIGRATION_SERVICE_DIR}" { for VER2 in "${MIGRATION_PATH[@]}"; do + MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + + if [ -f "${MIGRATION_TOOL_FILE}" ]; then + __info "Migration tool ${MIGRATION_TOOL_FILE} exists. Skip downloading." + continue + fi + MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz __info "Dowloading ${MIGRATION_TOOL_URL}..." curl -sL -O "${MIGRATION_TOOL_URL}" @@ -147,9 +170,6 @@ pushd "${MIGRATION_SERVICE_DIR}" __info "Extracting ${MIGRATION_TOOL_FILE}..." tar zxvf "${MIGRATION_TOOL_FILE}" || __error "Failed to extract ${MIGRATION_TOOL_FILE}" - MIGRATION_SYSROOT_DIR=$(realpath -e "${MIGRATION_SERVICE_DIR}"/build/sysroot || __error "Failed to find sysroot directory for migration") - cp -rv "${MIGRATION_SYSROOT_DIR}"/* / || __error "Failed to copy sysroot directory for migration" - MIGRATION_TOOL_PATH=build/sysroot/usr/bin/${APP_NAME}-migration-tool __info "Running ${MIGRATION_TOOL_PATH}..." ${MIGRATION_TOOL_PATH} diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 9f0512d..2867263 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,2 +1,3 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha4 -v0.3.5 v0.3.6-alpha4 +LEGACY_WITHOUT_VERSION v0.3.6-alpha5 +v0.3.5 v0.3.6-alpha5 +v0.3.5.1 v0.3.6-alpha5 diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go index 3e9271e..d0f3bd0 100644 --- a/cmd/migration-tool/main.go +++ b/cmd/migration-tool/main.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "flag" "fmt" "os" @@ -11,10 +12,14 @@ import ( ) const ( - userServiceConfigSampleFilePath = "/etc/casaos/user-service.conf.sample" - userServiceName = "casaos-user-service.service" + userServiceConfigDirPath = "/etc/casaos" + userServiceConfigFilePath = "/etc/casaos/user-service.conf" + userServiceName = "casaos-user-service.service" ) +//go:embedded ../../build/sysroot/etc/casaos/user-service.conf.sample +var _userServiceConfigFileSample string + var _logger *Logger func main() { @@ -24,7 +29,7 @@ func main() { flag.Parse() if *versionFlag { - fmt.Println(common.Version) + fmt.Printf("v%s\n", common.Version) os.Exit(0) } diff --git a/cmd/migration-tool/migration_032_and_older.go b/cmd/migration-tool/migration_032_and_older.go index 3136cf9..be27a5b 100644 --- a/cmd/migration-tool/migration_032_and_older.go +++ b/cmd/migration-tool/migration_032_and_older.go @@ -53,9 +53,26 @@ func (u *migrationTool1) IsMigrationNeeded() (bool, error) { } func (u *migrationTool1) PreMigrate() error { - _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) - if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { - return err + if _, err := os.Stat(userServiceConfigDirPath); os.IsNotExist(err) { + _logger.Info("Creating %s since it doesn't exists...", userServiceConfigDirPath) + if err := os.Mkdir(userServiceConfigDirPath, 0o755); err != nil { + return err + } + } + + if _, err := os.Stat(userServiceConfigFilePath); os.IsNotExist(err) { + _logger.Info("Creating %s since it doesn't exist...", userServiceConfigFilePath) + + f, err := os.Create(userServiceConfigFilePath) + if err != nil { + return err + } + + defer f.Close() + + if _, err := f.WriteString(_userServiceConfigFileSample); err != nil { + return err + } } extension := "." + time.Now().Format("20060102") + ".bak" diff --git a/cmd/migration-tool/migration_033_034_035.go b/cmd/migration-tool/migration_033_034_035.go index 97bf9bb..e096767 100644 --- a/cmd/migration-tool/migration_033_034_035.go +++ b/cmd/migration-tool/migration_033_034_035.go @@ -16,6 +16,8 @@ import ( "gopkg.in/ini.v1" ) +const defaultDBPath = "/var/lib/casaos" + type migrationTool2 struct{} func (u *migrationTool2) IsMigrationNeeded() (bool, error) { @@ -51,9 +53,26 @@ func (u *migrationTool2) IsMigrationNeeded() (bool, error) { } func (u *migrationTool2) PreMigrate() error { - _logger.Info("Copying %s to %s if it doesn't exist...", userServiceConfigSampleFilePath, config.UserServiceConfigFilePath) - if err := file.CopySingleFile(userServiceConfigSampleFilePath, config.UserServiceConfigFilePath, "skip"); err != nil { - return err + if _, err := os.Stat(userServiceConfigDirPath); os.IsNotExist(err) { + _logger.Info("Creating %s since it doesn't exists...", userServiceConfigDirPath) + if err := os.Mkdir(userServiceConfigDirPath, 0o755); err != nil { + return err + } + } + + if _, err := os.Stat(userServiceConfigFilePath); os.IsNotExist(err) { + _logger.Info("Creating %s since it doesn't exist...", userServiceConfigFilePath) + + f, err := os.Create(userServiceConfigFilePath) + if err != nil { + return err + } + + defer f.Close() + + if _, err := f.WriteString(_userServiceConfigFileSample); err != nil { + return err + } } extension := "." + time.Now().Format("20060102") + ".bak" @@ -72,6 +91,14 @@ func (u *migrationTool2) PreMigrate() error { dbFile := filepath.Join(dbPath, "db", "casaOS.db") + if _, err := os.Stat(dbFile); err != nil { + dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + return err + } + } + _logger.Info("Creating a backup %s if it doesn't exist...", dbFile+extension) if err := file.CopySingleFile(dbFile, dbFile+extension, "skip"); err != nil { return err @@ -103,7 +130,11 @@ func (u *migrationTool2) PostMigrate() error { dbFile := filepath.Join(dbPath, "db", "casaOS.db") if _, err := os.Stat(dbFile); err != nil { - return err + dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + return err + } } legacyDB, err := sql.Open("sqlite3", dbFile) @@ -122,7 +153,12 @@ func (u *migrationTool2) PostMigrate() error { _logger.Error("Failed to drop `o_users` table in legacy database: %s", err) } } - return nil + + _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) + + legacyConfigFile.DeleteSection("user") + + return legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath) } func NewMigrationToolFor033_034_035() interfaces.MigrationTool { @@ -171,9 +207,12 @@ func migrateUser2(legacyConfigFile *ini.File) error { dbFile := filepath.Join(dbPath, "db", "casaOS.db") if _, err := os.Stat(dbFile); err != nil { - return err - } + dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") + if _, err := os.Stat(dbFile); err != nil { + return err + } + } legacyDB, err := sql.Open("sqlite3", dbFile) if err != nil { return err diff --git a/go.mod b/go.mod index 74619a2..af1b0a6 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6 - github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4 + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2 + github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 @@ -16,8 +16,10 @@ require ( ) require ( + github.com/andybalholm/brotli v1.0.1 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect @@ -26,19 +28,25 @@ require ( github.com/goccy/go-json v0.9.10 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/golang/snappy v0.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/klauspost/pgzip v1.2.5 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-sqlite3 v1.14.14 // indirect + github.com/mholt/archiver/v3 v3.5.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/nwaples/rardecode v1.1.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -48,6 +56,8 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect + github.com/ulikunitz/xz v0.5.9 // indirect + github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect diff --git a/go.sum b/go.sum index 2d22d6d..f8b8d87 100644 --- a/go.sum +++ b/go.sum @@ -39,10 +39,12 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6 h1:ICitt/XvD1oh3BTdQbzV95G48TFY/aiZr55iA8dMD8M= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220830042034-a4df79c84ce6/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4 h1:fSlA5kNBS/Q4D6bFWiNZTwUfsYQ5F/78vJLvUoowXao= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha4/go.mod h1:8E5T8HJn2OUXz+KBZRD84CzwhBdCWsIBuQChZJ7XDwE= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2 h1:l/f2wj7Xs1nbdhbio3ENzPT2cHuFIXuAhptqIIfndrg= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5 h1:aRDy7ug77eZN19vqRjH1N6HHYuzYUnwp9ByMwdfnmJw= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5/go.mod h1:v2d+VlVMF6i0XPGRJbmUt1b270J8kn1+pV5xmCJFrXk= +github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= +github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -60,6 +62,9 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= +github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= +github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -120,6 +125,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= +github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -168,6 +175,13 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= +github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -186,6 +200,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= +github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -193,11 +209,15 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= +github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= +github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM= +github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -245,6 +265,11 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= +github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/main.go b/main.go index b179b77..f4d2257 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func init() { flag.Parse() if *versionFlag { - fmt.Println(version) + fmt.Printf("v%s\n", common.Version) os.Exit(0) } From 6c73a4be13f1590d5dd1c565309230511245627c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Wed, 31 Aug 2022 17:56:39 -0400 Subject: [PATCH 19/95] fix migration from v0.3.3 (#11) --- .../service.d/user-service/migration.list | 6 +- cmd/migration-tool/migration_032_and_older.go | 47 +++++++- cmd/migration-tool/migration_033_034_035.go | 106 ++++++++++-------- pkg/sqlite/db.go | 23 +--- 4 files changed, 115 insertions(+), 67 deletions(-) diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 2867263..63b80e8 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,3 +1,3 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha5 -v0.3.5 v0.3.6-alpha5 -v0.3.5.1 v0.3.6-alpha5 +LEGACY_WITHOUT_VERSION v0.3.6-alpha6 +v0.3.5 v0.3.6-alpha6 +v0.3.5.1 v0.3.6-alpha6 diff --git a/cmd/migration-tool/migration_032_and_older.go b/cmd/migration-tool/migration_032_and_older.go index be27a5b..eef3f65 100644 --- a/cmd/migration-tool/migration_032_and_older.go +++ b/cmd/migration-tool/migration_032_and_older.go @@ -1,6 +1,7 @@ package main import ( + "database/sql" "os" "path/filepath" "strconv" @@ -94,16 +95,56 @@ func (u *migrationTool1) Migrate() error { } func (u *migrationTool1) PostMigrate() error { - _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) if err != nil { return err } + _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) + legacyConfigFile.DeleteSection("user") - return legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath) + if err := legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath); err != nil { + return err + } + + dbPath := legacyConfigFile.Section("app").Key("DBPath").String() + + dbFile := filepath.Join(dbPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") + + if _, err := os.Stat(dbFile); err != nil { + return nil + } + } + + legacyDB, err := sql.Open("sqlite3", dbFile) + if err != nil { + return err + } + + defer legacyDB.Close() + + for _, tableName := range []string{"o_users", "o_user"} { + tableExists, err := isTableExist(legacyDB, tableName) + if err != nil { + return err + } + + if !tableExists { + continue + } + + _logger.Info("Dropping `%s` table in legacy database...", tableName) + + if _, err = legacyDB.Exec("DROP TABLE " + tableName); err != nil { + _logger.Error("Failed to drop `%s` table in legacy database: %s", tableName, err) + } + } + + return nil } func NewMigrationToolFor032AndOlder() interfaces.MigrationTool { diff --git a/cmd/migration-tool/migration_033_034_035.go b/cmd/migration-tool/migration_033_034_035.go index e096767..192b571 100644 --- a/cmd/migration-tool/migration_033_034_035.go +++ b/cmd/migration-tool/migration_033_034_035.go @@ -125,6 +125,14 @@ func (u *migrationTool2) PostMigrate() error { return err } + _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) + + legacyConfigFile.DeleteSection("user") + + if err := legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath); err != nil { + return err + } + dbPath := legacyConfigFile.Section("app").Key("DBPath").String() dbFile := filepath.Join(dbPath, "db", "casaOS.db") @@ -133,7 +141,7 @@ func (u *migrationTool2) PostMigrate() error { dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") if _, err := os.Stat(dbFile); err != nil { - return err + return nil } } @@ -144,21 +152,24 @@ func (u *migrationTool2) PostMigrate() error { defer legacyDB.Close() - if tableExists, err := isTableExist(legacyDB, "o_users"); err != nil { - return err - } else if tableExists { - _logger.Info("Dropping `o_users` table in legacy database...") + for _, tableName := range []string{"o_users", "o_user"} { + tableExists, err := isTableExist(legacyDB, tableName) + if err != nil { + return err + } - if _, err = legacyDB.Exec("DROP TABLE o_users"); err != nil { - _logger.Error("Failed to drop `o_users` table in legacy database: %s", err) + if !tableExists { + continue + } + + _logger.Info("Dropping `%s` table in legacy database...", tableName) + + if _, err = legacyDB.Exec("DROP TABLE " + tableName); err != nil { + _logger.Error("Failed to drop `%s` table in legacy database: %s", tableName, err) } } - _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) - - legacyConfigFile.DeleteSection("user") - - return legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath) + return nil } func NewMigrationToolFor033_034_035() interfaces.MigrationTool { @@ -220,47 +231,54 @@ func migrateUser2(legacyConfigFile *ini.File) error { defer legacyDB.Close() - if tableExists, err := isTableExist(legacyDB, "o_users"); err != nil { - return err - } else if !tableExists { - _logger.Info("Table `o_users` not found in legacy database. Skipping...") - return nil - } - - sqlStatement := "SELECT id, username, password, role, email, nickname, avatar, description, created_at FROM o_users ORDER BY id ASC" - - rows, err := legacyDB.Query(sqlStatement) - if err != nil { - return err - } - - defer rows.Close() - newDB := sqlite.GetDb(config.AppInfo.DBPath) userService := service.NewUserService(newDB) - for rows.Next() { - if err := rows.Scan( - &user.Id, - &user.Username, - &user.Password, - &user.Role, - &user.Email, - &user.Nickname, - &user.Avatar, - &user.Description, - &user.CreatedAt, - ); err != nil { + // create an inline map from string to string + sqlTableStatementMap := make(map[string]string) + sqlTableStatementMap["o_users"] = "SELECT id, username, password, role, email, nickname, avatar, description, created_at FROM o_users ORDER BY id ASC" + sqlTableStatementMap["o_user"] = "SELECT id, user_name, password, role, email, nick_name, avatar, description, created_at FROM o_user ORDER BY id ASC" + + // historically there were two names for user table: o_users and users + for tableName, sqlStatement := range sqlTableStatementMap { + tableExists, err := isTableExist(legacyDB, tableName) + if err != nil { return err } - if userService.GetUserAllInfoByName(user.Username).Id > 0 { - _logger.Info("User %s already exists in user database at %s, skipping...", user.Username, config.AppInfo.DBPath) + if !tableExists { continue } + rows, err := legacyDB.Query(sqlStatement) + if err != nil { + return err + } - _logger.Info("Creating user %s in user database...", user.Username) - user = userService.CreateUser(user) + defer rows.Close() + + for rows.Next() { + if err := rows.Scan( + &user.Id, + &user.Username, + &user.Password, + &user.Role, + &user.Email, + &user.Nickname, + &user.Avatar, + &user.Description, + &user.CreatedAt, + ); err != nil { + return err + } + + if userService.GetUserAllInfoByName(user.Username).Id > 0 { + _logger.Info("User %s already exists in user database at %s, skipping...", user.Username, config.AppInfo.DBPath) + continue + } + + _logger.Info("Creating user %s in user database...", user.Username) + user = userService.CreateUser(user) + } } return nil diff --git a/pkg/sqlite/db.go b/pkg/sqlite/db.go index 114fe46..e767c6d 100644 --- a/pkg/sqlite/db.go +++ b/pkg/sqlite/db.go @@ -26,31 +26,20 @@ func GetDb(dbPath string) *gorm.DB { if gdb != nil { return gdb } - // Refer https://github.com/go-sql-driver/mysql#dsn-data-source-name - // dsn := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8mb4&parseTime=True&loc=Local", m.User, m.PWD, m.IP, m.Port, m.DBName) - // db, err := gorm.Open(mysql2.Open(dsn), &gorm.Config{}) + file.IsNotExistMkDir(dbPath) db, err := gorm.Open(sqlite.Open(dbPath+"/user.db"), &gorm.Config{}) + if err != nil { + panic(err) + } + c, _ := db.DB() c.SetMaxIdleConns(10) c.SetMaxOpenConns(100) c.SetConnMaxIdleTime(time.Second * 1000) - if err != nil { - logger.Error("sqlite connect error", zap.Any("db connect error", err)) - panic("sqlite connect error") - } + gdb = db - db.Exec(`alter table o_user rename to old_user; - - create table o_users ( id integer primary key,username text,password text,role text,email text,nickname text,avatar text,description text,created_at datetime,updated_at datetime); - - insert into o_users select id,user_name,password,role,email,nick_name,avatar,description,created_at,updated_at from old_user; - - drop table old_user; - drop table o_user; - `) - err = db.AutoMigrate(model2.UserDBModel{}) if err != nil { logger.Error("check or create db error", zap.Any("error", err)) From 38fee52518f19c6cf2bd43772b746ae15ac1847e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Wed, 31 Aug 2022 23:58:59 -0400 Subject: [PATCH 20/95] add migration versioning (#12) --- .../service.d/user-service/migration.list | 6 +++--- cmd/migration-tool/main.go | 7 ++++++- cmd/migration-tool/migration_032_and_older.go | 13 +++++++++++++ cmd/migration-tool/migration_033_034_035.go | 17 +++++++++++++++-- go.mod | 4 ++-- go.sum | 10 ++++++---- pkg/utils/file/file.go | 9 ++++----- route/v1/user.go | 4 ++-- 8 files changed, 51 insertions(+), 19 deletions(-) diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 63b80e8..0dd5be1 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,3 +1,3 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha6 -v0.3.5 v0.3.6-alpha6 -v0.3.5.1 v0.3.6-alpha6 +LEGACY_WITHOUT_VERSION v0.3.6-alpha7 +v0.3.5 v0.3.6-alpha7 +v0.3.5.1 v0.3.6-alpha7 diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go index d0f3bd0..f592a5e 100644 --- a/cmd/migration-tool/main.go +++ b/cmd/migration-tool/main.go @@ -8,6 +8,7 @@ import ( interfaces "github.com/IceWhaleTech/CasaOS-Common" "github.com/IceWhaleTech/CasaOS-Common/utils/systemctl" + "github.com/IceWhaleTech/CasaOS-Common/utils/version" "github.com/IceWhaleTech/CasaOS-UserService/common" ) @@ -15,12 +16,16 @@ const ( userServiceConfigDirPath = "/etc/casaos" userServiceConfigFilePath = "/etc/casaos/user-service.conf" userServiceName = "casaos-user-service.service" + userServiceNameShort = "user-service" ) //go:embedded ../../build/sysroot/etc/casaos/user-service.conf.sample var _userServiceConfigFileSample string -var _logger *Logger +var ( + _logger *Logger + _status *version.GlobalMigrationStatus +) func main() { versionFlag := flag.Bool("v", false, "version") diff --git a/cmd/migration-tool/migration_032_and_older.go b/cmd/migration-tool/migration_032_and_older.go index eef3f65..87260c6 100644 --- a/cmd/migration-tool/migration_032_and_older.go +++ b/cmd/migration-tool/migration_032_and_older.go @@ -10,6 +10,7 @@ import ( interfaces "github.com/IceWhaleTech/CasaOS-Common" "github.com/IceWhaleTech/CasaOS-Common/utils/version" + "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" @@ -22,6 +23,16 @@ import ( type migrationTool1 struct{} func (u *migrationTool1) IsMigrationNeeded() (bool, error) { + if status, err := version.GetGlobalMigrationStatus(userServiceNameShort); err == nil { + _status = status + if status.LastMigratedVersion != "" { + _logger.Info("Last migrated version: %s", status.LastMigratedVersion) + if r, err := version.Compare(status.LastMigratedVersion, common.Version); err == nil { + return r < 0, nil + } + } + } + if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) return false, nil @@ -95,6 +106,8 @@ func (u *migrationTool1) Migrate() error { } func (u *migrationTool1) PostMigrate() error { + defer _status.Done(common.Version) + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) if err != nil { return err diff --git a/cmd/migration-tool/migration_033_034_035.go b/cmd/migration-tool/migration_033_034_035.go index 192b571..fcf5ffe 100644 --- a/cmd/migration-tool/migration_033_034_035.go +++ b/cmd/migration-tool/migration_033_034_035.go @@ -8,6 +8,7 @@ import ( interfaces "github.com/IceWhaleTech/CasaOS-Common" "github.com/IceWhaleTech/CasaOS-Common/utils/version" + "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" @@ -16,11 +17,21 @@ import ( "gopkg.in/ini.v1" ) -const defaultDBPath = "/var/lib/casaos" - type migrationTool2 struct{} +const defaultDBPath = "/var/lib/casaos" + func (u *migrationTool2) IsMigrationNeeded() (bool, error) { + if status, err := version.GetGlobalMigrationStatus(userServiceNameShort); err == nil { + _status = status + if status.LastMigratedVersion != "" { + _logger.Info("Last migrated version: %s", status.LastMigratedVersion) + if r, err := version.Compare(status.LastMigratedVersion, common.Version); err == nil { + return r < 0, nil + } + } + } + if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) return false, nil @@ -120,6 +131,8 @@ func (u *migrationTool2) Migrate() error { } func (u *migrationTool2) PostMigrate() error { + defer _status.Done(common.Version) + legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) if err != nil { return err diff --git a/go.mod b/go.mod index af1b0a6..38bf209 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2 - github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5 + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 + github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 diff --git a/go.sum b/go.sum index f8b8d87..01e7a80 100644 --- a/go.sum +++ b/go.sum @@ -39,10 +39,10 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2 h1:l/f2wj7Xs1nbdhbio3ENzPT2cHuFIXuAhptqIIfndrg= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220831042533-e51a41247ea2/go.mod h1:5sqNKg5cEH7IUnCklLSTrVoGx1dMBhm9DFDsCYVPvPQ= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5 h1:aRDy7ug77eZN19vqRjH1N6HHYuzYUnwp9ByMwdfnmJw= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha5/go.mod h1:v2d+VlVMF6i0XPGRJbmUt1b270J8kn1+pV5xmCJFrXk= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 h1:q4I/lSsCooxdd6LxinGy90y0n6V8EcaPBV1JCfpEnV4= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6 h1:3xTv3ACQItJph1EwTaq0qTThCIKodsU7Ej/ntLyXIMA= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -611,6 +611,8 @@ gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMT gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pkg/utils/file/file.go b/pkg/utils/file/file.go index 9948a07..93bf307 100644 --- a/pkg/utils/file/file.go +++ b/pkg/utils/file/file.go @@ -2,7 +2,6 @@ package file import ( "io" - "io/ioutil" "os" "path" "strings" @@ -36,7 +35,7 @@ func MkDir(src string) error { if err != nil { return err } - os.Chmod(src, 0777) + os.Chmod(src, 0o777) return nil } @@ -53,7 +52,7 @@ func IsNotExistCreateFile(src string) error { } func Exists(path string) bool { - _, err := os.Stat(path) //os.Stat获取文件信息 + _, err := os.Stat(path) // os.Stat获取文件信息 if err != nil { return os.IsExist(err) } @@ -75,7 +74,7 @@ func ReadFullFile(path string) []byte { return []byte("") } defer file.Close() - content, err := ioutil.ReadAll(file) + content, err := io.ReadAll(file) if err != nil { return []byte("") } @@ -134,7 +133,7 @@ func WriteToPath(data []byte, path, name string) error { IsNotExistCreateFile(fullPath) file, err := os.OpenFile(fullPath, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, - 0666, + 0o666, ) if err != nil { return err diff --git a/route/v1/user.go b/route/v1/user.go index 1ab5077..6aedd2d 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -2,7 +2,7 @@ package v1 import ( json2 "encoding/json" - "io/ioutil" + "io" "net/http" url2 "net/url" "os" @@ -418,7 +418,7 @@ func PostUserCustomConf(c *gin.Context) { model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) return } - data, _ := ioutil.ReadAll(c.Request.Body) + data, _ := io.ReadAll(c.Request.Body) filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) file.WriteToPath(data, filePath, name+".json") From 7b3bdbbf8ac4240b72331cb1b73487145310ae3e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 1 Sep 2022 17:34:37 +0000 Subject: [PATCH 21/95] cleanup setup and migration scripts --- .../script.d/02-migrate-user-service.sh | 32 ++++++++++++------- .../setup/script.d/02-setup-user-service.sh | 8 +++-- .../user-service/debian/setup-user-service.sh | 10 +++--- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh index 3e95f2a..9e35a0e 100644 --- a/build/scripts/migration/script.d/02-migrate-user-service.sh +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -58,29 +58,37 @@ __is_migration_needed() { } BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. -SOURCE_ROOT=${BUILD_PATH}/sysroot -APP_NAME="casaos-user-service" -APP_NAME_FORMAL="CasaOS-UserService" -APP_NAME_SHORT="user-service" -APP_NAME_LEGACY="casaos" +readonly BUILD_PATH +readonly SOURCE_ROOT=${BUILD_PATH}/sysroot + +readonly APP_NAME="casaos-user-service" +readonly APP_NAME_FORMAL="CasaOS-UserService" +readonly APP_NAME_SHORT="user-service" +readonly APP_NAME_LEGACY="casaos" # check if migration is needed -SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin -SOURCE_BIN_FILE=${SOURCE_BIN_PATH}/${APP_NAME} +readonly SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin +readonly SOURCE_BIN_FILE=${SOURCE_BIN_PATH}/${APP_NAME} + +readonly CURRENT_BIN_PATH=/usr/bin +readonly CURRENT_BIN_PATH_LEGACY=/usr/local/bin +readonly CURRENT_BIN_FILE=${CURRENT_BIN_PATH}/${APP_NAME} -CURRENT_BIN_PATH=/usr/bin -CURRENT_BIN_PATH_LEGACY=/usr/local/bin -CURRENT_BIN_FILE=${CURRENT_BIN_PATH}/${APP_NAME} CURRENT_BIN_FILE_LEGACY=$(realpath -e ${CURRENT_BIN_PATH}/${APP_NAME_LEGACY} || realpath -e ${CURRENT_BIN_PATH_LEGACY}/${APP_NAME_LEGACY} || which ${APP_NAME_LEGACY} || echo CURRENT_BIN_FILE_LEGACY_NOT_FOUND) +readonly CURRENT_BIN_FILE_LEGACY SOURCE_VERSION="$(${SOURCE_BIN_FILE} -v)" +readonly SOURCE_VERSION + CURRENT_VERSION="$(${CURRENT_BIN_FILE} -v || ${CURRENT_BIN_FILE_LEGACY} -v || (stat "${CURRENT_BIN_FILE_LEGACY}" > /dev/null && echo LEGACY_WITHOUT_VERSION) || echo CURRENT_VERSION_NOT_FOUND)" +readonly CURRENT_VERSION __info_done "CURRENT_VERSION: ${CURRENT_VERSION}" __info_done "SOURCE_VERSION: ${SOURCE_VERSION}" NEED_MIGRATION=$(__is_migration_needed "${CURRENT_VERSION}" "${SOURCE_VERSION}" && echo "true" || echo "false") +readonly NEED_MIGRATION if [ "${NEED_MIGRATION}" = "false" ]; then __info_done "Migration is not needed." @@ -93,9 +101,9 @@ if [ -z "${MIGRATION_SERVICE_DIR}" ]; then MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} fi -MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list -MIGRATION_PATH=() +readonly MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list +MIGRATION_PATH=() CURRENT_VERSION_FOUND="false" # a VERSION_PAIR looks like "v0.3.5 v0.3.6-alpha2" diff --git a/build/scripts/setup/script.d/02-setup-user-service.sh b/build/scripts/setup/script.d/02-setup-user-service.sh index 3553c72..93a3474 100755 --- a/build/scripts/setup/script.d/02-setup-user-service.sh +++ b/build/scripts/setup/script.d/02-setup-user-service.sh @@ -4,7 +4,8 @@ set -e BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. -APP_NAME_SHORT=user-service +readonly BUILD_PATH +readonly APP_NAME_SHORT=user-service __get_setup_script_directory_by_os_release() { pushd "$(dirname "${BASH_SOURCE[0]}")/../service.d/${APP_NAME_SHORT}" >/dev/null @@ -39,9 +40,10 @@ __get_setup_script_directory_by_os_release() { } SETUP_SCRIPT_DIRECTORY=$(__get_setup_script_directory_by_os_release) -SETUP_SCRIPT_FILENAME="setup-${APP_NAME_SHORT}.sh" -SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}" +readonly SETUP_SCRIPT_DIRECTORY +readonly SETUP_SCRIPT_FILENAME="setup-${APP_NAME_SHORT}.sh" +readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}" { echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..." diff --git a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh index 0e5494f..98d262b 100644 --- a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh +++ b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh @@ -2,13 +2,13 @@ set -e -APP_NAME="casaos-user-service" -APP_NAME_SHORT="user-service" +readonly APP_NAME="casaos-user-service" +readonly APP_NAME_SHORT="user-service" # copy config files -CONF_PATH=/etc/casaos -CONF_FILE=${CONF_PATH}/${APP_NAME_SHORT}.conf -CONF_FILE_SAMPLE=${CONF_PATH}/${APP_NAME_SHORT}.conf.sample +readonly CONF_PATH=/etc/casaos +readonly CONF_FILE=${CONF_PATH}/${APP_NAME_SHORT}.conf +readonly CONF_FILE_SAMPLE=${CONF_PATH}/${APP_NAME_SHORT}.conf.sample if [ ! -f "${CONF_FILE}" ]; then \ echo "Initializing config file..." From e141c51b9391b37755a03349b5d7cd35d7d9445d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 1 Sep 2022 17:37:38 +0000 Subject: [PATCH 22/95] bump version to v0.3.6 --- .../scripts/migration/service.d/user-service/migration.list | 6 +++--- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 0dd5be1..2035e42 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,3 +1,3 @@ -LEGACY_WITHOUT_VERSION v0.3.6-alpha7 -v0.3.5 v0.3.6-alpha7 -v0.3.5.1 v0.3.6-alpha7 +LEGACY_WITHOUT_VERSION v0.3.6 +v0.3.5 v0.3.6 +v0.3.5.1 v0.3.6 diff --git a/go.mod b/go.mod index 38bf209..a112453 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 - github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6 + github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 diff --git a/go.sum b/go.sum index 01e7a80..2ff75d7 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 h1:q4I/lSsCooxdd6LxinGy90y0n6V8EcaPBV1JCfpEnV4= github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6 h1:3xTv3ACQItJph1EwTaq0qTThCIKodsU7Ej/ntLyXIMA= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From 931d466df6149d47ddf27b750eec8dd0747f58c1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 1 Sep 2022 23:09:54 +0000 Subject: [PATCH 23/95] minor code cleanup --- main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.go b/main.go index f4d2257..dc49ed7 100644 --- a/main.go +++ b/main.go @@ -18,10 +18,7 @@ import ( "go.uber.org/zap" ) -const ( - version = "0.3.6" - localhost = "127.0.0.1" -) +const localhost = "127.0.0.1" func init() { configFlag := flag.String("c", "", "config address") From ace8e30dfb6a3dd5e9ab7776a9012a32b7e93e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Tue, 6 Sep 2022 19:13:00 -0400 Subject: [PATCH 24/95] fix service startup issue (#13) - update service to be ready only when initialization is completed - remove starting service within setup script (let calling script to start the service instead) --- .../service.d/user-service/debian/setup-user-service.sh | 4 ++-- .../usr/lib/systemd/system/casaos-user-service.service | 2 ++ go.mod | 3 +++ go.sum | 8 ++++++++ main.go | 9 +++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh index 98d262b..93739aa 100644 --- a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh +++ b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh @@ -21,5 +21,5 @@ systemctl daemon-reload echo "Enabling service..." systemctl enable --force --no-ask-password "${APP_NAME}.service" -echo "Starting service..." -systemctl start --force --no-ask-password "${APP_NAME}.service" +#echo "Starting service..." +#systemctl start --force --no-ask-password "${APP_NAME}.service" diff --git a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service index 4a46e82..41f6325 100644 --- a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service +++ b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service @@ -4,9 +4,11 @@ ConditionFileNotEmpty=/etc/casaos/user-service.conf Description=CasaOS User Service [Service] +ExecStartPre=/usr/bin/casaos-user-service -v ExecStart=/usr/bin/casaos-user-service -c /etc/casaos/user-service.conf PIDFile=/var/run/casaos/user-service.pid Restart=always +Type=notify [Install] WantedBy=multi-user.target diff --git a/go.mod b/go.mod index a112453..191245f 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.19 require ( github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 + github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 github.com/satori/go.uuid v1.2.0 @@ -59,6 +60,8 @@ require ( github.com/ulikunitz/xz v0.5.9 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect go.uber.org/atomic v1.9.0 // indirect + go.uber.org/dig v1.14.0 // indirect + go.uber.org/fx v1.17.1 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect diff --git a/go.sum b/go.sum index 2ff75d7..1d1c547 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,8 @@ github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 h1:q4I/ github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.7-0.20220906162414-f612e28aa31e h1:+I3ozIDXV+XC2afZ8vwK+EI5UTgPln1c1joZgQlD9Mk= +github.com/IceWhaleTech/CasaOS-Gateway v0.3.7-0.20220906162414-f612e28aa31e/go.mod h1:N4nEyNgJ9RzSCWHStLSgQhHt3uua2Vnn+CP8fY3j6Kg= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -56,6 +58,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -284,6 +288,10 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/dig v1.14.0 h1:VmGvIH45/aapXPQkaOrK5u4B5B7jxZB98HM/utx0eME= +go.uber.org/dig v1.14.0/go.mod h1:jHAn/z1Ld1luVVyGKOAIFYz/uBFqKjjEEdIqVAqfQ2o= +go.uber.org/fx v1.17.1 h1:S42dZ6Pok8hQ3jxKwo6ZMYcCgHQA/wAS/gnpRa1Pksg= +go.uber.org/fx v1.17.1/go.mod h1:yO7KN5rhlARljyo4LR047AjaV6J+KFzd/Z7rnTbEn0A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= diff --git a/main.go b/main.go index dc49ed7..e410fcd 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/random" "github.com/IceWhaleTech/CasaOS-UserService/route" "github.com/IceWhaleTech/CasaOS-UserService/service" + "github.com/coreos/go-systemd/daemon" "go.uber.org/zap" ) @@ -84,6 +85,14 @@ func main() { panic(err) } + if supported, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil { + logger.Error("Failed to notify systemd that user service is ready", zap.Any("error", err)) + } else if supported { + logger.Info("Notified systemd that user service is ready") + } else { + logger.Info("This process is not running as a systemd service.") + } + logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) err = http.Serve(listener, r) if err != nil { From 828fd3b8f55498f44d728e6b6b705f6ece2dd7ff Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 6 Sep 2022 23:17:09 +0000 Subject: [PATCH 25/95] cleanup mod --- go.mod | 2 -- go.sum | 6 ------ 2 files changed, 8 deletions(-) diff --git a/go.mod b/go.mod index 191245f..b9d778a 100644 --- a/go.mod +++ b/go.mod @@ -60,8 +60,6 @@ require ( github.com/ulikunitz/xz v0.5.9 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect go.uber.org/atomic v1.9.0 // indirect - go.uber.org/dig v1.14.0 // indirect - go.uber.org/fx v1.17.1 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect diff --git a/go.sum b/go.sum index 1d1c547..de19462 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,6 @@ github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 h1:q4I/ github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.7-0.20220906162414-f612e28aa31e h1:+I3ozIDXV+XC2afZ8vwK+EI5UTgPln1c1joZgQlD9Mk= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.7-0.20220906162414-f612e28aa31e/go.mod h1:N4nEyNgJ9RzSCWHStLSgQhHt3uua2Vnn+CP8fY3j6Kg= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -288,10 +286,6 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/dig v1.14.0 h1:VmGvIH45/aapXPQkaOrK5u4B5B7jxZB98HM/utx0eME= -go.uber.org/dig v1.14.0/go.mod h1:jHAn/z1Ld1luVVyGKOAIFYz/uBFqKjjEEdIqVAqfQ2o= -go.uber.org/fx v1.17.1 h1:S42dZ6Pok8hQ3jxKwo6ZMYcCgHQA/wAS/gnpRa1Pksg= -go.uber.org/fx v1.17.1/go.mod h1:yO7KN5rhlARljyo4LR047AjaV6J+KFzd/Z7rnTbEn0A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= From 58ce3d1210cad951d3be96e1993c756619aae0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Fri, 9 Sep 2022 09:00:49 -0400 Subject: [PATCH 26/95] fix migration from v0.3.5 (#14) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b9d778a..bdef3e7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 + github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5 github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/gin-contrib/gzip v0.0.6 diff --git a/go.sum b/go.sum index de19462..29a9bc1 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9 h1:q4I/lSsCooxdd6LxinGy90y0n6V8EcaPBV1JCfpEnV4= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5 h1:vgAf0jVKCBo3wyjOZ4z9tB77lVrgIfz2CcQX2+4JTSI= +github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg= github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= From 71e4f36c42035e618edeaf426873785b597b37c7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 16 Sep 2022 02:48:38 -0400 Subject: [PATCH 27/95] wip (#15) --- route/v1/user.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/route/v1/user.go b/route/v1/user.go index 6aedd2d..773502d 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -421,7 +421,18 @@ func PostUserCustomConf(c *gin.Context) { data, _ := io.ReadAll(c.Request.Body) filePath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) - file.WriteToPath(data, filePath, name+".json") + if err := file.IsNotExistMkDir(filePath); err != nil { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)}) + return + } + + if err := file.WriteToPath(data, filePath, name+".json"); err != nil { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR)}) + return + } + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))}) } From 8fcaee063debc46d69fc604b0d8760dcabf7a50b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Sep 2022 23:10:17 -0400 Subject: [PATCH 28/95] add go test to goreleaser --- .goreleaser.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a39f536..abba285 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,8 +3,8 @@ project_name: casaos-user-service before: hooks: - # You may remove this if you don't use go modules. - go mod tidy + - go test -v ./... builds: - id: casaos-user-service-amd64 binary: build/sysroot/usr/bin/casaos-user-service @@ -131,15 +131,15 @@ archives: files: - build/sysroot/etc/**/* checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ incpatch .Version }}-snapshot" changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" release: github: owner: IceWhaleTech From 0d7fee0cb1a4d2bfa3d16e9927c1d96e65a3b5e4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 28 Sep 2022 17:30:34 -0400 Subject: [PATCH 29/95] fix gosec G114/G112 --- common/version.go | 2 +- main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/version.go b/common/version.go index 6564be8..ebc0f4c 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.3.6" +const Version = "0.3.7" diff --git a/main.go b/main.go index e410fcd..03822e7 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "net" "net/http" "os" + "time" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-Gateway/common" @@ -94,7 +95,13 @@ func main() { } logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) - err = http.Serve(listener, r) + + s := &http.Server{ + Handler: r, + ReadHeaderTimeout: 5 * time.Second, // fix G112: Potential slowloris attack (see https://github.com/securego/gosec) + } + + err = s.Serve(listener) // not using http.serve() to fix G114: Use of net/http serve function that has no support for setting timeouts (see https://github.com/securego/gosec) if err != nil { panic(err) } From 58a10d2200f948f4ef6decc8fdfd8ecc0df2d123 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 28 Sep 2022 17:38:35 -0400 Subject: [PATCH 30/95] fix incorrect version reference --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 03822e7..13bb435 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,8 @@ import ( "time" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" - "github.com/IceWhaleTech/CasaOS-Gateway/common" + gatewayCommon "github.com/IceWhaleTech/CasaOS-Gateway/common" + "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" @@ -77,7 +78,7 @@ func main() { panic(err) } - err = service.MyService.Gateway().CreateRoute(&common.Route{ + err = service.MyService.Gateway().CreateRoute(&gatewayCommon.Route{ Path: "/v1/users", Target: "http://" + listener.Addr().String(), }) From 06ec3d5142e82c771c4ba50344790cddd2348bad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 20 Oct 2022 21:07:35 -0400 Subject: [PATCH 31/95] add cleanup script for future uninstall modularization (#16) --- .../script.d/02-migrate-user-service.sh | 96 +++++++-------- .../service.d/user-service/migration.list | 6 +- .../user-service/debian/setup-user-service.sh | 5 +- .../script.d/02-cleanup-user-service.sh | 46 ++++++++ .../debian/bullseye/cleanup-user-service.sh | 1 + .../debian/cleanup-user-service.sh | 109 ++++++++++++++++++ .../ubuntu/cleanup-user-service.sh | 1 + .../ubuntu/jammy/cleanup-user-service.sh | 1 + 8 files changed, 210 insertions(+), 55 deletions(-) create mode 100755 build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh create mode 120000 build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/bullseye/cleanup-user-service.sh create mode 100644 build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/cleanup-user-service.sh create mode 120000 build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/cleanup-user-service.sh create mode 120000 build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/jammy/cleanup-user-service.sh diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh index 9e35a0e..cb82b6f 100644 --- a/build/scripts/migration/script.d/02-migrate-user-service.sh +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -63,7 +63,6 @@ readonly BUILD_PATH readonly SOURCE_ROOT=${BUILD_PATH}/sysroot readonly APP_NAME="casaos-user-service" -readonly APP_NAME_FORMAL="CasaOS-UserService" readonly APP_NAME_SHORT="user-service" readonly APP_NAME_LEGACY="casaos" @@ -95,46 +94,6 @@ if [ "${NEED_MIGRATION}" = "false" ]; then exit 0 fi -MIGRATION_SERVICE_DIR=${1} - -if [ -z "${MIGRATION_SERVICE_DIR}" ]; then - MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} -fi - -readonly MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list - -MIGRATION_PATH=() -CURRENT_VERSION_FOUND="false" - -# a VERSION_PAIR looks like "v0.3.5 v0.3.6-alpha2" -# -# - "v0.3.5" is the current version installed on this host -# - "v0.3.6-alpha2" is the version of the migration tool from GitHub -while read -r VERSION_PAIR; do - if [ -z "${VERSION_PAIR}" ]; then - continue - fi - - # obtain "v0.3.5" from "v0.3.5 v0.3.6-alpha2" - VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1) - - # obtain "v0.3.6-alpha2" from "v0.3.5 v0.3.6-alpha2" - VER2=$(echo "${VERSION_PAIR}" | cut -d' ' -f2) - - if [ "${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then - CURRENT_VERSION_FOUND="true" - fi - - if [ "${CURRENT_VERSION_FOUND}" = "true" ]; then - MIGRATION_PATH+=("${VER2// /}") - fi -done < "${MIGRATION_LIST_FILE}" - -if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then - __warning "No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}" - exit 0 -fi - ARCH="unknown" case $(uname -m) in @@ -152,20 +111,61 @@ case $(uname -m) in ;; esac +__info "ARCH: ${ARCH}" + +MIGRATION_SERVICE_DIR=${1} + +if [ -z "${MIGRATION_SERVICE_DIR}" ]; then + MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME_SHORT} +fi + +readonly MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list + +MIGRATION_PATH=() +CURRENT_VERSION_FOUND="false" + +# a VERSION_PAIR looks like "v0.3.5 " +# +# - "v0.3.5" is the current version installed on this host +# - "" is the url of the migration tool +while read -r VERSION_PAIR; do + if [ -z "${VERSION_PAIR}" ]; then + continue + fi + + # obtain "v0.3.5" from "v0.3.5 v0.3.6-alpha2" + VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1) + + # obtain "" from "v0.3.5 " + URL=$(eval echo "${VERSION_PAIR}" | cut -d' ' -f2) + + if [ "${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then + CURRENT_VERSION_FOUND="true" + fi + + if [ "${CURRENT_VERSION_FOUND}" = "true" ]; then + MIGRATION_PATH+=("${URL// /}") + fi +done < "${MIGRATION_LIST_FILE}" + +if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then + __warning "No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}" + exit 0 +fi + pushd "${MIGRATION_SERVICE_DIR}" { - for VER2 in "${MIGRATION_PATH[@]}"; do - MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + for URL in "${MIGRATION_PATH[@]}"; do + MIGRATION_TOOL_FILE=$(basename "${URL}") if [ -f "${MIGRATION_TOOL_FILE}" ]; then __info "Migration tool ${MIGRATION_TOOL_FILE} exists. Skip downloading." continue fi - MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz - __info "Dowloading ${MIGRATION_TOOL_URL}..." - curl -sL -O "${MIGRATION_TOOL_URL}" + __info "Dowloading ${URL}..." + curl -fsSL -o "${MIGRATION_TOOL_FILE}" -O "${URL}" done } || { popd @@ -173,8 +173,8 @@ pushd "${MIGRATION_SERVICE_DIR}" } { - for VER2 in "${MIGRATION_PATH[@]}"; do - MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + for URL in "${MIGRATION_PATH[@]}"; do + MIGRATION_TOOL_FILE=$(basename "${URL}") __info "Extracting ${MIGRATION_TOOL_FILE}..." tar zxvf "${MIGRATION_TOOL_FILE}" || __error "Failed to extract ${MIGRATION_TOOL_FILE}" diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 2035e42..2bcb2f3 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,3 +1,3 @@ -LEGACY_WITHOUT_VERSION v0.3.6 -v0.3.5 v0.3.6 -v0.3.5.1 v0.3.6 +LEGACY_WITHOUT_VERSION https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz +v0.3.5 https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz +v0.3.5.1 https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz diff --git a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh index 93739aa..86e7b09 100644 --- a/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh +++ b/build/scripts/setup/service.d/user-service/debian/setup-user-service.sh @@ -15,11 +15,8 @@ if [ ! -f "${CONF_FILE}" ]; then \ cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"; \ fi -# enable and start service systemctl daemon-reload +# enable service (without starting) echo "Enabling service..." systemctl enable --force --no-ask-password "${APP_NAME}.service" - -#echo "Starting service..." -#systemctl start --force --no-ask-password "${APP_NAME}.service" diff --git a/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh new file mode 100755 index 0000000..2a4f03c --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +readonly APP_NAME_SHORT=user-service + +__get_setup_script_directory_by_os_release() { + pushd "$(dirname "${BASH_SOURCE[0]}")/../service.d/${APP_NAME_SHORT}" &>/dev/null + + { + # shellcheck source=/dev/null + { + source /etc/os-release + { + pushd "${ID}"/"${VERSION_CODENAME}" &>/dev/null + } || { + pushd "${ID}" &>/dev/null + } || { + pushd "${ID_LIKE}" &>/dev/null + } || { + echo "Unsupported OS: ${ID} ${VERSION_CODENAME} (${ID_LIKE})" + exit 1 + } + + pwd + + popd &>/dev/null + + } || { + echo "Unsupported OS: unknown" + exit 1 + } + + } + + popd &>/dev/null +} + +SETUP_SCRIPT_DIRECTORY=$(__get_setup_script_directory_by_os_release) + +readonly SETUP_SCRIPT_DIRECTORY +readonly SETUP_SCRIPT_FILENAME="cleanup-${APP_NAME_SHORT}.sh" +readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}" + +echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..." +$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" diff --git a/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/bullseye/cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/bullseye/cleanup-user-service.sh new file mode 120000 index 0000000..4062f1d --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/bullseye/cleanup-user-service.sh @@ -0,0 +1 @@ +../cleanup-user-service.sh \ No newline at end of file diff --git a/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/cleanup-user-service.sh new file mode 100644 index 0000000..f39f4ad --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/debian/cleanup-user-service.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +set -e + +readonly CASA_EXEC=casaos-user-service +readonly CASA_SERVICE=casaos-user-service.service + +CASA_SERVICE_PATH=$(systemctl show ${CASA_SERVICE} --no-pager --property FragmentPath | cut -d'=' -sf2) +readonly CASA_SERVICE_PATH + +CASA_CONF=$( grep -i ExecStart= "${CASA_SERVICE_PATH}" | cut -d'=' -sf2 | cut -d' ' -sf3) +if [[ -z "${CASA_CONF}" ]]; then + CASA_CONF=/etc/casaos/user-service.conf +fi + +CASA_DB_PATH=$( (grep -i dbpath "${CASA_CONF}" || echo "/var/lib/casaos/db") | cut -d'=' -sf2 | xargs ) +readonly CASA_DB_PATH + +CASA_DB_FILE=${CASA_DB_PATH}/user-service.db + +readonly aCOLOUR=( + '\e[38;5;154m' # green | Lines, bullets and separators + '\e[1m' # Bold white | Main descriptions + '\e[90m' # Grey | Credits + '\e[91m' # Red | Update notifications Alert + '\e[33m' # Yellow | Emphasis +) + +Show() { + # OK + if (($1 == 0)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # FAILED + elif (($1 == 1)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # INFO + elif (($1 == 2)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # NOTICE + elif (($1 == 3)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + fi +} + +Warn() { + echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" +} + +trap 'onCtrlC' INT +onCtrlC() { + echo -e "${COLOUR_RESET}" + exit 1 +} + +if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then + Show 2 "${CASA_EXEC} is not detected, exit the script." + exit 1 +fi + +while true; do + echo -n -e " ${aCOLOUR[4]}Do you want delete user database? Y/n :${COLOUR_RESET}" + read -r input + case $input in + [yY][eE][sS] | [yY]) + REMOVE_USER_DATABASE=true + break + ;; + [nN][oO] | [nN]) + REMOVE_USER_DATABASE=false + break + ;; + *) + echo -e " ${aCOLOUR[3]}Invalid input, please try again.${COLOUR_RESET}" + ;; + esac +done + +while true; do + echo -n -e " ${aCOLOUR[4]}Do you want delete user directory? Y/n :${COLOUR_RESET}" + read -r input + case $input in + [yY][eE][sS] | [yY]) + REMOVE_USER_DIRECTORY=true + break + ;; + [nN][oO] | [nN]) + REMOVE_USER_DIRECTORY=false + break + ;; + *) + echo -e " ${aCOLOUR[3]}Invalid input, please try again.${COLOUR_RESET}" + ;; + esac +done + +Show 2 "Stopping ${CASA_SERVICE}..." +systemctl disable --now "${CASA_SERVICE}" || Show 3 "Failed to disable ${CASA_SERVICE}" + +rm -rvf "$(which ${CASA_EXEC})" || Show 3 "Failed to remove ${CASA_EXEC}" +rm -rvf "${CASA_CONF}" || Show 3 "Failed to remove ${CASA_CONF}" + +if [[ "${REMOVE_USER_DATABASE}" == true ]]; then + rm -rvf "${CASA_DB_FILE}" || Show 3 "Failed to remove ${CASA_DB_FILE}" +fi + +if [[ "${REMOVE_USER_DIRECTORY}" == true ]]; then + Show 2 "Removing user directories..." + rm -rvf /var/lib/casaos/[1-9]* +fi diff --git a/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/cleanup-user-service.sh new file mode 120000 index 0000000..3aeecd6 --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/cleanup-user-service.sh @@ -0,0 +1 @@ +../debian/cleanup-user-service.sh \ No newline at end of file diff --git a/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/jammy/cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/jammy/cleanup-user-service.sh new file mode 120000 index 0000000..f1d1773 --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/ubuntu/jammy/cleanup-user-service.sh @@ -0,0 +1 @@ +../../debian/bullseye/cleanup-user-service.sh \ No newline at end of file From 86a8c845c64a11d27e8c1026697d01f669ede161 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 21 Oct 2022 13:41:41 -0400 Subject: [PATCH 32/95] use $BASH instead of $SHELL in setup and cleanup script in case of running under non-bash shell. (#17) fixes https://github.com/IceWhaleTech/CasaOS/issues/572 --- build/scripts/setup/script.d/02-setup-user-service.sh | 2 +- .../share/casaos/cleanup/script.d/02-cleanup-user-service.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/setup/script.d/02-setup-user-service.sh b/build/scripts/setup/script.d/02-setup-user-service.sh index 93a3474..a7bdb04 100755 --- a/build/scripts/setup/script.d/02-setup-user-service.sh +++ b/build/scripts/setup/script.d/02-setup-user-service.sh @@ -47,7 +47,7 @@ readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAM { echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..." - $SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" + $BASH "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" } || { echo "🟥 ${SETUP_SCRIPT_FILENAME} failed." exit 1 diff --git a/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh index 2a4f03c..5a50659 100755 --- a/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh +++ b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh @@ -43,4 +43,4 @@ readonly SETUP_SCRIPT_FILENAME="cleanup-${APP_NAME_SHORT}.sh" readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}" echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..." -$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" +$BASH "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}" From 1813afe0aec07993fba05a68d17456b26ec20921 Mon Sep 17 00:00:00 2001 From: link Date: Wed, 26 Oct 2022 17:05:01 +0800 Subject: [PATCH 33/95] Update release.yml Signed-off-by: link --- .github/workflows/release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f92f949..69986d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,9 @@ jobs: - name: Fetch all tags run: git fetch --force --tags + - name: Get version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Set up Go uses: actions/setup-go@v2 @@ -45,3 +48,16 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + - name: Upload to oss + id: upload_to_oss + uses: tvrcgo/upload-to-oss@master + with: + key-id: ${{ secrets.OSS_KEY_ID }} + key-secret: ${{ secrets.OSS_KEY_SECRET }} + region: oss-cn-shanghai + bucket: casaos + assets: | + dist/checksums.txt:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt + dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz From f112ed17834ff4ee050cc32f3a3f933ec21e882d Mon Sep 17 00:00:00 2001 From: link Date: Wed, 26 Oct 2022 17:09:42 +0800 Subject: [PATCH 34/95] Update release.yml Signed-off-by: link --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69986d8..be32650 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,6 +58,6 @@ jobs: bucket: casaos assets: | dist/checksums.txt:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt - dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz From 2866ad73b5d2088b07cfc24ea848028fdd8079d8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 28 Oct 2022 17:28:04 -0400 Subject: [PATCH 35/95] change to use CasaOS-Common for calling gateway (#18) --- go.mod | 15 +- go.sum | 429 +-------------------------------------------- main.go | 4 +- service/service.go | 10 +- 4 files changed, 10 insertions(+), 448 deletions(-) diff --git a/go.mod b/go.mod index bdef3e7..f16e038 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5 - github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 + github.com/IceWhaleTech/CasaOS-Common v0.3.7-1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 @@ -21,7 +20,6 @@ require ( github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect @@ -30,30 +28,20 @@ require ( github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/golang/snappy v0.0.2 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.13.6 // indirect github.com/klauspost/pgzip v1.2.5 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-sqlite3 v1.14.14 // indirect github.com/mholt/archiver/v3 v3.5.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/nwaples/rardecode v1.1.0 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect github.com/pierrec/lz4/v4 v4.1.2 // indirect - github.com/spf13/afero v1.8.2 // indirect - github.com/spf13/cast v1.5.0 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.12.0 // indirect - github.com/subosito/gotenv v1.3.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect @@ -68,5 +56,4 @@ require ( google.golang.org/protobuf v1.28.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // 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 29a9bc1..3c08694 100644 --- a/go.sum +++ b/go.sum @@ -1,61 +1,11 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5 h1:vgAf0jVKCBo3wyjOZ4z9tB77lVrgIfz2CcQX2+4JTSI= -github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220909125858-92fc5b2e0ae5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg= -github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA= +github.com/IceWhaleTech/CasaOS-Common v0.3.7-1 h1:paay9dFGAWjNcjtCrN6ymvuU21KtxPoIpNG3wo10ufk= +github.com/IceWhaleTech/CasaOS-Common v0.3.7-1/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -67,24 +17,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -101,72 +39,12 @@ github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -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 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= @@ -174,9 +52,6 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= @@ -184,7 +59,6 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -195,8 +69,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= -github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -204,8 +76,6 @@ github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLv github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -213,8 +83,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= @@ -223,41 +91,22 @@ github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuR github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= -github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= -github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -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.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= -github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -272,17 +121,7 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -294,300 +133,48 @@ go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95a go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8= golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= @@ -600,7 +187,6 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -613,15 +199,4 @@ gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMT gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/main.go b/main.go index 13bb435..3953cf6 100644 --- a/main.go +++ b/main.go @@ -8,8 +8,8 @@ import ( "os" "time" + "github.com/IceWhaleTech/CasaOS-Common/model" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" - gatewayCommon "github.com/IceWhaleTech/CasaOS-Gateway/common" "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" @@ -78,7 +78,7 @@ func main() { panic(err) } - err = service.MyService.Gateway().CreateRoute(&gatewayCommon.Route{ + err = service.MyService.Gateway().CreateRoute(&model.Route{ Path: "/v1/users", Target: "http://" + listener.Addr().String(), }) diff --git a/service/service.go b/service/service.go index 8d7f9db..bb5b4f6 100644 --- a/service/service.go +++ b/service/service.go @@ -1,20 +1,20 @@ package service import ( - gateway "github.com/IceWhaleTech/CasaOS-Gateway/common" + "github.com/IceWhaleTech/CasaOS-Common/external" "gorm.io/gorm" ) var MyService Repository type Repository interface { - Gateway() gateway.ManagementService + Gateway() external.ManagementService User() UserService } func NewService(db *gorm.DB, RuntimePath string) Repository { - gatewayManagement, err := gateway.NewManagementService(RuntimePath) + gatewayManagement, err := external.NewManagementService(RuntimePath) if err != nil { panic(err) } @@ -26,11 +26,11 @@ func NewService(db *gorm.DB, RuntimePath string) Repository { } type store struct { - gateway gateway.ManagementService + gateway external.ManagementService user UserService } -func (c *store) Gateway() gateway.ManagementService { +func (c *store) Gateway() external.ManagementService { return c.gateway } From 7da057088cc182fe8285697d1a2f4e26da5d3a72 Mon Sep 17 00:00:00 2001 From: link Date: Mon, 31 Oct 2022 14:43:36 +0800 Subject: [PATCH 36/95] Update release.yml Signed-off-by: link --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index be32650..188441f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,3 +61,6 @@ jobs: dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-arm-7--casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-arm64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz + dist/linux-amd64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz From e2d9ecf2299dca7f65de094e552276286d7bb417 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Nov 2022 11:05:42 -0400 Subject: [PATCH 37/95] bump version and cleanup migration tool for previous version (#19) --- cmd/migration-tool/main.go | 13 +- cmd/migration-tool/migration_032_and_older.go | 262 --------------- cmd/migration-tool/migration_033_034_035.go | 309 ------------------ cmd/migration-tool/migration_dummy.go | 27 ++ common/version.go | 2 +- go.mod | 10 - go.sum | 26 -- 7 files changed, 33 insertions(+), 616 deletions(-) delete mode 100644 cmd/migration-tool/migration_032_and_older.go delete mode 100644 cmd/migration-tool/migration_033_034_035.go create mode 100644 cmd/migration-tool/migration_dummy.go diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go index f592a5e..e725a57 100644 --- a/cmd/migration-tool/main.go +++ b/cmd/migration-tool/main.go @@ -8,7 +8,6 @@ import ( interfaces "github.com/IceWhaleTech/CasaOS-Common" "github.com/IceWhaleTech/CasaOS-Common/utils/systemctl" - "github.com/IceWhaleTech/CasaOS-Common/utils/version" "github.com/IceWhaleTech/CasaOS-UserService/common" ) @@ -20,12 +19,11 @@ const ( ) //go:embedded ../../build/sysroot/etc/casaos/user-service.conf.sample -var _userServiceConfigFileSample string +//var _userServiceConfigFileSample string -var ( - _logger *Logger - _status *version.GlobalMigrationStatus -) +var _logger *Logger + +// var _status *version.GlobalMigrationStatus func main() { versionFlag := flag.Bool("v", false, "version") @@ -63,8 +61,7 @@ func main() { } migrationTools := []interfaces.MigrationTool{ - NewMigrationToolFor032AndOlder(), - NewMigrationToolFor033_034_035(), + NewMigrationDummy(), } var selectedMigrationTool interfaces.MigrationTool diff --git a/cmd/migration-tool/migration_032_and_older.go b/cmd/migration-tool/migration_032_and_older.go deleted file mode 100644 index 87260c6..0000000 --- a/cmd/migration-tool/migration_032_and_older.go +++ /dev/null @@ -1,262 +0,0 @@ -package main - -import ( - "database/sql" - "os" - "path/filepath" - "strconv" - "strings" - "time" - - interfaces "github.com/IceWhaleTech/CasaOS-Common" - "github.com/IceWhaleTech/CasaOS-Common/utils/version" - "github.com/IceWhaleTech/CasaOS-UserService/common" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/encryption" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" - "github.com/IceWhaleTech/CasaOS-UserService/service" - "github.com/IceWhaleTech/CasaOS-UserService/service/model" - "gopkg.in/ini.v1" -) - -type migrationTool1 struct{} - -func (u *migrationTool1) IsMigrationNeeded() (bool, error) { - if status, err := version.GetGlobalMigrationStatus(userServiceNameShort); err == nil { - _status = status - if status.LastMigratedVersion != "" { - _logger.Info("Last migrated version: %s", status.LastMigratedVersion) - if r, err := version.Compare(status.LastMigratedVersion, common.Version); err == nil { - return r < 0, nil - } - } - } - - if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { - _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) - return false, nil - } - - majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion() - if err != nil { - if err == version.ErrLegacyVersionNotFound { - return false, nil - } - - return false, err - } - - if majorVersion != 0 { - return false, nil - } - - if minorVersion == 2 { - _logger.Info("Migration is needed for a CasaOS version 0.2.x...") - return true, nil - } - - if minorVersion == 3 && patchVersion < 2 { - _logger.Info("Migration is needed for a CasaOS version between 0.3.0 and 0.3.2...") - return true, nil - } - - return false, nil -} - -func (u *migrationTool1) PreMigrate() error { - if _, err := os.Stat(userServiceConfigDirPath); os.IsNotExist(err) { - _logger.Info("Creating %s since it doesn't exists...", userServiceConfigDirPath) - if err := os.Mkdir(userServiceConfigDirPath, 0o755); err != nil { - return err - } - } - - if _, err := os.Stat(userServiceConfigFilePath); os.IsNotExist(err) { - _logger.Info("Creating %s since it doesn't exist...", userServiceConfigFilePath) - - f, err := os.Create(userServiceConfigFilePath) - if err != nil { - return err - } - - defer f.Close() - - if _, err := f.WriteString(_userServiceConfigFileSample); err != nil { - return err - } - } - - extension := "." + time.Now().Format("20060102") + ".bak" - - _logger.Info("Creating a backup %s if it doesn't exist...", version.LegacyCasaOSConfigFilePath+extension) - return file.CopySingleFile(version.LegacyCasaOSConfigFilePath, version.LegacyCasaOSConfigFilePath+extension, "skip") -} - -func (u *migrationTool1) Migrate() error { - _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - migrateConfigurationFile1(legacyConfigFile) - - return migrateUser1(legacyConfigFile) -} - -func (u *migrationTool1) PostMigrate() error { - defer _status.Done(common.Version) - - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) - - legacyConfigFile.DeleteSection("user") - - if err := legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath); err != nil { - return err - } - - dbPath := legacyConfigFile.Section("app").Key("DBPath").String() - - dbFile := filepath.Join(dbPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - return nil - } - } - - legacyDB, err := sql.Open("sqlite3", dbFile) - if err != nil { - return err - } - - defer legacyDB.Close() - - for _, tableName := range []string{"o_users", "o_user"} { - tableExists, err := isTableExist(legacyDB, tableName) - if err != nil { - return err - } - - if !tableExists { - continue - } - - _logger.Info("Dropping `%s` table in legacy database...", tableName) - - if _, err = legacyDB.Exec("DROP TABLE " + tableName); err != nil { - _logger.Error("Failed to drop `%s` table in legacy database: %s", tableName, err) - } - } - - return nil -} - -func NewMigrationToolFor032AndOlder() interfaces.MigrationTool { - return &migrationTool1{} -} - -func migrateConfigurationFile1(legacyConfigFile *ini.File) { - _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) - config.InitSetup(config.UserServiceConfigFilePath) - - // LogPath - if logPath, err := legacyConfigFile.Section("app").GetKey("LogPath"); err == nil { - _logger.Info("[app] LogPath = %s", logPath.Value()) - config.AppInfo.LogPath = logPath.Value() - } - - if logPath, err := legacyConfigFile.Section("app").GetKey("LogSavePath"); err == nil { - _logger.Info("[app] LogSavePath = %s", logPath.Value()) - config.AppInfo.LogPath = logPath.Value() - } - - // LogFileExt - if logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt"); err == nil { - _logger.Info("[app] LogFileExt = %s", logFileExt.Value()) - config.AppInfo.LogFileExt = logFileExt.Value() - } - - // UserDataPath - if userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath"); err == nil { - _logger.Info("[app] UserDataPath = %s", userDataPath.Value()) - config.AppInfo.UserDataPath = userDataPath.Value() - } - - _logger.Info("Saving %s...", config.UserServiceConfigFilePath) - config.SaveSetup(config.UserServiceConfigFilePath) -} - -func migrateUser1(legacyConfigFile *ini.File) error { - _logger.Info("Migrating user from configuration file to database...") - - user := model.UserDBModel{Role: "admin"} - - // UserName - if userName, err := legacyConfigFile.Section("user").GetKey("UserName"); err == nil { - _logger.Info("[user] UserName = %s", userName.Value()) - user.Username = userName.Value() - } - - // Email - if userEmail, err := legacyConfigFile.Section("user").GetKey("Email"); err == nil { - _logger.Info("[user] Email = %s", userEmail.Value()) - user.Email = userEmail.Value() - } - - // NickName - if userNickName, err := legacyConfigFile.Section("user").GetKey("NickName"); err == nil { - _logger.Info("[user] NickName = %s", userNickName.Value()) - user.Nickname = userNickName.Value() - } - - // Password - if userPassword, err := legacyConfigFile.Section("user").GetKey("PWD"); err == nil { - _logger.Info("[user] Password = %s", strings.Repeat("*", len(userPassword.Value()))) - user.Password = encryption.GetMD5ByStr(userPassword.Value()) - } - - newDB := sqlite.GetDb(config.AppInfo.DBPath) - userService := service.NewUserService(newDB) - - if len(user.Username) == 0 { - _logger.Info("No user found in legacy configuration file. Skipping...") - return nil - } - - if userService.GetUserInfoByUserName(user.Username).Id > 0 { - _logger.Info("User `%s` already exists in user database at %s. Skipping...", user.Username, config.AppInfo.DBPath) - return nil - } - - _logger.Info("Creating user %s in database at %s...", user.Username, config.AppInfo.DBPath) - user = userService.CreateUser(user) - if user.Id > 0 { - userPath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id) - _logger.Info("Creating user data path: %s", userPath) - if err := file.MkDir(userPath); err != nil { - return err - } - - if legacyProjectPath, err := legacyConfigFile.Section("app").GetKey("ProjectPath"); err == nil { - appOrderJSONFile := filepath.Join(legacyProjectPath.Value(), "app_order.json") - - if _, err := os.Stat(appOrderJSONFile); err == nil { - _logger.Info("Moving %s to %s...", appOrderJSONFile, userPath) - if err := os.Rename(appOrderJSONFile, filepath.Join(userPath, "app_order.json")); err != nil { - return err - } - } - } - } - - return nil -} diff --git a/cmd/migration-tool/migration_033_034_035.go b/cmd/migration-tool/migration_033_034_035.go deleted file mode 100644 index fcf5ffe..0000000 --- a/cmd/migration-tool/migration_033_034_035.go +++ /dev/null @@ -1,309 +0,0 @@ -package main - -import ( - "database/sql" - "os" - "path/filepath" - "time" - - interfaces "github.com/IceWhaleTech/CasaOS-Common" - "github.com/IceWhaleTech/CasaOS-Common/utils/version" - "github.com/IceWhaleTech/CasaOS-UserService/common" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" - "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" - "github.com/IceWhaleTech/CasaOS-UserService/service" - "github.com/IceWhaleTech/CasaOS-UserService/service/model" - "gopkg.in/ini.v1" -) - -type migrationTool2 struct{} - -const defaultDBPath = "/var/lib/casaos" - -func (u *migrationTool2) IsMigrationNeeded() (bool, error) { - if status, err := version.GetGlobalMigrationStatus(userServiceNameShort); err == nil { - _status = status - if status.LastMigratedVersion != "" { - _logger.Info("Last migrated version: %s", status.LastMigratedVersion) - if r, err := version.Compare(status.LastMigratedVersion, common.Version); err == nil { - return r < 0, nil - } - } - } - - if _, err := os.Stat(version.LegacyCasaOSConfigFilePath); err != nil { - _logger.Info("`%s` not found, migration is not needed.", version.LegacyCasaOSConfigFilePath) - return false, nil - } - - majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion() - if err != nil { - if err == version.ErrLegacyVersionNotFound { - return false, nil - } - - return false, err - } - - if majorVersion != 0 { - return false, nil - } - - if minorVersion != 3 { - return false, nil - } - - if patchVersion < 3 || patchVersion > 5 { - return false, nil - } - - // legacy version has to be between 0.3.3 and 0.3.5 - _logger.Info("Migration is needed for a CasaOS version between 0.3.3 and 0.3.5...") - return true, nil -} - -func (u *migrationTool2) PreMigrate() error { - if _, err := os.Stat(userServiceConfigDirPath); os.IsNotExist(err) { - _logger.Info("Creating %s since it doesn't exists...", userServiceConfigDirPath) - if err := os.Mkdir(userServiceConfigDirPath, 0o755); err != nil { - return err - } - } - - if _, err := os.Stat(userServiceConfigFilePath); os.IsNotExist(err) { - _logger.Info("Creating %s since it doesn't exist...", userServiceConfigFilePath) - - f, err := os.Create(userServiceConfigFilePath) - if err != nil { - return err - } - - defer f.Close() - - if _, err := f.WriteString(_userServiceConfigFileSample); err != nil { - return err - } - } - - extension := "." + time.Now().Format("20060102") + ".bak" - - _logger.Info("Creating a backup %s if it doesn't exist...", version.LegacyCasaOSConfigFilePath+extension) - if err := file.CopySingleFile(version.LegacyCasaOSConfigFilePath, version.LegacyCasaOSConfigFilePath+extension, "skip"); err != nil { - return err - } - - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - dbPath := legacyConfigFile.Section("app").Key("DBPath").String() - - dbFile := filepath.Join(dbPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - return err - } - } - - _logger.Info("Creating a backup %s if it doesn't exist...", dbFile+extension) - if err := file.CopySingleFile(dbFile, dbFile+extension, "skip"); err != nil { - return err - } - - return nil -} - -func (u *migrationTool2) Migrate() error { - _logger.Info("Loading legacy %s...", version.LegacyCasaOSConfigFilePath) - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - migrateConfigurationFile2(legacyConfigFile) - - return migrateUser2(legacyConfigFile) -} - -func (u *migrationTool2) PostMigrate() error { - defer _status.Done(common.Version) - - legacyConfigFile, err := ini.Load(version.LegacyCasaOSConfigFilePath) - if err != nil { - return err - } - - _logger.Info("Deleting legacy `user` section in %s...", version.LegacyCasaOSConfigFilePath) - - legacyConfigFile.DeleteSection("user") - - if err := legacyConfigFile.SaveTo(version.LegacyCasaOSConfigFilePath); err != nil { - return err - } - - dbPath := legacyConfigFile.Section("app").Key("DBPath").String() - - dbFile := filepath.Join(dbPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - return nil - } - } - - legacyDB, err := sql.Open("sqlite3", dbFile) - if err != nil { - return err - } - - defer legacyDB.Close() - - for _, tableName := range []string{"o_users", "o_user"} { - tableExists, err := isTableExist(legacyDB, tableName) - if err != nil { - return err - } - - if !tableExists { - continue - } - - _logger.Info("Dropping `%s` table in legacy database...", tableName) - - if _, err = legacyDB.Exec("DROP TABLE " + tableName); err != nil { - _logger.Error("Failed to drop `%s` table in legacy database: %s", tableName, err) - } - } - - return nil -} - -func NewMigrationToolFor033_034_035() interfaces.MigrationTool { - return &migrationTool2{} -} - -func migrateConfigurationFile2(legacyConfigFile *ini.File) { - _logger.Info("Updating %s with settings from legacy configuration...", config.UserServiceConfigFilePath) - config.InitSetup(config.UserServiceConfigFilePath) - - // LogPath - if logPath, err := legacyConfigFile.Section("app").GetKey("LogPath"); err == nil { - _logger.Info("[app] LogPath = %s", logPath.Value()) - config.AppInfo.LogPath = logPath.Value() - } - - // LogFileExt - if logFileExt, err := legacyConfigFile.Section("app").GetKey("LogFileExt"); err == nil { - _logger.Info("[app] LogFileExt = %s", logFileExt.Value()) - config.AppInfo.LogFileExt = logFileExt.Value() - } - - // DBPath - if dbPath, err := legacyConfigFile.Section("app").GetKey("DBPath"); err == nil { - _logger.Info("[app] DBPath = %s", dbPath.Value()) - config.AppInfo.DBPath = dbPath.Value() + "/db" - } - - // UserDataPath - if userDataPath, err := legacyConfigFile.Section("app").GetKey("UserDataPath"); err == nil { - _logger.Info("[app] UserDataPath = %s", userDataPath.Value()) - config.AppInfo.UserDataPath = userDataPath.Value() - } - - _logger.Info("Saving %s...", config.UserServiceConfigFilePath) - config.SaveSetup(config.UserServiceConfigFilePath) -} - -func migrateUser2(legacyConfigFile *ini.File) error { - _logger.Info("Migrating user from legacy database to user database...") - - user := model.UserDBModel{Role: "admin"} - - dbPath := legacyConfigFile.Section("app").Key("DBPath").String() - - dbFile := filepath.Join(dbPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - dbFile = filepath.Join(defaultDBPath, "db", "casaOS.db") - - if _, err := os.Stat(dbFile); err != nil { - return err - } - } - legacyDB, err := sql.Open("sqlite3", dbFile) - if err != nil { - return err - } - - defer legacyDB.Close() - - newDB := sqlite.GetDb(config.AppInfo.DBPath) - userService := service.NewUserService(newDB) - - // create an inline map from string to string - sqlTableStatementMap := make(map[string]string) - sqlTableStatementMap["o_users"] = "SELECT id, username, password, role, email, nickname, avatar, description, created_at FROM o_users ORDER BY id ASC" - sqlTableStatementMap["o_user"] = "SELECT id, user_name, password, role, email, nick_name, avatar, description, created_at FROM o_user ORDER BY id ASC" - - // historically there were two names for user table: o_users and users - for tableName, sqlStatement := range sqlTableStatementMap { - tableExists, err := isTableExist(legacyDB, tableName) - if err != nil { - return err - } - - if !tableExists { - continue - } - rows, err := legacyDB.Query(sqlStatement) - if err != nil { - return err - } - - defer rows.Close() - - for rows.Next() { - if err := rows.Scan( - &user.Id, - &user.Username, - &user.Password, - &user.Role, - &user.Email, - &user.Nickname, - &user.Avatar, - &user.Description, - &user.CreatedAt, - ); err != nil { - return err - } - - if userService.GetUserAllInfoByName(user.Username).Id > 0 { - _logger.Info("User %s already exists in user database at %s, skipping...", user.Username, config.AppInfo.DBPath) - continue - } - - _logger.Info("Creating user %s in user database...", user.Username) - user = userService.CreateUser(user) - } - } - - return nil -} - -func isTableExist(legacyDB *sql.DB, tableName string) (bool, error) { - rows, err := legacyDB.Query("SELECT name FROM sqlite_master WHERE type='table' AND name= ?", tableName) - if err != nil { - return false, err - } - - defer rows.Close() - - return rows.Next(), nil -} diff --git a/cmd/migration-tool/migration_dummy.go b/cmd/migration-tool/migration_dummy.go new file mode 100644 index 0000000..6d08df2 --- /dev/null +++ b/cmd/migration-tool/migration_dummy.go @@ -0,0 +1,27 @@ +package main + +import ( + interfaces "github.com/IceWhaleTech/CasaOS-Common" +) + +type migrationTool struct{} + +func (u *migrationTool) IsMigrationNeeded() (bool, error) { + return false, nil +} + +func (u *migrationTool) PreMigrate() error { + return nil +} + +func (u *migrationTool) Migrate() error { + return nil +} + +func (u *migrationTool) PostMigrate() error { + return nil +} + +func NewMigrationDummy() interfaces.MigrationTool { + return &migrationTool{} +} diff --git a/common/version.go b/common/version.go index ebc0f4c..75c33fe 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.3.7" +const Version = "0.3.8" diff --git a/go.mod b/go.mod index f16e038..97d86eb 100644 --- a/go.mod +++ b/go.mod @@ -16,10 +16,8 @@ require ( ) require ( - github.com/andybalholm/brotli v1.0.1 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect @@ -27,26 +25,18 @@ require ( github.com/goccy/go-json v0.9.10 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/golang/snappy v0.0.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/klauspost/pgzip v1.2.5 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-sqlite3 v1.14.14 // indirect - github.com/mholt/archiver/v3 v3.5.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/nwaples/rardecode v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect - github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect - github.com/ulikunitz/xz v0.5.9 // indirect - github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect diff --git a/go.sum b/go.sum index 3c08694..d2d9014 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/IceWhaleTech/CasaOS-Common v0.3.7-1 h1:paay9dFGAWjNcjtCrN6ymvuU21KtxPoIpNG3wo10ufk= github.com/IceWhaleTech/CasaOS-Common v0.3.7-1/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= -github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= -github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -14,9 +12,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= -github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= -github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -40,8 +35,6 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= -github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -52,13 +45,6 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= -github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -74,20 +60,14 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= -github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ= -github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= -github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM= -github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -116,11 +96,6 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= -github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= -github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -199,4 +174,3 @@ gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMT gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= From 12b047295e60578587142b21cd05344351e8ecbc Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 3 Nov 2022 18:07:11 -0400 Subject: [PATCH 38/95] fix potential goroutine leak due to http request without a timeout (#20) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 97d86eb..a1e2382 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.3.7-1 + github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 diff --git a/go.sum b/go.sum index d2d9014..336d887 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.3.7-1 h1:paay9dFGAWjNcjtCrN6ymvuU21KtxPoIpNG3wo10ufk= -github.com/IceWhaleTech/CasaOS-Common v0.3.7-1/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 h1:CLPeUaFoGCA3WNnOWxtdFbBmLIg7odCQglZJ/c878uU= +github.com/IceWhaleTech/CasaOS-Common v0.3.7-5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From 23d3c282883fd608e72967488d041ceab5b020cf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 10 Nov 2022 19:40:11 -0500 Subject: [PATCH 39/95] add restrictive license check to gorelease workflow (#21) --- .goreleaser.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index abba285..0764cbd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,6 +3,7 @@ project_name: casaos-user-service before: hooks: + - go run github.com/google/go-licenses@latest check . --disallowed_types=restricted - go mod tidy - go test -v ./... builds: From 85128763920de2ba90764643bdbac4d6c8d5ecf9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 25 Nov 2022 17:03:55 -0500 Subject: [PATCH 40/95] update CasaOS-Common --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a1e2382..2a3c025 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 + github.com/IceWhaleTech/CasaOS-Common v0.3.8 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 diff --git a/go.sum b/go.sum index 336d887..ae0c3e0 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 h1:CLPeUaFoGCA3WNnOWxtdFbBmLIg7odCQglZJ/c878uU= github.com/IceWhaleTech/CasaOS-Common v0.3.7-5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/IceWhaleTech/CasaOS-Common v0.3.8 h1:cbSREowQBYMEeLbaAjnqhQxOfbAaXgmSLfh7nu3nl7E= +github.com/IceWhaleTech/CasaOS-Common v0.3.8/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From a50025f31663f5f6aa48d255e7bd14443c7048c9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 25 Nov 2022 17:06:38 -0500 Subject: [PATCH 41/95] update go.sum --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index ae0c3e0..880acee 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 h1:CLPeUaFoGCA3WNnOWxtdFbBmLIg7odCQglZJ/c878uU= -github.com/IceWhaleTech/CasaOS-Common v0.3.7-5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/IceWhaleTech/CasaOS-Common v0.3.8 h1:cbSREowQBYMEeLbaAjnqhQxOfbAaXgmSLfh7nu3nl7E= github.com/IceWhaleTech/CasaOS-Common v0.3.8/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From 36f4943020757211aa2f8e26b2e47b62106db241 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 28 Nov 2022 16:43:08 +0000 Subject: [PATCH 42/95] bump version from 0.3.8 to 0.4.0 --- common/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index 75c33fe..876bac4 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.3.8" +const Version = "0.4.0" From a45ded5088421bd82af5a07ecbbbfb2f842d2a55 Mon Sep 17 00:00:00 2001 From: Ns2Kracy <89824014+Ns2Kracy@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:31:12 +0800 Subject: [PATCH 43/95] added arch support (#22) --- .../user-service/arch/setup-user-service.sh | 22 ++++ .../user-service/arch/cleanup-user-service.sh | 109 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 build/scripts/setup/service.d/user-service/arch/setup-user-service.sh create mode 100644 build/sysroot/usr/share/casaos/cleanup/service.d/user-service/arch/cleanup-user-service.sh diff --git a/build/scripts/setup/service.d/user-service/arch/setup-user-service.sh b/build/scripts/setup/service.d/user-service/arch/setup-user-service.sh new file mode 100644 index 0000000..86e7b09 --- /dev/null +++ b/build/scripts/setup/service.d/user-service/arch/setup-user-service.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +readonly APP_NAME="casaos-user-service" +readonly APP_NAME_SHORT="user-service" + +# copy config files +readonly CONF_PATH=/etc/casaos +readonly CONF_FILE=${CONF_PATH}/${APP_NAME_SHORT}.conf +readonly CONF_FILE_SAMPLE=${CONF_PATH}/${APP_NAME_SHORT}.conf.sample + +if [ ! -f "${CONF_FILE}" ]; then \ + echo "Initializing config file..." + cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"; \ +fi + +systemctl daemon-reload + +# enable service (without starting) +echo "Enabling service..." +systemctl enable --force --no-ask-password "${APP_NAME}.service" diff --git a/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/arch/cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/arch/cleanup-user-service.sh new file mode 100644 index 0000000..f39f4ad --- /dev/null +++ b/build/sysroot/usr/share/casaos/cleanup/service.d/user-service/arch/cleanup-user-service.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +set -e + +readonly CASA_EXEC=casaos-user-service +readonly CASA_SERVICE=casaos-user-service.service + +CASA_SERVICE_PATH=$(systemctl show ${CASA_SERVICE} --no-pager --property FragmentPath | cut -d'=' -sf2) +readonly CASA_SERVICE_PATH + +CASA_CONF=$( grep -i ExecStart= "${CASA_SERVICE_PATH}" | cut -d'=' -sf2 | cut -d' ' -sf3) +if [[ -z "${CASA_CONF}" ]]; then + CASA_CONF=/etc/casaos/user-service.conf +fi + +CASA_DB_PATH=$( (grep -i dbpath "${CASA_CONF}" || echo "/var/lib/casaos/db") | cut -d'=' -sf2 | xargs ) +readonly CASA_DB_PATH + +CASA_DB_FILE=${CASA_DB_PATH}/user-service.db + +readonly aCOLOUR=( + '\e[38;5;154m' # green | Lines, bullets and separators + '\e[1m' # Bold white | Main descriptions + '\e[90m' # Grey | Credits + '\e[91m' # Red | Update notifications Alert + '\e[33m' # Yellow | Emphasis +) + +Show() { + # OK + if (($1 == 0)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # FAILED + elif (($1 == 1)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # INFO + elif (($1 == 2)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + # NOTICE + elif (($1 == 3)); then + echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" + fi +} + +Warn() { + echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" +} + +trap 'onCtrlC' INT +onCtrlC() { + echo -e "${COLOUR_RESET}" + exit 1 +} + +if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then + Show 2 "${CASA_EXEC} is not detected, exit the script." + exit 1 +fi + +while true; do + echo -n -e " ${aCOLOUR[4]}Do you want delete user database? Y/n :${COLOUR_RESET}" + read -r input + case $input in + [yY][eE][sS] | [yY]) + REMOVE_USER_DATABASE=true + break + ;; + [nN][oO] | [nN]) + REMOVE_USER_DATABASE=false + break + ;; + *) + echo -e " ${aCOLOUR[3]}Invalid input, please try again.${COLOUR_RESET}" + ;; + esac +done + +while true; do + echo -n -e " ${aCOLOUR[4]}Do you want delete user directory? Y/n :${COLOUR_RESET}" + read -r input + case $input in + [yY][eE][sS] | [yY]) + REMOVE_USER_DIRECTORY=true + break + ;; + [nN][oO] | [nN]) + REMOVE_USER_DIRECTORY=false + break + ;; + *) + echo -e " ${aCOLOUR[3]}Invalid input, please try again.${COLOUR_RESET}" + ;; + esac +done + +Show 2 "Stopping ${CASA_SERVICE}..." +systemctl disable --now "${CASA_SERVICE}" || Show 3 "Failed to disable ${CASA_SERVICE}" + +rm -rvf "$(which ${CASA_EXEC})" || Show 3 "Failed to remove ${CASA_EXEC}" +rm -rvf "${CASA_CONF}" || Show 3 "Failed to remove ${CASA_CONF}" + +if [[ "${REMOVE_USER_DATABASE}" == true ]]; then + rm -rvf "${CASA_DB_FILE}" || Show 3 "Failed to remove ${CASA_DB_FILE}" +fi + +if [[ "${REMOVE_USER_DIRECTORY}" == true ]]; then + Show 2 "Removing user directories..." + rm -rvf /var/lib/casaos/[1-9]* +fi From b41ab1ecced5002cadc2e3efb9b7c64f67a23ef9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 29 Nov 2022 17:51:12 +0000 Subject: [PATCH 44/95] remove "-snapshot" from package naming --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0764cbd..38b090c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -134,7 +134,7 @@ archives: checksum: name_template: "checksums.txt" snapshot: - name_template: "{{ incpatch .Version }}-snapshot" + name_template: "{{ incpatch .Version }}" changelog: sort: asc filters: From dab1fdd6becdd5e414dc7feab31999ee08611928 Mon Sep 17 00:00:00 2001 From: link Date: Wed, 30 Nov 2022 12:16:11 +0800 Subject: [PATCH 45/95] Event retention (#23) Signed-off-by: link --- .gitignore | 1 + api/index.html | 24 +++++ api/user-service/openapi.yaml | 176 ++++++++++++++++++++++++++++++++++ go.mod | 37 +++++-- go.sum | 92 ++++++++++++++---- main.go | 48 ++++++++-- model/event.go | 13 +++ pkg/sqlite/db.go | 3 +- route/event_listen.go | 65 +++++++++++++ route/{route.go => v1.go} | 0 route/v2.go | 105 ++++++++++++++++++++ route/v2/api_route_event.go | 20 ++++ route/v2/route.go | 9 ++ service/event.go | 37 +++++++ service/service.go | 6 ++ 15 files changed, 601 insertions(+), 35 deletions(-) create mode 100644 api/index.html create mode 100644 api/user-service/openapi.yaml create mode 100644 model/event.go create mode 100644 route/event_listen.go rename route/{route.go => v1.go} (100%) create mode 100644 route/v2.go create mode 100644 route/v2/api_route_event.go create mode 100644 route/v2/route.go create mode 100644 service/event.go diff --git a/.gitignore b/.gitignore index 5ab2489..03f08ff 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ target/ dist/ __debug_bin +codegen/ \ No newline at end of file diff --git a/api/index.html b/api/index.html new file mode 100644 index 0000000..b787fd3 --- /dev/null +++ b/api/index.html @@ -0,0 +1,24 @@ + + + + + CasaOS | Developers + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/user-service/openapi.yaml b/api/user-service/openapi.yaml new file mode 100644 index 0000000..0fe18f0 --- /dev/null +++ b/api/user-service/openapi.yaml @@ -0,0 +1,176 @@ +openapi: 3.0.3 + +info: + title: Casaos User Service API + version: v2 + description: | + + + + CasaOS + + This is the API for the Casaos User Service. + It is used to manage users and their access to Casaos services. + +servers: + - url: /v2/users + description: Casaos User Service API + +tags: + - name: event + description: Event related operations +security: + - access_token: [] + +paths: + /event/{event_uuid}: + delete: + summary: Delete an event + description: Delete an event + operationId: deleteEvent + tags: + - event + parameters: + - $ref: "#/components/parameters/event_uuid" + + responses: + "200": + description: Event deleted + $ref: "#/components/responses/DeleteEventOK" + "401": + description: Event not found + + "404": + description: Event not found + $ref: "#/components/responses/ResponseNotFound" + "500": + $ref: "#/components/responses/BadResponse" + description: Internal server error + /events: + get: + summary: Get all events + description: Get all events + operationId: getEvents + tags: + - event + parameters: + - name: form + in: query + description: Form of the events to get + required: false + schema: + type: string + format: date-time + example: "2021-01-01T00:00:00Z" + responses: + "200": + description: Events found + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Event" + "500": + description: Internal server error + $ref: "#/components/responses/BadResponse" + +components: + securitySchemes: + access_token: + type: apiKey + in: header + name: Authorization + parameters: + event_uuid: + name: event_uuid + in: path + description: UUID of the event to get + required: true + schema: + type: string + format: uuid + example: 123e4567-e89b-12d3-a456-426655440000 + responses: + DeleteEventOK: + description: Event deleted + content: + application/json: + schema: + type: object + $ref: "#/components/schemas/Event" + BadResponse: + description: Bad request + content: + application/json: + schema: + $ref: "#/components/schemas/BaseResponse" + ResponseNotFound: + description: Not Found + content: + application/json: + schema: + $ref: "#/components/schemas/BaseResponse" + example: + message: "Not Found" + schemas: + BaseResponse: + type: object + properties: + message: + readOnly: true + type: string + example: "Bad request" + description: Error message + Property: + type: object + properties: + name: + type: string + description: Name of the property + value: + type: string + description: Value of the property + Event: + type: object + required: + - "sourceID" + - "name" + - "properties" + properties: + event_uuid: + type: string + format: uuid + description: UUID of the event + sourceID: + type: string + description: associated source id + example: "local-storage" + name: + type: string + description: event name + example: "local-storage:disk:added" + properties: + type: array + description: event properties + items: + $ref: "#/components/schemas/Property" + example: + - name: local-storage:vendor + value: SanDisk + - name: local-storage:model + value: Cruzer + - name: local-storage:uuid + value: 442e0e5b-9d3e-4fe8-b46f-9c4141fdecd7 + - name: casaos-ui:type + value: notification-style-2 + - name: casaos-ui:title + value: "New disk found" + - name: casaos-ui:icon-1 + value: casaos-icon-disk + - name: casaos-ui:message-1 + value: "A new disk, SanDisk Cruzer, is added." + timestamp: + type: string + description: timestamp this event took place + format: date-time diff --git a/go.mod b/go.mod index 2a3c025..f67aae9 100644 --- a/go.mod +++ b/go.mod @@ -5,45 +5,64 @@ go 1.19 require ( github.com/IceWhaleTech/CasaOS-Common v0.3.8 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf + github.com/deepmap/oapi-codegen v1.12.2 + github.com/getkin/kin-openapi v0.108.0 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 + github.com/labstack/echo/v4 v4.9.1 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.1 go.uber.org/zap v1.21.0 + golang.org/x/net v0.1.0 gopkg.in/ini.v1 v1.67.0 gorm.io/driver/sqlite v1.3.6 gorm.io/gorm v1.23.8 ) require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/swag v0.21.1 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.0 // indirect - github.com/goccy/go-json v0.9.10 // indirect + github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/goccy/go-json v0.9.11 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/mux v1.8.0 // indirect + github.com/invopop/yaml v0.1.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/labstack/gommon v0.4.0 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mattn/go-sqlite3 v1.14.14 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect - golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect - golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 // indirect - golang.org/x/text v0.3.7 // indirect - google.golang.org/protobuf v1.28.0 // indirect + golang.org/x/crypto v0.1.0 // indirect + golang.org/x/sys v0.1.0 // indirect + golang.org/x/text v0.4.0 // indirect + golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // 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 880acee..239a4e2 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,13 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/IceWhaleTech/CasaOS-Common v0.3.8 h1:cbSREowQBYMEeLbaAjnqhQxOfbAaXgmSLfh7nu3nl7E= github.com/IceWhaleTech/CasaOS-Common v0.3.8/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -12,12 +16,21 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deepmap/oapi-codegen v1.12.2 h1:F7SMEn0UMpJV6kWwDYqfDmnnOYHIcU7ETV8qTVFdyI0= +github.com/deepmap/oapi-codegen v1.12.2/go.mod h1:ao2aFwsl/muMHbez870+KelJ1yusV01RznwAFFrVjDc= +github.com/getkin/kin-openapi v0.108.0 h1:EYf0GtsKa4hQNIlplGS+Au7NEfGQ1F7MoHD2kcVevPQ= +github.com/getkin/kin-openapi v0.108.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= +github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -25,26 +38,37 @@ github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= -github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc= -github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= +github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= +github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -53,10 +77,23 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y= +github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo= +github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= +github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -65,9 +102,12 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= -github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= +github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= +github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -78,15 +118,17 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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 v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 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/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -96,6 +138,11 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -111,8 +158,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -121,8 +168,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= -golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= +golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -134,14 +181,20 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8= -golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.0.0-20220411224347-583f2d630306 h1:+gHMid33q6pen7kv9xvT+JRinntgeXO2AeZVd0AWD3w= +golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -151,10 +204,12 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -162,11 +217,14 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ= diff --git a/main.go b/main.go index 3953cf6..3c357a7 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,9 @@ +//go:generate bash -c "mkdir -p codegen/user-service && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -generate types,server,spec -package codegen api/user-service/openapi.yaml > codegen/user-service/user_service_api.go" +//go:generate bash -c "mkdir -p codegen/message_bus && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -package message_bus https://raw.githubusercontent.com/IceWhaleTech/CasaOS-MessageBus/main/api/message_bus/openapi.yaml > codegen/message_bus/api.go" package main import ( + _ "embed" "flag" "fmt" "net" @@ -9,6 +12,7 @@ import ( "time" "github.com/IceWhaleTech/CasaOS-Common/model" + util_http "github.com/IceWhaleTech/CasaOS-Common/utils/http" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" @@ -23,6 +27,14 @@ import ( const localhost = "127.0.0.1" +var ( + //go:embed api/index.html + _docHTML string + + //go:embed api/user-service/openapi.yaml + _docYAML string +) + func init() { configFlag := flag.String("c", "", "config address") dbFlag := flag.String("db", "", "db path") @@ -71,20 +83,40 @@ func init() { } func main() { - r := route.InitRouter() + + go route.EventListen() + + v1Router := route.InitRouter() + v2Router := route.InitV2Router() + v2DocRouter := route.InitV2DocRouter(_docHTML, _docYAML) + + mux := &util_http.HandlerMultiplexer{ + HandlerMap: map[string]http.Handler{ + "v1": v1Router, + "v2": v2Router, + "doc": v2DocRouter, + }, + } listener, err := net.Listen("tcp", net.JoinHostPort(localhost, "0")) if err != nil { panic(err) } - err = service.MyService.Gateway().CreateRoute(&model.Route{ - Path: "/v1/users", - Target: "http://" + listener.Addr().String(), - }) + apiPaths := []string{ + "/v1/users", + route.V2APIPath, + route.V2DocPath, + } + for _, v := range apiPaths { + err = service.MyService.Gateway().CreateRoute(&model.Route{ + Path: v, + Target: "http://" + listener.Addr().String(), + }) - if err != nil { - panic(err) + if err != nil { + panic(err) + } } if supported, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil { @@ -98,7 +130,7 @@ func main() { logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) s := &http.Server{ - Handler: r, + Handler: mux, ReadHeaderTimeout: 5 * time.Second, // fix G112: Potential slowloris attack (see https://github.com/securego/gosec) } diff --git a/model/event.go b/model/event.go new file mode 100644 index 0000000..f5768ca --- /dev/null +++ b/model/event.go @@ -0,0 +1,13 @@ +package model + +type EventModel struct { + UUID string `gorm:"primaryKey" json:"uuid"` + SourceID string `gorm:"index" json:"source_id"` + Name string `json:"name"` + Properties string `gorm:"serializer:json" json:"properties"` + Timestamp int64 `gorm:"autoCreateTime:milli" json:"timestamp"` +} + +func (p *EventModel) TableName() string { + return "events" +} diff --git a/pkg/sqlite/db.go b/pkg/sqlite/db.go index e767c6d..a228767 100644 --- a/pkg/sqlite/db.go +++ b/pkg/sqlite/db.go @@ -13,6 +13,7 @@ import ( "time" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/IceWhaleTech/CasaOS-UserService/model" "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" model2 "github.com/IceWhaleTech/CasaOS-UserService/service/model" "go.uber.org/zap" @@ -40,7 +41,7 @@ func GetDb(dbPath string) *gorm.DB { gdb = db - err = db.AutoMigrate(model2.UserDBModel{}) + err = db.AutoMigrate(model2.UserDBModel{}, model.EventModel{}) if err != nil { logger.Error("check or create db error", zap.Any("error", err)) } diff --git a/route/event_listen.go b/route/event_listen.go new file mode 100644 index 0000000..1ac688a --- /dev/null +++ b/route/event_listen.go @@ -0,0 +1,65 @@ +package route + +import ( + "encoding/json" + "fmt" + "log" + "strings" + + "github.com/IceWhaleTech/CasaOS-Common/external" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + message_bus "github.com/IceWhaleTech/CasaOS-UserService/codegen/message_bus" + "github.com/IceWhaleTech/CasaOS-UserService/model" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" + "github.com/IceWhaleTech/CasaOS-UserService/service" + "go.uber.org/zap" + "golang.org/x/net/websocket" +) + +func EventListen() { + + messageBusUrl, err := external.GetMessageBusAddress(config.CommonInfo.RuntimePath) + if err != nil { + logger.Error("get message bus url error", zap.Any("err", err)) + return + } + + wsURL := fmt.Sprintf("ws://%s/event/%s", strings.ReplaceAll(messageBusUrl, "http://", ""), "local-storage") + ws, err := websocket.Dial(wsURL, "", "http://localhost") + if err != nil { + logger.Error("connect websocket err", zap.Any("error", err)) + } + defer ws.Close() + + log.Println("subscribed to", wsURL) + for { + + msg := make([]byte, 1024) + n, err := ws.Read(msg) + if err != nil { + log.Fatalln(err.Error()) + } + + var event message_bus.Event + + if err := json.Unmarshal(msg[:n], &event); err != nil { + log.Println(err.Error()) + } + propertiesStr, err := json.Marshal(event.Properties) + if err != nil { + continue + } + model := model.EventModel{ + SourceID: event.SourceID, + Name: event.Name, + Properties: string(propertiesStr), + UUID: *event.Uuid, + } + service.MyService.Event().CreateEvemt(model) + output, err := json.MarshalIndent(event, "", " ") + if err != nil { + log.Println(err.Error()) + } + log.Println(string(output)) + } +} diff --git a/route/route.go b/route/v1.go similarity index 100% rename from route/route.go rename to route/v1.go diff --git a/route/v2.go b/route/v2.go new file mode 100644 index 0000000..e7e6542 --- /dev/null +++ b/route/v2.go @@ -0,0 +1,105 @@ +package route + +import ( + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" + "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" + codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" + v2 "github.com/IceWhaleTech/CasaOS-UserService/route/v2" + "github.com/deepmap/oapi-codegen/pkg/middleware" + "github.com/getkin/kin-openapi/openapi3" + "github.com/getkin/kin-openapi/openapi3filter" + "github.com/labstack/echo/v4" + echo_middleware "github.com/labstack/echo/v4/middleware" +) + +var ( + _swagger *openapi3.T + + V2APIPath string + V2DocPath string +) + +func init() { + swagger, err := codegen.GetSwagger() + if err != nil { + panic(err) + } + + _swagger = swagger + + u, err := url.Parse(_swagger.Servers[0].URL) + if err != nil { + panic(err) + } + + V2APIPath = strings.TrimRight(u.Path, "/") + V2DocPath = "/doc" + V2APIPath +} + +func InitV2Router() http.Handler { + UserService := v2.NewUserService() + + e := echo.New() + + e.Use((echo_middleware.CORSWithConfig(echo_middleware.CORSConfig{ + AllowOrigins: []string{"*"}, + AllowMethods: []string{echo.POST, echo.GET, echo.OPTIONS, echo.PUT, echo.DELETE}, + AllowHeaders: []string{echo.HeaderAuthorization, echo.HeaderContentLength, echo.HeaderXCSRFToken, echo.HeaderContentType, echo.HeaderAccessControlAllowOrigin, echo.HeaderAccessControlAllowHeaders, echo.HeaderAccessControlAllowMethods, echo.HeaderConnection, echo.HeaderOrigin, echo.HeaderXRequestedWith}, + ExposeHeaders: []string{echo.HeaderContentLength, echo.HeaderAccessControlAllowOrigin, echo.HeaderAccessControlAllowHeaders}, + MaxAge: 172800, + AllowCredentials: true, + }))) + + e.Use(echo_middleware.Gzip()) + + e.Use(echo_middleware.Logger()) + + e.Use(echo_middleware.JWTWithConfig(echo_middleware.JWTConfig{ + Skipper: func(c echo.Context) bool { + return c.RealIP() == "::1" || c.RealIP() == "127.0.0.1" + }, + ParseTokenFunc: func(token string, c echo.Context) (interface{}, error) { + claims, code := jwt.Validate(token) + if code != common_err.SUCCESS { + return nil, echo.ErrUnauthorized + } + + c.Request().Header.Set("user_id", strconv.Itoa(claims.ID)) + + return claims, nil + }, + TokenLookupFuncs: []echo_middleware.ValuesExtractor{ + func(c echo.Context) ([]string, error) { + return []string{c.Request().Header.Get(echo.HeaderAuthorization)}, nil + }, + }, + })) + + e.Use(middleware.OapiRequestValidatorWithOptions(_swagger, &middleware.Options{Options: openapi3filter.Options{AuthenticationFunc: openapi3filter.NoopAuthenticationFunc}})) + + codegen.RegisterHandlersWithBaseURL(e, UserService, V2APIPath) + + return e +} + +func InitV2DocRouter(docHTML string, docYAML string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == V2DocPath { + if _, err := w.Write([]byte(docHTML)); err != nil { + w.WriteHeader(http.StatusInternalServerError) + } + return + } + + if r.URL.Path == V2DocPath+"/openapi.yaml" { + if _, err := w.Write([]byte(docYAML)); err != nil { + w.WriteHeader(http.StatusInternalServerError) + } + } + }) +} diff --git a/route/v2/api_route_event.go b/route/v2/api_route_event.go new file mode 100644 index 0000000..925bd88 --- /dev/null +++ b/route/v2/api_route_event.go @@ -0,0 +1,20 @@ +package v2 + +import ( + "net/http" + + codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" + "github.com/IceWhaleTech/CasaOS-UserService/service" + "github.com/labstack/echo/v4" +) + +func (s *UserService) DeleteEvent(ctx echo.Context, params codegen.EventUuid) error { + m := service.MyService.Event().GetEventByUUID(params.String()) + service.MyService.Event().DeleteEvent(params.String()) + return ctx.JSON(http.StatusOK, m) +} + +func (s *UserService) GetEvents(ctx echo.Context, params codegen.GetEventsParams) error { + list := service.MyService.Event().GetEvents() + return ctx.JSON(http.StatusOK, list) +} diff --git a/route/v2/route.go b/route/v2/route.go new file mode 100644 index 0000000..be0efb9 --- /dev/null +++ b/route/v2/route.go @@ -0,0 +1,9 @@ +package v2 + +import codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" + +type UserService struct{} + +func NewUserService() codegen.ServerInterface { + return &UserService{} +} diff --git a/service/event.go b/service/event.go new file mode 100644 index 0000000..947e147 --- /dev/null +++ b/service/event.go @@ -0,0 +1,37 @@ +package service + +import ( + "github.com/IceWhaleTech/CasaOS-UserService/model" + "gorm.io/gorm" +) + +type EventService interface { + CreateEvemt(m model.EventModel) model.EventModel + GetEvents() (list []model.EventModel) + GetEventByUUID(uuid string) (m model.EventModel) + DeleteEvent(uuid string) +} + +type eventService struct { + db *gorm.DB +} + +func (e *eventService) CreateEvemt(m model.EventModel) model.EventModel { + e.db.Create(&m) + return m +} +func (e *eventService) GetEvents() (list []model.EventModel) { + e.db.Find(&list) + return +} +func (e *eventService) GetEventByUUID(uuid string) (m model.EventModel) { + e.db.Where("uuid = ?", uuid).First(&m) + return +} +func (e *eventService) DeleteEvent(uuid string) { + e.db.Where("uuid = ?", uuid).Delete(&model.EventModel{}) +} + +func NewEventService(db *gorm.DB) EventService { + return &eventService{db: db} +} diff --git a/service/service.go b/service/service.go index bb5b4f6..8d29cab 100644 --- a/service/service.go +++ b/service/service.go @@ -10,6 +10,7 @@ var MyService Repository type Repository interface { Gateway() external.ManagementService User() UserService + Event() EventService } func NewService(db *gorm.DB, RuntimePath string) Repository { @@ -22,14 +23,19 @@ func NewService(db *gorm.DB, RuntimePath string) Repository { return &store{ gateway: gatewayManagement, user: NewUserService(db), + event: NewEventService(db), } } type store struct { gateway external.ManagementService user UserService + event EventService } +func (c *store) Event() EventService { + return c.event +} func (c *store) Gateway() external.ManagementService { return c.gateway } From f6ad3aa89a5f5b6b69185f709376d8f4792989a3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 30 Nov 2022 00:07:36 -0500 Subject: [PATCH 46/95] replace CGO implementation of sqlite with an implementation in pure Go (#24) --- .goreleaser.yaml | 12 +++---- go.mod | 11 +++++-- go.sum | 62 ++++++++++++++++++++++++++++++++----- main.go | 3 +- pkg/sqlite/db.go | 2 +- route/v2.go | 2 +- route/v2/api_route_event.go | 2 +- route/v2/route.go | 2 +- 8 files changed, 73 insertions(+), 23 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 38b090c..1e45cc7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,7 +10,6 @@ builds: - id: casaos-user-service-amd64 binary: build/sysroot/usr/bin/casaos-user-service env: - - CGO_ENABLED=1 - CC=x86_64-linux-gnu-gcc ldflags: - -s @@ -19,6 +18,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: @@ -26,7 +26,6 @@ builds: - id: casaos-user-service-arm64 binary: build/sysroot/usr/bin/casaos-user-service env: - - CGO_ENABLED=1 - CC=aarch64-linux-gnu-gcc ldflags: - -s @@ -35,6 +34,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: @@ -42,7 +42,6 @@ builds: - id: casaos-user-service-arm-7 binary: build/sysroot/usr/bin/casaos-user-service env: - - CGO_ENABLED=1 - CC=arm-linux-gnueabihf-gcc ldflags: - -s @@ -51,6 +50,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: @@ -61,7 +61,6 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - - CGO_ENABLED=1 - CC=x86_64-linux-gnu-gcc ldflags: - -s @@ -70,6 +69,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: @@ -78,7 +78,6 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - - CGO_ENABLED=1 - CC=aarch64-linux-gnu-gcc ldflags: - -s @@ -87,6 +86,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: @@ -95,7 +95,6 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - - CGO_ENABLED=1 - CC=arm-linux-gnueabihf-gcc ldflags: - -s @@ -104,6 +103,7 @@ builds: tags: - musl - netgo + - osusergo goos: - linux goarch: diff --git a/go.mod b/go.mod index f67aae9..64a3b36 100644 --- a/go.mod +++ b/go.mod @@ -9,14 +9,14 @@ require ( github.com/getkin/kin-openapi v0.108.0 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.8.1 + github.com/glebarez/sqlite v1.5.0 github.com/labstack/echo/v4 v4.9.1 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.1 go.uber.org/zap v1.21.0 golang.org/x/net v0.1.0 gopkg.in/ini.v1 v1.67.0 - gorm.io/driver/sqlite v1.3.6 - gorm.io/gorm v1.23.8 + gorm.io/gorm v1.24.0 ) require ( @@ -24,6 +24,7 @@ require ( github.com/benbjohnson/clock v1.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/glebarez/go-sqlite v1.19.1 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/swag v0.21.1 // indirect github.com/go-playground/locales v0.14.0 // indirect @@ -45,11 +46,11 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mattn/go-sqlite3 v1.14.14 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect @@ -65,4 +66,8 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + modernc.org/libc v1.19.0 // indirect + modernc.org/mathutil v1.5.0 // indirect + modernc.org/memory v1.4.0 // indirect + modernc.org/sqlite v1.19.1 // indirect ) diff --git a/go.sum b/go.sum index 239a4e2..83e99be 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deepmap/oapi-codegen v1.12.2 h1:F7SMEn0UMpJV6kWwDYqfDmnnOYHIcU7ETV8qTVFdyI0= github.com/deepmap/oapi-codegen v1.12.2/go.mod h1:ao2aFwsl/muMHbez870+KelJ1yusV01RznwAFFrVjDc= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/getkin/kin-openapi v0.108.0 h1:EYf0GtsKa4hQNIlplGS+Au7NEfGQ1F7MoHD2kcVevPQ= github.com/getkin/kin-openapi v0.108.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= @@ -26,6 +27,10 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/glebarez/go-sqlite v1.19.1 h1:o2XhjyR8CQ2m84+bVz10G0cabmG0tY4sIMiCbrcUTrY= +github.com/glebarez/go-sqlite v1.19.1/go.mod h1:9AykawGIyIcxoSfpYWiX1SgTNHTNsa/FVc75cDkbp4M= +github.com/glebarez/sqlite v1.5.0 h1:+8LAEpmywqresSoGlqjjT+I9m4PseIM3NcerIJ/V7mk= +github.com/glebarez/sqlite v1.5.0/go.mod h1:0wzXzTvfVJIN2GqRhCdMbnYd+m+aH5/QV7B30rM6NgY= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= @@ -50,6 +55,7 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -69,6 +75,7 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -91,12 +98,11 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.14 h1:qZgc/Rwetq+MtyE18WhzjokPD93dNqLGNT3QJuLvBGw= -github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -113,6 +119,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= @@ -143,6 +151,7 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -156,24 +165,30 @@ go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -182,6 +197,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= @@ -198,6 +214,7 @@ golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -227,8 +244,37 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ= -gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMTgE= -gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= -gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.24.0 h1:j/CoiSm6xpRpmzbFJsQHYj+I8bGYWLXVHeYEyyKlF74= +gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= +modernc.org/cc/v3 v3.37.0/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= +modernc.org/cc/v3 v3.38.1/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= +modernc.org/ccgo/v3 v3.0.0-20220904174949-82d86e1b6d56/go.mod h1:YSXjPL62P2AMSxBphRHPn7IkzhVHqkvOnRKAKh+W6ZI= +modernc.org/ccgo/v3 v3.0.0-20220910160915-348f15de615a/go.mod h1:8p47QxPkdugex9J4n9P2tLZ9bK01yngIVp00g4nomW0= +modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= +modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= +modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= +modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= +modernc.org/libc v1.17.4/go.mod h1:WNg2ZH56rDEwdropAJeZPQkXmDwh+JCA1s/htl6r2fA= +modernc.org/libc v1.18.0/go.mod h1:vj6zehR5bfc98ipowQOM2nIDUZnVew/wNC/2tOGS+q0= +modernc.org/libc v1.19.0 h1:bXyVhGQg6KIClTr8FMVIDPl7jtbcs7aS5WP7vLDaxPs= +modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= +modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= +modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= +modernc.org/memory v1.3.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk= +modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sqlite v1.19.1 h1:8xmS5oLnZtAK//vnd4aTVj8VOeTAccEFOtUnIzfSw+4= +modernc.org/sqlite v1.19.1/go.mod h1:UfQ83woKMaPW/ZBruK0T7YaFCrI+IE0LeWVY6pmnVms= +modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= +modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= +modernc.org/tcl v1.14.0/go.mod h1:gQ7c1YPMvryCHCcmf8acB6VPabE59QBeuRQLL7cTUlM= +modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/z v1.6.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ= diff --git a/main.go b/main.go index 3c357a7..4ca9830 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -//go:generate bash -c "mkdir -p codegen/user-service && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -generate types,server,spec -package codegen api/user-service/openapi.yaml > codegen/user-service/user_service_api.go" +//go:generate bash -c "mkdir -p codegen/user_service && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -generate types,server,spec -package codegen api/user-service/openapi.yaml > codegen/user_service/user_service_api.go" //go:generate bash -c "mkdir -p codegen/message_bus && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -package message_bus https://raw.githubusercontent.com/IceWhaleTech/CasaOS-MessageBus/main/api/message_bus/openapi.yaml > codegen/message_bus/api.go" package main @@ -83,7 +83,6 @@ func init() { } func main() { - go route.EventListen() v1Router := route.InitRouter() diff --git a/pkg/sqlite/db.go b/pkg/sqlite/db.go index a228767..253beb9 100644 --- a/pkg/sqlite/db.go +++ b/pkg/sqlite/db.go @@ -16,8 +16,8 @@ import ( "github.com/IceWhaleTech/CasaOS-UserService/model" "github.com/IceWhaleTech/CasaOS-UserService/pkg/utils/file" model2 "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "github.com/glebarez/sqlite" "go.uber.org/zap" - "gorm.io/driver/sqlite" "gorm.io/gorm" ) diff --git a/route/v2.go b/route/v2.go index e7e6542..c5fe160 100644 --- a/route/v2.go +++ b/route/v2.go @@ -8,7 +8,7 @@ import ( "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" - codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" + codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user_service" v2 "github.com/IceWhaleTech/CasaOS-UserService/route/v2" "github.com/deepmap/oapi-codegen/pkg/middleware" "github.com/getkin/kin-openapi/openapi3" diff --git a/route/v2/api_route_event.go b/route/v2/api_route_event.go index 925bd88..87868af 100644 --- a/route/v2/api_route_event.go +++ b/route/v2/api_route_event.go @@ -3,7 +3,7 @@ package v2 import ( "net/http" - codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" + codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user_service" "github.com/IceWhaleTech/CasaOS-UserService/service" "github.com/labstack/echo/v4" ) diff --git a/route/v2/route.go b/route/v2/route.go index be0efb9..eda56fb 100644 --- a/route/v2/route.go +++ b/route/v2/route.go @@ -1,6 +1,6 @@ package v2 -import codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user-service" +import codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user_service" type UserService struct{} From 98a35cb1075ba57ba8e3500b4ccc3a20ad4f84b4 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 1 Dec 2022 17:17:44 +0800 Subject: [PATCH 47/95] add message_bus service dependency (#25) --- api/user-service/openapi.yaml | 37 ++++++++- .../system/casaos-user-service.service | 2 + route/event_listen.go | 77 ++++++++++--------- route/v2/api_route_event.go | 4 + service/event.go | 19 +++++ 5 files changed, 102 insertions(+), 37 deletions(-) diff --git a/api/user-service/openapi.yaml b/api/user-service/openapi.yaml index 0fe18f0..feb76ee 100644 --- a/api/user-service/openapi.yaml +++ b/api/user-service/openapi.yaml @@ -74,7 +74,27 @@ paths: "500": description: Internal server error $ref: "#/components/responses/BadResponse" - + /event/local_storage/{serial}: + delete: + summary: Delete an event + description: Delete an event + operationId: deleteEventBySerial + tags: + - event + parameters: + - $ref: "#/components/parameters/serial" + responses: + "200": + description: Event deleted + $ref: "#/components/responses/OKResponse" + "401": + description: Event not found + "404": + description: Event not found + $ref: "#/components/responses/ResponseNotFound" + "500": + $ref: "#/components/responses/BadResponse" + description: Internal server error components: securitySchemes: access_token: @@ -82,6 +102,14 @@ components: in: header name: Authorization parameters: + serial: + name: serial + in: path + description: Serial of the local storage + required: true + schema: + type: string + example: "1234567890" event_uuid: name: event_uuid in: path @@ -92,6 +120,13 @@ components: format: uuid example: 123e4567-e89b-12d3-a456-426655440000 responses: + OKResponse: + description: OK + content: + application/json: + schema: + type: object + $ref: "#/components/schemas/BaseResponse" DeleteEventOK: description: Event deleted content: diff --git a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service index 41f6325..45a16d1 100644 --- a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service +++ b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service @@ -1,5 +1,7 @@ [Unit] After=casaos-gateway.service +After=casaos-message-bus.service +After=casaos-local-storage.service ConditionFileNotEmpty=/etc/casaos/user-service.conf Description=CasaOS User Service diff --git a/route/event_listen.go b/route/event_listen.go index 1ac688a..d6f559a 100644 --- a/route/event_listen.go +++ b/route/event_listen.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "time" "github.com/IceWhaleTech/CasaOS-Common/external" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" @@ -17,49 +18,53 @@ import ( ) func EventListen() { + for i := 0; i < 100; i++ { - messageBusUrl, err := external.GetMessageBusAddress(config.CommonInfo.RuntimePath) - if err != nil { - logger.Error("get message bus url error", zap.Any("err", err)) - return - } - - wsURL := fmt.Sprintf("ws://%s/event/%s", strings.ReplaceAll(messageBusUrl, "http://", ""), "local-storage") - ws, err := websocket.Dial(wsURL, "", "http://localhost") - if err != nil { - logger.Error("connect websocket err", zap.Any("error", err)) - } - defer ws.Close() - - log.Println("subscribed to", wsURL) - for { - - msg := make([]byte, 1024) - n, err := ws.Read(msg) + messageBusUrl, err := external.GetMessageBusAddress(config.CommonInfo.RuntimePath) if err != nil { - log.Fatalln(err.Error()) + logger.Error("get message bus url error", zap.Any("err", err)) + return } - var event message_bus.Event - - if err := json.Unmarshal(msg[:n], &event); err != nil { - log.Println(err.Error()) - } - propertiesStr, err := json.Marshal(event.Properties) + wsURL := fmt.Sprintf("ws://%s/event/%s", strings.ReplaceAll(messageBusUrl, "http://", ""), "local-storage") + ws, err := websocket.Dial(wsURL, "", "http://localhost") if err != nil { + logger.Error("connect websocket err", zap.Any("error", err)) + time.Sleep(time.Second * 5) continue } - model := model.EventModel{ - SourceID: event.SourceID, - Name: event.Name, - Properties: string(propertiesStr), - UUID: *event.Uuid, + defer ws.Close() + + log.Println("subscribed to", wsURL) + for { + + msg := make([]byte, 1024) + n, err := ws.Read(msg) + if err != nil { + log.Fatalln(err.Error()) + } + + var event message_bus.Event + + if err := json.Unmarshal(msg[:n], &event); err != nil { + log.Println(err.Error()) + } + propertiesStr, err := json.Marshal(event.Properties) + if err != nil { + continue + } + model := model.EventModel{ + SourceID: event.SourceID, + Name: event.Name, + Properties: string(propertiesStr), + UUID: *event.Uuid, + } + service.MyService.Event().CreateEvemt(model) + output, err := json.MarshalIndent(event, "", " ") + if err != nil { + log.Println(err.Error()) + } + log.Println(string(output)) } - service.MyService.Event().CreateEvemt(model) - output, err := json.MarshalIndent(event, "", " ") - if err != nil { - log.Println(err.Error()) - } - log.Println(string(output)) } } diff --git a/route/v2/api_route_event.go b/route/v2/api_route_event.go index 87868af..78db94f 100644 --- a/route/v2/api_route_event.go +++ b/route/v2/api_route_event.go @@ -18,3 +18,7 @@ func (s *UserService) GetEvents(ctx echo.Context, params codegen.GetEventsParams list := service.MyService.Event().GetEvents() return ctx.JSON(http.StatusOK, list) } +func (s *UserService) DeleteEventBySerial(ctx echo.Context, serial codegen.Serial) error { + service.MyService.Event().DeleteEventBySerial(serial) + return ctx.JSON(http.StatusOK, serial) +} diff --git a/service/event.go b/service/event.go index 947e147..8b45ba7 100644 --- a/service/event.go +++ b/service/event.go @@ -1,6 +1,8 @@ package service import ( + "encoding/json" + "github.com/IceWhaleTech/CasaOS-UserService/model" "gorm.io/gorm" ) @@ -10,6 +12,7 @@ type EventService interface { GetEvents() (list []model.EventModel) GetEventByUUID(uuid string) (m model.EventModel) DeleteEvent(uuid string) + DeleteEventBySerial(serial string) } type eventService struct { @@ -31,7 +34,23 @@ func (e *eventService) GetEventByUUID(uuid string) (m model.EventModel) { func (e *eventService) DeleteEvent(uuid string) { e.db.Where("uuid = ?", uuid).Delete(&model.EventModel{}) } +func (e *eventService) DeleteEventBySerial(serial string) { + list := []model.EventModel{} + e.db.Find(&list) + for _, v := range list { + if v.SourceID == "local-storage" { + properties := make(map[string]string) + err := json.Unmarshal([]byte(v.Properties), &properties) + if err != nil { + continue + } + if properties["serial"] == serial { + e.db.Delete(&v) + } + } + } +} func NewEventService(db *gorm.DB) EventService { return &eventService{db: db} } From a7aec4cc5bc4c6981544741f8be869d28abad58a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 1 Dec 2022 18:29:58 -0500 Subject: [PATCH 48/95] add missing `go generate` to build process --- .goreleaser.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1e45cc7..5ee3628 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,6 +3,7 @@ project_name: casaos-user-service before: hooks: + - go generate - go run github.com/google/go-licenses@latest check . --disallowed_types=restricted - go mod tidy - go test -v ./... From e2f9de8d4ca0293e23fa0eb510e0811ee651c28f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 2 Dec 2022 18:23:24 +0000 Subject: [PATCH 49/95] add .goreleaser.debug.yaml for debugging --- .goreleaser.debug.yaml | 152 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 .goreleaser.debug.yaml diff --git a/.goreleaser.debug.yaml b/.goreleaser.debug.yaml new file mode 100644 index 0000000..664fbf9 --- /dev/null +++ b/.goreleaser.debug.yaml @@ -0,0 +1,152 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +project_name: casaos-user-service +before: + hooks: + - go generate + - go run github.com/google/go-licenses@latest check . --disallowed_types=restricted + - go mod tidy + - go test -v ./... +builds: + - id: casaos-user-service-amd64 + binary: build/sysroot/usr/bin/casaos-user-service + env: + - CC=x86_64-linux-gnu-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - amd64 + - id: casaos-user-service-arm64 + binary: build/sysroot/usr/bin/casaos-user-service + env: + - CC=aarch64-linux-gnu-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - arm64 + - id: casaos-user-service-arm-7 + binary: build/sysroot/usr/bin/casaos-user-service + env: + - CC=arm-linux-gnueabihf-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - arm + goarm: + - "7" + - id: casaos-user-service-migration-tool-amd64 + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CC=x86_64-linux-gnu-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - amd64 + - id: casaos-user-service-migration-tool-arm64 + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CC=aarch64-linux-gnu-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - arm64 + - id: casaos-user-service-migration-tool-arm-7 + binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + main: ./cmd/migration-tool + env: + - CC=arm-linux-gnueabihf-gcc + gcflags: + - all=-N -l + ldflags: + - -extldflags "-static" + tags: + - musl + - netgo + - osusergo + goos: + - linux + goarch: + - arm + goarm: + - "7" +archives: + - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-v{{ .Version }}" + id: casaos-user-service + builds: + - casaos-user-service-amd64 + - casaos-user-service-arm64 + - casaos-user-service-arm-7 + replacements: + arm: arm-7 + files: + - build/**/* + - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-migration-tool-v{{ .Version }}" + id: casaos-user-service-migration-tool + builds: + - casaos-user-service-migration-tool-amd64 + - casaos-user-service-migration-tool-arm64 + - casaos-user-service-migration-tool-arm-7 + replacements: + arm: arm-7 + files: + - build/sysroot/etc/**/* +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ incpatch .Version }}" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +release: + github: + owner: IceWhaleTech + name: CasaOS-UserService + draft: true + prerelease: auto + mode: replace + name_template: "v{{ .Version }}" From 2acf34b224f2f484cd218467a7204e8b198b1c4c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 2 Dec 2022 17:14:57 -0500 Subject: [PATCH 50/95] fix sqlite db lock by reducing maximum open connections to 1 (#26) --- pkg/sqlite/db.go | 2 +- route/v2/api_route_event.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sqlite/db.go b/pkg/sqlite/db.go index 253beb9..331d64e 100644 --- a/pkg/sqlite/db.go +++ b/pkg/sqlite/db.go @@ -36,7 +36,7 @@ func GetDb(dbPath string) *gorm.DB { c, _ := db.DB() c.SetMaxIdleConns(10) - c.SetMaxOpenConns(100) + c.SetMaxOpenConns(1) c.SetConnMaxIdleTime(time.Second * 1000) gdb = db diff --git a/route/v2/api_route_event.go b/route/v2/api_route_event.go index 78db94f..180df2e 100644 --- a/route/v2/api_route_event.go +++ b/route/v2/api_route_event.go @@ -18,6 +18,7 @@ func (s *UserService) GetEvents(ctx echo.Context, params codegen.GetEventsParams list := service.MyService.Event().GetEvents() return ctx.JSON(http.StatusOK, list) } + func (s *UserService) DeleteEventBySerial(ctx echo.Context, serial codegen.Serial) error { service.MyService.Event().DeleteEventBySerial(serial) return ctx.JSON(http.StatusOK, serial) From cbaba50f6f7ec1b2e4ef0c190c08dc74e87f3687 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 7 Dec 2022 02:23:38 +0000 Subject: [PATCH 51/95] update deepmap/oapi-codegen from v0.12.2 to v0.12.4 (openapi) --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4ca9830..07fbcc9 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ -//go:generate bash -c "mkdir -p codegen/user_service && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -generate types,server,spec -package codegen api/user-service/openapi.yaml > codegen/user_service/user_service_api.go" -//go:generate bash -c "mkdir -p codegen/message_bus && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.2 -package message_bus https://raw.githubusercontent.com/IceWhaleTech/CasaOS-MessageBus/main/api/message_bus/openapi.yaml > codegen/message_bus/api.go" +//go:generate bash -c "mkdir -p codegen/user_service && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 -generate types,server,spec -package codegen api/user-service/openapi.yaml > codegen/user_service/user_service_api.go" +//go:generate bash -c "mkdir -p codegen/message_bus && go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 -package message_bus https://raw.githubusercontent.com/IceWhaleTech/CasaOS-MessageBus/main/api/message_bus/openapi.yaml > codegen/message_bus/api.go" package main import ( From 6b1d67efb159de3a59422575c06ce85abd1db290 Mon Sep 17 00:00:00 2001 From: link Date: Wed, 7 Dec 2022 11:01:33 +0800 Subject: [PATCH 52/95] Dependency (#27) --- .../system/casaos-user-service.service | 2 -- main.go | 3 +-- route/event_listen.go | 27 ++++++++++--------- route/v1.go | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service index 45a16d1..f52ae1c 100644 --- a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service +++ b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service @@ -1,7 +1,5 @@ [Unit] -After=casaos-gateway.service After=casaos-message-bus.service -After=casaos-local-storage.service ConditionFileNotEmpty=/etc/casaos/user-service.conf Description=CasaOS User Service diff --git a/main.go b/main.go index 07fbcc9..4f400b3 100644 --- a/main.go +++ b/main.go @@ -83,7 +83,6 @@ func init() { } func main() { - go route.EventListen() v1Router := route.InitRouter() v2Router := route.InitV2Router() @@ -125,7 +124,7 @@ func main() { } else { logger.Info("This process is not running as a systemd service.") } - + go route.EventListen() logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) s := &http.Server{ diff --git a/route/event_listen.go b/route/event_listen.go index d6f559a..892bb9a 100644 --- a/route/event_listen.go +++ b/route/event_listen.go @@ -3,7 +3,7 @@ package route import ( "encoding/json" "fmt" - "log" + "strconv" "strings" "time" @@ -18,7 +18,7 @@ import ( ) func EventListen() { - for i := 0; i < 100; i++ { + for i := 0; i < 1000; i++ { messageBusUrl, err := external.GetMessageBusAddress(config.CommonInfo.RuntimePath) if err != nil { @@ -29,28 +29,29 @@ func EventListen() { wsURL := fmt.Sprintf("ws://%s/event/%s", strings.ReplaceAll(messageBusUrl, "http://", ""), "local-storage") ws, err := websocket.Dial(wsURL, "", "http://localhost") if err != nil { - logger.Error("connect websocket err", zap.Any("error", err)) - time.Sleep(time.Second * 5) + logger.Error("connect websocket err"+strconv.Itoa(i), zap.Any("error", err)) + time.Sleep(time.Second * 1) continue } defer ws.Close() - log.Println("subscribed to", wsURL) + logger.Info("subscribed to", zap.Any("url", wsURL)) for { msg := make([]byte, 1024) n, err := ws.Read(msg) if err != nil { - log.Fatalln(err.Error()) + logger.Error("err", zap.Any("err", err.Error())) } var event message_bus.Event if err := json.Unmarshal(msg[:n], &event); err != nil { - log.Println(err.Error()) + logger.Error("err", zap.Any("err", err.Error())) } propertiesStr, err := json.Marshal(event.Properties) if err != nil { + logger.Error("marshal error", zap.Any("err", err.Error()), zap.Any("event", event)) continue } model := model.EventModel{ @@ -59,12 +60,14 @@ func EventListen() { Properties: string(propertiesStr), UUID: *event.Uuid, } + logger.Info("write to database", zap.Any("model", model)) service.MyService.Event().CreateEvemt(model) - output, err := json.MarshalIndent(event, "", " ") - if err != nil { - log.Println(err.Error()) - } - log.Println(string(output)) + // logger.Info("info", zap.Any("写入信息1", model)) + // output, err := json.MarshalIndent(event, "", " ") + // if err != nil { + // logger.Error("err", zap.Any("err", err.Error())) + // } + // logger.Info("info", zap.Any("写入信息", string(output))) } } } diff --git a/route/v1.go b/route/v1.go index 127f67f..bb1e09a 100644 --- a/route/v1.go +++ b/route/v1.go @@ -13,7 +13,7 @@ import ( func InitRouter() *gin.Engine { r := gin.Default() r.Use(middleware.Cors()) - r.Use(middleware.WriteLog()) + //r.Use(middleware.WriteLog()) r.Use(gzip.Gzip(gzip.DefaultCompression)) // check if environment variable is set From 8c960524e067b16bf59b6f47516bc197b8a5ddf4 Mon Sep 17 00:00:00 2001 From: LinkLeong Date: Wed, 7 Dec 2022 03:56:35 +0000 Subject: [PATCH 53/95] add error log --- route/event_listen.go | 1 + 1 file changed, 1 insertion(+) diff --git a/route/event_listen.go b/route/event_listen.go index 892bb9a..dc096d9 100644 --- a/route/event_listen.go +++ b/route/event_listen.go @@ -70,4 +70,5 @@ func EventListen() { // logger.Info("info", zap.Any("写入信息", string(output))) } } + logger.Error("error when try to connect to message bus") } From 856c5aeb485303e16c88e1fe3babc9ea53e65e79 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 29 Dec 2022 18:19:49 -0500 Subject: [PATCH 54/95] add `upx` as part of building step to shrink the size of binary files (#28) --- .github/workflows/release.yml | 2 +- .goreleaser.yaml | 30 ++++++ cmd/migration-tool/main.go | 10 +- common/version.go | 2 +- go.mod | 63 ++++++------- go.sum | 168 ++++++++++++++++------------------ main.go | 7 +- 7 files changed, 160 insertions(+), 122 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 188441f..5bcca83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: run: | sudo apt update sudo apt-get --no-install-recommends --yes install \ - libc6-dev-amd64-cross \ + upx libc6-dev-amd64-cross \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 5ee3628..a23c733 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,9 +10,14 @@ before: builds: - id: casaos-user-service-amd64 binary: build/sysroot/usr/bin/casaos-user-service + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" env: - CC=x86_64-linux-gnu-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" @@ -26,9 +31,14 @@ builds: - amd64 - id: casaos-user-service-arm64 binary: build/sysroot/usr/bin/casaos-user-service + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" env: - CC=aarch64-linux-gnu-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" @@ -42,9 +52,14 @@ builds: - arm64 - id: casaos-user-service-arm-7 binary: build/sysroot/usr/bin/casaos-user-service + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" env: - CC=arm-linux-gnueabihf-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" @@ -60,10 +75,15 @@ builds: - "7" - id: casaos-user-service-migration-tool-amd64 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" main: ./cmd/migration-tool env: - CC=x86_64-linux-gnu-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" @@ -77,10 +97,15 @@ builds: - amd64 - id: casaos-user-service-migration-tool-arm64 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" main: ./cmd/migration-tool env: - CC=aarch64-linux-gnu-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" @@ -94,10 +119,15 @@ builds: - arm64 - id: casaos-user-service-migration-tool-arm-7 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool + hooks: + post: + - upx --best --lzma -v --no-progress "{{ .Path }}" main: ./cmd/migration-tool env: - CC=arm-linux-gnueabihf-gcc ldflags: + - -X main.commit={{.Commit}} + - -X main.date={{.Date}} - -s - -w - -extldflags "-static" diff --git a/cmd/migration-tool/main.go b/cmd/migration-tool/main.go index e725a57..cbf1322 100644 --- a/cmd/migration-tool/main.go +++ b/cmd/migration-tool/main.go @@ -21,7 +21,12 @@ const ( //go:embedded ../../build/sysroot/etc/casaos/user-service.conf.sample //var _userServiceConfigFileSample string -var _logger *Logger +var ( + commit = "private build" + date = "private build" + + _logger *Logger +) // var _status *version.GlobalMigrationStatus @@ -36,6 +41,9 @@ func main() { os.Exit(0) } + println("git commit:", commit) + println("build date:", date) + _logger = NewLogger() if os.Getuid() != 0 { diff --git a/common/version.go b/common/version.go index 876bac4..529e972 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.4.0" +const Version = "0.4.1" diff --git a/go.mod b/go.mod index 64a3b36..782d8df 100644 --- a/go.mod +++ b/go.mod @@ -3,40 +3,41 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.19 require ( - github.com/IceWhaleTech/CasaOS-Common v0.3.8 + github.com/IceWhaleTech/CasaOS-Common v0.4.0 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf - github.com/deepmap/oapi-codegen v1.12.2 - github.com/getkin/kin-openapi v0.108.0 + github.com/deepmap/oapi-codegen v1.12.4 + github.com/getkin/kin-openapi v0.112.0 github.com/gin-contrib/gzip v0.0.6 - github.com/gin-gonic/gin v1.8.1 - github.com/glebarez/sqlite v1.5.0 - github.com/labstack/echo/v4 v4.9.1 + github.com/gin-gonic/gin v1.8.2 + github.com/glebarez/sqlite v1.6.0 + github.com/labstack/echo/v4 v4.10.0 github.com/satori/go.uuid v1.2.0 - github.com/tidwall/gjson v1.14.1 - go.uber.org/zap v1.21.0 - golang.org/x/net v0.1.0 + github.com/tidwall/gjson v1.14.4 + go.uber.org/zap v1.24.0 + golang.org/x/net v0.4.0 gopkg.in/ini.v1 v1.67.0 - gorm.io/gorm v1.24.0 + gorm.io/gorm v1.24.2 ) require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect - github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/glebarez/go-sqlite v1.19.1 // indirect + github.com/glebarez/go-sqlite v1.20.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/swag v0.21.1 // indirect + github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect - github.com/goccy/go-json v0.9.11 // indirect - github.com/godbus/dbus/v5 v5.0.4 // indirect + github.com/goccy/go-json v0.10.0 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/mux v1.8.0 // indirect - github.com/invopop/yaml v0.1.0 // indirect + github.com/invopop/yaml v0.2.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -45,29 +46,29 @@ require ( github.com/leodido/go-urn v1.2.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/pelletier/go-toml/v2 v2.0.5 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect - github.com/ugorji/go/codec v1.2.7 // indirect + github.com/tidwall/pretty v1.2.1 // indirect + github.com/ugorji/go/codec v1.2.8 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/sys v0.1.0 // indirect - golang.org/x/text v0.4.0 // indirect - golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + golang.org/x/crypto v0.4.0 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect + golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.19.0 // indirect + modernc.org/libc v1.22.2 // indirect modernc.org/mathutil v1.5.0 // indirect - modernc.org/memory v1.4.0 // indirect - modernc.org/sqlite v1.19.1 // indirect + modernc.org/memory v1.5.0 // indirect + modernc.org/sqlite v1.20.1 // indirect ) diff --git a/go.sum b/go.sum index 83e99be..032e8d3 100644 --- a/go.sum +++ b/go.sum @@ -1,41 +1,45 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.3.8 h1:cbSREowQBYMEeLbaAjnqhQxOfbAaXgmSLfh7nu3nl7E= -github.com/IceWhaleTech/CasaOS-Common v0.3.8/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk= +github.com/IceWhaleTech/CasaOS-Common v0.4.0 h1:PaNmbQRbqKYdAU/3XFbrk2c6/AWER22eoFyDYa4fQPU= +github.com/IceWhaleTech/CasaOS-Common v0.4.0/go.mod h1:xcemiRsXcs1zrmQxYMyExDjZ7UHYwkJqYE71IDIV0xA= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= +github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deepmap/oapi-codegen v1.12.2 h1:F7SMEn0UMpJV6kWwDYqfDmnnOYHIcU7ETV8qTVFdyI0= -github.com/deepmap/oapi-codegen v1.12.2/go.mod h1:ao2aFwsl/muMHbez870+KelJ1yusV01RznwAFFrVjDc= +github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP7g5Q2s= +github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/getkin/kin-openapi v0.108.0 h1:EYf0GtsKa4hQNIlplGS+Au7NEfGQ1F7MoHD2kcVevPQ= -github.com/getkin/kin-openapi v0.108.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= +github.com/getkin/kin-openapi v0.112.0 h1:lnLXx3bAG53EJVI4E/w0N8i1Y/vUZUEsnrXkgnfn7/Y= +github.com/getkin/kin-openapi v0.112.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/glebarez/go-sqlite v1.19.1 h1:o2XhjyR8CQ2m84+bVz10G0cabmG0tY4sIMiCbrcUTrY= -github.com/glebarez/go-sqlite v1.19.1/go.mod h1:9AykawGIyIcxoSfpYWiX1SgTNHTNsa/FVc75cDkbp4M= -github.com/glebarez/sqlite v1.5.0 h1:+8LAEpmywqresSoGlqjjT+I9m4PseIM3NcerIJ/V7mk= -github.com/glebarez/sqlite v1.5.0/go.mod h1:0wzXzTvfVJIN2GqRhCdMbnYd+m+aH5/QV7B30rM6NgY= +github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= +github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= +github.com/glebarez/go-sqlite v1.20.0 h1:6D9uRXq3Kd+W7At+hOU2eIAeahv6qcYfO8jzmvb4Dr8= +github.com/glebarez/go-sqlite v1.20.0/go.mod h1:uTnJoqtwMQjlULmljLT73Cg7HB+2X6evsBHODyyq1ak= +github.com/glebarez/sqlite v1.6.0 h1:ZpvDLv4zBi2cuuQPitRiVz/5Uh6sXa5d8eBu0xNTpAo= +github.com/glebarez/sqlite v1.6.0/go.mod h1:6D6zPU/HTrFlYmVDKqBJlmQvma90P6r7sRRdkUUZOYk= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= -github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -46,25 +50,30 @@ github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXS github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= -github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= +github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= +github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= +github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= @@ -84,24 +93,23 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y= -github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo= +github.com/labstack/echo/v4 v4.10.0 h1:5CiyngihEO4HXsz3vVsJn7f8xAlWwRr3aY6Ih280ZKA= +github.com/labstack/echo/v4 v4.10.0/go.mod h1:S/T/5fy/GigaXnHTkh0ZGe4LpkkQysvRjFMSUTkDRNQ= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -110,17 +118,16 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= -github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa h1:tEkEyxYeZ43TR55QU/hsIt9aRGBxbgGuz9CGykjvogY= +github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= @@ -137,85 +144,73 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= -github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= +github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= +github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +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/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= -go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= +golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/time v0.0.0-20220411224347-583f2d630306 h1:+gHMid33q6pen7kv9xvT+JRinntgeXO2AeZVd0AWD3w= -golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -226,7 +221,6 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -235,46 +229,46 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.24.0 h1:j/CoiSm6xpRpmzbFJsQHYj+I8bGYWLXVHeYEyyKlF74= -gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0= +gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= +lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.37.0/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= modernc.org/cc/v3 v3.38.1/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= +modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= modernc.org/ccgo/v3 v3.0.0-20220904174949-82d86e1b6d56/go.mod h1:YSXjPL62P2AMSxBphRHPn7IkzhVHqkvOnRKAKh+W6ZI= modernc.org/ccgo/v3 v3.0.0-20220910160915-348f15de615a/go.mod h1:8p47QxPkdugex9J4n9P2tLZ9bK01yngIVp00g4nomW0= -modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= +modernc.org/ccgo/v3 v3.16.13-0.20221017192402-261537637ce8/go.mod h1:fUB3Vn0nVPReA+7IG7yZDfjv1TMWjhQP8gCxrFAtL5g= +modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= modernc.org/libc v1.17.4/go.mod h1:WNg2ZH56rDEwdropAJeZPQkXmDwh+JCA1s/htl6r2fA= modernc.org/libc v1.18.0/go.mod h1:vj6zehR5bfc98ipowQOM2nIDUZnVew/wNC/2tOGS+q0= -modernc.org/libc v1.19.0 h1:bXyVhGQg6KIClTr8FMVIDPl7jtbcs7aS5WP7vLDaxPs= modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= -modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= +modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= +modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= +modernc.org/libc v1.22.2 h1:4U7v51GyhlWqQmwCHj28Rdq2Yzwk55ovjFrdPjs8Hb0= +modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.3.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk= modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= +modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.19.1 h1:8xmS5oLnZtAK//vnd4aTVj8VOeTAccEFOtUnIzfSw+4= -modernc.org/sqlite v1.19.1/go.mod h1:UfQ83woKMaPW/ZBruK0T7YaFCrI+IE0LeWVY6pmnVms= -modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= +modernc.org/sqlite v1.20.0/go.mod h1:EsYz8rfOvLCiYTy5ZFsOYzoCcRMu98YYkwAcCw5YIYw= +modernc.org/sqlite v1.20.1 h1:z6qRLw72B0VfRrJjs3l6hWkzYDx1bo0WGVrBGP4ohhM= +modernc.org/sqlite v1.20.1/go.mod h1:fODt+bFmc/j8LcoCbMSkAuKuGmhxjG45KGc25N2705M= modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/tcl v1.14.0/go.mod h1:gQ7c1YPMvryCHCcmf8acB6VPabE59QBeuRQLL7cTUlM= -modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/tcl v1.15.0/go.mod h1:xRoGotBZ6dU+Zo2tca+2EqVEeMmOUBzHnhIwq4YrVnE= modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.6.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ= +modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ= diff --git a/main.go b/main.go index 4f400b3..221a73a 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,9 @@ import ( const localhost = "127.0.0.1" var ( + commit = "private build" + date = "private build" + //go:embed api/index.html _docHTML string @@ -49,6 +52,9 @@ func init() { os.Exit(0) } + println("git commit:", commit) + println("build date:", date) + config.InitSetup(*configFlag) logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) @@ -83,7 +89,6 @@ func init() { } func main() { - v1Router := route.InitRouter() v2Router := route.InitV2Router() v2DocRouter := route.InitV2DocRouter(_docHTML, _docYAML) From 13b6091c79bebb0afe9ed3176676c083c383b11b Mon Sep 17 00:00:00 2001 From: link Date: Thu, 5 Jan 2023 03:36:45 +0000 Subject: [PATCH 55/95] update migration tool url --- .../migration/script.d/02-migrate-user-service.sh | 15 +++++++++++++++ .../service.d/user-service/migration.list | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build/scripts/migration/script.d/02-migrate-user-service.sh b/build/scripts/migration/script.d/02-migrate-user-service.sh index cb82b6f..a93f49b 100644 --- a/build/scripts/migration/script.d/02-migrate-user-service.sh +++ b/build/scripts/migration/script.d/02-migrate-user-service.sh @@ -56,6 +56,21 @@ __is_migration_needed() { __is_version_gt "${version2}" "${version1}" } +__get_download_domain(){ + local region + # Use ipconfig.io/country and https://ifconfig.io/country_code to get the country code + region=$(curl --connect-timeout 2 -s ipconfig.io/country || echo "") + if [ "${region}" = "" ]; then + region=$(curl --connect-timeout 2 -s https://ifconfig.io/country_code || echo "") + fi + if [[ "${region}" = "China" ]] || [[ "${region}" = "CN" ]]; then + echo "https://casaos.oss-cn-shanghai.aliyuncs.com/" + else + echo "https://github.com/" + fi +} + +DOWNLOAD_DOMAIN=$(__get_download_domain) BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. diff --git a/build/scripts/migration/service.d/user-service/migration.list b/build/scripts/migration/service.d/user-service/migration.list index 2bcb2f3..9f66bcb 100644 --- a/build/scripts/migration/service.d/user-service/migration.list +++ b/build/scripts/migration/service.d/user-service/migration.list @@ -1,3 +1,3 @@ -LEGACY_WITHOUT_VERSION https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz -v0.3.5 https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz -v0.3.5.1 https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz +LEGACY_WITHOUT_VERSION ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz +v0.3.5 ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz +v0.3.5.1 ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UserService/releases/download/v0.3.6/linux-${ARCH}-casaos-user-service-migration-tool-v0.3.6.tar.gz From 4fc80b5a1e78a394fceb2aafd1a9d762af74dd90 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 17 Jan 2023 12:38:22 -0500 Subject: [PATCH 56/95] enable code coverage (#30) --- .github/workflows/codecov.yml | 24 ++++++++++++++++++++++++ .goreleaser.debug.yaml | 2 +- .goreleaser.yaml | 2 +- README.md | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..581786b --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,24 @@ +name: Collect Code Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Go Generate + run: go generate + - name: Run coverage + run: go test -race -failfast -coverprofile=coverage.txt -covermode=atomic -v ./... + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.goreleaser.debug.yaml b/.goreleaser.debug.yaml index 664fbf9..dafcc4d 100644 --- a/.goreleaser.debug.yaml +++ b/.goreleaser.debug.yaml @@ -6,7 +6,7 @@ before: - go generate - go run github.com/google/go-licenses@latest check . --disallowed_types=restricted - go mod tidy - - go test -v ./... + - go test -race -v ./... builds: - id: casaos-user-service-amd64 binary: build/sysroot/usr/bin/casaos-user-service diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a23c733..dba7a6a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,7 +6,7 @@ before: - go generate - go run github.com/google/go-licenses@latest check . --disallowed_types=restricted - go mod tidy - - go test -v ./... + - go test -race -v ./... builds: - id: casaos-user-service-amd64 binary: build/sysroot/usr/bin/casaos-user-service diff --git a/README.md b/README.md index 0c8a9e8..fc187b7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CasaOS-UserService -[![Go Reference](https://pkg.go.dev/badge/github.com/IceWhaleTech/CasaOS-UserService.svg)](https://pkg.go.dev/github.com/IceWhaleTech/CasaOS-UserService) [![Go Report Card](https://goreportcard.com/badge/github.com/IceWhaleTech/CasaOS-UserService)](https://goreportcard.com/report/github.com/IceWhaleTech/CasaOS-UserService) [![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/IceWhaleTech/CasaOS-UserService.svg)](https://pkg.go.dev/github.com/IceWhaleTech/CasaOS-UserService) [![Go Report Card](https://goreportcard.com/badge/github.com/IceWhaleTech/CasaOS-UserService)](https://goreportcard.com/report/github.com/IceWhaleTech/CasaOS-UserService) [![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService/branch/main/graph/badge.svg?token=4GWJIF6FDD)](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService) User Service provides user management functionalities to CasaOS. From 0d57552952b48f5fbd2077d6bdf7cd5343d958a2 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 19 Jan 2023 17:05:39 +0000 Subject: [PATCH 57/95] fix wrong checksum.txt gets uploaded to OSS Signed-off-by: Tiger Wang --- .github/workflows/release.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5bcca83..e34c0c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,32 +12,27 @@ jobs: goreleaser: runs-on: ubuntu-22.04 steps: - - - name: Install dependencies for cross-compiling + - name: Install dependencies for cross-compiling run: | sudo apt update sudo apt-get --no-install-recommends --yes install \ upx libc6-dev-amd64-cross \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - - - name: Fetch all tags + - name: Fetch all tags run: git fetch --force --tags - name: Get version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - - name: Set up Go + - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.19 - - - name: Run GoReleaser + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: # either 'goreleaser' (default) or 'goreleaser-pro' @@ -57,7 +52,7 @@ jobs: region: oss-cn-shanghai bucket: casaos assets: | - dist/checksums.txt:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt + dist/checksums.txt:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz From 3f89c925f234ecb7c2375b7f9cfd563d1b769be2 Mon Sep 17 00:00:00 2001 From: link Date: Tue, 31 Jan 2023 18:27:49 +0800 Subject: [PATCH 58/95] Create push_test_server.yml Signed-off-by: link --- .github/workflows/push_test_server.yml | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/push_test_server.yml diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml new file mode 100644 index 0000000..2c34ae3 --- /dev/null +++ b/.github/workflows/push_test_server.yml @@ -0,0 +1,58 @@ +name: Auto Publish Website +on: + push: + branches: + - main +permissions: + contents: write +jobs: + goreleaser: + runs-on: ubuntu-22.04 + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: isntall git + run: sudo apt install --yes git + - name: git global + run: sudo git config --global --add safe.directory '*' + - + name: Fetch all tags + run: sudo git fetch --force --tags + - name: Get version + id: get_version + # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + run: echo "VERSION=$(git describe --abbrev=0 --tags | awk -F- '{print $1}')" >> $GITHUB_ENV + - name: show version + id: show_version + # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + run: echo ${{env.VERSION}} + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + - name: install sshpass + run: sudo apt install sshpass --yes + - name: copy tar to target host + shell: bash + run: | + sshpass -p "${{ secrets.ssh_password }}" scp -r -o StrictHostKeyChecking=no -P ${{ secrets.ssh_port }} ./dist/*.gz root@${{ secrets.ssh_ip }}:/var/www/download + echo "ping success" + - name: send message + run: | + curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"CasaOS-User updated"}}' https://open.feishu.cn/open-apis/bot/v2/hook/eb8f45c7-9636-4b64-84f2-a66d9aeb9d30 From 76adb01211576bba631d42f0c6592a8dddaaf724 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 9 Feb 2023 19:45:39 -0500 Subject: [PATCH 59/95] fix installation issue for Mint Linux (#31) Signed-off-by: Tiger Wang --- build/scripts/setup/script.d/02-setup-user-service.sh | 4 +++- .../share/casaos/cleanup/script.d/02-cleanup-user-service.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/scripts/setup/script.d/02-setup-user-service.sh b/build/scripts/setup/script.d/02-setup-user-service.sh index a7bdb04..42c98e4 100755 --- a/build/scripts/setup/script.d/02-setup-user-service.sh +++ b/build/scripts/setup/script.d/02-setup-user-service.sh @@ -19,7 +19,9 @@ __get_setup_script_directory_by_os_release() { } || { pushd "${ID}" >/dev/null } || { - pushd "${ID_LIKE}" >/dev/null + [[ -n ${ID_LIKE} ]] && for ID in ${ID_LIKE}; do + pushd "${ID}" >/dev/null && break + done } || { echo "Unsupported OS: ${ID} ${VERSION_CODENAME} (${ID_LIKE})" exit 1 diff --git a/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh index 5a50659..ddd754c 100755 --- a/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh +++ b/build/sysroot/usr/share/casaos/cleanup/script.d/02-cleanup-user-service.sh @@ -16,7 +16,9 @@ __get_setup_script_directory_by_os_release() { } || { pushd "${ID}" &>/dev/null } || { - pushd "${ID_LIKE}" &>/dev/null + [[ -n ${ID_LIKE} ]] && for ID in ${ID_LIKE}; do + pushd "${ID}" >/dev/null && break + done } || { echo "Unsupported OS: ${ID} ${VERSION_CODENAME} (${ID_LIKE})" exit 1 From f054c5340e5e7c07ac32e5fdd94ee6c651269acb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 9 Feb 2023 19:46:34 -0500 Subject: [PATCH 60/95] bump version from 0.4.1 to 0.4.2 Signed-off-by: Tiger Wang --- common/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index 529e972..9a3ad2a 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.4.1" +const Version = "0.4.2" From f4dda2d6dd4240e9600eefe8b3d351e173311008 Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Fri, 17 Feb 2023 13:40:26 +0800 Subject: [PATCH 61/95] Update push_test_server.yml Signed-off-by: raller1028 <57336867+raller1028@users.noreply.github.com> --- .github/workflows/push_test_server.yml | 36 +++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml index 2c34ae3..df67ad0 100644 --- a/.github/workflows/push_test_server.yml +++ b/.github/workflows/push_test_server.yml @@ -21,38 +21,44 @@ jobs: - name: Fetch all tags run: sudo git fetch --force --tags - - name: Get version - id: get_version - # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - run: echo "VERSION=$(git describe --abbrev=0 --tags | awk -F- '{print $1}')" >> $GITHUB_ENV - - name: show version - id: show_version - # run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - run: echo ${{env.VERSION}} - - - name: Set up Go + + - name: set version + run: sudo git tag v99.99.99-alpha + + - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.19 - - - name: Run GoReleaser + + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest - args: release --rm-dist + args: release --rm-dist --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + - name: remove migration file + run: find . -type f \( -name '*migration*' \) -delete + - name: install sshpass run: sudo apt install sshpass --yes + + - name: ZeroTier + uses: zerotier/github-action@v1.0.1 + with: + network_id: ${{ secrets.ZEROTIER_NETWORK_ID }} + auth_token: ${{ secrets.ZEROTIER_CENTRAL_TOKEN }} + - name: copy tar to target host shell: bash run: | - sshpass -p "${{ secrets.ssh_password }}" scp -r -o StrictHostKeyChecking=no -P ${{ secrets.ssh_port }} ./dist/*.gz root@${{ secrets.ssh_ip }}:/var/www/download + sshpass -p "${{ secrets.ssh_password }}" scp -r -o StrictHostKeyChecking=no -P 22 ./dist/*.gz root@10.147.18.11:/var/www/download echo "ping success" - name: send message run: | - curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"CasaOS-User updated"}}' https://open.feishu.cn/open-apis/bot/v2/hook/eb8f45c7-9636-4b64-84f2-a66d9aeb9d30 + curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"text","content":{"text":"CasaOS-User updated"}}' ${{ secrets.SSH_ROBOT_URL }} From b7cc389ef9759c592eb41b6d283088f92d5c517f Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Tue, 21 Feb 2023 16:49:30 +0800 Subject: [PATCH 62/95] Update push_test_server.yml Signed-off-by: raller1028 <57336867+raller1028@users.noreply.github.com> --- .github/workflows/push_test_server.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml index df67ad0..6345ba7 100644 --- a/.github/workflows/push_test_server.yml +++ b/.github/workflows/push_test_server.yml @@ -53,6 +53,17 @@ jobs: with: network_id: ${{ secrets.ZEROTIER_NETWORK_ID }} auth_token: ${{ secrets.ZEROTIER_CENTRAL_TOKEN }} + + - name: ping host + shell: bash + run: | + count=10 + while ! ping -c 1 10.147.18.11 ; do + echo "waiting..." ; + sleep 1 ; + let count=count-1 + done + echo "ping success" - name: copy tar to target host shell: bash From ac34a1356d373ce1a0bad62de06dd090c08eb5d5 Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:49:35 +0800 Subject: [PATCH 63/95] Update push_test_server.yml Signed-off-by: raller1028 <57336867+raller1028@users.noreply.github.com> --- .github/workflows/push_test_server.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml index 6345ba7..baf2cc3 100644 --- a/.github/workflows/push_test_server.yml +++ b/.github/workflows/push_test_server.yml @@ -26,9 +26,9 @@ jobs: run: sudo git tag v99.99.99-alpha - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 'stable' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 From f5fcd9ed92bc3a3ea9b3b1426ae4706c45d3a4c6 Mon Sep 17 00:00:00 2001 From: zhanghengxin <812718649@qq.com> Date: Thu, 16 Mar 2023 02:07:38 +0800 Subject: [PATCH 64/95] =?UTF-8?q?=F0=9F=8E=A8:=20Add=20openapi.=20(#32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghengxin <812718649@qq.com> --- .github/workflows/publish_npm.yml | 38 +++++++++++++++++++++++++++++++ .gitignore | 7 +++++- README.md | 25 ++++++++++++++++++++ package.json | 36 +++++++++++++++++++++++++++++ tsconfig.json | 25 ++++++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish_npm.yml create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml new file mode 100644 index 0000000..af88fec --- /dev/null +++ b/.github/workflows/publish_npm.yml @@ -0,0 +1,38 @@ +name: publish npm + +on: + push: + tags: + - v*.*.* + workflow_dispatch: + +permissions: + contents: write + +jobs: + publish-npm: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - name: Get version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Set version + run: | + apt install jq + jq '.version="${{ steps.get_version.outputs.VERSION }}"' package.json > package.json.new + mv package.json.new package.json + - name: Generate SDK + run: | + npm cache clean --force + npm install @openapitools/openapi-generator-cli -g + make build + - run: npm i + - run: npm run start + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 03f08ff..bbd1446 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,9 @@ target/ dist/ __debug_bin -codegen/ \ No newline at end of file +codegen/ + +node_modules/ +dist/ +.idea +.package-lock.json \ No newline at end of file diff --git a/README.md b/README.md index fc187b7..7379f01 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,28 @@ [![Go Reference](https://pkg.go.dev/badge/github.com/IceWhaleTech/CasaOS-UserService.svg)](https://pkg.go.dev/github.com/IceWhaleTech/CasaOS-UserService) [![Go Report Card](https://goreportcard.com/badge/github.com/IceWhaleTech/CasaOS-UserService)](https://goreportcard.com/report/github.com/IceWhaleTech/CasaOS-UserService) [![goreleaser](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml/badge.svg)](https://github.com/IceWhaleTech/CasaOS-UserService/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService/branch/main/graph/badge.svg?token=4GWJIF6FDD)](https://codecov.io/gh/IceWhaleTech/CasaOS-UserService) User Service provides user management functionalities to CasaOS. + + + +## publish api to npm + +### edit version in package.json + +### run +```bash +yarn + +yarn start +``` + +### publish + +Manual publish +```bash +yarn publish +``` + +Auto publish +```bash +git push origin dev** +``` \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ce77a7 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "casaos-userservice-openapi", + "version": "0.0.1", + "scripts": { + "build": "rm -rf dist && tsc && rm -rf generate", + "generate:local": "openapi-generator-cli generate -g typescript-axios -i ./api/user-service/openapi.yaml -o ./generate", + "generate:npx": "npx @openapitools/openapi-generator-cli generate -g typescript-axios -i ./api/user-service/openapi.yaml -o ./generate", + "generate:ts": "npx openapi-typescript-codegen --input ./api/user-service/openapi.yaml --output ./generate", + "publish": "npm publish --access public", + "start": "yarn generate:ts && yarn build" + }, + "homepage": "https://github.com/IceWhaleTech/CasaOS-UserService#readme", + "description": "Casaos-Localstorage Typescript+Axios SDK", + "keywords": [ + "CasaOS-UserService", + "SDK", + "CasaOS-UserService Axios" + ], + "main": "dist/index", + "files": [ + "LICENSE", + "README.md", + "dist" + ], + "dependencies": { + "axios": "^1.1.0" + }, + "devDependencies": { + "@openapitools/openapi-generator-cli": "2.5.2", + "@types/node": "^18.8.3", + "openapi-typescript-codegen": "^0.23.0", + "typescript": "^4.9.5" + }, + "author": "casaos", + "license": "Apache-2.0" +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..89d3573 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "declaration": true, + "lib": [ + "es2017", + "DOM" + ], + "module": "commonjs", + "target": "es6", + "skipLibCheck": true, + "sourceMap": false, + "strict": true, + "useUnknownInCatchVariables": false, + "resolveJsonModule": true, + "esModuleInterop": true, + "outDir": "dist", + "types": [ + "node" + ], + }, + "exclude": [ + "node_modules" + ], + "main": "generate/index" +} \ No newline at end of file From 6dfbf0eba9fcea4b57a5459d7dc44d2e299871ba Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 21 Mar 2023 22:57:30 -0400 Subject: [PATCH 65/95] update github workflow with newer version of different actions (#33) --- .github/workflows/codecov.yml | 2 +- .github/workflows/publish_npm.yml | 4 ++-- .github/workflows/push_test_server.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 581786b..c7daecd 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Go Generate diff --git a/.github/workflows/publish_npm.yml b/.github/workflows/publish_npm.yml index af88fec..91db9f4 100644 --- a/.github/workflows/publish_npm.yml +++ b/.github/workflows/publish_npm.yml @@ -13,8 +13,8 @@ jobs: publish-npm: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: 16 registry-url: https://registry.npmjs.org/ diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml index baf2cc3..18fce62 100644 --- a/.github/workflows/push_test_server.yml +++ b/.github/workflows/push_test_server.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: isntall git @@ -26,12 +26,12 @@ jobs: run: sudo git tag v99.99.99-alpha - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: 'stable' - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v4 with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e34c0c5..e4534ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Fetch all tags @@ -29,11 +29,11 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: 1.19 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v4 with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser From 7ef878cb1a6238aa427b910b42b8d6229f4b1071 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 25 Mar 2023 23:27:34 -0400 Subject: [PATCH 66/95] upgrade dependencies (#34) Signed-off-by: Tiger Wang --- .github/workflows/codecov.yml | 4 + .github/workflows/release.yml | 2 +- common/version.go | 2 +- go.mod | 65 +++++------ go.sum | 197 ++++++++++++++-------------------- 5 files changed, 122 insertions(+), 148 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index c7daecd..e8f4851 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -16,6 +16,10 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" - name: Go Generate run: go generate - name: Run coverage diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4534ae..475861a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: "1.20" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/common/version.go b/common/version.go index 9a3ad2a..f921571 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.4.2" +const Version = "0.4.3" diff --git a/go.mod b/go.mod index 782d8df..f90e248 100644 --- a/go.mod +++ b/go.mod @@ -1,40 +1,42 @@ module github.com/IceWhaleTech/CasaOS-UserService -go 1.19 +go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.0 + github.com/IceWhaleTech/CasaOS-Common v0.4.3 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 - github.com/getkin/kin-openapi v0.112.0 + github.com/getkin/kin-openapi v0.115.0 github.com/gin-contrib/gzip v0.0.6 - github.com/gin-gonic/gin v1.8.2 - github.com/glebarez/sqlite v1.6.0 - github.com/labstack/echo/v4 v4.10.0 + github.com/gin-gonic/gin v1.9.0 + github.com/glebarez/sqlite v1.7.0 + github.com/labstack/echo/v4 v4.10.2 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.4 go.uber.org/zap v1.24.0 - golang.org/x/net v0.4.0 + golang.org/x/net v0.8.0 gopkg.in/ini.v1 v1.67.0 - gorm.io/gorm v1.24.2 + gorm.io/gorm v1.24.6 ) require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect + github.com/bytedance/sonic v1.8.6 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/dustin/go-humanize v1.0.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/glebarez/go-sqlite v1.20.0 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/glebarez/go-sqlite v1.21.0 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/swag v0.22.3 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.1 // indirect - github.com/goccy/go-json v0.10.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.12.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/golang-jwt/jwt/v4 v4.4.3 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/invopop/yaml v0.2.0 // indirect @@ -42,33 +44,36 @@ require ( github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/labstack/gommon v0.4.0 // indirect - github.com/leodido/go-urn v1.2.1 // indirect + github.com/leodido/go-urn v1.2.2 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect + github.com/pelletier/go-toml/v2 v2.0.7 // indirect + github.com/perimeterx/marshmallow v1.1.4 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect - github.com/ugorji/go/codec v1.2.8 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.4.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect + go.uber.org/multierr v1.10.0 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect golang.org/x/time v0.3.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.22.2 // indirect + modernc.org/libc v1.22.3 // indirect modernc.org/mathutil v1.5.0 // indirect modernc.org/memory v1.5.0 // indirect - modernc.org/sqlite v1.20.1 // indirect + modernc.org/sqlite v1.21.0 // indirect ) diff --git a/go.sum b/go.sum index 032e8d3..221b689 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,17 @@ -github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= -github.com/IceWhaleTech/CasaOS-Common v0.4.0 h1:PaNmbQRbqKYdAU/3XFbrk2c6/AWER22eoFyDYa4fQPU= -github.com/IceWhaleTech/CasaOS-Common v0.4.0/go.mod h1:xcemiRsXcs1zrmQxYMyExDjZ7UHYwkJqYE71IDIV0xA= +github.com/IceWhaleTech/CasaOS-Common v0.4.3 h1:sYsWYhP5EyksH6D0BDv8secIRGAKUZZDTIKqACdFZQ4= +github.com/IceWhaleTech/CasaOS-Common v0.4.3/go.mod h1:zLzM1RhoBRDdW7DFlEoPq18OhbJYsvc8yFodW0bm/QI= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.6 h1:aUgO9S8gvdN6SyW2EhIpAw5E4ChworywIEndZCkCVXk= +github.com/bytedance/sonic v1.8.6/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= @@ -20,63 +22,64 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP7g5Q2s= github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/getkin/kin-openapi v0.112.0 h1:lnLXx3bAG53EJVI4E/w0N8i1Y/vUZUEsnrXkgnfn7/Y= -github.com/getkin/kin-openapi v0.112.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/getkin/kin-openapi v0.115.0 h1:c8WHRLVY3G8m9jQTy0/DnIuljgRwTCB5twZytQS4JyU= +github.com/getkin/kin-openapi v0.115.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= -github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= -github.com/glebarez/go-sqlite v1.20.0 h1:6D9uRXq3Kd+W7At+hOU2eIAeahv6qcYfO8jzmvb4Dr8= -github.com/glebarez/go-sqlite v1.20.0/go.mod h1:uTnJoqtwMQjlULmljLT73Cg7HB+2X6evsBHODyyq1ak= -github.com/glebarez/sqlite v1.6.0 h1:ZpvDLv4zBi2cuuQPitRiVz/5Uh6sXa5d8eBu0xNTpAo= -github.com/glebarez/sqlite v1.6.0/go.mod h1:6D6zPU/HTrFlYmVDKqBJlmQvma90P6r7sRRdkUUZOYk= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= +github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= +github.com/glebarez/go-sqlite v1.21.0 h1:b8MHPtBagkSD2gntImZPsG3o3QEXgMDxguW/GLUonHQ= +github.com/glebarez/go-sqlite v1.21.0/go.mod h1:GodsA6yGSa3eKbvpr7dS+JaqazzVfMcjIXvx6KHhW/c= +github.com/glebarez/sqlite v1.7.0 h1:A7Xj/KN2Lvie4Z4rrgQHY8MsbebX3NyWsL3n2i82MVI= +github.com/glebarez/sqlite v1.7.0/go.mod h1:PkeevrRlF/1BhQBCnzcMWzgrIk7IOop+qS2jUYLfHhk= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= -github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-playground/validator/v10 v10.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI= +github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= -github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= -github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= @@ -84,7 +87,9 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -93,12 +98,13 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/labstack/echo/v4 v4.10.0 h1:5CiyngihEO4HXsz3vVsJn7f8xAlWwRr3aY6Ih280ZKA= -github.com/labstack/echo/v4 v4.10.0/go.mod h1:S/T/5fy/GigaXnHTkh0ZGe4LpkkQysvRjFMSUTkDRNQ= +github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M= +github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/leodido/go-urn v1.2.2 h1:7z68G0FCGvDk646jz1AelTYNYWrTNm0bEcFAo147wt4= +github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -108,9 +114,8 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -119,18 +124,21 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= +github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= +github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa h1:tEkEyxYeZ43TR55QU/hsIt9aRGBxbgGuz9CGykjvogY= -github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= @@ -142,8 +150,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -151,74 +160,56 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= -github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= -golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -226,49 +217,23 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= -gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0= -gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= -lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.37.0/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= -modernc.org/cc/v3 v3.38.1/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20= -modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= -modernc.org/ccgo/v3 v3.0.0-20220904174949-82d86e1b6d56/go.mod h1:YSXjPL62P2AMSxBphRHPn7IkzhVHqkvOnRKAKh+W6ZI= -modernc.org/ccgo/v3 v3.0.0-20220910160915-348f15de615a/go.mod h1:8p47QxPkdugex9J4n9P2tLZ9bK01yngIVp00g4nomW0= -modernc.org/ccgo/v3 v3.16.13-0.20221017192402-261537637ce8/go.mod h1:fUB3Vn0nVPReA+7IG7yZDfjv1TMWjhQP8gCxrFAtL5g= -modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= -modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= -modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v1.17.4/go.mod h1:WNg2ZH56rDEwdropAJeZPQkXmDwh+JCA1s/htl6r2fA= -modernc.org/libc v1.18.0/go.mod h1:vj6zehR5bfc98ipowQOM2nIDUZnVew/wNC/2tOGS+q0= -modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= -modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0= -modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= -modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= -modernc.org/libc v1.22.2 h1:4U7v51GyhlWqQmwCHj28Rdq2Yzwk55ovjFrdPjs8Hb0= -modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug= +gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s= +gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY= +modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.3.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.20.0/go.mod h1:EsYz8rfOvLCiYTy5ZFsOYzoCcRMu98YYkwAcCw5YIYw= -modernc.org/sqlite v1.20.1 h1:z6qRLw72B0VfRrJjs3l6hWkzYDx1bo0WGVrBGP4ohhM= -modernc.org/sqlite v1.20.1/go.mod h1:fODt+bFmc/j8LcoCbMSkAuKuGmhxjG45KGc25N2705M= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= -modernc.org/tcl v1.15.0/go.mod h1:xRoGotBZ6dU+Zo2tca+2EqVEeMmOUBzHnhIwq4YrVnE= -modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ= +modernc.org/sqlite v1.21.0 h1:4aP4MdUf15i3R3M2mx6Q90WHKz3nZLoz96zlB6tNdow= +modernc.org/sqlite v1.21.0/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= From 28b9015f29ad03e00c1e78be3e2a8a4bda8178bf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 22 Apr 2023 00:46:18 -0400 Subject: [PATCH 67/95] use formal JWT validation (#35) --- go.mod | 30 +++++++++++------------ go.sum | 62 ++++++++++++++++++++++++------------------------ main.go | 37 +++++++++++++++++++++++++---- route/v1.go | 11 +++++++-- route/v1/user.go | 56 +++++++++++++++++++++++++++++++++++-------- route/v2.go | 12 +++++++--- service/user.go | 40 +++++++++++++++++++++++++++---- 7 files changed, 178 insertions(+), 70 deletions(-) diff --git a/go.mod b/go.mod index f90e248..f21d2c8 100644 --- a/go.mod +++ b/go.mod @@ -3,31 +3,31 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.3 + github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 - github.com/getkin/kin-openapi v0.115.0 + github.com/getkin/kin-openapi v0.116.0 github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.9.0 - github.com/glebarez/sqlite v1.7.0 + github.com/glebarez/sqlite v1.8.0 github.com/labstack/echo/v4 v4.10.2 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.4 go.uber.org/zap v1.24.0 - golang.org/x/net v0.8.0 + golang.org/x/net v0.9.0 gopkg.in/ini.v1 v1.67.0 - gorm.io/gorm v1.24.6 + gorm.io/gorm v1.25.0 ) require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect - github.com/benbjohnson/clock v1.3.0 // indirect - github.com/bytedance/sonic v1.8.6 // indirect + github.com/benbjohnson/clock v1.3.1 // indirect + github.com/bytedance/sonic v1.8.7 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/glebarez/go-sqlite v1.21.0 // indirect + github.com/glebarez/go-sqlite v1.21.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/locales v0.14.1 // indirect @@ -46,7 +46,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/labstack/gommon v0.4.0 // indirect - github.com/leodido/go-urn v1.2.2 // indirect + github.com/leodido/go-urn v1.2.3 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.18 // indirect @@ -63,17 +63,17 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.10.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.8.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.22.3 // indirect + modernc.org/libc v1.22.4 // indirect modernc.org/mathutil v1.5.0 // indirect modernc.org/memory v1.5.0 // indirect - modernc.org/sqlite v1.21.0 // indirect + modernc.org/sqlite v1.21.2 // indirect ) diff --git a/go.sum b/go.sum index 221b689..789dca7 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,14 @@ -github.com/IceWhaleTech/CasaOS-Common v0.4.3 h1:sYsWYhP5EyksH6D0BDv8secIRGAKUZZDTIKqACdFZQ4= -github.com/IceWhaleTech/CasaOS-Common v0.4.3/go.mod h1:zLzM1RhoBRDdW7DFlEoPq18OhbJYsvc8yFodW0bm/QI= +github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2 h1:EIuQbVpuU2QZVui+ApYCEt27qGCUaQhgHCdOeHmgAwc= +github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2/go.mod h1:iv6fJJs7IKv1tSrsbyA3Fq9xfeKNoaxhqA6IQUBeg9Q= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.1 h1:Heo0FGXzOxUHquZbraxt+tT7UXVDhesUQH5ISbsOkCQ= +github.com/benbjohnson/clock v1.3.1/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.8.6 h1:aUgO9S8gvdN6SyW2EhIpAw5E4ChworywIEndZCkCVXk= -github.com/bytedance/sonic v1.8.6/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.8.7 h1:d3sry5vGgVq/OpgozRUNP6xBsSo0mtNdwliApw+SAMQ= +github.com/bytedance/sonic v1.8.7/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= @@ -24,8 +24,8 @@ github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/getkin/kin-openapi v0.115.0 h1:c8WHRLVY3G8m9jQTy0/DnIuljgRwTCB5twZytQS4JyU= -github.com/getkin/kin-openapi v0.115.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= +github.com/getkin/kin-openapi v0.116.0 h1:o986hwgMzR972JzOG5j6+WTwWqllZLs1EJKMKCivs2E= +github.com/getkin/kin-openapi v0.116.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -33,10 +33,10 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= -github.com/glebarez/go-sqlite v1.21.0 h1:b8MHPtBagkSD2gntImZPsG3o3QEXgMDxguW/GLUonHQ= -github.com/glebarez/go-sqlite v1.21.0/go.mod h1:GodsA6yGSa3eKbvpr7dS+JaqazzVfMcjIXvx6KHhW/c= -github.com/glebarez/sqlite v1.7.0 h1:A7Xj/KN2Lvie4Z4rrgQHY8MsbebX3NyWsL3n2i82MVI= -github.com/glebarez/sqlite v1.7.0/go.mod h1:PkeevrRlF/1BhQBCnzcMWzgrIk7IOop+qS2jUYLfHhk= +github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= +github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= +github.com/glebarez/sqlite v1.8.0 h1:02X12E2I/4C1n+v90yTqrjRa8yuo7c3KeHI3FRznCvc= +github.com/glebarez/sqlite v1.8.0/go.mod h1:bpET16h1za2KOOMb8+jCp6UBP/iahDpfPQqSaYLTLx8= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= @@ -103,8 +103,8 @@ github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.2 h1:7z68G0FCGvDk646jz1AelTYNYWrTNm0bEcFAo147wt4= -github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ= +github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= +github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -138,7 +138,6 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= @@ -173,20 +172,20 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= 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/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -195,13 +194,14 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -226,14 +226,14 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s= -gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY= -modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw= +gorm.io/gorm v1.25.0 h1:+KtYtb2roDz14EQe4bla8CbQlmb9dN3VejSai3lprfU= +gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +modernc.org/libc v1.22.4 h1:wymSbZb0AlrjdAVX3cjreCHTPCpPARbQXNz6BHPzdwQ= +modernc.org/libc v1.22.4/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/sqlite v1.21.0 h1:4aP4MdUf15i3R3M2mx6Q90WHKz3nZLoz96zlB6tNdow= -modernc.org/sqlite v1.21.0/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI= +modernc.org/sqlite v1.21.2 h1:ixuUG0QS413Vfzyx6FWx6PYTmHaOegTY+hjzhn7L+a0= +modernc.org/sqlite v1.21.2/go.mod h1:cxbLkB5WS32DnQqeH4h4o1B0eMr8W/y8/RGuxQ3JsC0= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/main.go b/main.go index 221a73a..4c39f7c 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,14 @@ import ( "net" "net/http" "os" + "path/filepath" + "strings" "time" + "github.com/IceWhaleTech/CasaOS-Common/external" "github.com/IceWhaleTech/CasaOS-Common/model" util_http "github.com/IceWhaleTech/CasaOS-Common/utils/http" + "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" @@ -93,11 +97,19 @@ func main() { v2Router := route.InitV2Router() v2DocRouter := route.InitV2DocRouter(_docHTML, _docYAML) + _, publicKey := service.MyService.User().GetKeyPair() + + jswkJSON, err := jwt.GenerateJwksJSON(publicKey) + if err != nil { + panic(err) + } + mux := &util_http.HandlerMultiplexer{ HandlerMap: map[string]http.Handler{ - "v1": v1Router, - "v2": v2Router, - "doc": v2DocRouter, + "v1": v1Router, + "v2": v2Router, + "doc": v2DocRouter, + strings.SplitN(jwt.JWKSPath, "/", 2)[0]: jwt.JWKSHandler(jswkJSON), }, } @@ -110,6 +122,7 @@ func main() { "/v1/users", route.V2APIPath, route.V2DocPath, + "/" + jwt.JWKSPath, } for _, v := range apiPaths { err = service.MyService.Gateway().CreateRoute(&model.Route{ @@ -122,6 +135,12 @@ func main() { } } + // write address file + addressFilePath, err := writeAddressFile(config.CommonInfo.RuntimePath, external.UserServiceAddressFilename, "http://"+listener.Addr().String()) + if err != nil { + panic(err) + } + if supported, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil { logger.Error("Failed to notify systemd that user service is ready", zap.Any("error", err)) } else if supported { @@ -130,7 +149,7 @@ func main() { logger.Info("This process is not running as a systemd service.") } go route.EventListen() - logger.Info("User service is listening...", zap.Any("address", listener.Addr().String())) + logger.Info("User service is listening...", zap.Any("address", listener.Addr().String()), zap.String("filepath", addressFilePath)) s := &http.Server{ Handler: mux, @@ -142,3 +161,13 @@ func main() { panic(err) } } + +func writeAddressFile(runtimePath string, filename string, address string) (string, error) { + err := os.MkdirAll(runtimePath, 0o755) + if err != nil { + return "", err + } + + filepath := filepath.Join(runtimePath, filename) + return filepath, os.WriteFile(filepath, []byte(address), 0o600) +} diff --git a/route/v1.go b/route/v1.go index bb1e09a..4f31cd5 100644 --- a/route/v1.go +++ b/route/v1.go @@ -1,11 +1,13 @@ package route import ( + "crypto/ecdsa" "os" "github.com/IceWhaleTech/CasaOS-Common/middleware" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" v1 "github.com/IceWhaleTech/CasaOS-UserService/route/v1" + "github.com/IceWhaleTech/CasaOS-UserService/service" "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" ) @@ -13,7 +15,7 @@ import ( func InitRouter() *gin.Engine { r := gin.Default() r.Use(middleware.Cors()) - //r.Use(middleware.WriteLog()) + // r.Use(middleware.WriteLog()) r.Use(gzip.Gzip(gzip.DefaultCompression)) // check if environment variable is set @@ -34,7 +36,12 @@ func InitRouter() *gin.Engine { v1Group := r.Group("/v1") - v1Group.Use(jwt.JWT()) + v1Group.Use(jwt.JWT( + func() (*ecdsa.PublicKey, error) { + _, publicKey := service.MyService.User().GetKeyPair() + return publicKey, nil + }, + )) { v1UsersGroup := v1Group.Group("/users") v1UsersGroup.Use() diff --git a/route/v1/user.go b/route/v1/user.go index 773502d..1034bad 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -1,6 +1,7 @@ package v1 import ( + "crypto/ecdsa" json2 "encoding/json" "io" "net/http" @@ -109,9 +110,23 @@ func PostUserLogin(c *gin.Context) { model.Result{Success: common_err.PWD_INVALID, Message: common_err.GetMsg(common_err.PWD_INVALID)}) return } + + privateKey, _ := service.MyService.User().GetKeyPair() + token := system_model.VerifyInformation{} - token.AccessToken = jwt.GetAccessToken(user.Username, user.Password, user.Id) - token.RefreshToken = jwt.GetRefreshToken(user.Username, user.Password, user.Id) + + accessToken, err := jwt.GetAccessToken(user.Username, privateKey, user.Id) + if err != nil { + c.JSON(http.StatusInternalServerError, model.Result{Success: common_err.SERVICE_ERROR, Message: err.Error()}) + } + token.AccessToken = accessToken + + refreshToken, err := jwt.GetRefreshToken(user.Username, privateKey, user.Id) + if err != nil { + c.JSON(http.StatusInternalServerError, model.Result{Success: common_err.SERVICE_ERROR, Message: err.Error()}) + } + token.RefreshToken = refreshToken + token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix() data := make(map[string]interface{}, 2) user.Password = "" @@ -639,20 +654,41 @@ func PostUserRefreshToken(c *gin.Context) { js := make(map[string]string) c.ShouldBind(&js) refresh := js["refresh_token"] - claims, err := jwt.ParseToken(refresh, true) + + privateKey, _ := service.MyService.User().GetKeyPair() + + claims, err := jwt.ParseToken( + refresh, + func() (*ecdsa.PublicKey, error) { + _, publicKey := service.MyService.User().GetKeyPair() + return publicKey, nil + }) if err != nil { - c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE), Data: err.Error()}) + c.JSON(http.StatusUnauthorized, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE), Data: err.Error()}) return } if !claims.VerifyExpiresAt(time.Now(), true) || !claims.VerifyIssuer("refresh", true) { - c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)}) + c.JSON(http.StatusUnauthorized, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)}) return } - newToken := jwt.GetAccessToken(claims.Username, claims.Password, claims.ID) - verifyInfo := system_model.VerifyInformation{} - verifyInfo.AccessToken = newToken - verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.Username, claims.Password, claims.ID) - verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Unix() + + newAccessToken, err := jwt.GetAccessToken(claims.Username, privateKey, claims.ID) + if err != nil { + c.JSON(http.StatusInternalServerError, model.Result{Success: common_err.SERVICE_ERROR, Message: err.Error()}) + return + } + + newRefreshToken, err := jwt.GetRefreshToken(claims.Username, privateKey, claims.ID) + if err != nil { + c.JSON(http.StatusInternalServerError, model.Result{Success: common_err.SERVICE_ERROR, Message: err.Error()}) + return + } + + verifyInfo := system_model.VerifyInformation{ + AccessToken: newAccessToken, + RefreshToken: newRefreshToken, + ExpiresAt: time.Now().Add(3 * time.Hour).Unix(), + } c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo}) } diff --git a/route/v2.go b/route/v2.go index c5fe160..93c2c7a 100644 --- a/route/v2.go +++ b/route/v2.go @@ -1,15 +1,16 @@ package route import ( + "crypto/ecdsa" "net/http" "net/url" "strconv" "strings" - "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" codegen "github.com/IceWhaleTech/CasaOS-UserService/codegen/user_service" v2 "github.com/IceWhaleTech/CasaOS-UserService/route/v2" + "github.com/IceWhaleTech/CasaOS-UserService/service" "github.com/deepmap/oapi-codegen/pkg/middleware" "github.com/getkin/kin-openapi/openapi3" "github.com/getkin/kin-openapi/openapi3filter" @@ -64,8 +65,13 @@ func InitV2Router() http.Handler { return c.RealIP() == "::1" || c.RealIP() == "127.0.0.1" }, ParseTokenFunc: func(token string, c echo.Context) (interface{}, error) { - claims, code := jwt.Validate(token) - if code != common_err.SUCCESS { + valid, claims, err := jwt.Validate( + token, + func() (*ecdsa.PublicKey, error) { + _, publicKey := service.MyService.User().GetKeyPair() + return publicKey, nil + }) + if err != nil || !valid { return nil, echo.ErrUnauthorized } diff --git a/service/user.go b/service/user.go index 21d9148..54bed10 100644 --- a/service/user.go +++ b/service/user.go @@ -10,11 +10,15 @@ package service import ( + "crypto/ecdsa" "io" "mime/multipart" "os" + "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-UserService/service/model" + "go.uber.org/zap" "gorm.io/gorm" ) @@ -31,17 +35,23 @@ type UserService interface { DeleteAllUser() GetUserInfoByUserName(userName string) (m model.UserDBModel) GetAllUserName() (list []model.UserDBModel) + + GetKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey) } var UserRegisterHash = make(map[string]string) type userService struct { + privateKey *ecdsa.PrivateKey // keep this private - NEVER expose it!!! + publicKey *ecdsa.PublicKey + db *gorm.DB } func (u *userService) DeleteAllUser() { u.db.Where("1=1").Delete(&model.UserDBModel{}) } + func (u *userService) DeleteUserById(id string) { u.db.Where("id= ?", id).Delete(&model.UserDBModel{}) } @@ -50,6 +60,7 @@ func (u *userService) GetAllUserName() (list []model.UserDBModel) { u.db.Select("username").Find(&list) return } + func (u *userService) CreateUser(m model.UserDBModel) model.UserDBModel { u.db.Create(&m) return m @@ -63,17 +74,21 @@ func (u *userService) GetUserCount() (userCount int64) { func (u *userService) UpdateUser(m model.UserDBModel) { u.db.Model(&m).Omit("password").Updates(&m) } + func (u *userService) UpdateUserPassword(m model.UserDBModel) { u.db.Model(&m).Update("password", m.Password) } + func (u *userService) GetUserAllInfoById(id string) (m model.UserDBModel) { u.db.Where("id= ?", id).First(&m) return } + func (u *userService) GetUserAllInfoByName(userName string) (m model.UserDBModel) { u.db.Where("username= ?", userName).First(&m) return } + func (u *userService) GetUserInfoById(id string) (m model.UserDBModel) { u.db.Select("username", "id", "role", "nickname", "description", "avatar", "email").Where("id= ?", id).First(&m) return @@ -84,15 +99,30 @@ func (u *userService) GetUserInfoByUserName(userName string) (m model.UserDBMode return } -//上传文件 +// 上传文件 func (c *userService) UpLoadFile(file multipart.File, url string) error { - out, _ := os.OpenFile(url, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + out, _ := os.OpenFile(url, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644) defer out.Close() io.Copy(out, file) return nil } -//获取用户Service -func NewUserService(db *gorm.DB) UserService { - return &userService{db: db} +func (u *userService) GetKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey) { + return u.privateKey, u.publicKey +} + +// 获取用户Service +func NewUserService(db *gorm.DB) UserService { + // DO NOT store private key anywhere - keep it in memory ONLY!!! + privateKey, publicKey, err := jwt.GenerateKeyPair() + if err != nil { + logger.Error("failed to generate key pair for JWT", zap.Error(err)) + return nil + } + + return &userService{ + privateKey: privateKey, + publicKey: publicKey, + db: db, + } } From a2a23d1541960fb6b73ff5ee49ced5ccb5455dc4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 22 Apr 2023 14:03:04 +0000 Subject: [PATCH 68/95] bump version from 0.4.3 to 0.4.4 Signed-off-by: Tiger Wang --- common/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index f921571..feb4161 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,3 @@ package common -const Version = "0.4.3" +const Version = "0.4.4" From 97c42efa711ad0ed7d4e8539ffc0ea053057b652 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 24 Apr 2023 18:22:18 -0400 Subject: [PATCH 69/95] fix extra content in the response body when JWT is invalid (#36) Signed-off-by: Tiger Wang --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f21d2c8..8f20dc7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2 + github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 github.com/getkin/kin-openapi v0.116.0 diff --git a/go.sum b/go.sum index 789dca7..166604f 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2 h1:EIuQbVpuU2QZVui+ApYCEt27qGCUaQhgHCdOeHmgAwc= -github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha2/go.mod h1:iv6fJJs7IKv1tSrsbyA3Fq9xfeKNoaxhqA6IQUBeg9Q= +github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3 h1:OzOihzq8qESNu8aEJfgqoxAECeipoXCjT70gtUKEfY0= +github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3/go.mod h1:iv6fJJs7IKv1tSrsbyA3Fq9xfeKNoaxhqA6IQUBeg9Q= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= From f4e57069351a5320d532373d3b2f0525beceea7e Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Fri, 14 Jul 2023 16:45:34 +0800 Subject: [PATCH 70/95] Update push_test_server.yml (#37) Signed-off-by: raller1028 <57336867+raller1028@users.noreply.github.com> --- .github/workflows/push_test_server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_test_server.yml b/.github/workflows/push_test_server.yml index 18fce62..4cdfa56 100644 --- a/.github/workflows/push_test_server.yml +++ b/.github/workflows/push_test_server.yml @@ -35,7 +35,7 @@ jobs: with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser - version: latest + version: 1.14.1 args: release --rm-dist --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f626b025705b6312586016b1039ed41678fae59e Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Fri, 14 Jul 2023 16:46:26 +0800 Subject: [PATCH 71/95] Update release.yml (#38) Signed-off-by: raller1028 <57336867+raller1028@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 475861a..50f2273 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser - version: latest + version: 1.14.1 args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9a986a60ada2b385e8a843630932c90aacb0a797 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 31 Jul 2023 17:18:09 +0800 Subject: [PATCH 72/95] create default config if it does not already exist (#39) --- .../system/casaos-user-service.service | 1 - main.go | 5 +- pkg/config/init.go | 51 +++++++++++++------ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service index f52ae1c..7fcff9f 100644 --- a/build/sysroot/usr/lib/systemd/system/casaos-user-service.service +++ b/build/sysroot/usr/lib/systemd/system/casaos-user-service.service @@ -1,6 +1,5 @@ [Unit] After=casaos-message-bus.service -ConditionFileNotEmpty=/etc/casaos/user-service.conf Description=CasaOS User Service [Service] diff --git a/main.go b/main.go index 4c39f7c..67a9041 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,9 @@ var ( //go:embed api/user-service/openapi.yaml _docYAML string + + //go:embed build/sysroot/etc/casaos/user-service.conf.sample + _confSample string ) func init() { @@ -59,7 +62,7 @@ func init() { println("git commit:", commit) println("build date:", date) - config.InitSetup(*configFlag) + config.InitSetup(*configFlag, _confSample) logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) diff --git a/pkg/config/init.go b/pkg/config/init.go index 38d9f56..ac9b341 100644 --- a/pkg/config/init.go +++ b/pkg/config/init.go @@ -5,35 +5,56 @@ import ( "log" "os" + "github.com/IceWhaleTech/CasaOS-Common/utils/constants" "github.com/IceWhaleTech/CasaOS-UserService/model" "gopkg.in/ini.v1" ) // models with default values -var CommonInfo = &model.CommonModel{ - RuntimePath: "/var/run/casaos", -} +var ( + CommonInfo = &model.CommonModel{ + RuntimePath: constants.DefaultRuntimePath, + } -var AppInfo = &model.APPModel{ - DBPath: "/var/lib/casaos", - UserDataPath: "/var/lib/casaos", - LogPath: "/var/log/casaos", - LogSaveName: "user", - LogFileExt: "log", -} + AppInfo = &model.APPModel{ + DBPath: constants.DefaultDataPath, + UserDataPath: constants.DefaultDataPath, + LogPath: constants.DefaultLogPath, + LogSaveName: "user", + LogFileExt: "log", + } -var Cfg *ini.File + Cfg *ini.File + ConfigFilePath string +) -func InitSetup(config string) { - configFilePath := UserServiceConfigFilePath +func InitSetup(config string, sample string) { + ConfigFilePath = UserServiceConfigFilePath if len(config) > 0 { - configFilePath = config + ConfigFilePath = config + } + + // create default config file if not exist + if _, err := os.Stat(ConfigFilePath); os.IsNotExist(err) { + fmt.Println("config file not exist, create it") + // create config file + file, err := os.Create(ConfigFilePath) + if err != nil { + panic(err) + } + defer file.Close() + + // write default config + _, err = file.WriteString(sample) + if err != nil { + panic(err) + } } var err error - Cfg, err = ini.Load(configFilePath) + Cfg, err = ini.Load(ConfigFilePath) if err != nil { fmt.Printf("Fail to read file: %v", err) os.Exit(1) From 9c9a30c028ce45274d2be02e62a969e3caec10b4 Mon Sep 17 00:00:00 2001 From: Link Date: Mon, 20 Nov 2023 10:00:15 +0000 Subject: [PATCH 73/95] uodate releaser --- .github/workflows/release.yml | 60 +++++------------------------------ .goreleaser.yaml | 12 +++---- 2 files changed, 14 insertions(+), 58 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50f2273..a1829c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,58 +4,14 @@ on: push: tags: - v*.*.* - permissions: contents: write - jobs: - goreleaser: - runs-on: ubuntu-22.04 - steps: - - name: Install dependencies for cross-compiling - run: | - sudo apt update - sudo apt-get --no-install-recommends --yes install \ - upx libc6-dev-amd64-cross \ - gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Fetch all tags - run: git fetch --force --tags - - name: Get version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.20" - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - # either 'goreleaser' (default) or 'goreleaser-pro' - distribution: goreleaser - version: 1.14.1 - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution - # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - - name: Upload to oss - id: upload_to_oss - uses: tvrcgo/upload-to-oss@master - with: - key-id: ${{ secrets.OSS_KEY_ID }} - key-secret: ${{ secrets.OSS_KEY_SECRET }} - region: oss-cn-shanghai - bucket: casaos - assets: | - dist/checksums.txt:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt - dist/linux-arm-7--casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-arm-7--casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-arm64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz - dist/linux-amd64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS-UserService/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-user-service-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz + call-workflow-passing-data: + uses: IceWhaleTech/github/.github/workflows/go_release.yml@main + with: + project-name: CasaOS-UserService + file-name: casaos-user-service + secrets: + OSS_KEY_ID: ${{ secrets.OSS_KEY_ID }} + OSS_KEY_SECRET: ${{ secrets.OSS_KEY_SECRET }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index dba7a6a..a7aaad5 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -31,9 +31,9 @@ builds: - amd64 - id: casaos-user-service-arm64 binary: build/sysroot/usr/bin/casaos-user-service - hooks: - post: - - upx --best --lzma -v --no-progress "{{ .Path }}" + # hooks: + # post: + # - upx --best --lzma -v --no-progress "{{ .Path }}" env: - CC=aarch64-linux-gnu-gcc ldflags: @@ -97,9 +97,9 @@ builds: - amd64 - id: casaos-user-service-migration-tool-arm64 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool - hooks: - post: - - upx --best --lzma -v --no-progress "{{ .Path }}" + # hooks: + # post: + # - upx --best --lzma -v --no-progress "{{ .Path }}" main: ./cmd/migration-tool env: - CC=aarch64-linux-gnu-gcc From 527e583f22061111b55fd279691f38c4ce3a5b8a Mon Sep 17 00:00:00 2001 From: Link Date: Mon, 20 Nov 2023 10:05:22 +0000 Subject: [PATCH 74/95] update goreleaser --- .goreleaser.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a7aaad5..0e5a436 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -142,24 +142,21 @@ builds: goarm: - "7" archives: - - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-v{{ .Version }}" - id: casaos-user-service + - name_template: >- + {{ .Os }}-{{- if eq .Arch "arm" }}arm-7{{- else }}{{ .Arch }}{{- end }}-{{ .ProjectName }}-v{{ .Version }} builds: - casaos-user-service-amd64 - casaos-user-service-arm64 - casaos-user-service-arm-7 - replacements: - arm: arm-7 files: - build/**/* - - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-migration-tool-v{{ .Version }}" + - name_template: >- + {{ .Os }}-{{- if eq .Arch "arm" }}arm-7{{- else }}{{ .Arch }}{{- end }}-{{ .ProjectName }}-v{{ .Version }} id: casaos-user-service-migration-tool builds: - casaos-user-service-migration-tool-amd64 - casaos-user-service-migration-tool-arm64 - casaos-user-service-migration-tool-arm-7 - replacements: - arm: arm-7 files: - build/sysroot/etc/**/* checksum: From 869aa367f9c9d96b6e644a7a4cb7347d52e9b752 Mon Sep 17 00:00:00 2001 From: Link Date: Mon, 20 Nov 2023 10:10:44 +0000 Subject: [PATCH 75/95] update goreleaser --- .goreleaser.yaml | 2 +- go.mod | 30 +++++++++++++--------- go.sum | 67 ++++++++++++++++++++++++++++-------------------- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0e5a436..b74e4ef 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -151,7 +151,7 @@ archives: files: - build/**/* - name_template: >- - {{ .Os }}-{{- if eq .Arch "arm" }}arm-7{{- else }}{{ .Arch }}{{- end }}-{{ .ProjectName }}-v{{ .Version }} + {{ .Os }}-{{- if eq .Arch "arm" }}arm-7{{- else }}{{ .Arch }}{{- end }}-{{ .ProjectName }}-migration-tool-v{{ .Version }} id: casaos-user-service-migration-tool builds: - casaos-user-service-migration-tool-amd64 diff --git a/go.mod b/go.mod index 8f20dc7..394df3f 100644 --- a/go.mod +++ b/go.mod @@ -3,18 +3,18 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3 + github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 - github.com/getkin/kin-openapi v0.116.0 + github.com/getkin/kin-openapi v0.117.0 github.com/gin-contrib/gzip v0.0.6 - github.com/gin-gonic/gin v1.9.0 + github.com/gin-gonic/gin v1.9.1 github.com/glebarez/sqlite v1.8.0 github.com/labstack/echo/v4 v4.10.2 github.com/satori/go.uuid v1.2.0 github.com/tidwall/gjson v1.14.4 go.uber.org/zap v1.24.0 - golang.org/x/net v0.9.0 + golang.org/x/net v0.17.0 gopkg.in/ini.v1 v1.67.0 gorm.io/gorm v1.25.0 ) @@ -22,21 +22,23 @@ require ( require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/benbjohnson/clock v1.3.1 // indirect - github.com/bytedance/sonic v1.8.7 // indirect + github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/glebarez/go-sqlite v1.21.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.12.0 // indirect + github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/invopop/yaml v0.2.0 // indirect @@ -45,17 +47,20 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/labstack/gommon v0.4.0 // indirect - github.com/leodido/go-urn v1.2.3 // indirect + github.com/leodido/go-urn v1.2.4 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/pelletier/go-toml/v2 v2.0.7 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/perimeterx/marshmallow v1.1.4 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/samber/lo v1.38.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect @@ -65,9 +70,10 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.8.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 166604f..3e45fe2 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3 h1:OzOihzq8qESNu8aEJfgqoxAECeipoXCjT70gtUKEfY0= -github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha3/go.mod h1:iv6fJJs7IKv1tSrsbyA3Fq9xfeKNoaxhqA6IQUBeg9Q= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2 h1:8PuukQvQIlkw9mkK4THKTbSDMio9I6kbXulDTBxG2d0= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -7,8 +7,8 @@ github.com/benbjohnson/clock v1.3.1 h1:Heo0FGXzOxUHquZbraxt+tT7UXVDhesUQH5ISbsOk github.com/benbjohnson/clock v1.3.1/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.8.7 h1:d3sry5vGgVq/OpgozRUNP6xBsSo0mtNdwliApw+SAMQ= -github.com/bytedance/sonic v1.8.7/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= @@ -24,15 +24,17 @@ github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/getkin/kin-openapi v0.116.0 h1:o986hwgMzR972JzOG5j6+WTwWqllZLs1EJKMKCivs2E= -github.com/getkin/kin-openapi v0.116.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/getkin/kin-openapi v0.117.0 h1:QT2DyGujAL09F4NrKDHJGsUoIprlIcFVHWDVDcUFE8A= +github.com/getkin/kin-openapi v0.117.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= -github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= github.com/glebarez/sqlite v1.8.0 h1:02X12E2I/4C1n+v90yTqrjRa8yuo7c3KeHI3FRznCvc= @@ -52,8 +54,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI= -github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= +github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= +github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= @@ -68,7 +70,8 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -92,8 +95,9 @@ github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZX github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -103,8 +107,8 @@ github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= -github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -114,8 +118,8 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -124,8 +128,8 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= -github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -136,8 +140,12 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= +github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= @@ -150,8 +158,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -181,11 +190,13 @@ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUu golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= +golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -195,13 +206,13 @@ golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 5f166b9d3cf973ae818bdd833b3792095e65ed3e Mon Sep 17 00:00:00 2001 From: Link Date: Mon, 27 Nov 2023 08:56:29 +0000 Subject: [PATCH 76/95] add user avatar --- go.mod | 3 ++- go.sum | 5 ++--- route/v1.go | 4 ++-- route/v1/user.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 394df3f..278698b 100644 --- a/go.mod +++ b/go.mod @@ -61,6 +61,7 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/samber/lo v1.38.1 // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect @@ -71,7 +72,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect + golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index 3e45fe2..4187894 100644 --- a/go.sum +++ b/go.sum @@ -159,8 +159,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -192,8 +192,7 @@ golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= diff --git a/route/v1.go b/route/v1.go index 4f31cd5..9413d57 100644 --- a/route/v1.go +++ b/route/v1.go @@ -59,8 +59,8 @@ func InitRouter() *gin.Engine { // v1UserGroup.POST("/file/image/:key", v1.PostUserFileImage) v1UsersGroup.DELETE("/current/image", v1.DeleteUserImage) - // v1UserGroup.PUT("/avatar", v1.PutUserAvatar) - // v1UserGroup.GET("/avatar", v1.GetUserAvatar) + v1UsersGroup.PUT("/avatar", v1.PutUserAvatar) + v1UsersGroup.DELETE("/:id", v1.DeleteUser) v1UsersGroup.GET("/:username", v1.GetUserInfoByUsername) v1UsersGroup.DELETE("", v1.DeleteUserAll) diff --git a/route/v1/user.go b/route/v1/user.go index 1034bad..4ccf1a6 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -150,7 +150,7 @@ func PostUserLogin(c *gin.Context) { // @Param file formData file true "用户头像" // @Security ApiKeyAuth // @Success 200 {string} string "ok" -// @Router /user/avatar [put] +// @Router /users/avatar [put] func PutUserAvatar(c *gin.Context) { id := c.GetHeader("user_id") user := service.MyService.User().GetUserInfoById(id) From 8093de59adc42a914341e2ffce2b419f713acc4a Mon Sep 17 00:00:00 2001 From: Link Date: Thu, 28 Dec 2023 11:34:09 +0000 Subject: [PATCH 77/95] update common --- go.mod | 6 +++--- go.sum | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 278698b..bfe4c38 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2 + github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 github.com/getkin/kin-openapi v0.117.0 @@ -52,7 +52,7 @@ require ( github.com/leodido/go-urn v1.2.4 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect @@ -73,7 +73,7 @@ require ( golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/go.sum b/go.sum index 4187894..4d9eac9 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,4 @@ -github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2 h1:8PuukQvQIlkw9mkK4THKTbSDMio9I6kbXulDTBxG2d0= -github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha2/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3 h1:5E5LAqi2uXpOZqcPOgQ4m6d9MagYyfhKIFXnzd8s3W4= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -118,8 +117,7 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -205,8 +203,7 @@ golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From e6c78401e79cc8fb087a13790b108714a9ca0799 Mon Sep 17 00:00:00 2001 From: link Date: Fri, 29 Dec 2023 08:06:22 +0000 Subject: [PATCH 78/95] update go sum --- go.sum | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go.sum b/go.sum index 4d9eac9..3849aaf 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3 h1:5E5LAqi2uXpOZqcPOgQ4m6d9MagYyfhKIFXnzd8s3W4= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -118,6 +119,7 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -159,6 +161,7 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -191,6 +194,7 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= @@ -204,6 +208,7 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 3eaceda8d1d3aba3c4f1ad0cf586388617037f6b Mon Sep 17 00:00:00 2001 From: link Date: Fri, 29 Dec 2023 15:21:06 +0000 Subject: [PATCH 79/95] update avatar --- route/v1/user.go | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/route/v1/user.go b/route/v1/user.go index 4ccf1a6..60182f1 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -2,8 +2,12 @@ package v1 import ( "crypto/ecdsa" + "encoding/base64" json2 "encoding/json" + "image" + "image/png" "io" + "log" "net/http" url2 "net/url" "os" @@ -15,6 +19,7 @@ import ( "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-UserService/model" "github.com/IceWhaleTech/CasaOS-UserService/model/system_model" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" @@ -23,6 +28,7 @@ import ( model2 "github.com/IceWhaleTech/CasaOS-UserService/service/model" uuid "github.com/satori/go.uuid" "github.com/tidwall/gjson" + "go.uber.org/zap" "github.com/IceWhaleTech/CasaOS-UserService/service" "github.com/gin-gonic/gin" @@ -159,18 +165,35 @@ func PutUserAvatar(c *gin.Context) { model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) return } - f, err := c.FormFile("file") + json := make(map[string]string) + c.ShouldBind(&json) + + data := json["file"] + imgBase64 := strings.Replace(data, "data:image/png;base64,", "", 1) + decodeData, err := base64.StdEncoding.DecodeString(string(imgBase64)) if err != nil { - c.JSON(common_err.CLIENT_ERROR, - model.Result{Success: common_err.CLIENT_ERROR, Message: common_err.GetMsg(common_err.CLIENT_ERROR), Data: err.Error()}) - return + panic(err) } - if len(user.Avatar) > 0 { - os.RemoveAll(config.AppInfo.UserDataPath + "/" + id + "/" + user.Avatar) + + // 将字节数组转为图片 + img, _, err := image.Decode(strings.NewReader(string(decodeData))) + if err != nil { + log.Fatal(err) } - ext := filepath.Ext(f.Filename) + + ext := ".png" avatarPath := config.AppInfo.UserDataPath + "/" + id + "/avatar" + ext - c.SaveUploadedFile(f, avatarPath) + os.Remove(avatarPath) + outFile, err := os.Create(avatarPath) + if err != nil { + logger.Error("create file error", zap.Error(err)) + } + defer outFile.Close() + + err = png.Encode(outFile, img) + if err != nil { + logger.Error("encode error", zap.Error(err)) + } user.Avatar = avatarPath service.MyService.User().UpdateUser(user) c.JSON(http.StatusOK, From b65d1350e340bd9311a44b8f8db2e059ee296e0e Mon Sep 17 00:00:00 2001 From: link Date: Tue, 2 Jan 2024 06:20:48 +0000 Subject: [PATCH 80/95] add get avatar function --- route/v1.go | 1 + route/v1/user.go | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/route/v1.go b/route/v1.go index 9413d57..0c97230 100644 --- a/route/v1.go +++ b/route/v1.go @@ -60,6 +60,7 @@ func InitRouter() *gin.Engine { v1UsersGroup.DELETE("/current/image", v1.DeleteUserImage) v1UsersGroup.PUT("/avatar", v1.PutUserAvatar) + v1UsersGroup.GET("/avatar", v1.PutUserAvatar) v1UsersGroup.DELETE("/:id", v1.DeleteUser) v1UsersGroup.GET("/:username", v1.GetUserInfoByUsername) diff --git a/route/v1/user.go b/route/v1/user.go index 60182f1..71259db 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -172,7 +172,8 @@ func PutUserAvatar(c *gin.Context) { imgBase64 := strings.Replace(data, "data:image/png;base64,", "", 1) decodeData, err := base64.StdEncoding.DecodeString(string(imgBase64)) if err != nil { - panic(err) + c.JSON(http.StatusInternalServerError, model.Result{Success: common_err.SERVICE_ERROR, Message: err.Error()}) + return } // 将字节数组转为图片 @@ -204,6 +205,35 @@ func PutUserAvatar(c *gin.Context) { }) } +// @Summary get user head +// @Produce application/json +// @Tags user +// @Param file formData file true "用户头像" +// @Security ApiKeyAuth +// @Success 200 {string} string "ok" +// @Router /users/avatar [get] +func GetUserAvatar(c *gin.Context) { + id := c.GetHeader("user_id") + user := service.MyService.User().GetUserInfoById(id) + if user.Id == 0 { + c.JSON(common_err.SERVICE_ERROR, + model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + return + } + + if file.Exists(user.Avatar) { + // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析 + c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.File(user.Avatar) + return + } + c.JSON(http.StatusNotFound, + model.Result{ + Success: common_err.SERVICE_ERROR, + Message: user.Avatar + " not found", + }) +} + // @Summary edit user name // @Produce application/json // @Accept application/json From 6267b241a04d837b248ef0d8ceea4ae82d0028a2 Mon Sep 17 00:00:00 2001 From: Link Date: Thu, 4 Jan 2024 03:08:50 +0000 Subject: [PATCH 81/95] update user avatar cache --- route/v1.go | 2 +- route/v1/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/route/v1.go b/route/v1.go index 0c97230..70df0a6 100644 --- a/route/v1.go +++ b/route/v1.go @@ -60,7 +60,7 @@ func InitRouter() *gin.Engine { v1UsersGroup.DELETE("/current/image", v1.DeleteUserImage) v1UsersGroup.PUT("/avatar", v1.PutUserAvatar) - v1UsersGroup.GET("/avatar", v1.PutUserAvatar) + v1UsersGroup.GET("/avatar", v1.GetUserAvatar) v1UsersGroup.DELETE("/:id", v1.DeleteUser) v1UsersGroup.GET("/:username", v1.GetUserInfoByUsername) diff --git a/route/v1/user.go b/route/v1/user.go index 71259db..7224838 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -222,8 +222,8 @@ func GetUserAvatar(c *gin.Context) { } if file.Exists(user.Avatar) { - // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析 c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") c.File(user.Avatar) return } From dc6cf30f7d3dac190c485b3637132a146c84c137 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 4 Jan 2024 04:02:51 +0000 Subject: [PATCH 82/95] update avatar --- route/v1.go | 2 +- route/v1/user.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/route/v1.go b/route/v1.go index 0c97230..70df0a6 100644 --- a/route/v1.go +++ b/route/v1.go @@ -60,7 +60,7 @@ func InitRouter() *gin.Engine { v1UsersGroup.DELETE("/current/image", v1.DeleteUserImage) v1UsersGroup.PUT("/avatar", v1.PutUserAvatar) - v1UsersGroup.GET("/avatar", v1.PutUserAvatar) + v1UsersGroup.GET("/avatar", v1.GetUserAvatar) v1UsersGroup.DELETE("/:id", v1.DeleteUser) v1UsersGroup.GET("/:username", v1.GetUserInfoByUsername) diff --git a/route/v1/user.go b/route/v1/user.go index 71259db..5237b58 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -222,16 +222,14 @@ func GetUserAvatar(c *gin.Context) { } if file.Exists(user.Avatar) { - // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析 c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") c.File(user.Avatar) return } - c.JSON(http.StatusNotFound, - model.Result{ - Success: common_err.SERVICE_ERROR, - Message: user.Avatar + " not found", - }) + user.Avatar = "/usr/share/casaos/www/avatar.svg" + c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.File(user.Avatar) } // @Summary edit user name From 2c1a72c5e5fc394bc9fb894ba4a8990fbcd54742 Mon Sep 17 00:00:00 2001 From: link Date: Tue, 9 Jan 2024 02:41:43 +0000 Subject: [PATCH 83/95] jump local-storage:raid_status event --- route/event_listen.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/route/event_listen.go b/route/event_listen.go index dc096d9..a6e851b 100644 --- a/route/event_listen.go +++ b/route/event_listen.go @@ -60,7 +60,9 @@ func EventListen() { Properties: string(propertiesStr), UUID: *event.Uuid, } - logger.Info("write to database", zap.Any("model", model)) + if event.Name == "local-storage:raid_status" { + continue + } service.MyService.Event().CreateEvemt(model) // logger.Info("info", zap.Any("写入信息1", model)) // output, err := json.MarshalIndent(event, "", " ") From fd925df5d18a969c657369d45a21eac23c3a94f3 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 11 Jan 2024 07:01:22 +0000 Subject: [PATCH 84/95] remove cache --- route/v1/user.go | 1 + 1 file changed, 1 insertion(+) diff --git a/route/v1/user.go b/route/v1/user.go index 5237b58..5cd974d 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -229,6 +229,7 @@ func GetUserAvatar(c *gin.Context) { } user.Avatar = "/usr/share/casaos/www/avatar.svg" c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") c.File(user.Avatar) } From 4d2b65e34c6d01800273009d60756205c08cb0c3 Mon Sep 17 00:00:00 2001 From: link Date: Thu, 11 Jan 2024 09:21:47 +0000 Subject: [PATCH 85/95] add user avatar --- route/v1/user.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/route/v1/user.go b/route/v1/user.go index 5cd974d..bdc352e 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -228,6 +228,13 @@ func GetUserAvatar(c *gin.Context) { return } user.Avatar = "/usr/share/casaos/www/avatar.svg" + if file.Exists(user.Avatar) { + c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) + c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") + c.File(user.Avatar) + return + } + user.Avatar = "/var/lib/casaos/www/avatar.svg" c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(path.Base(user.Avatar))) c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate, value") c.File(user.Avatar) From 3f4558e23c0a9958f9a0e20aabc64aa8fd51840e Mon Sep 17 00:00:00 2001 From: link Date: Sun, 4 Feb 2024 11:08:01 +0800 Subject: [PATCH 86/95] Merge pull request from GHSA-h5gf-cmm8-cg7c --- route/v1/user.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/route/v1/user.go b/route/v1/user.go index bdc352e..21fe0cb 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -13,6 +13,7 @@ import ( "os" "path" "path/filepath" + "regexp" "strconv" "strings" "time" @@ -667,6 +668,16 @@ func GetUserImage(c *gin.Context) { return } + matched, err := regexp.MatchString(`^/var/lib/casaos/\d`, filePath) + if err != nil { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) + return + } + if !matched { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) + return + } + fileTmp, _ := os.Open(filePath) defer fileTmp.Close() From 2fdbdcf1ec7b7439a399f4d52d8d91d5f3f40693 Mon Sep 17 00:00:00 2001 From: Link Date: Sun, 4 Feb 2024 06:36:38 +0000 Subject: [PATCH 87/95] Adding Absolute Path Determination --- route/v1/user.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/route/v1/user.go b/route/v1/user.go index 21fe0cb..c772c95 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -659,16 +659,21 @@ func GetUserImage(c *gin.Context) { c.JSON(http.StatusNotFound, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) return } - if !file.Exists(filePath) { + absFilePath, err := filepath.Abs(filepath.Clean(filePath)) + if err != nil { + c.JSON(http.StatusNotFound, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) + return + } + if !file.Exists(absFilePath) { c.JSON(http.StatusNotFound, model.Result{Success: common_err.FILE_DOES_NOT_EXIST, Message: common_err.GetMsg(common_err.FILE_DOES_NOT_EXIST)}) return } - if !strings.Contains(filePath, config.AppInfo.UserDataPath) { + if !strings.Contains(absFilePath, config.AppInfo.UserDataPath) { c.JSON(http.StatusNotFound, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) return } - matched, err := regexp.MatchString(`^/var/lib/casaos/\d`, filePath) + matched, err := regexp.MatchString(`^/var/lib/casaos/\d`, absFilePath) if err != nil { c.JSON(http.StatusNotFound, model.Result{Success: common_err.INSUFFICIENT_PERMISSIONS, Message: common_err.GetMsg(common_err.INSUFFICIENT_PERMISSIONS)}) return @@ -678,14 +683,11 @@ func GetUserImage(c *gin.Context) { return } - fileTmp, _ := os.Open(filePath) - defer fileTmp.Close() - - fileName := path.Base(filePath) + fileName := path.Base(absFilePath) // @tiger - RESTful 规范下不应该返回文件本身内容,而是返回文件的静态URL,由前端去解析 c.Header("Content-Disposition", "attachment; filename*=utf-8''"+url2.PathEscape(fileName)) - c.File(filePath) + c.File(absFilePath) } func DeleteUserImage(c *gin.Context) { From 3db4be01c47d9ce09b470024aff5c38911a48435 Mon Sep 17 00:00:00 2001 From: Link Date: Sun, 4 Feb 2024 08:15:37 +0000 Subject: [PATCH 88/95] Send notification --- common/version.go | 1 + go.mod | 2 +- main.go | 19 +++++++++++++++++++ route/v1/user.go | 16 ++++++++++++++++ service/service.go | 22 ++++++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index feb4161..b7ad0ad 100644 --- a/common/version.go +++ b/common/version.go @@ -1,3 +1,4 @@ package common const Version = "0.4.4" +const SERVICENAME = "CasaOS-UserService" diff --git a/go.mod b/go.mod index bfe4c38..a2829b2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/IceWhaleTech/CasaOS-UserService go 1.20 require ( - github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3 + github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha12 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/deepmap/oapi-codegen v1.12.4 github.com/getkin/kin-openapi v0.117.0 diff --git a/main.go b/main.go index 67a9041..5d886bf 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( + "context" _ "embed" "flag" "fmt" @@ -18,6 +19,7 @@ import ( util_http "github.com/IceWhaleTech/CasaOS-Common/utils/http" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/IceWhaleTech/CasaOS-UserService/codegen/message_bus" "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "github.com/IceWhaleTech/CasaOS-UserService/pkg/sqlite" @@ -154,6 +156,23 @@ func main() { go route.EventListen() logger.Info("User service is listening...", zap.Any("address", listener.Addr().String()), zap.String("filepath", addressFilePath)) + var events []message_bus.EventType + events = append(events, message_bus.EventType{Name: "zimaos:user:save_config", SourceID: common.SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}}) + // register at message bus + for i := 0; i < 10; i++ { + response, err := service.MyService.MessageBus().RegisterEventTypesWithResponse(context.Background(), events) + if err != nil { + logger.Error("error when trying to register one or more event types - some event type will not be discoverable", zap.Error(err)) + } + if response != nil && response.StatusCode() != http.StatusOK { + logger.Error("error when trying to register one or more event types - some event type will not be discoverable", zap.String("status", response.Status()), zap.String("body", string(response.Body))) + } + if response.StatusCode() == http.StatusOK { + break + } + time.Sleep(time.Second) + } + s := &http.Server{ Handler: mux, ReadHeaderTimeout: 5 * time.Second, // fix G112: Potential slowloris attack (see https://github.com/securego/gosec) diff --git a/route/v1/user.go b/route/v1/user.go index c772c95..87e0077 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -1,6 +1,7 @@ package v1 import ( + "context" "crypto/ecdsa" "encoding/base64" json2 "encoding/json" @@ -21,6 +22,7 @@ import ( "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" + "github.com/IceWhaleTech/CasaOS-UserService/common" "github.com/IceWhaleTech/CasaOS-UserService/model" "github.com/IceWhaleTech/CasaOS-UserService/model/system_model" "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" @@ -508,6 +510,20 @@ func PostUserCustomConf(c *gin.Context) { return } + if name == "system" { + dataMap := make(map[string]string, 1) + dataMap["system"] = string(data) + response, err := service.MyService.MessageBus().PublishEventWithResponse(context.Background(), common.SERVICENAME, "zimaos:user:save_config", dataMap) + if err != nil { + logger.Error("failed to publish event to message bus", zap.Error(err), zap.Any("event", string(data))) + return + } + if response.StatusCode() != http.StatusOK { + logger.Error("failed to publish event to message bus", zap.String("status", response.Status()), zap.Any("response", response)) + } + + } + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))}) } diff --git a/service/service.go b/service/service.go index 8d29cab..8235635 100644 --- a/service/service.go +++ b/service/service.go @@ -2,6 +2,8 @@ package service import ( "github.com/IceWhaleTech/CasaOS-Common/external" + "github.com/IceWhaleTech/CasaOS-UserService/codegen/message_bus" + "github.com/IceWhaleTech/CasaOS-UserService/pkg/config" "gorm.io/gorm" ) @@ -10,6 +12,7 @@ var MyService Repository type Repository interface { Gateway() external.ManagementService User() UserService + MessageBus() *message_bus.ClientWithResponses Event() EventService } @@ -43,3 +46,22 @@ func (c *store) Gateway() external.ManagementService { func (c *store) User() UserService { return c.user } +func (c *store) MessageBus() *message_bus.ClientWithResponses { + client, _ := message_bus.NewClientWithResponses("", func(c *message_bus.Client) error { + // error will never be returned, as we always want to return a client, even with wrong address, + // in order to avoid panic. + // + // If we don't avoid panic, message bus becomes a hard dependency, which is not what we want. + + messageBusAddress, err := external.GetMessageBusAddress(config.CommonInfo.RuntimePath) + if err != nil { + c.Server = "message bus address not found" + return nil + } + + c.Server = messageBusAddress + return nil + }) + + return client +} From 6738be00dfa2f51c3bef4d402f1304439edc6b86 Mon Sep 17 00:00:00 2001 From: Link Date: Sun, 4 Feb 2024 08:43:07 +0000 Subject: [PATCH 89/95] update sum --- go.sum | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 3849aaf..bc16b76 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3 h1:5E5LAqi2uXpOZqcPOgQ4m6d9MagYyfhKIFXnzd8s3W4= -github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha3/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha12 h1:TikSpmsMOxKufqoq8Q4K3PLh8zIKFrRtLH4JDIG+910= +github.com/IceWhaleTech/CasaOS-Common v0.4.8-alpha12/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -240,6 +240,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/gorm v1.25.0 h1:+KtYtb2roDz14EQe4bla8CbQlmb9dN3VejSai3lprfU= gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= modernc.org/libc v1.22.4 h1:wymSbZb0AlrjdAVX3cjreCHTPCpPARbQXNz6BHPzdwQ= modernc.org/libc v1.22.4/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= From c75063d7ca5800948e9c09c0a6efe9809b5d39f7 Mon Sep 17 00:00:00 2001 From: CorrectRoadH Date: Mon, 5 Feb 2024 14:13:58 +0800 Subject: [PATCH 90/95] Merge pull request from GHSA-c967-2652-gfjm * fix: fix username enumeration * fix typo msg type * fix: recovery error patch * fix: recovery error patch --------- Signed-off-by: CorrectRoadH --- route/v1/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/route/v1/user.go b/route/v1/user.go index 87e0077..90a7c01 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -116,7 +116,7 @@ func PostUserLogin(c *gin.Context) { } if user.Password != encryption.GetMD5ByStr(password) { c.JSON(common_err.CLIENT_ERROR, - model.Result{Success: common_err.PWD_INVALID, Message: common_err.GetMsg(common_err.PWD_INVALID)}) + model.Result{Success: common_err.USER_NOT_EXIST_OR_PWD_INVALID, Message: common_err.GetMsg(common_err.USER_NOT_EXIST_OR_PWD_INVALID)}) return } @@ -258,7 +258,7 @@ func PutUserInfo(c *gin.Context) { user := service.MyService.User().GetUserInfoById(id) if user.Id == 0 { c.JSON(common_err.SERVICE_ERROR, - model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + model.Result{Success: common_err.USER_NOT_EXIST_OR_PWD_INVALID, Message: common_err.GetMsg(common_err.USER_NOT_EXIST_OR_PWD_INVALID)}) return } if len(json.Username) > 0 { From 62006f61b55951048dbace4ebd9e483274838699 Mon Sep 17 00:00:00 2001 From: CorrectRoadH Date: Mon, 5 Feb 2024 14:15:00 +0800 Subject: [PATCH 91/95] Merge pull request from GHSA-c69x-5xmw-v44x * feat: limit too many login request * fix: fix error rate limt --------- Signed-off-by: CorrectRoadH --- go.mod | 2 +- route/v1/user.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a2829b2..fe75d9f 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/tidwall/gjson v1.14.4 go.uber.org/zap v1.24.0 golang.org/x/net v0.17.0 + golang.org/x/time v0.3.0 gopkg.in/ini.v1 v1.67.0 gorm.io/gorm v1.25.0 ) @@ -75,7 +76,6 @@ require ( golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.13.0 // indirect - golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/route/v1/user.go b/route/v1/user.go index 90a7c01..03def9c 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -32,6 +32,7 @@ import ( uuid "github.com/satori/go.uuid" "github.com/tidwall/gjson" "go.uber.org/zap" + "golang.org/x/time/rate" "github.com/IceWhaleTech/CasaOS-UserService/service" "github.com/gin-gonic/gin" @@ -84,6 +85,8 @@ func PostUserRegister(c *gin.Context) { c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)}) } +var limiter = rate.NewLimiter(rate.Every(time.Minute), 5) + // @Summary login // @Produce application/json // @Accept application/json @@ -93,6 +96,16 @@ func PostUserRegister(c *gin.Context) { // @Success 200 {string} string "ok" // @Router /user/login [post] func PostUserLogin(c *gin.Context) { + + if !limiter.Allow() { + c.JSON(common_err.TOO_MANY_REQUEST, + model.Result{ + Success: common_err.TOO_MANY_LOGIN_REQUESTS, + Message: common_err.GetMsg(common_err.TOO_MANY_LOGIN_REQUESTS), + }) + return + } + json := make(map[string]string) c.ShouldBind(&json) From 7bd0df6441c25c322460f75c55bf18fe908441f9 Mon Sep 17 00:00:00 2001 From: Link Date: Fri, 1 Mar 2024 09:09:05 +0000 Subject: [PATCH 92/95] add gpu number --- route/v1/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/route/v1/user.go b/route/v1/user.go index 03def9c..b030289 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -19,6 +19,7 @@ import ( "strings" "time" + "github.com/IceWhaleTech/CasaOS-Common/external" "github.com/IceWhaleTech/CasaOS-Common/utils/common_err" "github.com/IceWhaleTech/CasaOS-Common/utils/jwt" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" @@ -818,6 +819,11 @@ func GetUserStatus(c *gin.Context) { data["key"] = key data["initialized"] = false } + gpus, err := external.NvidiaGPUInfoList() + if err != nil { + logger.Error("NvidiaGPUInfoList error", zap.Error(err)) + } + data["gpus"] = len(gpus) c.JSON(common_err.SUCCESS, model.Result{ Success: common_err.SUCCESS, From 9c261dd8df63fe2644708695d2eb85495784e415 Mon Sep 17 00:00:00 2001 From: CorrectRoad Date: Mon, 11 Mar 2024 17:29:22 +0800 Subject: [PATCH 93/95] feat:clean login limit after login successful (#42) --- route/v1/user.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/route/v1/user.go b/route/v1/user.go index b030289..c19d833 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -134,6 +134,9 @@ func PostUserLogin(c *gin.Context) { return } + // clean limit + limiter = rate.NewLimiter(rate.Every(time.Minute), 5) + privateKey, _ := service.MyService.User().GetKeyPair() token := system_model.VerifyInformation{} From dd927fe1c805e53790f73cfe10c7a4ded3bc5bdb Mon Sep 17 00:00:00 2001 From: CorrectRoad Date: Tue, 12 Mar 2024 18:17:46 +0800 Subject: [PATCH 94/95] Merge pull request from GHSA-hcw2-2r9c-gc6p --- route/v1/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/route/v1/user.go b/route/v1/user.go index c19d833..fcc2005 100644 --- a/route/v1/user.go +++ b/route/v1/user.go @@ -125,7 +125,7 @@ func PostUserLogin(c *gin.Context) { user := service.MyService.User().GetUserAllInfoByName(username) if user.Id == 0 { c.JSON(common_err.CLIENT_ERROR, - model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)}) + model.Result{Success: common_err.USER_NOT_EXIST_OR_PWD_INVALID, Message: common_err.GetMsg(common_err.USER_NOT_EXIST_OR_PWD_INVALID)}) return } if user.Password != encryption.GetMD5ByStr(password) { From 5cf4ed5424be4c62b97d67b51f6338c47285f47b Mon Sep 17 00:00:00 2001 From: CorrectRoad Date: Tue, 26 Mar 2024 11:35:25 +0800 Subject: [PATCH 95/95] chore: bump version to 0.4.8 (#43) --- common/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/version.go b/common/version.go index b7ad0ad..619d87d 100644 --- a/common/version.go +++ b/common/version.go @@ -1,4 +1,4 @@ package common -const Version = "0.4.4" +const Version = "0.4.8" const SERVICENAME = "CasaOS-UserService"