diff --git a/cli/cli/cli.go b/cli/cli/cli.go index 264962369..f94a00581 100644 --- a/cli/cli/cli.go +++ b/cli/cli/cli.go @@ -35,6 +35,7 @@ import ( configure "github.com/opencurve/curveadm/internal/configure/curveadm" "github.com/opencurve/curveadm/internal/configure/hosts" "github.com/opencurve/curveadm/internal/configure/topology" + "github.com/opencurve/curveadm/internal/daemon" "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/storage" tools "github.com/opencurve/curveadm/internal/tools/upgrade" @@ -43,6 +44,7 @@ import ( cliutil "github.com/opencurve/curveadm/internal/utils" log "github.com/opencurve/curveadm/pkg/log/glg" "github.com/opencurve/curveadm/pkg/module" + pigeoncore "github.com/opencurve/pigeon" ) type CurveAdm struct { @@ -71,6 +73,9 @@ type CurveAdm struct { clusterPoolData string // cluster pool clusterType string // cluster type like develop, production, etc. monitor storage.Monitor + + // pigeon + pigeon *pigeoncore.Pigeon } /* @@ -197,6 +202,8 @@ func (curveadm *CurveAdm) init() error { curveadm.clusterPoolData = cluster.Pool curveadm.monitor = monitor curveadm.clusterType = cluster.Type + admServer := daemon.NewServer() + curveadm.pigeon = pigeoncore.NewPigeon([]*pigeoncore.HTTPServer{admServer}) return nil } @@ -536,3 +543,7 @@ func (curveadm *CurveAdm) PostAudit(id int64, ec error) { log.Field("Error", err)) } } + +func (curveadm *CurveAdm) GetPigeon() *pigeoncore.Pigeon { + return curveadm.pigeon +} diff --git a/cli/command/cmd.go b/cli/command/cmd.go index 91faca5bd..0660c0378 100644 --- a/cli/command/cmd.go +++ b/cli/command/cmd.go @@ -31,6 +31,7 @@ import ( "github.com/opencurve/curveadm/cli/command/client" "github.com/opencurve/curveadm/cli/command/cluster" "github.com/opencurve/curveadm/cli/command/config" + "github.com/opencurve/curveadm/cli/command/daemon" "github.com/opencurve/curveadm/cli/command/hosts" "github.com/opencurve/curveadm/cli/command/monitor" "github.com/opencurve/curveadm/cli/command/pfs" @@ -66,6 +67,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) { target.NewTargetCommand(curveadm), // curveadm target ... pfs.NewPFSCommand(curveadm), // curveadm pfs ... monitor.NewMonitorCommand(curveadm), // curveadm monitor ... + daemon.NewDaemonCommand(curveadm), // curveadm deamon ... NewAuditCommand(curveadm), // curveadm audit NewCleanCommand(curveadm), // curveadm clean diff --git a/cli/command/daemon/cmd.go b/cli/command/daemon/cmd.go new file mode 100644 index 000000000..a879354ac --- /dev/null +++ b/cli/command/daemon/cmd.go @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +/* +* Project: Curveadm +* Created Date: 2023-12-13 +* Author: liuminjian + */ + +package daemon + +import ( + "github.com/opencurve/curveadm/cli/cli" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command { + cmd := &cobra.Command{ + Use: "daemon", + Short: "Manage curveadm deamon service", + Args: cliutil.NoArgs, + RunE: cliutil.ShowHelp(curveadm.Err()), + } + + cmd.AddCommand( + NewStartCommand(curveadm), + NewStopCommand(curveadm), + ) + return cmd +} diff --git a/cli/command/daemon/start.go b/cli/command/daemon/start.go new file mode 100644 index 000000000..86e92a09e --- /dev/null +++ b/cli/command/daemon/start.go @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +/* +* Project: Curveadm +* Created Date: 2023-12-13 +* Author: liuminjian + */ + +package daemon + +import ( + "github.com/opencurve/curveadm/cli/cli" + "github.com/spf13/cobra" +) + +const ( + START_EXAMPLR = `Examples: + $ curveadm daemon start -c config/pigeon.yaml # Start an http service to receive requests` +) + +type startOptions struct { + filename string +} + +func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options startOptions + pigeon := curveadm.GetPigeon() + + cmd := &cobra.Command{ + Use: "start [OPTIONS]", + Short: "Start http service", + Example: START_EXAMPLR, + RunE: func(cmd *cobra.Command, args []string) error { + return pigeon.Start(options.filename) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(), + "Specify pigeon configure file") + + return cmd +} diff --git a/cli/command/daemon/stop.go b/cli/command/daemon/stop.go new file mode 100644 index 000000000..f3485f29c --- /dev/null +++ b/cli/command/daemon/stop.go @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +/* +* Project: Curveadm +* Created Date: 2023-12-13 +* Author: liuminjian + */ + +package daemon + +import ( + "github.com/opencurve/curveadm/cli/cli" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +const ( + STOP_EXAMPLR = `Examples: + $ curveadm daemon stop -c config/pigeon.yaml # Stop an http service` +) + +type stopOptions struct { + filename string +} + +func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options stopOptions + pigeon := curveadm.GetPigeon() + + cmd := &cobra.Command{ + Use: "stop", + Short: "Stop http service", + Args: cliutil.NoArgs, + Example: STOP_EXAMPLR, + RunE: func(cmd *cobra.Command, args []string) error { + return pigeon.Stop(options.filename) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(), + "Specify pigeon configure file") + + return cmd +} diff --git a/go.mod b/go.mod index 9d217ec1b..f31536731 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,11 @@ require ( github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629 github.com/kpango/glg v1.6.14 github.com/mattn/go-sqlite3 v1.14.16 + github.com/mcuadros/go-defaults v1.2.0 github.com/melbahja/goph v1.3.0 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/moby/term v0.0.0-20221205130635-1aeaba878587 + github.com/opencurve/pigeon v0.0.0-20231207070543-aa3a2494c114 github.com/pingcap/log v1.1.0 github.com/sergi/go-diff v1.2.0 github.com/spf13/cobra v1.7.0 @@ -25,10 +27,47 @@ require ( golang.org/x/crypto v0.8.0 ) +require ( + github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c // indirect + github.com/bytedance/sonic v1.8.7 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect + github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434 // indirect + github.com/facebookgo/httpdown v0.0.0-20180706035922-5979d39b15c2 // indirect + github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/gin-gonic/gin v1.9.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/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/imroc/req/v3 v3.33.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leodido/go-urn v1.2.3 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/onsi/ginkgo/v2 v2.9.2 // indirect + github.com/quic-go/qpack v0.4.0 // indirect + github.com/quic-go/qtls-go1-18 v0.2.0 // indirect + github.com/quic-go/qtls-go1-19 v0.3.2 // indirect + github.com/quic-go/qtls-go1-20 v0.2.2 // indirect + github.com/quic-go/quic-go v0.33.0 // indirect + github.com/sevlyar/go-daemon v0.1.6 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect +) + require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect github.com/VividCortex/ewma v1.2.0 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/benbjohnson/clock v1.3.0 // indirect @@ -81,18 +120,21 @@ require ( github.com/subosito/gotenv v1.4.2 // indirect github.com/theupdateframework/notary v0.7.0 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.8.0 // indirect - golang.org/x/mod v0.9.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/sys v0.7.0 // indirect golang.org/x/term v0.7.0 // indirect golang.org/x/text v0.9.0 // indirect - golang.org/x/tools v0.7.0 // indirect - google.golang.org/protobuf v1.29.1 // indirect + golang.org/x/tools v0.8.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gotest.tools/v3 v3.0.3 // indirect ) replace github.com/melbahja/goph v1.3.0 => github.com/Wine93/goph v0.0.0-20220907033045-3b286d827fb3 + +replace github.com/quic-go/quic-go => github.com/quic-go/quic-go v0.32.0 + +replace go.uber.org/multierr => go.uber.org/multierr v1.8.0 diff --git a/go.sum b/go.sum index ce71e43db..542d413a3 100644 --- a/go.sum +++ b/go.sum @@ -44,11 +44,12 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= -github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/Wine93/goph v0.0.0-20220907033045-3b286d827fb3 h1:gP0W63xa8rP8uV0CZQDgtcc9QCBIYN5cq3vMavCGT1Q= github.com/Wine93/goph v0.0.0-20220907033045-3b286d827fb3/go.mod h1:vy08GGf/z8wGP++yuLpgmuN2JcifRNCJ1lsjMPfN2X8= +github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c h1:LfrAhPNuQo38pAX5gBoRRskbskCgbISKC7CnWlirC78= +github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c/go.mod h1:dJEV7kdyv2Oc0L5RzV5mtkh+FmjRsHJWI7avFjJw+Ro= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -70,9 +71,15 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembj github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/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= @@ -119,6 +126,22 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y 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/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= +github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 h1:wWke/RUCl7VRjQhwPlR/v0glZXNYzBHdNUzf/Am2Nmg= +github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9/go.mod h1:uPmAp6Sws4L7+Q/OokbWDAK1ibXYhB3PXFP1kol5hPg= +github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434 h1:mOp33BLbcbJ8fvTAmZacbBiOASfxN+MLcLxymZCIrGE= +github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434/go.mod h1:KigFdumBXUPSwzLDbeuzyt0elrL7+CP7TKuhrhT4bcU= +github.com/facebookgo/httpdown v0.0.0-20180706035922-5979d39b15c2 h1:nXeeRHmgNgjLxi+7dY9l9aDvSS1uwVlNLqUWIY4Ath0= +github.com/facebookgo/httpdown v0.0.0-20180706035922-5979d39b15c2/go.mod h1:TUV/fX3XrTtBQb5+ttSUJzcFgLNpILONFTKmBuk5RSw= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4 h1:0YtRCqIZs2+Tz49QuH6cJVw/IFqzo39gEqZ0iYLxD2M= +github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4/go.mod h1:vsJz7uE339KUCpBXx3JAJzSRH7Uk4iGGyJzR529qDIA= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= @@ -127,17 +150,31 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw= github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= +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.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= +github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= 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-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +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.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.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI= +github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-sql-driver/mysql v1.3.0 h1:pgwjLi/dvffoP9aabwkT3AKpXQM93QARkjFhDDqC1UE= github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= 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/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -158,6 +195,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt 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/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= 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= @@ -204,6 +243,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf 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/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -216,6 +257,11 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -223,6 +269,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 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/imroc/req/v3 v3.33.2 h1:mqphLIo++p+IPYdjgP/Wd5rqXUjKvuEIst2U+EsLIwQ= +github.com/imroc/req/v3 v3.33.2/go.mod h1:cZ+7C3L/AYOr4tLGG16hZF90F1WzAdAdzt1xFSlizXY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -235,12 +283,19 @@ github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629 h1:1dSBUfGl github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629/go.mod h1:mb5nS4uRANwOJSZj8rlCWAfAcGi72GGMIXx+xGOjA7M= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +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/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/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/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kpango/fastime v1.1.6 h1:lAw1Tiwnlbsx1xZs6W9eM7/8niwabknewbmLkh/yTVo= @@ -256,6 +311,8 @@ 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.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= +github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -277,6 +334,8 @@ github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mcuadros/go-defaults v1.2.0 h1:FODb8WSf0uGaY8elWJAkoLL0Ri6AlZ1bFlenk56oZtc= +github.com/mcuadros/go-defaults v1.2.0/go.mod h1:WEZtHEVIGYVDqkKSWBdWKUVdRyKlMfulPaGDWIVeCWY= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -290,23 +349,31 @@ github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWK github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= 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 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= +github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b h1:YWuSjZCQAPM8UUBLkYUk1e+rZcvWHJmFb6i6rM44Xs8= github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= +github.com/opencurve/pigeon v0.0.0-20231207070543-aa3a2494c114 h1:g9BaB/e2RMXct9sLjM6rpb0wZSUFLhj4k6R2+tfX2OY= +github.com/opencurve/pigeon v0.0.0-20231207070543-aa3a2494c114/go.mod h1:vhh5An943zAOYL26DJkMMhPTk68PVrY0X8oYXJrbSyQ= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= @@ -348,16 +415,28 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= +github.com/quic-go/qtls-go1-18 v0.2.0 h1:5ViXqBZ90wpUcZS0ge79rf029yx0dYB0McyPJwqqj7U= +github.com/quic-go/qtls-go1-18 v0.2.0/go.mod h1:moGulGHK7o6O8lSPSZNoOwcLvJKJ85vVNc7oJFD65bc= +github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= +github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= +github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA= +github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rqlite/gorqlite v0.0.0-20230310040812-ec5e524a562e h1:updBXFrJFAJO/3b/mctukZQEIVUq09iwV/wireIlZFA= github.com/rqlite/gorqlite v0.0.0-20230310040812-ec5e524a562e/go.mod h1:xF/KoXmrRyahPfo5L7Szb5cAAUl53dMWBh9cMruGEZg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sevlyar/go-daemon v0.1.6 h1:EUh1MDjEM4BI109Jign0EaknA2izkOyi0LV3ro3QQGs= +github.com/sevlyar/go-daemon v0.1.6/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= @@ -375,7 +454,6 @@ github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431/go.mod h1: 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.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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 v0.0.0-20150530192845-be5ff3e4840c/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= @@ -390,6 +468,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf 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.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -400,12 +479,17 @@ github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= +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/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/vbauerster/mpb/v7 v7.5.3 h1:BkGfmb6nMrrBQDFECR/Q7RkKCw7ylMetCb4079CGs4w= github.com/vbauerster/mpb/v7 v7.5.3/go.mod h1:i+h4QY6lmLvBNK2ah1fSreiw3ajskRlBp9AhY/PnuOE= 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= @@ -418,13 +502,14 @@ 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.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= 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.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= 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-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -450,6 +535,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 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/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= 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= @@ -473,8 +560,9 @@ 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.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -509,6 +597,7 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY 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-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= @@ -532,6 +621,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ 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/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -572,12 +662,15 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w 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-20210616094352-59db8d763f22/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-20211216021012-1d35b9e2eb4e/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-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -616,7 +709,6 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn 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-20190624222133-a101b041ded4/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= @@ -656,8 +748,9 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/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.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= +golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= 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= @@ -753,8 +846,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj 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.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= -google.golang.org/protobuf v1.29.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/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= @@ -784,7 +877,6 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= -gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= 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= @@ -793,5 +885,6 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt 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/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= 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/internal/configure/hosts/hc_get.go b/internal/configure/hosts/hc_get.go index c7c0c6a07..a8ab33faf 100644 --- a/internal/configure/hosts/hc_get.go +++ b/internal/configure/hosts/hc_get.go @@ -85,7 +85,13 @@ func (hc *HostConfig) GetUser() string { return user } +func (hc *HostConfig) GetProtocol() string { return hc.getString(CONFIG_PROTOCOL) } func (hc *HostConfig) GetSSHConfig() *module.SSHConfig { + + if hc.GetProtocol() != SSH_PROTOCOL { + return nil + } + hostname := hc.GetSSHHostname() if len(hostname) == 0 { hostname = hc.GetHostname() @@ -103,3 +109,40 @@ func (hc *HostConfig) GetSSHConfig() *module.SSHConfig { ConnectRetries: curveadm.GlobalCurveAdmConfig.GetSSHRetries(), } } + +func (hc *HostConfig) GetHTTPConfig() *module.HTTPConfig { + + if hc.GetProtocol() != HTTP_PROTOCOL { + return nil + } + + return &module.HTTPConfig{ + Host: hc.GetHostname(), + Port: (uint)(hc.GetHTTPPort()), + } +} + +func (hc *HostConfig) GetConnectConfig() *module.ConnectConfig { + + hostname := hc.GetSSHHostname() + if len(hostname) == 0 { + hostname = hc.GetHostname() + } + + return &module.ConnectConfig{ + User: hc.GetUser(), + Host: hostname, + SSHPort: (uint)(hc.GetSSHPort()), + HTTPPort: (uint)(hc.GetHTTPPort()), + PrivateKeyPath: hc.GetPrivateKeyFile(), + ForwardAgent: hc.GetForwardAgent(), + BecomeMethod: "sudo", + BecomeFlags: "-iu", + BecomeUser: hc.GetBecomeUser(), + ConnectTimeoutSec: curveadm.GlobalCurveAdmConfig.GetSSHTimeout(), + ConnectRetries: curveadm.GlobalCurveAdmConfig.GetSSHRetries(), + Protocol: hc.GetProtocol(), + } +} + +func (hc *HostConfig) GetHTTPPort() int { return hc.getInt(CONFIG_HTTP_PORT) } diff --git a/internal/configure/hosts/hc_item.go b/internal/configure/hosts/hc_item.go index 6900cbd63..a7fb50cc8 100644 --- a/internal/configure/hosts/hc_item.go +++ b/internal/configure/hosts/hc_item.go @@ -32,7 +32,10 @@ import ( ) const ( - DEFAULT_SSH_PORT = 22 + DEFAULT_SSH_PORT = 22 + DEFAULT_HTTP_PORT = 8000 + SSH_PROTOCOL = "ssh" + HTTP_PROTOCOL = "http" ) var ( @@ -97,4 +100,18 @@ var ( false, nil, ) + + CONFIG_PROTOCOL = itemset.Insert( + "protocol", + comm.REQUIRE_STRING, + false, + SSH_PROTOCOL, + ) + + CONFIG_HTTP_PORT = itemset.Insert( + "http_port", + comm.REQUIRE_POSITIVE_INTEGER, + false, + DEFAULT_HTTP_PORT, + ) ) diff --git a/internal/configure/hosts/hosts.go b/internal/configure/hosts/hosts.go index c8fa86011..e9ffcfe30 100644 --- a/internal/configure/hosts/hosts.go +++ b/internal/configure/hosts/hosts.go @@ -32,6 +32,7 @@ import ( "github.com/opencurve/curveadm/internal/configure/os" "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/utils" + "github.com/opencurve/curveadm/pkg/module" "github.com/spf13/viper" ) @@ -158,7 +159,7 @@ func (hc *HostConfig) Build() error { F("hosts[%d].private_key_file = %s", hc.sequence, privateKeyFile) } - if hc.GetForwardAgent() == false { + if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL { if !utils.PathExist(privateKeyFile) { return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST. F("%s: no such file", privateKeyFile) diff --git a/internal/daemon/core/core.go b/internal/daemon/core/core.go new file mode 100644 index 000000000..d10f503ea --- /dev/null +++ b/internal/daemon/core/core.go @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +package core + +import ( + "fmt" + "strconv" + + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/pigeon" +) + +func Exit(r *pigeon.Request, err error) bool { + var status int + if err == nil { + status = 200 + r.SendJSON(pigeon.JSON{ + "errorCode": "0", + "errorMsg": "success", + }) + } else { + code := err.(*errno.ErrorCode) + if code.IsHttpErr() { + status = code.HttpCode() + } else { + status = 503 + } + r.SendJSON(pigeon.JSON{ + "errorCode": strconv.Itoa(code.GetCode()), + "errorMsg": fmt.Sprintf("desc: %s; clue: %s", code.GetDescription(), code.GetClue()), + }) + } + return r.Exit(status) +} + +func Default(r *pigeon.Request) bool { + r.Logger().Warn("unupport request uri", pigeon.Field("uri", r.Uri)) + return Exit(r, errno.ERR_UNSUPPORT_REQUEST_URI) +} + +func ExitSuccessWithData(r *pigeon.Request, data interface{}) bool { + r.SendJSON(pigeon.JSON{ + "data": data, + "errorCode": "0", + "errorMsg": "success", + }) + return r.Exit(200) +} + +func ExitFailWithData(r *pigeon.Request, data interface{}, message string) bool { + r.SendJSON(pigeon.JSON{ + "errorCode": "503", + "errorMsg": message, + "data": data, + }) + return r.Exit(503) +} diff --git a/internal/daemon/manager/bind.go b/internal/daemon/manager/bind.go new file mode 100644 index 000000000..9af73ee9d --- /dev/null +++ b/internal/daemon/manager/bind.go @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +package manager + +import ( + "mime/multipart" + "net/http" + + "github.com/opencurve/pigeon" +) + +var METHOD_REQUEST map[string]Request + +type ( + HandlerFunc func(r *pigeon.Request, ctx *Context) bool + + Context struct { + Data interface{} + } + + Request struct { + httpMethod string + method string + vType interface{} + handler HandlerFunc + } +) + +func init() { + METHOD_REQUEST = map[string]Request{} + for _, request := range requests { + METHOD_REQUEST[request.method] = request + } +} + +type DeployClusterCmdRequest struct { + Command string `json:"command" binding:"required"` +} + +type DeployClusterUploadRequest struct { + FilePath string `json:"filepath" form:"filepath" binding:"required"` + File *multipart.FileHeader `form:"file" binding:"required"` +} + +type DeployClusterDownloadRequest struct { + FilePath string `json:"filepath" form:"filepath" binding:"required"` +} + +var requests = []Request{ + { + http.MethodPost, + "cluster.deploy.cmd", + DeployClusterCmdRequest{}, + DeployClusterCmd, + }, + { + http.MethodPost, + "cluster.deploy.upload", + DeployClusterUploadRequest{}, + DeployClusterUpload, + }, + { + http.MethodGet, + "cluster.deploy.download", + DeployClusterDownloadRequest{}, + DeployClusterDownload, + }, +} diff --git a/internal/daemon/manager/entrypoint.go b/internal/daemon/manager/entrypoint.go new file mode 100644 index 000000000..30e3a929b --- /dev/null +++ b/internal/daemon/manager/entrypoint.go @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +package manager + +import ( + "reflect" + + "github.com/mcuadros/go-defaults" + "github.com/opencurve/curveadm/internal/daemon/core" + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/pigeon" +) + +func Entrypoint(r *pigeon.Request) bool { + if r.Method != pigeon.HTTP_METHOD_GET && + r.Method != pigeon.HTTP_METHOD_POST { + return core.Exit(r, errno.ERR_UNSUPPORT_HTTP_METHOD) + } + + request, ok := METHOD_REQUEST[r.Args["method"]] + if !ok { + return core.Exit(r, errno.ERR_UNSUPPORT_METHOD_ARGUMENT) + } else if request.httpMethod != r.Method { + return core.Exit(r, errno.ERR_HTTP_METHOD_MISMATCHED) + } + + vType := reflect.TypeOf(request.vType) + data := reflect.New(vType).Interface() + if err := r.BindBody(data); err != nil { + r.Logger().Error("bad request form param", + pigeon.Field("error", err)) + return core.Exit(r, errno.ERR_BAD_REQUEST_FORM_PARAM) + } + defaults.SetDefaults(data) + return request.handler(r, &Context{data}) +} diff --git a/internal/daemon/manager/manager.go b/internal/daemon/manager/manager.go new file mode 100644 index 000000000..537feaf81 --- /dev/null +++ b/internal/daemon/manager/manager.go @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +package manager + +import ( + "io" + "os/exec" + + "github.com/opencurve/curveadm/internal/daemon/core" + "github.com/opencurve/curveadm/internal/utils" + "github.com/opencurve/pigeon" +) + +func DeployClusterCmd(r *pigeon.Request, ctx *Context) bool { + data := ctx.Data.(*DeployClusterCmdRequest) + r.Logger().Info("DeployClusterCmd", pigeon.Field("command", data.Command)) + cmd := exec.Command("/bin/bash", "-c", data.Command) + out, err := cmd.CombinedOutput() + if err != nil { + r.Logger().Warn("DeployClusterCmd failed when execute command", + pigeon.Field("error", err)) + return core.ExitFailWithData(r, string(out), string(out)) + } + r.Logger().Info("DeployClusterCmd", pigeon.Field("result", out)) + return core.ExitSuccessWithData(r, string(out)) +} + +func DeployClusterUpload(r *pigeon.Request, ctx *Context) bool { + data := ctx.Data.(*DeployClusterUploadRequest) + r.Logger().Info("DeployClusterUpload", pigeon.Field("file", data.FilePath)) + mf, err := data.File.Open() + if err != nil { + r.Logger().Warn("DeployClusterUpload failed when open file", + pigeon.Field("error", err)) + return core.ExitFailWithData(r, err.Error(), err.Error()) + } + defer mf.Close() + content, err := io.ReadAll(mf) + if err != nil { + r.Logger().Warn("DeployClusterUpload failed when read file", + pigeon.Field("error", err)) + return core.ExitFailWithData(r, err.Error(), err.Error()) + } + err = utils.WriteFile(data.FilePath, string(content), 0644) + if err != nil { + r.Logger().Warn("DeployClusterUpload failed when write file", + pigeon.Field("error", err)) + return core.ExitFailWithData(r, err.Error(), err.Error()) + } + return core.Exit(r, err) +} + +func DeployClusterDownload(r *pigeon.Request, ctx *Context) bool { + data := ctx.Data.(*DeployClusterDownloadRequest) + r.Logger().Info("DeployClusterDownload", pigeon.Field("file", data.FilePath)) + return r.SendFile(data.FilePath) +} diff --git a/internal/daemon/server.go b/internal/daemon/server.go new file mode 100644 index 000000000..f02910361 --- /dev/null +++ b/internal/daemon/server.go @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2023 NetEase Inc. +* +* 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. + */ + +package daemon + +import ( + "github.com/opencurve/curveadm/internal/daemon/core" + "github.com/opencurve/curveadm/internal/daemon/manager" + "github.com/opencurve/pigeon" +) + +func NewServer() *pigeon.HTTPServer { + server := pigeon.NewHTTPServer("curveadm") + server.Route("/", manager.Entrypoint) + server.DefaultRoute(core.Default) + return server +} diff --git a/internal/errno/errno.go b/internal/errno/errno.go index 98bca1835..941a03abd 100644 --- a/internal/errno/errno.go +++ b/internal/errno/errno.go @@ -123,6 +123,14 @@ func (e *ErrorCode) Error() string { return tui.PromptErrorCode(e.code, e.description, e.clue, gLogpath) } +func (e *ErrorCode) IsHttpErr() bool { + return e.code/10000 == 70 +} + +func (e *ErrorCode) HttpCode() int { + return e.code % 1000 +} + /* * 0xx: init curveadm * @@ -253,8 +261,8 @@ var ( ERR_UNSUPPORT_CLEAN_ITEM = EC(210005, "unsupport clean item") ERR_NO_SERVICES_MATCHED = EC(210006, "no services matched") // TODO: please check pool set disk type - ERR_INVALID_DISK_TYPE = EC(210007, "poolset disk type must be lowercase and can only be one of ssd, hdd and nvme") - ERR_UNSUPPORT_DEPLOY_TYPE = EC(210008, "unknown deploy type") + ERR_INVALID_DISK_TYPE = EC(210007, "poolset disk type must be lowercase and can only be one of ssd, hdd and nvme") + ERR_UNSUPPORT_DEPLOY_TYPE = EC(210008, "unknown deploy type") // 220: commad options (client common) ERR_UNSUPPORT_CLIENT_KIND = EC(220000, "unsupport client kind") // 221: command options (client/bs) @@ -447,7 +455,8 @@ var ( ERR_METASERVER_REQUIRES_3_HOSTS = EC(503009, "metaserver requires at least 3 hosts to distrubute zones") // 510: checker (ssh) - ERR_SSH_CONNECT_FAILED = EC(510000, "SSH connect failed") + ERR_SSH_CONNECT_FAILED = EC(510000, "SSH connect failed") + ERR_HTTP_CONNECT_FAILED = EC(510001, "HTTP connect failed") // 520: checker (permission) ERR_USER_NOT_FOUND = EC(520000, "user not found") @@ -549,6 +558,13 @@ var ( // 690: execuetr task (others) ERR_START_CRONTAB_IN_CONTAINER_FAILED = EC(690000, "start crontab in container failed") + // 70: http service + ERR_UNSUPPORT_REQUEST_URI = EC(701400, "unsupport request uri") + ERR_UNSUPPORT_METHOD_ARGUMENT = EC(702400, "unsupport method argument") + ERR_HTTP_METHOD_MISMATCHED = EC(703400, "http method mismatch") + ERR_BAD_REQUEST_FORM_PARAM = EC(704400, "bad request form param") + ERR_UNSUPPORT_HTTP_METHOD = EC(705405, "unsupport http method") + // 900: others ERR_CANCEL_OPERATION = EC(CODE_CANCEL_OPERATION, "cancel operation") // 999 diff --git a/internal/task/context/context.go b/internal/task/context/context.go index bbc758373..693e170f6 100644 --- a/internal/task/context/context.go +++ b/internal/task/context/context.go @@ -29,27 +29,27 @@ import ( ) type Context struct { - sshClient *module.SSHClient - module *module.Module - register *Register + remoteClient module.RemoteClient + module *module.Module + register *Register } -func NewContext(sshClient *module.SSHClient) (*Context, error) { +func NewContext(remoteClient module.RemoteClient) (*Context, error) { return &Context{ - sshClient: sshClient, - module: module.NewModule(sshClient), - register: NewRegister(), + remoteClient: remoteClient, + module: module.NewModule(remoteClient), + register: NewRegister(), }, nil } func (ctx *Context) Close() { - if ctx.sshClient != nil { - ctx.sshClient.Client().Close() + if ctx.remoteClient != nil { + ctx.remoteClient.Close() } } -func (ctx *Context) SSHClient() *module.SSHClient { - return ctx.sshClient +func (ctx *Context) RemoteClient() module.RemoteClient { + return ctx.remoteClient } func (ctx *Context) Module() *module.Module { diff --git a/internal/task/step/shell.go b/internal/task/step/shell.go index 2545b0f7a..3096eddd8 100644 --- a/internal/task/step/shell.go +++ b/internal/task/step/shell.go @@ -607,18 +607,9 @@ func (s *Scp) Execute(ctx *context.Context) error { return errno.ERR_WRITE_FILE_FAILED.E(err) } - config := ctx.SSHClient().Config() - cmd := ctx.Module().Shell().Scp(localPath, config.User, config.Host, s.RemotePath) - cmd.AddOption("-P %d", config.Port) - if !config.ForwardAgent { - cmd.AddOption("-i %s", config.PrivateKeyPath) - } - - options := s.ExecOptions - options.ExecWithSudo = false - options.ExecInLocal = true - out, err := cmd.Execute(options) - return PostHandle(nil, nil, out, err, errno.ERR_SECURE_COPY_FILE_TO_REMOTE_FAILED) + err = ctx.Module().File().Upload(localPath, s.RemotePath) + + return PostHandle(nil, nil, "", err, errno.ERR_SECURE_COPY_FILE_TO_REMOTE_FAILED) } func (s *Command) Execute(ctx *context.Context) error { diff --git a/internal/task/task/bs/add_target.go b/internal/task/task/bs/add_target.go index 19f73c5d5..bf19c1f9e 100644 --- a/internal/task/task/bs/add_target.go +++ b/internal/task/task/bs/add_target.go @@ -52,7 +52,7 @@ func NewAddTargetTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task } subname := fmt.Sprintf("host=%s volume=%s", options.Host, volume) - t := task.NewTask("Add Target", subname, hc.GetSSHConfig()) + t := task.NewTask("Add Target", subname, hc.GetConnectConfig()) // add step var output string diff --git a/internal/task/task/bs/balance_leader.go b/internal/task/task/bs/balance_leader.go index 2c29f75a7..35f1b33e6 100644 --- a/internal/task/task/bs/balance_leader.go +++ b/internal/task/task/bs/balance_leader.go @@ -48,7 +48,7 @@ func NewBalanceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Balance Leader", subname, hc.GetSSHConfig()) + t := task.NewTask("Balance Leader", subname, hc.GetConnectConfig()) // add step t.AddStep(&step.ContainerExec{ diff --git a/internal/task/task/bs/create_volume.go b/internal/task/task/bs/create_volume.go index 0142424f2..68e013dd7 100644 --- a/internal/task/task/bs/create_volume.go +++ b/internal/task/task/bs/create_volume.go @@ -106,7 +106,7 @@ func NewCreateVolumeTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*t } subname := fmt.Sprintf("hostname=%s image=%s", hc.GetHostname(), cc.GetContainerImage()) - t := task.NewTask("Create Volume", subname, hc.GetSSHConfig()) + t := task.NewTask("Create Volume", subname, hc.GetConnectConfig()) // add step var out string diff --git a/internal/task/task/bs/delete_target.go b/internal/task/task/bs/delete_target.go index 562f4e821..da860fab2 100644 --- a/internal/task/task/bs/delete_target.go +++ b/internal/task/task/bs/delete_target.go @@ -58,7 +58,7 @@ func NewDeleteTargetTask(curveadm *cli.CurveAdm, cc *client.ClientConfig) (*task } subname := fmt.Sprintf("hostname=%s tid=%s", hc.GetHostname(), options.Tid) - t := task.NewTask("Delete Target", subname, hc.GetSSHConfig()) + t := task.NewTask("Delete Target", subname, hc.GetConnectConfig()) // add step var output string diff --git a/internal/task/task/bs/detect_release.go b/internal/task/task/bs/detect_release.go index b1cb0a23a..60e3810ef 100644 --- a/internal/task/task/bs/detect_release.go +++ b/internal/task/task/bs/detect_release.go @@ -75,7 +75,7 @@ func NewDetectOSReleaseTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, var success bool var out string subname := fmt.Sprintf("host=%s", host) - t := task.NewTask("Detect OS Release", subname, hc.GetSSHConfig()) + t := task.NewTask("Detect OS Release", subname, hc.GetConnectConfig()) // add step to task t.AddStep(&step.Cat{ diff --git a/internal/task/task/bs/format.go b/internal/task/task/bs/format.go index 1ea0f9de9..3a4b7aa84 100644 --- a/internal/task/task/bs/format.go +++ b/internal/task/task/bs/format.go @@ -182,7 +182,7 @@ func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConf chunkSize := fc.GetChunkSize() subname := fmt.Sprintf("host=%s device=%s mountPoint=%s usage=%d%%", fc.GetHost(), device, mountPoint, usagePercent) - t := task.NewTask("Start Format Chunkfile Pool", subname, hc.GetSSHConfig()) + t := task.NewTask("Start Format Chunkfile Pool", subname, hc.GetConnectConfig()) // add step to task var output, containerId, oldUUID string diff --git a/internal/task/task/bs/format_status.go b/internal/task/task/bs/format_status.go index 121dd80b9..8434f313b 100644 --- a/internal/task/task/bs/format_status.go +++ b/internal/task/task/bs/format_status.go @@ -26,10 +26,10 @@ import ( "fmt" "strings" - comm "github.com/opencurve/curveadm/internal/common" - "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/task/context" "github.com/opencurve/curveadm/internal/task/step" "github.com/opencurve/curveadm/internal/task/task" @@ -122,7 +122,7 @@ func NewGetFormatStatusTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) // new task device := fc.GetDevice() subname := fmt.Sprintf("host=%s device=%s", fc.GetHost(), fc.GetDevice()) - t := task.NewTask("Get Format Status", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Format Status", subname, hc.GetConnectConfig()) // add step to task var deviceUsage, containerStatus string diff --git a/internal/task/task/bs/format_stop.go b/internal/task/task/bs/format_stop.go index 6332e3f05..15986463d 100644 --- a/internal/task/task/bs/format_stop.go +++ b/internal/task/task/bs/format_stop.go @@ -79,7 +79,7 @@ func NewStopFormatTask(curveadm *cli.CurveAdm, fc *configure.FormatConfig) (*tas containerName := device2ContainerName(device) subname := fmt.Sprintf("host=%s device=%s mountPoint=%s containerName=%s", fc.GetHost(), device, mountPoint, containerName) - t := task.NewTask("Stop Format Chunkfile Pool", subname, hc.GetSSHConfig()) + t := task.NewTask("Stop Format Chunkfile Pool", subname, hc.GetConnectConfig()) var oldContainerId string var oldUUID string diff --git a/internal/task/task/bs/install_polarfs.go b/internal/task/task/bs/install_polarfs.go index 9b7976d36..693e87968 100644 --- a/internal/task/task/bs/install_polarfs.go +++ b/internal/task/task/bs/install_polarfs.go @@ -104,7 +104,7 @@ func NewInstallPolarFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) ( // new task release := getRelease(curveadm) subname := fmt.Sprintf("host=%s release=%s", host, release) - t := task.NewTask("Install PolarFS", subname, hc.GetSSHConfig()) + t := task.NewTask("Install PolarFS", subname, hc.GetConnectConfig()) // add step to task var input, output string diff --git a/internal/task/task/bs/list_targets.go b/internal/task/task/bs/list_targets.go index cab076dbb..f7c7b8fce 100644 --- a/internal/task/task/bs/list_targets.go +++ b/internal/task/task/bs/list_targets.go @@ -119,7 +119,7 @@ func NewListTargetsTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, erro } subname := fmt.Sprintf("host=%s", hc.GetHostname()) - t := task.NewTask("List Targets", subname, hc.GetSSHConfig()) + t := task.NewTask("List Targets", subname, hc.GetConnectConfig()) // add step var output string diff --git a/internal/task/task/bs/map.go b/internal/task/task/bs/map.go index b22a31ebf..a2d2f56df 100644 --- a/internal/task/task/bs/map.go +++ b/internal/task/task/bs/map.go @@ -79,7 +79,7 @@ func NewMapTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, } subname := fmt.Sprintf("hostname=%s volume=%s:%s", hc.GetHostname(), options.User, options.Volume) - t := task.NewTask("Map Volume", subname, hc.GetSSHConfig()) + t := task.NewTask("Map Volume", subname, hc.GetConnectConfig()) // add step var out string diff --git a/internal/task/task/bs/start_nebd.go b/internal/task/task/bs/start_nebd.go index a6ab93de5..d8742ab52 100644 --- a/internal/task/task/bs/start_nebd.go +++ b/internal/task/task/bs/start_nebd.go @@ -154,7 +154,7 @@ func NewStartNEBDServiceTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) } subname := fmt.Sprintf("hostname=%s image=%s", hc.GetHostname(), cc.GetContainerImage()) - t := task.NewTask("Start NEBD Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Start NEBD Service", subname, hc.GetConnectConfig()) // add step var containerId, out string diff --git a/internal/task/task/bs/start_tgtd.go b/internal/task/task/bs/start_tgtd.go index 0c2234405..cc3b0e705 100644 --- a/internal/task/task/bs/start_tgtd.go +++ b/internal/task/task/bs/start_tgtd.go @@ -66,7 +66,7 @@ func NewStartTargetDaemonTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig // new task subname := fmt.Sprintf("host=%s image=%s", options.Host, cc.GetContainerImage()) - t := task.NewTask("Start Target Daemon", subname, hc.GetSSHConfig()) + t := task.NewTask("Start Target Daemon", subname, hc.GetConnectConfig()) // add step to task var status, containerId, out string diff --git a/internal/task/task/bs/stop_tgtd.go b/internal/task/task/bs/stop_tgtd.go index 0725c0355..e32c3d289 100644 --- a/internal/task/task/bs/stop_tgtd.go +++ b/internal/task/task/bs/stop_tgtd.go @@ -50,7 +50,7 @@ func NewStopTargetDaemonTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, // new task subname := fmt.Sprintf("host=%s", options.Host) - t := task.NewTask("Stop Target Daemon", subname, hc.GetSSHConfig()) + t := task.NewTask("Stop Target Daemon", subname, hc.GetConnectConfig()) // add step var containerId string diff --git a/internal/task/task/bs/uninstall_polarfs.go b/internal/task/task/bs/uninstall_polarfs.go index c228403ca..929b129a3 100644 --- a/internal/task/task/bs/uninstall_polarfs.go +++ b/internal/task/task/bs/uninstall_polarfs.go @@ -77,7 +77,7 @@ func NewUninstallPolarFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, // new task release := getRelease(curveadm) subname := fmt.Sprintf("host=%s release=%s", host, release) - t := task.NewTask("Uninstall PolarFS", subname, hc.GetSSHConfig()) + t := task.NewTask("Uninstall PolarFS", subname, hc.GetConnectConfig()) // add step to task t.AddStep(&step.RemoveFile{ diff --git a/internal/task/task/bs/unmap.go b/internal/task/task/bs/unmap.go index 3e1dee29b..9888612a7 100644 --- a/internal/task/task/bs/unmap.go +++ b/internal/task/task/bs/unmap.go @@ -144,7 +144,7 @@ func NewUnmapTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { subname := fmt.Sprintf("hostname=%s volume=%s:%s containerId=%s", hc.GetHostname(), options.User, options.Volume, tui.TrimContainerId(containerId)) - t := task.NewTask("Unmap Volume", subname, hc.GetSSHConfig()) + t := task.NewTask("Unmap Volume", subname, hc.GetConnectConfig()) // add step var output string diff --git a/internal/task/task/checker/date.go b/internal/task/task/checker/date.go index 41a4900aa..74c3298f4 100644 --- a/internal/task/task/checker/date.go +++ b/internal/task/task/checker/date.go @@ -87,7 +87,7 @@ func NewGetHostDate(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Ta } subname := fmt.Sprintf("host=%s start=%d", dc.GetHost(), time.Now().Unix()) - t := task.NewTask("Get Host Date ", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Host Date ", subname, hc.GetConnectConfig()) var start int64 var out string diff --git a/internal/task/task/checker/kernel.go b/internal/task/task/checker/kernel.go index 3db2ed1d9..5e8f9c284 100644 --- a/internal/task/task/checker/kernel.go +++ b/internal/task/task/checker/kernel.go @@ -106,7 +106,7 @@ func NewCheckKernelVersionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig // new task subname := fmt.Sprintf("host=%s role=%s require=(>=%s)", dc.GetHost(), dc.GetRole(), CHUNKSERVER_LEAST_KERNEL_VERSION) - t := task.NewTask("Check Kernel Version ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Kernel Version ", subname, hc.GetConnectConfig()) // add step to task var out string @@ -132,7 +132,7 @@ func NewCheckKernelModuleTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig // new task name := curveadm.MemStorage().Get(comm.KEY_CHECK_KERNEL_MODULE_NAME).(string) subname := fmt.Sprintf("host=%s module=%s", host, name) - t := task.NewTask("Check Kernel Module", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Kernel Module", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/checker/network.go b/internal/task/task/checker/network.go index ece0e0595..d2f41c105 100644 --- a/internal/task/task/checker/network.go +++ b/internal/task/task/checker/network.go @@ -134,7 +134,7 @@ func NewCheckPortInUseTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* addresses := getServiceListenAddresses(dc) subname := fmt.Sprintf("host=%s role=%s ports={%s}", dc.GetHost(), dc.GetRole(), joinPorts(dc, addresses)) - t := task.NewTask("Check Port In Use ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Port In Use ", subname, hc.GetConnectConfig()) var containerId, out string var success bool @@ -203,7 +203,7 @@ func NewCheckDestinationReachableTask(curveadm *cli.CurveAdm, dc *topology.Deplo addresses := unique(getServiceConnectAddress(dc, dcs)) subname := fmt.Sprintf("host=%s role=%s ping={%s}", dc.GetHost(), dc.GetRole(), tui.TrimAddress(strings.Join(addresses, ","))) - t := task.NewTask("Check Destination Reachable ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Destination Reachable ", subname, hc.GetConnectConfig()) var out string var success bool @@ -258,7 +258,7 @@ func NewStartHTTPServerTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( addresses := getServiceListenAddresses(dc) subname := fmt.Sprintf("host=%s role=%s ports={%s}", dc.GetHost(), dc.GetRole(), joinPorts(dc, addresses)) - t := task.NewTask("Start Mock HTTP Server ", subname, hc.GetSSHConfig()) + t := task.NewTask("Start Mock HTTP Server ", subname, hc.GetConnectConfig()) // add step to task var containerId, out string @@ -329,7 +329,7 @@ func NewCheckNetworkFirewallTask(curveadm *cli.CurveAdm, dc *topology.DeployConf // add task subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) - t := task.NewTask("Check Network Firewall ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Network Firewall ", subname, hc.GetConnectConfig()) // add step to task var out string @@ -395,7 +395,7 @@ func NewCleanEnvironmentTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) // new task subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) - t := task.NewTask("Clean Precheck Environment", subname, hc.GetSSHConfig()) + t := task.NewTask("Clean Precheck Environment", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/checker/permission.go b/internal/task/task/checker/permission.go index 42504ce0b..323a51b13 100644 --- a/internal/task/task/checker/permission.go +++ b/internal/task/task/checker/permission.go @@ -119,7 +119,7 @@ func NewCheckPermissionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( // new task subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) - t := task.NewTask("Check Permission ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Permission ", subname, hc.GetConnectConfig()) // add step to task var out, hostname string @@ -145,7 +145,7 @@ func NewCheckPermissionTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( t.AddStep(&step.Ping{ Destination: &hostname, Count: 1, - Timeout: 1, + Timeout: 1, Success: &success, ExecOptions: curveadm.ExecOptions(), }) diff --git a/internal/task/task/checker/service.go b/internal/task/task/checker/service.go index f762f1942..1a862475e 100644 --- a/internal/task/task/checker/service.go +++ b/internal/task/task/checker/service.go @@ -138,7 +138,7 @@ func NewCheckChunkfilePoolTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig } subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) - t := task.NewTask("Check Chunkfile Pool ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check Chunkfile Pool ", subname, hc.GetConnectConfig()) t.AddStep(&step2CheckChunkfilePool{ dc: dc, @@ -171,7 +171,7 @@ func NewCheckMdsAddressTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) address := cc.GetClusterMDSAddr() subname := fmt.Sprintf("host=%s address=%s", host, address) - t := task.NewTask("Check MDS Address", subname, hc.GetSSHConfig()) + t := task.NewTask("Check MDS Address", subname, hc.GetConnectConfig()) return t, nil } diff --git a/internal/task/task/checker/ssh.go b/internal/task/task/checker/ssh.go index 9d0e893bd..37ac818c2 100644 --- a/internal/task/task/checker/ssh.go +++ b/internal/task/task/checker/ssh.go @@ -35,6 +35,7 @@ import ( "github.com/opencurve/curveadm/internal/task/step" "github.com/opencurve/curveadm/internal/task/task" "github.com/opencurve/curveadm/internal/utils" + "github.com/opencurve/curveadm/pkg/module" ) const ( @@ -51,7 +52,7 @@ func doNothing() step.LambdaType { func checkHost(hc *hosts.HostConfig) step.LambdaType { return func(ctx *context.Context) error { privateKeyFile := hc.GetPrivateKeyFile() - if hc.GetForwardAgent() == false { + if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL { if !utils.PathExist(privateKeyFile) { return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST. F("%s: no such file", privateKeyFile) @@ -73,7 +74,7 @@ func NewCheckSSHConnectTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( // new task method := utils.Choose(hc.GetForwardAgent(), "forwardAgent", "privateKey") subname := fmt.Sprintf("host=%s method=%s", dc.GetHost(), method) - t := task.NewTask("Check SSH Connect ", subname, hc.GetSSHConfig()) + t := task.NewTask("Check SSH Connect ", subname, hc.GetConnectConfig()) // add step to task t.AddStep(&step.Lambda{ diff --git a/internal/task/task/common/backup_etcd.go b/internal/task/task/common/backup_etcd.go index e9aaeb3b7..2968b9186 100644 --- a/internal/task/task/common/backup_etcd.go +++ b/internal/task/task/common/backup_etcd.go @@ -57,7 +57,7 @@ func NewBackupEtcdDataTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Backup Etcd Data", subname, hc.GetSSHConfig()) + t := task.NewTask("Backup Etcd Data", subname, hc.GetConnectConfig()) t.AddStep(&step.ContainerExec{ ContainerId: &containerId, diff --git a/internal/task/task/common/clean_service.go b/internal/task/task/common/clean_service.go index a3e94c87a..474c04ed9 100644 --- a/internal/task/task/common/clean_service.go +++ b/internal/task/task/common/clean_service.go @@ -149,7 +149,7 @@ func NewCleanServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*ta recycle := curveadm.MemStorage().Get(comm.KEY_CLEAN_BY_RECYCLE).(bool) subname := fmt.Sprintf("host=%s role=%s containerId=%s clean=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) - t := task.NewTask("Clean Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Clean Service", subname, hc.GetConnectConfig()) // add step to task clean := utils.Slice2Map(only) diff --git a/internal/task/task/common/client_status.go b/internal/task/task/common/client_status.go index 87628814a..d1e39a198 100644 --- a/internal/task/task/common/client_status.go +++ b/internal/task/task/common/client_status.go @@ -164,7 +164,7 @@ func NewGetClientStatusTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, containerId := client.ContainerId subname := fmt.Sprintf("host=%s kind=%s containerId=%s", hc.GetHost(), client.Kind, tui.TrimContainerId(containerId)) - t := task.NewTask("Get Client Status", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Client Status", subname, hc.GetConnectConfig()) // add step var status string diff --git a/internal/task/task/common/collect_client.go b/internal/task/task/common/collect_client.go index f9085cf20..82eccda73 100644 --- a/internal/task/task/common/collect_client.go +++ b/internal/task/task/common/collect_client.go @@ -47,7 +47,7 @@ func NewCollectClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, er containerId := client.ContainerId subname := fmt.Sprintf("host=%s kind=%s containerId=%s", hc.GetHost(), client.Kind, tui.TrimContainerId(containerId)) - t := task.NewTask("Collect Client", subname, hc.GetSSHConfig()) + t := task.NewTask("Collect Client", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/collect_service.go b/internal/task/task/common/collect_service.go index 9718d38a6..6a53b1154 100644 --- a/internal/task/task/common/collect_service.go +++ b/internal/task/task/common/collect_service.go @@ -93,7 +93,7 @@ func NewCollectServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Collect Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Collect Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/create_container.go b/internal/task/task/common/create_container.go index 1a6d6676c..1f71e37ec 100644 --- a/internal/task/task/common/create_container.go +++ b/internal/task/task/common/create_container.go @@ -214,7 +214,7 @@ func NewCreateContainerTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( // new task subname := fmt.Sprintf("host=%s role=%s", dc.GetHost(), dc.GetRole()) - t := task.NewTask("Create Container", subname, hc.GetSSHConfig()) + t := task.NewTask("Create Container", subname, hc.GetConnectConfig()) // add step to task var oldContainerId, containerId string diff --git a/internal/task/task/common/create_pool.go b/internal/task/task/common/create_pool.go index 3adbbc200..8feee04b4 100644 --- a/internal/task/task/common/create_pool.go +++ b/internal/task/task/common/create_pool.go @@ -200,7 +200,7 @@ func NewCreateTopologyTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* "Create Logical Pool", "Create Physical Pool") subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask(name, subname, hc.GetSSHConfig()) + t := task.NewTask(name, subname, hc.GetConnectConfig()) // add step to task var success bool diff --git a/internal/task/task/common/etcd_auth_enable.go b/internal/task/task/common/etcd_auth_enable.go index 9d3b71109..07d2b9767 100644 --- a/internal/task/task/common/etcd_auth_enable.go +++ b/internal/task/task/common/etcd_auth_enable.go @@ -63,7 +63,7 @@ func NewEnableEtcdAuthTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Enable Etcd Auth", subname, hc.GetSSHConfig()) + t := task.NewTask("Enable Etcd Auth", subname, hc.GetConnectConfig()) script := scripts.ENABLE_ETCD_AUTH layout := dc.GetProjectLayout() diff --git a/internal/task/task/common/install_client.go b/internal/task/task/common/install_client.go index dcb691b12..192d41e45 100644 --- a/internal/task/task/common/install_client.go +++ b/internal/task/task/common/install_client.go @@ -142,7 +142,7 @@ func NewInstallClientTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (* release := getRelease(curveadm) subname := fmt.Sprintf("host=%s release=%s", host, release) name := utils.Choose(kind == KIND_CURVEBS, "CurveBS", "CurveFS") - t := task.NewTask(fmt.Sprintf("Install %s Client", name), subname, hc.GetSSHConfig()) + t := task.NewTask(fmt.Sprintf("Install %s Client", name), subname, hc.GetConnectConfig()) // add step to task var input, output string diff --git a/internal/task/task/common/pull_image.go b/internal/task/task/common/pull_image.go index ee40f930d..0b75a718f 100644 --- a/internal/task/task/common/pull_image.go +++ b/internal/task/task/common/pull_image.go @@ -41,7 +41,7 @@ func NewPullImageTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task. // new task subname := fmt.Sprintf("host=%s image=%s", dc.GetHost(), dc.GetContainerImage()) - t := task.NewTask("Pull Image", subname, hc.GetSSHConfig()) + t := task.NewTask("Pull Image", subname, hc.GetConnectConfig()) // add step to task t.AddStep(&step.PullImage{ diff --git a/internal/task/task/common/restart_service.go b/internal/task/task/common/restart_service.go index 25915a7e3..67c6c9f98 100644 --- a/internal/task/task/common/restart_service.go +++ b/internal/task/task/common/restart_service.go @@ -71,7 +71,7 @@ func NewRestartServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Restart Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Restart Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/service_status.go b/internal/task/task/common/service_status.go index 660fd68c7..4597b1962 100644 --- a/internal/task/task/common/service_status.go +++ b/internal/task/task/common/service_status.go @@ -265,7 +265,7 @@ func NewGetServiceStatusTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Get Service Status", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Service Status", subname, hc.GetConnectConfig()) // add step to task var status string diff --git a/internal/task/task/common/start_service.go b/internal/task/task/common/start_service.go index 7f592f23b..52b748de6 100644 --- a/internal/task/task/common/start_service.go +++ b/internal/task/task/common/start_service.go @@ -89,7 +89,7 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*ta // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Start Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Start Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/stop_service.go b/internal/task/task/common/stop_service.go index 9600d9f99..132c80fb6 100644 --- a/internal/task/task/common/stop_service.go +++ b/internal/task/task/common/stop_service.go @@ -73,7 +73,7 @@ func NewStopServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*tas // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Stop Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Stop Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/sync_config.go b/internal/task/task/common/sync_config.go index b247a56a5..bee16df04 100644 --- a/internal/task/task/common/sync_config.go +++ b/internal/task/task/common/sync_config.go @@ -103,7 +103,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Sync Config", subname, hc.GetSSHConfig()) + t := task.NewTask("Sync Config", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/common/uninstall_client.go b/internal/task/task/common/uninstall_client.go index ce939832d..aa3aa755f 100644 --- a/internal/task/task/common/uninstall_client.go +++ b/internal/task/task/common/uninstall_client.go @@ -81,7 +81,7 @@ func NewUninstallClientTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, kind := curveadm.MemStorage().Get(comm.KEY_CLIENT_KIND).(string) subname := fmt.Sprintf("host=%s release=%s kind=%s", host, release, kind) name := utils.Choose(kind == KIND_CURVEBS, "CurveBS", "CurveFS") - t := task.NewTask(fmt.Sprintf("Uninstall %s Client", name), subname, hc.GetSSHConfig()) + t := task.NewTask(fmt.Sprintf("Uninstall %s Client", name), subname, hc.GetConnectConfig()) // add step to task t.AddPostStep(&step2UninstallPackage{ diff --git a/internal/task/task/fs/mount.go b/internal/task/task/fs/mount.go index 124d3f8ef..ae27bf044 100644 --- a/internal/task/task/fs/mount.go +++ b/internal/task/task/fs/mount.go @@ -289,7 +289,7 @@ func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.T mountFSName := options.MountFSName mountFSType := options.MountFSType subname := fmt.Sprintf("mountFSName=%s mountFSType=%s mountPoint=%s", mountFSName, mountFSType, mountPoint) - t := task.NewTask("Mount FileSystem", subname, hc.GetSSHConfig()) + t := task.NewTask("Mount FileSystem", subname, hc.GetConnectConfig()) // add step to task var containerId, out string diff --git a/internal/task/task/fs/umount.go b/internal/task/task/fs/umount.go index 9a1275cae..0980d3cc4 100644 --- a/internal/task/task/fs/umount.go +++ b/internal/task/task/fs/umount.go @@ -131,7 +131,7 @@ func NewUmountFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) // new task mountPoint := options.MountPoint subname := fmt.Sprintf("host=%s mountPoint=%s", options.Host, mountPoint) - t := task.NewTask("Umount FileSystem", subname, hc.GetSSHConfig()) + t := task.NewTask("Umount FileSystem", subname, hc.GetConnectConfig()) // add step to task var status string diff --git a/internal/task/task/monitor/clean_container.go b/internal/task/task/monitor/clean_container.go index 1756be472..b8d411af4 100644 --- a/internal/task/task/monitor/clean_container.go +++ b/internal/task/task/monitor/clean_container.go @@ -44,7 +44,7 @@ func NewCleanConfigContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorC if err != nil { return nil, err } - t := task.NewTask("Clean Config Container", "", hc.GetSSHConfig()) + t := task.NewTask("Clean Config Container", "", hc.GetConnectConfig()) t.AddStep(&common.Step2CleanContainer{ ServiceId: serviceId, ContainerId: containerId, diff --git a/internal/task/task/monitor/clean_service.go b/internal/task/task/monitor/clean_service.go index 26e928dc4..d432141a1 100644 --- a/internal/task/task/monitor/clean_service.go +++ b/internal/task/task/monitor/clean_service.go @@ -73,7 +73,7 @@ func NewCleanMonitorTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( only := curveadm.MemStorage().Get(comm.KEY_CLEAN_ITEMS).([]string) subname := fmt.Sprintf("host=%s role=%s containerId=%s clean=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId), strings.Join(only, ",")) - t := task.NewTask("Clean Monitor", subname, hc.GetSSHConfig()) + t := task.NewTask("Clean Monitor", subname, hc.GetConnectConfig()) // add step to task clean := utils.Slice2Map(only) diff --git a/internal/task/task/monitor/create_container.go b/internal/task/task/monitor/create_container.go index a01f3e514..d25c0cd62 100644 --- a/internal/task/task/monitor/create_container.go +++ b/internal/task/task/monitor/create_container.go @@ -120,7 +120,7 @@ func NewCreateContainerTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig // new task subname := fmt.Sprintf("host=%s role=%s", host, cfg.GetRole()) - t := task.NewTask("Create Container", subname, hc.GetSSHConfig()) + t := task.NewTask("Create Container", subname, hc.GetConnectConfig()) // add step to task var oldContainerId, containerId string diff --git a/internal/task/task/monitor/pull_image.go b/internal/task/task/monitor/pull_image.go index 80883e43d..81cbcb1a5 100644 --- a/internal/task/task/monitor/pull_image.go +++ b/internal/task/task/monitor/pull_image.go @@ -41,7 +41,7 @@ func NewPullImageTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*ta // new task subname := fmt.Sprintf("host=%s image=%s", host, image) - t := task.NewTask("Pull Image", subname, hc.GetSSHConfig()) + t := task.NewTask("Pull Image", subname, hc.GetConnectConfig()) // add step to task t.AddStep(&step.PullImage{ Image: image, diff --git a/internal/task/task/monitor/restart_service.go b/internal/task/task/monitor/restart_service.go index 25be8d924..0e5ec4dbf 100644 --- a/internal/task/task/monitor/restart_service.go +++ b/internal/task/task/monitor/restart_service.go @@ -49,7 +49,7 @@ func NewRestartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Restart Monitor Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Restart Monitor Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/monitor/start_service.go b/internal/task/task/monitor/start_service.go index 7391e1aaf..c2e2b96e7 100644 --- a/internal/task/task/monitor/start_service.go +++ b/internal/task/task/monitor/start_service.go @@ -59,7 +59,7 @@ func NewStartServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) ( // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Start Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Start Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/monitor/status_service.go b/internal/task/task/monitor/status_service.go index 9c9c36323..1c308e3de 100644 --- a/internal/task/task/monitor/status_service.go +++ b/internal/task/task/monitor/status_service.go @@ -154,7 +154,7 @@ func NewGetMonitorStatusTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfi // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Get Monitor Status", subname, hc.GetSSHConfig()) + t := task.NewTask("Get Monitor Status", subname, hc.GetConnectConfig()) // add step to task var status string diff --git a/internal/task/task/monitor/stop_service.go b/internal/task/task/monitor/stop_service.go index 126a5801d..735259462 100644 --- a/internal/task/task/monitor/stop_service.go +++ b/internal/task/task/monitor/stop_service.go @@ -49,7 +49,7 @@ func NewStopServiceTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (* // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Stop Service", subname, hc.GetSSHConfig()) + t := task.NewTask("Stop Service", subname, hc.GetConnectConfig()) // add step to task var out string diff --git a/internal/task/task/monitor/sync_config.go b/internal/task/task/monitor/sync_config.go index 6393d2797..1ac897012 100644 --- a/internal/task/task/monitor/sync_config.go +++ b/internal/task/task/monitor/sync_config.go @@ -72,7 +72,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, cfg *configure.MonitorConfig) (*t // new task subname := fmt.Sprintf("host=%s role=%s containerId=%s", cfg.GetHost(), cfg.GetRole(), tui.TrimContainerId(containerId)) - t := task.NewTask("Sync Config", subname, hc.GetSSHConfig()) + t := task.NewTask("Sync Config", subname, hc.GetConnectConfig()) // add step to task var out string t.AddStep(&step.ListContainers{ // gurantee container exist diff --git a/internal/task/task/task.go b/internal/task/task/task.go index 47a6fa6f2..249153c92 100644 --- a/internal/task/task/task.go +++ b/internal/task/task/task.go @@ -26,9 +26,7 @@ package task import ( "errors" - "github.com/google/uuid" - "github.com/opencurve/curveadm/internal/errno" "github.com/opencurve/curveadm/internal/task/context" "github.com/opencurve/curveadm/pkg/module" ) @@ -44,25 +42,25 @@ type ( } Task struct { - tid string // task id - ptid string // parent task id - name string - subname string - steps []Step - postSteps []Step - sshConfig *module.SSHConfig - context context.Context + tid string // task id + ptid string // parent task id + name string + subname string + steps []Step + postSteps []Step + connectConfig *module.ConnectConfig + context context.Context } ) -func NewTask(name, subname string, sshConfig *module.SSHConfig) *Task { +func NewTask(name, subname string, connectConfig *module.ConnectConfig) *Task { tid := uuid.NewString()[:12] return &Task{ - tid: tid, - ptid: tid, - name: name, - subname: subname, - sshConfig: sshConfig, + tid: tid, + ptid: tid, + name: name, + subname: subname, + connectConfig: connectConfig, } } @@ -112,16 +110,12 @@ func (t *Task) executePost(ctx *context.Context) { } func (t *Task) Execute() error { - var sshClient *module.SSHClient - if t.sshConfig != nil { - client, err := module.NewSSHClient(*t.sshConfig) - if err != nil { - return errno.ERR_SSH_CONNECT_FAILED.E(err) - } - sshClient = client + remoteClient, err := module.NewRemoteClient(t.connectConfig) + if err != nil { + return err } - ctx, err := context.NewContext(sshClient) + ctx, err := context.NewContext(remoteClient) if err != nil { return err } diff --git a/internal/tui/hosts.go b/internal/tui/hosts.go index 9a19ba983..67366c89c 100644 --- a/internal/tui/hosts.go +++ b/internal/tui/hosts.go @@ -45,6 +45,8 @@ func FormatHosts(hcs []*configure.HostConfig, verbose bool) string { "Hostname", "User", "Port", + "Protocol", + "HTTP Port", "Private Key File", "Forward Agent", "Become User", @@ -60,8 +62,10 @@ func FormatHosts(hcs []*configure.HostConfig, verbose bool) string { host := hc.GetHost() hostname := hc.GetHostname() + protocol := hc.GetProtocol() user := hc.GetUser() port := strconv.Itoa(hc.GetSSHPort()) + httpPort := strconv.Itoa(hc.GetHTTPPort()) forwardAgent := utils.Choose(hc.GetForwardAgent(), "Y", "N") becomeUser := utils.Choose(len(hc.GetBecomeUser()) > 0, hc.GetBecomeUser(), "-") labels := utils.Choose(len(hc.GetLabels()) > 0, strings.Join(hc.GetLabels(), ","), "-") @@ -78,6 +82,8 @@ func FormatHosts(hcs []*configure.HostConfig, verbose bool) string { hostname, user, port, + protocol, + httpPort, privateKeyFile, forwardAgent, becomeUser, diff --git a/pkg/module/docker_cli.go b/pkg/module/docker_cli.go index 43974faf8..926fc5fef 100644 --- a/pkg/module/docker_cli.go +++ b/pkg/module/docker_cli.go @@ -49,18 +49,18 @@ const ( ) type DockerCli struct { - sshClient *SSHClient - options []string - tmpl *template.Template - data map[string]interface{} + options []string + tmpl *template.Template + data map[string]interface{} + remoteClient RemoteClient } -func NewDockerCli(sshClient *SSHClient) *DockerCli { +func NewDockerCli(remoteClient RemoteClient) *DockerCli { return &DockerCli{ - sshClient: sshClient, - options: []string{}, - tmpl: nil, - data: map[string]interface{}{}, + remoteClient: remoteClient, + options: []string{}, + tmpl: nil, + data: map[string]interface{}{}, } } @@ -72,7 +72,7 @@ func (s *DockerCli) AddOption(format string, args ...interface{}) *DockerCli { func (cli *DockerCli) Execute(options ExecOptions) (string, error) { cli.data["options"] = strings.Join(cli.options, " ") cli.data["engine"] = options.ExecWithEngine - return execCommand(cli.sshClient, cli.tmpl, cli.data, options) + return execCommand(cli.remoteClient, cli.tmpl, cli.data, options) } func (cli *DockerCli) DockerInfo() *DockerCli { diff --git a/pkg/module/file.go b/pkg/module/file.go index b7d686420..4a8f49062 100644 --- a/pkg/module/file.go +++ b/pkg/module/file.go @@ -41,35 +41,36 @@ var ( ) type FileManager struct { - sshClient *SSHClient + remoteClient RemoteClient } -func NewFileManager(sshClient *SSHClient) *FileManager { - return &FileManager{sshClient: sshClient} +func NewFileManager(remoteClient RemoteClient) *FileManager { + return &FileManager{remoteClient: remoteClient} } func (f *FileManager) Upload(localPath, remotePath string) error { - if f.sshClient == nil { + if f.remoteClient == nil { return ERR_UNREACHED } - err := f.sshClient.Client().Upload(localPath, remotePath) + err := f.remoteClient.Upload(localPath, remotePath) log.SwitchLevel(err)("UploadFile", - log.Field("remoteAddress", remoteAddr(f.sshClient)), + log.Field("remoteAddress", remoteAddr(f.remoteClient)), log.Field("localPath", localPath), log.Field("remotePath", remotePath), - log.Field("error", err)) + log.Field("error", err), + log.Field("protocol", f.remoteClient.Protocol())) return err } func (f *FileManager) Download(remotePath, localPath string) error { - if f.sshClient == nil { + if f.remoteClient == nil { return ERR_UNREACHED } - err := f.sshClient.Client().Download(remotePath, localPath) + err := f.remoteClient.Download(remotePath, localPath) log.SwitchLevel(err)("DownloadFile", - log.Field("remoteAddress", remoteAddr(f.sshClient)), + log.Field("remoteAddress", remoteAddr(f.remoteClient)), log.Field("remotePath", remotePath), log.Field("localPath", localPath), log.Field("error", err)) diff --git a/pkg/module/http.go b/pkg/module/http.go new file mode 100644 index 000000000..ca2d145b2 --- /dev/null +++ b/pkg/module/http.go @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * 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. + */ + +package module + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "os" + + log "github.com/opencurve/curveadm/pkg/log/glg" +) + +const ( + HTTP_PROTOCOL = "http" +) + +type ( + HTTPConfig struct { + Host string + Port uint + } + + HttpClient struct { + config HTTPConfig + client *http.Client + } + + HttpResult struct { + Data string `json:"data"` + ErrorCode string `json:"errorCode"` + ErrorMsg string `json:"errorMsg"` + } +) + +func (client *HttpClient) Protocol() string { + return HTTP_PROTOCOL +} + +func (client *HttpClient) WrapperCommand(command string, execInLocal bool) (wrapperCmd string) { + return command +} + +func (client *HttpClient) RunCommand(ctx context.Context, command string) (out []byte, err error) { + data := make(map[string]interface{}) + data["command"] = command + bytesData, _ := json.Marshal(data) + + baseURL, _ := url.Parse(fmt.Sprintf("http://%s:%d", client.config.Host, client.config.Port)) + params := url.Values{} + params.Add("method", "cluster.deploy.cmd") + baseURL.RawQuery = params.Encode() + resp, err := client.client.Post(baseURL.String(), "application/json", bytes.NewReader(bytesData)) + if err != nil { + return + } + respData, err := io.ReadAll(resp.Body) + if err != nil { + return + } + result := &HttpResult{} + err = json.Unmarshal(respData, result) + if err != nil { + return + } + + log.Info("http resp", log.Field("result", result)) + + if result.ErrorCode != "0" { + return []byte(result.Data), fmt.Errorf(result.ErrorMsg) + } + + return []byte(result.Data), nil +} + +func (client *HttpClient) RemoteAddr() (addr string) { + config := client.Config() + return fmt.Sprintf("%s:%d", config.Host, config.Port) +} + +func (client *HttpClient) Upload(localPath string, remotePath string) (err error) { + bodyBuf := &bytes.Buffer{} + bodyWriter := multipart.NewWriter(bodyBuf) + fh, err := os.Open(localPath) + if err != nil { + return err + } + defer fh.Close() + fileWriter, err := bodyWriter.CreateFormFile("file", localPath) + if err != nil { + return err + } + _, err = io.Copy(fileWriter, fh) + if err != nil { + return err + } + + baseURL, _ := url.Parse(fmt.Sprintf("http://%s:%d", client.config.Host, client.config.Port)) + params := url.Values{} + params.Add("method", "cluster.deploy.upload") + baseURL.RawQuery = params.Encode() + boundary := "--boundary" + bodyWriter.SetBoundary(boundary) + bodyWriter.WriteField("filepath", remotePath) + bodyWriter.Close() + resp, err := client.client.Post(baseURL.String(), bodyWriter.FormDataContentType(), bodyBuf) + if err != nil { + return err + } + defer resp.Body.Close() + return err +} + +func (client *HttpClient) Download(remotePath string, localPath string) (err error) { + baseURL, _ := url.Parse(fmt.Sprintf("http://%s:%d", client.config.Host, client.config.Port)) + params := url.Values{} + params.Add("method", "cluster.deploy.download") + params.Add("filepath", remotePath) + baseURL.RawQuery = params.Encode() + resp, err := client.client.Get(baseURL.String()) + if err != nil { + return + } + defer resp.Body.Close() + localFile, err := os.Create(localPath) + if err != nil { + return + } + defer localFile.Close() + _, err = io.Copy(localFile, resp.Body) + return +} + +func (client *HttpClient) Close() { + +} + +func (client *HttpClient) Config() HTTPConfig { + return client.config +} + +func NewHTTPClient(config HTTPConfig) (*HttpClient, error) { + return &HttpClient{ + config: config, + client: &http.Client{}, + }, nil +} diff --git a/pkg/module/module.go b/pkg/module/module.go index 5c0571f82..5ff2bbf8b 100644 --- a/pkg/module/module.go +++ b/pkg/module/module.go @@ -33,13 +33,12 @@ import ( "text/template" "time" - "github.com/melbahja/goph" log "github.com/opencurve/curveadm/pkg/log/glg" ) type ( Module struct { - sshClient *SSHClient + remoteClient RemoteClient } ExecOptions struct { @@ -60,33 +59,31 @@ func (e *TimeoutError) Error() string { e.timeout) } -func NewModule(sshClient *SSHClient) *Module { - return &Module{sshClient: sshClient} +func NewModule(remoteClient RemoteClient) *Module { + return &Module{remoteClient: remoteClient} } func (m *Module) Shell() *Shell { - return NewShell(m.sshClient) + return NewShell(m.remoteClient) } func (m *Module) File() *FileManager { - return NewFileManager(m.sshClient) + return NewFileManager(m.remoteClient) } func (m *Module) DockerCli() *DockerCli { - return NewDockerCli(m.sshClient) + return NewDockerCli(m.remoteClient) } // common utils -func remoteAddr(client *SSHClient) string { +func remoteAddr(client RemoteClient) string { if client == nil { return "-" } - - config := client.Config() - return fmt.Sprintf("%s@%s:%d", config.User, config.Host, config.Port) + return client.RemoteAddr() } -func execCommand(sshClient *SSHClient, +func execCommand(remoteClient RemoteClient, tmpl *template.Template, data map[string]interface{}, options ExecOptions) (string, error) { @@ -108,14 +105,8 @@ func execCommand(sshClient *SSHClient, command = strings.TrimLeft(command, " ") // (3) handle 'become_user' - if sshClient != nil { - becomeMethod := sshClient.Config().BecomeMethod - becomeFlags := sshClient.Config().BecomeFlags - becomeUser := sshClient.Config().BecomeUser - if len(becomeUser) > 0 && !options.ExecInLocal { - become := strings.Join([]string{becomeMethod, becomeFlags, becomeUser}, " ") - command = strings.Join([]string{become, command}, " ") - } + if remoteClient != nil { + command = remoteClient.WrapperCommand(command, options.ExecInLocal) } // (4) create context for timeout @@ -134,11 +125,7 @@ func execCommand(sshClient *SSHClient, cmd.Env = []string{"LANG=en_US.UTF-8"} out, err = cmd.CombinedOutput() } else { - var cmd *goph.Cmd - cmd, err = sshClient.Client().CommandContext(ctx, command) - if err == nil { - out, err = cmd.CombinedOutput() - } + out, err = remoteClient.RunCommand(ctx, command) } if ctx.Err() == context.DeadlineExceeded { @@ -146,7 +133,7 @@ func execCommand(sshClient *SSHClient, } log.SwitchLevel(err)("Execute command", - log.Field("remoteAddr", remoteAddr(sshClient)), + log.Field("remoteAddr", remoteAddr(remoteClient)), log.Field("command", command), log.Field("output", strings.TrimSuffix(string(out), "\n")), log.Field("error", err)) diff --git a/pkg/module/remote_client.go b/pkg/module/remote_client.go new file mode 100644 index 000000000..aad2577eb --- /dev/null +++ b/pkg/module/remote_client.go @@ -0,0 +1,74 @@ +package module + +import ( + "context" + "github.com/opencurve/curveadm/internal/errno" +) + +type ConnectConfig struct { + User string + Host string + SSHPort uint + HTTPPort uint + ForwardAgent bool // ForwardAgent > PrivateKeyPath > Password + BecomeMethod string + BecomeFlags string + BecomeUser string + PrivateKeyPath string + ConnectRetries int + ConnectTimeoutSec int + Protocol string +} + +func (c *ConnectConfig) GetSSHConfig() *SSHConfig { + return &SSHConfig{ + User: c.User, + Host: c.Host, + Port: c.SSHPort, + ForwardAgent: c.ForwardAgent, + BecomeMethod: c.BecomeMethod, + BecomeFlags: c.BecomeFlags, + BecomeUser: c.BecomeUser, + PrivateKeyPath: c.PrivateKeyPath, + ConnectRetries: c.ConnectRetries, + ConnectTimeoutSec: c.ConnectTimeoutSec, + } +} + +func (c *ConnectConfig) GetHTTPConfig() *HTTPConfig { + return &HTTPConfig{ + Host: c.Host, + Port: c.HTTPPort, + } +} + +type RemoteClient interface { + Protocol() string + WrapperCommand(command string, execInLocal bool) (wrapperCmd string) + RunCommand(ctx context.Context, command string) (out []byte, err error) + RemoteAddr() (addr string) + Upload(localPath string, remotePath string) (err error) + Download(remotePath string, localPath string) (err error) + Close() +} + +func NewRemoteClient(cfg *ConnectConfig) (client RemoteClient, err error) { + if cfg == nil { + return + } + + if cfg.Protocol == SSH_PROTOCOL { + client, err = NewSSHClient(*cfg.GetSSHConfig()) + if err != nil { + return nil, errno.ERR_SSH_CONNECT_FAILED.E(err) + } + return client, nil + } else if cfg.Protocol == HTTP_PROTOCOL { + client, err = NewHTTPClient(*cfg.GetHTTPConfig()) + if err != nil { + return nil, errno.ERR_HTTP_CONNECT_FAILED.E(err) + } + return + } + return +} diff --git a/pkg/module/shell.go b/pkg/module/shell.go index 9be3379dd..9c7114cc2 100644 --- a/pkg/module/shell.go +++ b/pkg/module/shell.go @@ -79,18 +79,18 @@ const ( // TODO(P1): support command pipe type Shell struct { - sshClient *SSHClient - options []string - tmpl *template.Template - data map[string]interface{} + remoteClient RemoteClient + options []string + tmpl *template.Template + data map[string]interface{} } -func NewShell(sshClient *SSHClient) *Shell { +func NewShell(remoteClient RemoteClient) *Shell { return &Shell{ - sshClient: sshClient, - options: []string{}, - tmpl: nil, - data: map[string]interface{}{}, + remoteClient: remoteClient, + options: []string{}, + tmpl: nil, + data: map[string]interface{}{}, } } @@ -111,7 +111,7 @@ func (s *Shell) String() (string, error) { func (s *Shell) Execute(options ExecOptions) (string, error) { s.data["options"] = strings.Join(s.options, " ") - return execCommand(s.sshClient, s.tmpl, s.data, options) + return execCommand(s.remoteClient, s.tmpl, s.data, options) } // text diff --git a/pkg/module/ssh.go b/pkg/module/ssh.go index 4e8abf889..990aab263 100644 --- a/pkg/module/ssh.go +++ b/pkg/module/ssh.go @@ -25,8 +25,11 @@ package module import ( + "context" "errors" + "fmt" "net" + "strings" "time" "github.com/melbahja/goph" @@ -34,6 +37,10 @@ import ( "golang.org/x/crypto/ssh" ) +const ( + SSH_PROTOCOL = "ssh" +) + type ( SSHConfig struct { User string @@ -151,3 +158,45 @@ connect: config: config, }, err } + +func (client *SSHClient) WrapperCommand(command string, execInLocal bool) string { + becomeMethod := client.Config().BecomeMethod + becomeFlags := client.Config().BecomeFlags + becomeUser := client.Config().BecomeUser + if len(becomeUser) > 0 && !execInLocal { + become := strings.Join([]string{becomeMethod, becomeFlags, becomeUser}, " ") + command = strings.Join([]string{become, command}, " ") + } + return command +} + +func (client *SSHClient) RunCommand(ctx context.Context, command string) (out []byte, err error) { + var cmd *goph.Cmd + cmd, err = client.Client().CommandContext(ctx, command) + if err == nil { + cmd.Env = []string{"LANG=en_US.UTF-8"} + out, err = cmd.CombinedOutput() + } + return +} + +func (client *SSHClient) RemoteAddr() (addr string) { + config := client.Config() + return fmt.Sprintf("%s@%s:%d", config.User, config.Host, config.Port) +} + +func (client *SSHClient) Upload(localPath string, remotePath string) (err error) { + return client.client.Upload(localPath, remotePath) +} + +func (client *SSHClient) Download(remotePath string, localPath string) (err error) { + return client.client.Download(remotePath, localPath) +} + +func (client *SSHClient) Close() { + client.client.Close() +} + +func (client *SSHClient) Protocol() string { + return SSH_PROTOCOL +} diff --git a/scripts/install.sh b/scripts/install.sh index 1a7b2e7d3..c25771f01 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -48,7 +48,7 @@ backup() { setup() { mkdir -p "${g_curveadm_home}"/{bin,data,module,logs,temp} - + mkdir -p "${g_curveadm_home}"/daemon/{logs,conf} # generate config file local confpath="${g_curveadm_home}/curveadm.cfg" if [ ! -f "${confpath}" ]; then @@ -65,6 +65,18 @@ timeout = 10 [database] url = "${g_db_path}" +__EOF__ + fi + + + # generate http service config file + local httpConfpath="${g_curveadm_home}/daemon/conf/pigeon.yaml" + if [ ! -f $httpConfpath ]; then + cat << __EOF__ > $httpConfpath +servers: + - name: curveadm + log_level: info + listen: :11000 __EOF__ fi }