From 5fb928234fa9e0a5462cf5f21d279e1c94a60b9f Mon Sep 17 00:00:00 2001 From: Wu22e Date: Sun, 30 Jul 2023 23:05:23 +0900 Subject: [PATCH 01/12] feat : add viper libraray & login & save context --- cmd/yorkie/commands.go | 17 +++-- cmd/yorkie/config/config.go | 4 ++ cmd/yorkie/login.go | 19 ++++-- go.mod | 31 ++++++--- go.sum | 129 ++++++++++++++++++++++++++++++------ 5 files changed, 161 insertions(+), 39 deletions(-) diff --git a/cmd/yorkie/commands.go b/cmd/yorkie/commands.go index ab682684f..a57025edf 100644 --- a/cmd/yorkie/commands.go +++ b/cmd/yorkie/commands.go @@ -19,10 +19,12 @@ package main import ( "os" + "path" "github.com/spf13/cobra" + "github.com/spf13/viper" - "github.com/yorkie-team/yorkie/cmd/yorkie/config" + "github.com/yorkie-team/yorkie/cmd/yorkie/context" "github.com/yorkie-team/yorkie/cmd/yorkie/document" "github.com/yorkie-team/yorkie/cmd/yorkie/project" ) @@ -46,8 +48,13 @@ func init() { rootCmd.SetErr(os.Stderr) rootCmd.AddCommand(project.SubCmd) rootCmd.AddCommand(document.SubCmd) - // TODO(chacha912): set rpcAddr from env using viper. - // https://github.com/spf13/cobra/blob/main/user_guide.md#bind-flags-with-config - rootCmd.PersistentFlags().StringVar(&config.RPCAddr, "rpc-addr", "localhost:11101", "Address of the rpc server") - rootCmd.PersistentFlags().BoolVar(&config.IsInsecure, "insecure", false, "Skip the TLS connection of the client") + rootCmd.AddCommand(context.SubCmd) + viper.SetConfigName("config") + viper.SetConfigType("json") + viper.AddConfigPath(path.Join(os.Getenv("HOME"), ".yorkie")) + + rootCmd.PersistentFlags().String("rpc-addr", "localhost:11101", "Address of the rpc server") + rootCmd.PersistentFlags().Bool("insecure", false, "Skip the TLS connection of the client") + viper.BindPFlag("rpcAddr", rootCmd.PersistentFlags().Lookup("rpc-addr")) + viper.BindPFlag("isInsecure", rootCmd.PersistentFlags().Lookup("insecure")) } diff --git a/cmd/yorkie/config/config.go b/cmd/yorkie/config/config.go index 29e3b9959..c616ea705 100644 --- a/cmd/yorkie/config/config.go +++ b/cmd/yorkie/config/config.go @@ -54,6 +54,10 @@ func configPath() (string, error) { type Config struct { // Auths is the map of the address and the token. Auths map[string]string `json:"auths"` + // RPCAddr is the address of the rpc server + RPCAddr string `json:"rpcAddr"` + // IsInsecure specifies whether to skip the TLS connection of the client + IsInsecure bool `json:"isInsecure"` } // New creates a new configuration. diff --git a/cmd/yorkie/login.go b/cmd/yorkie/login.go index 39c8a0ef1..08fd3db6e 100644 --- a/cmd/yorkie/login.go +++ b/cmd/yorkie/login.go @@ -20,6 +20,7 @@ import ( "context" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" "github.com/yorkie-team/yorkie/cmd/yorkie/config" @@ -34,8 +35,14 @@ func newLoginCmd() *cobra.Command { return &cobra.Command{ Use: "login", Short: "Log in to the Yorkie server", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { - cli, err := admin.Dial(config.RPCAddr, admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(viper.GetString("rpcAddr"), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } @@ -48,13 +55,17 @@ func newLoginCmd() *cobra.Command { if err != nil { return err } - conf, err := config.Load() if err != nil { return nil } - - conf.Auths[config.RPCAddr] = token + if conf.Auths == nil { + conf.Auths = make(map[string]string) + } + rpcAddr := viper.GetString("rpcAddr") + conf.Auths[rpcAddr] = token + conf.RPCAddr = rpcAddr + conf.IsInsecure = viper.GetBool("isInsecure") if err := config.Save(conf); err != nil { return err } diff --git a/go.mod b/go.mod index e238ecc15..af44b18ec 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-playground/validator/v10 v10.11.1 github.com/gogo/protobuf v1.3.2 github.com/golang-jwt/jwt v3.2.2+incompatible - github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/hashicorp/go-memdb v1.3.3 @@ -16,15 +16,16 @@ require ( github.com/prometheus/client_golang v1.13.0 github.com/rs/xid v1.4.0 github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.8.0 + github.com/spf13/viper v1.16.0 + github.com/stretchr/testify v1.8.3 github.com/undefinedlabs/go-mpatch v1.0.6 go.mongodb.org/mongo-driver v1.11.7 go.uber.org/zap v1.23.0 - golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b - golang.org/x/net v0.7.0 - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f - google.golang.org/grpc v1.53.0 - google.golang.org/protobuf v1.28.1 + golang.org/x/crypto v0.9.0 + golang.org/x/net v0.10.0 + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 + google.golang.org/grpc v1.55.0 + google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -32,31 +33,41 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/klauspost/compress v1.15.11 // indirect github.com/leodido/go-urn v1.2.1 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/montanaflynn/stats v0.6.6 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/rivo/uniseg v0.4.2 // indirect + github.com/spf13/afero v1.9.5 // indirect + github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.4.2 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.1 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f637bcbdc..55f662286 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,7 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= @@ -13,6 +14,9 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -30,6 +34,7 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -53,6 +58,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -61,7 +68,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= 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= @@ -113,8 +125,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -134,6 +147,7 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -141,9 +155,14 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= @@ -159,7 +178,10 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -181,23 +203,28 @@ github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= 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.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM= github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -209,12 +236,15 @@ github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -247,30 +277,43 @@ github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/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/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= +github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= +github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +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/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/undefinedlabs/go-mpatch v1.0.6 h1:h8q5ORH/GaOE1Se1DMhrOyljXZEhRcROO7agMqWXCOY= @@ -295,6 +338,7 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= @@ -313,10 +357,12 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b h1:huxqepDufQpLLIRXiVkTvnxrzJlpwmIWAObmcCcUFr0= -golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -339,6 +385,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -347,6 +394,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -376,17 +425,25 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -400,8 +457,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ 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.0.0-20220929204114-8fcdb60fdcc0 h1:cu5kTvlzcw1Q5S9f5ip1/cpiB4nXvw1XYzFPGgzLUOY= -golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -433,17 +490,24 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/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-20210603081109-ebe580a85c40/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-20210806184541-e5e7981a1069/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-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -451,10 +515,11 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -499,7 +564,14 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-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/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= @@ -520,12 +592,16 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -556,8 +632,15 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -570,8 +653,12 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -584,8 +671,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.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -593,6 +680,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 6fe0f6ef74db8b124b621407a127671ebf0e18cb Mon Sep 17 00:00:00 2001 From: Wu22e Date: Sun, 30 Jul 2023 23:08:22 +0900 Subject: [PATCH 02/12] add : context command --- cmd/yorkie/context/context.go | 30 ++++++++++++++++ cmd/yorkie/context/list.go | 62 ++++++++++++++++++++++++++++++++ cmd/yorkie/context/remove.go | 61 +++++++++++++++++++++++++++++++ cmd/yorkie/context/set.go | 67 +++++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 cmd/yorkie/context/context.go create mode 100644 cmd/yorkie/context/list.go create mode 100644 cmd/yorkie/context/remove.go create mode 100644 cmd/yorkie/context/set.go diff --git a/cmd/yorkie/context/context.go b/cmd/yorkie/context/context.go new file mode 100644 index 000000000..1577bcbfb --- /dev/null +++ b/cmd/yorkie/context/context.go @@ -0,0 +1,30 @@ +/* + * Copyright 2022 The Yorkie Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Package context provides the context(configuration) command. +package context + +import ( + "github.com/spf13/cobra" +) + +var ( + // SubCmd represents the document command + SubCmd = &cobra.Command{ + Use: "context", + Short: "Manage contexts", + } +) diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go new file mode 100644 index 000000000..c4fe1a73a --- /dev/null +++ b/cmd/yorkie/context/list.go @@ -0,0 +1,62 @@ +/* + * Copyright 2022 The Yorkie Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package context + +import ( + "fmt" + + "github.com/jedib0t/go-pretty/v6/table" + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/yorkie-team/yorkie/cmd/yorkie/config" +) + +func newListCommand() *cobra.Command { + return &cobra.Command{ + Use: "ls", + Short: "List all contexts from configuration", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + conf, err := config.Load() + if err != nil { + return err + } + + fmt.Println("Current Context:") + fmt.Printf(" rpcAddr: %s\n isInsecure: %v\n", viper.GetString("rpcAddr"), viper.GetBool("isInsecure")) + + fmt.Println("All Auth Contexts:") + tw := table.NewWriter() + tw.AppendHeader(table.Row{"RpcAddr", "Token"}) + for addr, auth := range conf.Auths { + tw.AppendRow(table.Row{addr, auth}) + } + fmt.Println(tw.Render()) + + return nil + }, + } +} + +func init() { + SubCmd.AddCommand(newListCommand()) +} diff --git a/cmd/yorkie/context/remove.go b/cmd/yorkie/context/remove.go new file mode 100644 index 000000000..60ecbdbcc --- /dev/null +++ b/cmd/yorkie/context/remove.go @@ -0,0 +1,61 @@ +/* + * Copyright 2022 The Yorkie Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package context + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/yorkie-team/yorkie/cmd/yorkie/config" +) + +func newRemoveCmd() *cobra.Command { + return &cobra.Command{ + Use: "remove [rpcAddr]", + Short: "Remove the context for the specified rpcAddr", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + conf, err := config.Load() + if err != nil { + return err + } + + rpcAddr := args[0] + + // Check if auth exists for the rpcAddr + if _, ok := conf.Auths[rpcAddr]; !ok { + return fmt.Errorf("no context exists for the rpcAddr: %s", rpcAddr) + } + + // Delete the context for the rpcAddr + delete(conf.Auths, rpcAddr) + + err = config.Save(conf) + if err != nil { + return err + } + + fmt.Printf("Context for rpcAddr: %s has been removed.\n", rpcAddr) + return nil + }, + } +} + +func init() { + SubCmd.AddCommand(newRemoveCmd()) +} diff --git a/cmd/yorkie/context/set.go b/cmd/yorkie/context/set.go new file mode 100644 index 000000000..516c37b86 --- /dev/null +++ b/cmd/yorkie/context/set.go @@ -0,0 +1,67 @@ +/* + * Copyright 2022 The Yorkie Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package context + +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/yorkie-team/yorkie/cmd/yorkie/config" +) + +func newSetContextCmd() *cobra.Command { + return &cobra.Command{ + Use: "set", + Short: "Set the current global flags as the context", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + conf, err := config.Load() + if err != nil { + return err + } + + rpcAddr := viper.GetString("rpcAddr") + conf.RPCAddr = rpcAddr + conf.IsInsecure = viper.GetBool("isInsecure") + + // check if auth exists for the rpcAddr + if _, ok := conf.Auths[rpcAddr]; !ok { + conf.Auths[rpcAddr] = "" + fmt.Println("A new RPC address has been set. Please log in again.") + } + + err = config.Save(conf) + if err != nil { + return err + } + + fmt.Println("Context has been updated.") + return nil + }, + } +} + +func init() { + SubCmd.AddCommand(newSetContextCmd()) +} From be7ac3b2e0e42b2784da1ce578ee5fc581aa9841 Mon Sep 17 00:00:00 2001 From: Wu22e Date: Sun, 30 Jul 2023 23:09:29 +0900 Subject: [PATCH 03/12] fix : update context variable using viper --- cmd/yorkie/document/list.go | 14 ++++++++++++-- cmd/yorkie/document/remove.go | 12 ++++++++++-- cmd/yorkie/history.go | 12 ++++++++++-- cmd/yorkie/logout.go | 19 +++++++++++++++---- cmd/yorkie/project/create.go | 12 ++++++++++-- cmd/yorkie/project/list.go | 12 ++++++++++-- cmd/yorkie/project/update.go | 12 ++++++++++-- 7 files changed, 77 insertions(+), 16 deletions(-) diff --git a/cmd/yorkie/document/list.go b/cmd/yorkie/document/list.go index 50dbf5c99..76cf94028 100644 --- a/cmd/yorkie/document/list.go +++ b/cmd/yorkie/document/list.go @@ -23,6 +23,7 @@ import ( "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" "github.com/yorkie-team/yorkie/cmd/yorkie/config" @@ -39,17 +40,26 @@ func newListCommand() *cobra.Command { return &cobra.Command{ Use: "ls [project name]", Short: "List all documents in the project", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("project is required") } projectName := args[0] - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) + if err != nil { return err } diff --git a/cmd/yorkie/document/remove.go b/cmd/yorkie/document/remove.go index 3b98cb614..7946cc826 100644 --- a/cmd/yorkie/document/remove.go +++ b/cmd/yorkie/document/remove.go @@ -21,6 +21,7 @@ import ( "errors" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" "github.com/yorkie-team/yorkie/cmd/yorkie/config" @@ -35,6 +36,12 @@ func newRemoveCommand() *cobra.Command { Use: "remove [project name] [document key]", Short: "Remove documents in the project", Example: "yorkie document remove sample-project sample-document [options]", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") @@ -42,11 +49,12 @@ func newRemoveCommand() *cobra.Command { projectName := args[0] documentKey := args[1] - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } diff --git a/cmd/yorkie/history.go b/cmd/yorkie/history.go index f54aec715..83ec30ea4 100644 --- a/cmd/yorkie/history.go +++ b/cmd/yorkie/history.go @@ -22,6 +22,7 @@ import ( "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" "github.com/yorkie-team/yorkie/cmd/yorkie/config" @@ -38,17 +39,24 @@ func newHistoryCmd() *cobra.Command { return &cobra.Command{ Use: "history [project name] [document key]", Short: "Show the history of a document", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") } - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } diff --git a/cmd/yorkie/logout.go b/cmd/yorkie/logout.go index 9e1f0b32f..3b638283c 100644 --- a/cmd/yorkie/logout.go +++ b/cmd/yorkie/logout.go @@ -21,6 +21,7 @@ import ( "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/cmd/yorkie/config" ) @@ -33,24 +34,34 @@ func newLogoutCmd() *cobra.Command { return &cobra.Command{ Use: "logout", Short: "Log out from the Yorkie server", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { return err } + rpcAddr := viper.GetString("rpcAddr") if flagForce { return config.Delete() } - if config.RPCAddr == "" { + if rpcAddr == "" { return errors.New("you must specify the server address to log out") } - if _, ok := conf.Auths[config.RPCAddr]; !ok { - return fmt.Errorf("you are not logged in to %s", config.RPCAddr) + authToken, ok := conf.Auths[rpcAddr] + if !ok || authToken == "" { + return fmt.Errorf("you are not logged in to %s", rpcAddr) } if len(conf.Auths) <= 1 { return config.Delete() } - delete(conf.Auths, config.RPCAddr) + delete(conf.Auths, rpcAddr) + conf.IsInsecure = false + conf.RPCAddr = "" return config.Save(conf) }, } diff --git a/cmd/yorkie/project/create.go b/cmd/yorkie/project/create.go index 2a81cedf9..81a08a0cd 100644 --- a/cmd/yorkie/project/create.go +++ b/cmd/yorkie/project/create.go @@ -23,6 +23,7 @@ import ( "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/status" @@ -35,17 +36,24 @@ func newCreateCommand() *cobra.Command { Use: "create [name]", Short: "Create a new project", Example: "yorkie project create sample-project", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required") } name := args[0] - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } diff --git a/cmd/yorkie/project/list.go b/cmd/yorkie/project/list.go index 6235a5d4f..2a0e64948 100644 --- a/cmd/yorkie/project/list.go +++ b/cmd/yorkie/project/list.go @@ -22,6 +22,7 @@ import ( "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/yorkie-team/yorkie/admin" "github.com/yorkie-team/yorkie/cmd/yorkie/config" @@ -32,13 +33,20 @@ func newListCommand() *cobra.Command { return &cobra.Command{ Use: "ls", Short: "List all projects", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } diff --git a/cmd/yorkie/project/update.go b/cmd/yorkie/project/update.go index f480ac2c2..c2175819c 100644 --- a/cmd/yorkie/project/update.go +++ b/cmd/yorkie/project/update.go @@ -23,6 +23,7 @@ import ( "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/status" @@ -42,6 +43,12 @@ func newUpdateCommand() *cobra.Command { Use: "update [name]", Short: "Update a project", Example: "yorkie project update name [options]", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := viper.ReadInConfig(); err != nil { + return err + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required") @@ -49,12 +56,13 @@ func newUpdateCommand() *cobra.Command { name := args[0] - token, err := config.LoadToken(config.RPCAddr) + rpcAddr := viper.GetString("rpcAddr") + token, err := config.LoadToken(rpcAddr) if err != nil { return err } - cli, err := admin.Dial(config.RPCAddr, admin.WithToken(token), admin.WithInsecure(config.IsInsecure)) + cli, err := admin.Dial(rpcAddr, admin.WithToken(token), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { return err } From dbee189c49e8e0bbafeab67e94c0b40e8ab86d14 Mon Sep 17 00:00:00 2001 From: Wu22e Date: Mon, 31 Jul 2023 02:54:58 +0900 Subject: [PATCH 04/12] fix : add err check --- cmd/yorkie/commands.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/yorkie/commands.go b/cmd/yorkie/commands.go index a57025edf..62e51c6dc 100644 --- a/cmd/yorkie/commands.go +++ b/cmd/yorkie/commands.go @@ -18,6 +18,7 @@ package main import ( + "log" "os" "path" @@ -55,6 +56,10 @@ func init() { rootCmd.PersistentFlags().String("rpc-addr", "localhost:11101", "Address of the rpc server") rootCmd.PersistentFlags().Bool("insecure", false, "Skip the TLS connection of the client") - viper.BindPFlag("rpcAddr", rootCmd.PersistentFlags().Lookup("rpc-addr")) - viper.BindPFlag("isInsecure", rootCmd.PersistentFlags().Lookup("insecure")) + if err := viper.BindPFlag("rpcAddr", rootCmd.PersistentFlags().Lookup("rpc-addr")); err != nil { + log.Fatalf("Failed to bind rpcAddr flag: %v", err) + } + if err := viper.BindPFlag("isInsecure", rootCmd.PersistentFlags().Lookup("insecure")); err != nil { + log.Fatalf("Failed to bind isInsecure flag: %v", err) + } } From 51467ade5939bd307741b7c64320b31df2411e11 Mon Sep 17 00:00:00 2001 From: Wu22e Date: Mon, 31 Jul 2023 03:00:07 +0900 Subject: [PATCH 05/12] fix : add error wrapping --- cmd/yorkie/context/list.go | 2 +- cmd/yorkie/context/set.go | 2 +- cmd/yorkie/document/list.go | 3 ++- cmd/yorkie/document/remove.go | 3 ++- cmd/yorkie/history.go | 3 ++- cmd/yorkie/login.go | 3 ++- cmd/yorkie/logout.go | 2 +- cmd/yorkie/project/create.go | 2 +- cmd/yorkie/project/list.go | 3 ++- cmd/yorkie/project/update.go | 2 +- 10 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go index c4fe1a73a..1af633701 100644 --- a/cmd/yorkie/context/list.go +++ b/cmd/yorkie/context/list.go @@ -31,7 +31,7 @@ func newListCommand() *cobra.Command { Short: "List all contexts from configuration", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/context/set.go b/cmd/yorkie/context/set.go index 516c37b86..77b286484 100644 --- a/cmd/yorkie/context/set.go +++ b/cmd/yorkie/context/set.go @@ -31,7 +31,7 @@ func newSetContextCmd() *cobra.Command { Short: "Set the current global flags as the context", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/document/list.go b/cmd/yorkie/document/list.go index 76cf94028..6415e3afb 100644 --- a/cmd/yorkie/document/list.go +++ b/cmd/yorkie/document/list.go @@ -19,6 +19,7 @@ package document import ( "context" "errors" + "fmt" "time" "github.com/jedib0t/go-pretty/v6/table" @@ -42,7 +43,7 @@ func newListCommand() *cobra.Command { Short: "List all documents in the project", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/document/remove.go b/cmd/yorkie/document/remove.go index 7946cc826..1d2ace454 100644 --- a/cmd/yorkie/document/remove.go +++ b/cmd/yorkie/document/remove.go @@ -19,6 +19,7 @@ package document import ( "context" "errors" + "fmt" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -38,7 +39,7 @@ func newRemoveCommand() *cobra.Command { Example: "yorkie document remove sample-project sample-document [options]", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/history.go b/cmd/yorkie/history.go index 83ec30ea4..8d7b7d42c 100644 --- a/cmd/yorkie/history.go +++ b/cmd/yorkie/history.go @@ -19,6 +19,7 @@ package main import ( "context" "errors" + "fmt" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" @@ -41,7 +42,7 @@ func newHistoryCmd() *cobra.Command { Short: "Show the history of a document", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/login.go b/cmd/yorkie/login.go index 08fd3db6e..7233ad9ef 100644 --- a/cmd/yorkie/login.go +++ b/cmd/yorkie/login.go @@ -18,6 +18,7 @@ package main import ( "context" + "fmt" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -37,7 +38,7 @@ func newLoginCmd() *cobra.Command { Short: "Log in to the Yorkie server", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/logout.go b/cmd/yorkie/logout.go index 3b638283c..cf7135638 100644 --- a/cmd/yorkie/logout.go +++ b/cmd/yorkie/logout.go @@ -36,7 +36,7 @@ func newLogoutCmd() *cobra.Command { Short: "Log out from the Yorkie server", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/project/create.go b/cmd/yorkie/project/create.go index 81a08a0cd..f761ca725 100644 --- a/cmd/yorkie/project/create.go +++ b/cmd/yorkie/project/create.go @@ -38,7 +38,7 @@ func newCreateCommand() *cobra.Command { Example: "yorkie project create sample-project", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/project/list.go b/cmd/yorkie/project/list.go index 2a0e64948..bdbf766e6 100644 --- a/cmd/yorkie/project/list.go +++ b/cmd/yorkie/project/list.go @@ -18,6 +18,7 @@ package project import ( "context" + "fmt" "time" "github.com/jedib0t/go-pretty/v6/table" @@ -35,7 +36,7 @@ func newListCommand() *cobra.Command { Short: "List all projects", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, diff --git a/cmd/yorkie/project/update.go b/cmd/yorkie/project/update.go index c2175819c..64c926de6 100644 --- a/cmd/yorkie/project/update.go +++ b/cmd/yorkie/project/update.go @@ -45,7 +45,7 @@ func newUpdateCommand() *cobra.Command { Example: "yorkie project update name [options]", PreRunE: func(cmd *cobra.Command, args []string) error { if err := viper.ReadInConfig(); err != nil { - return err + return fmt.Errorf("failed to read in config: %w", err) } return nil }, From 4e36603a4cb934debf92f07b27a048eb3130de9e Mon Sep 17 00:00:00 2001 From: Wu22e Date: Mon, 31 Jul 2023 03:31:09 +0900 Subject: [PATCH 06/12] fix : goimports --- cmd/yorkie/context/list.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go index 1af633701..e9890e41b 100644 --- a/cmd/yorkie/context/list.go +++ b/cmd/yorkie/context/list.go @@ -22,6 +22,7 @@ import ( "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/yorkie-team/yorkie/cmd/yorkie/config" ) From aff8dad745c9624fb5b61dc22e68b42f169a988e Mon Sep 17 00:00:00 2001 From: Wu22e Date: Mon, 4 Sep 2023 22:24:33 +0900 Subject: [PATCH 07/12] refactor : remove duplicate preRunE function --- cmd/yorkie/config/config.go | 28 ++++++++++++++++++++++++++++ cmd/yorkie/context/list.go | 11 +++-------- cmd/yorkie/context/remove.go | 7 ++++--- cmd/yorkie/context/set.go | 11 +++-------- cmd/yorkie/document/list.go | 12 +++--------- cmd/yorkie/document/remove.go | 8 +------- cmd/yorkie/history.go | 12 +++--------- cmd/yorkie/login.go | 14 ++++---------- cmd/yorkie/logout.go | 11 +++-------- cmd/yorkie/project/create.go | 7 +------ cmd/yorkie/project/list.go | 12 +++--------- cmd/yorkie/project/update.go | 7 +------ 12 files changed, 57 insertions(+), 83 deletions(-) diff --git a/cmd/yorkie/config/config.go b/cmd/yorkie/config/config.go index c616ea705..999b1cb90 100644 --- a/cmd/yorkie/config/config.go +++ b/cmd/yorkie/config/config.go @@ -23,6 +23,9 @@ import ( "os" "path" "path/filepath" + + "github.com/spf13/cobra" + "github.com/spf13/viper" ) var ( @@ -141,3 +144,28 @@ func Delete() error { return nil } + +func ReadConfig(cmd *cobra.Command, args []string) error { + configPathValue, err := configPath() + if err != nil { + fmt.Fprintln(os.Stderr, "get config path: %w", err) + os.Exit(1) + } + + file, err := os.Open(filepath.Clean(configPathValue)) + if err != nil { + if os.IsNotExist(err) { + New() + return nil + } + + return fmt.Errorf("open config file: %w", err) + } + defer func() { + _ = file.Close() + }() + if err := viper.ReadInConfig(); err != nil { + return fmt.Errorf("failed to read in config: %w", err) + } + return nil +} diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go index e9890e41b..33fc93062 100644 --- a/cmd/yorkie/context/list.go +++ b/cmd/yorkie/context/list.go @@ -28,14 +28,9 @@ import ( func newListCommand() *cobra.Command { return &cobra.Command{ - Use: "ls", - Short: "List all contexts from configuration", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "ls", + Short: "List all contexts from configuration", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/context/remove.go b/cmd/yorkie/context/remove.go index 60ecbdbcc..83d3b94f9 100644 --- a/cmd/yorkie/context/remove.go +++ b/cmd/yorkie/context/remove.go @@ -26,9 +26,10 @@ import ( func newRemoveCmd() *cobra.Command { return &cobra.Command{ - Use: "remove [rpcAddr]", - Short: "Remove the context for the specified rpcAddr", - Args: cobra.ExactArgs(1), + Use: "remove [rpcAddr]", + Short: "Remove the context for the specified rpcAddr", + Args: cobra.ExactArgs(1), + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/context/set.go b/cmd/yorkie/context/set.go index 77b286484..13cc4715a 100644 --- a/cmd/yorkie/context/set.go +++ b/cmd/yorkie/context/set.go @@ -27,14 +27,9 @@ import ( func newSetContextCmd() *cobra.Command { return &cobra.Command{ - Use: "set", - Short: "Set the current global flags as the context", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "set", + Short: "Set the current global flags as the context", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/document/list.go b/cmd/yorkie/document/list.go index 6415e3afb..ab45ced7d 100644 --- a/cmd/yorkie/document/list.go +++ b/cmd/yorkie/document/list.go @@ -19,7 +19,6 @@ package document import ( "context" "errors" - "fmt" "time" "github.com/jedib0t/go-pretty/v6/table" @@ -39,14 +38,9 @@ var ( func newListCommand() *cobra.Command { return &cobra.Command{ - Use: "ls [project name]", - Short: "List all documents in the project", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "ls [project name]", + Short: "List all documents in the project", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("project is required") diff --git a/cmd/yorkie/document/remove.go b/cmd/yorkie/document/remove.go index 1d2ace454..7c1b96168 100644 --- a/cmd/yorkie/document/remove.go +++ b/cmd/yorkie/document/remove.go @@ -19,7 +19,6 @@ package document import ( "context" "errors" - "fmt" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -37,12 +36,7 @@ func newRemoveCommand() *cobra.Command { Use: "remove [project name] [document key]", Short: "Remove documents in the project", Example: "yorkie document remove sample-project sample-document [options]", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") diff --git a/cmd/yorkie/history.go b/cmd/yorkie/history.go index 8d7b7d42c..4d8b7264f 100644 --- a/cmd/yorkie/history.go +++ b/cmd/yorkie/history.go @@ -19,7 +19,6 @@ package main import ( "context" "errors" - "fmt" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" @@ -38,14 +37,9 @@ var ( func newHistoryCmd() *cobra.Command { return &cobra.Command{ - Use: "history [project name] [document key]", - Short: "Show the history of a document", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "history [project name] [document key]", + Short: "Show the history of a document", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") diff --git a/cmd/yorkie/login.go b/cmd/yorkie/login.go index 7233ad9ef..5a5ea96d8 100644 --- a/cmd/yorkie/login.go +++ b/cmd/yorkie/login.go @@ -18,7 +18,6 @@ package main import ( "context" - "fmt" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -34,14 +33,9 @@ var ( func newLoginCmd() *cobra.Command { return &cobra.Command{ - Use: "login", - Short: "Log in to the Yorkie server", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "login", + Short: "Log in to the Yorkie server", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { cli, err := admin.Dial(viper.GetString("rpcAddr"), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { @@ -58,7 +52,7 @@ func newLoginCmd() *cobra.Command { } conf, err := config.Load() if err != nil { - return nil + return err } if conf.Auths == nil { conf.Auths = make(map[string]string) diff --git a/cmd/yorkie/logout.go b/cmd/yorkie/logout.go index cf7135638..e562eb939 100644 --- a/cmd/yorkie/logout.go +++ b/cmd/yorkie/logout.go @@ -32,14 +32,9 @@ var ( func newLogoutCmd() *cobra.Command { return &cobra.Command{ - Use: "logout", - Short: "Log out from the Yorkie server", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "logout", + Short: "Log out from the Yorkie server", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/project/create.go b/cmd/yorkie/project/create.go index f761ca725..d0761f4a1 100644 --- a/cmd/yorkie/project/create.go +++ b/cmd/yorkie/project/create.go @@ -36,12 +36,7 @@ func newCreateCommand() *cobra.Command { Use: "create [name]", Short: "Create a new project", Example: "yorkie project create sample-project", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required") diff --git a/cmd/yorkie/project/list.go b/cmd/yorkie/project/list.go index bdbf766e6..b6bc1e0cf 100644 --- a/cmd/yorkie/project/list.go +++ b/cmd/yorkie/project/list.go @@ -18,7 +18,6 @@ package project import ( "context" - "fmt" "time" "github.com/jedib0t/go-pretty/v6/table" @@ -32,14 +31,9 @@ import ( func newListCommand() *cobra.Command { return &cobra.Command{ - Use: "ls", - Short: "List all projects", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + Use: "ls", + Short: "List all projects", + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { rpcAddr := viper.GetString("rpcAddr") token, err := config.LoadToken(rpcAddr) diff --git a/cmd/yorkie/project/update.go b/cmd/yorkie/project/update.go index 64c926de6..adb93365d 100644 --- a/cmd/yorkie/project/update.go +++ b/cmd/yorkie/project/update.go @@ -43,12 +43,7 @@ func newUpdateCommand() *cobra.Command { Use: "update [name]", Short: "Update a project", Example: "yorkie project update name [options]", - PreRunE: func(cmd *cobra.Command, args []string) error { - if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("failed to read in config: %w", err) - } - return nil - }, + PreRunE: config.ReadConfig, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required") From d9334c136c457c26aef35bf891f0d21883a495f3 Mon Sep 17 00:00:00 2001 From: Wu22e Date: Tue, 5 Sep 2023 23:40:00 +0900 Subject: [PATCH 08/12] fix : add comment for exported function --- cmd/yorkie/config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/yorkie/config/config.go b/cmd/yorkie/config/config.go index 999b1cb90..ca022d335 100644 --- a/cmd/yorkie/config/config.go +++ b/cmd/yorkie/config/config.go @@ -145,6 +145,7 @@ func Delete() error { return nil } +// Read configuration file for viper before runnning command func ReadConfig(cmd *cobra.Command, args []string) error { configPathValue, err := configPath() if err != nil { From ee803ae3c800f6283b0f5d95c22ca55686e1b75b Mon Sep 17 00:00:00 2001 From: Wu22e Date: Tue, 5 Sep 2023 23:51:59 +0900 Subject: [PATCH 09/12] fix : exported comment with function full name --- cmd/yorkie/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/yorkie/config/config.go b/cmd/yorkie/config/config.go index ca022d335..de4d04363 100644 --- a/cmd/yorkie/config/config.go +++ b/cmd/yorkie/config/config.go @@ -145,7 +145,7 @@ func Delete() error { return nil } -// Read configuration file for viper before runnning command +// ReadConfig read configuration file for viper before runnning command func ReadConfig(cmd *cobra.Command, args []string) error { configPathValue, err := configPath() if err != nil { From f8256dea1d14a2b53736ea64dd6d4647714980d0 Mon Sep 17 00:00:00 2001 From: Wu22e Date: Wed, 6 Sep 2023 00:55:39 +0900 Subject: [PATCH 10/12] fix : downgrading viper & grpc dependency --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index af44b18ec..94430d17c 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/prometheus/client_golang v1.13.0 github.com/rs/xid v1.4.0 github.com/spf13/cobra v1.5.0 - github.com/spf13/viper v1.16.0 + github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.3 github.com/undefinedlabs/go-mpatch v1.0.6 go.mongodb.org/mongo-driver v1.11.7 @@ -24,7 +24,7 @@ require ( golang.org/x/crypto v0.9.0 golang.org/x/net v0.10.0 google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 - google.golang.org/grpc v1.55.0 + google.golang.org/grpc v1.54.0 google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 55f662286..b491b87d8 100644 --- a/go.sum +++ b/go.sum @@ -295,8 +295,8 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= -github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= +github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= +github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -657,8 +657,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From fbdbf2ac65d6b6ace3bb329da92fe8326824fb3b Mon Sep 17 00:00:00 2001 From: Wu22e Date: Sat, 9 Sep 2023 14:41:41 +0900 Subject: [PATCH 11/12] fix : change copyright text 2022 to 2023 --- cmd/yorkie/context/context.go | 2 +- cmd/yorkie/context/list.go | 2 +- cmd/yorkie/context/remove.go | 2 +- cmd/yorkie/context/set.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/yorkie/context/context.go b/cmd/yorkie/context/context.go index 1577bcbfb..10e43b21f 100644 --- a/cmd/yorkie/context/context.go +++ b/cmd/yorkie/context/context.go @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Yorkie Authors. All rights reserved. + * Copyright 2023 The Yorkie Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go index 33fc93062..dcd74ec04 100644 --- a/cmd/yorkie/context/list.go +++ b/cmd/yorkie/context/list.go @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Yorkie Authors. All rights reserved. + * Copyright 2023 The Yorkie Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmd/yorkie/context/remove.go b/cmd/yorkie/context/remove.go index 83d3b94f9..beb584a24 100644 --- a/cmd/yorkie/context/remove.go +++ b/cmd/yorkie/context/remove.go @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Yorkie Authors. All rights reserved. + * Copyright 2023 The Yorkie Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmd/yorkie/context/set.go b/cmd/yorkie/context/set.go index 13cc4715a..7f09f2c70 100644 --- a/cmd/yorkie/context/set.go +++ b/cmd/yorkie/context/set.go @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Yorkie Authors. All rights reserved. + * Copyright 2023 The Yorkie Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 2dea9fd95230a792c0e4fbdb2bce4af4248ce9df Mon Sep 17 00:00:00 2001 From: Wu22e Date: Sat, 16 Sep 2023 17:26:01 +0900 Subject: [PATCH 12/12] fix : change ReadConfig name to Preload & fix logic --- cmd/yorkie/config/config.go | 20 +++++++++----------- cmd/yorkie/context/list.go | 2 +- cmd/yorkie/context/remove.go | 2 +- cmd/yorkie/context/set.go | 2 +- cmd/yorkie/document/list.go | 2 +- cmd/yorkie/document/remove.go | 2 +- cmd/yorkie/history.go | 2 +- cmd/yorkie/login.go | 2 +- cmd/yorkie/logout.go | 2 +- cmd/yorkie/project/create.go | 2 +- cmd/yorkie/project/list.go | 2 +- cmd/yorkie/project/update.go | 2 +- 12 files changed, 20 insertions(+), 22 deletions(-) diff --git a/cmd/yorkie/config/config.go b/cmd/yorkie/config/config.go index de4d04363..64d18dab0 100644 --- a/cmd/yorkie/config/config.go +++ b/cmd/yorkie/config/config.go @@ -145,26 +145,24 @@ func Delete() error { return nil } -// ReadConfig read configuration file for viper before runnning command -func ReadConfig(cmd *cobra.Command, args []string) error { +// Preload read configuration file for viper before running command +func Preload(cmd *cobra.Command, args []string) error { configPathValue, err := configPath() if err != nil { fmt.Fprintln(os.Stderr, "get config path: %w", err) os.Exit(1) } - file, err := os.Open(filepath.Clean(configPathValue)) - if err != nil { + if _, err := os.Stat(filepath.Clean(configPathValue)); err != nil { if os.IsNotExist(err) { - New() - return nil + if saveErr := Save(New()); saveErr != nil { + return fmt.Errorf("save default config: %w", saveErr) + } + } else { + return fmt.Errorf("check config file: %w", err) } - - return fmt.Errorf("open config file: %w", err) } - defer func() { - _ = file.Close() - }() + if err := viper.ReadInConfig(); err != nil { return fmt.Errorf("failed to read in config: %w", err) } diff --git a/cmd/yorkie/context/list.go b/cmd/yorkie/context/list.go index dcd74ec04..228685b8d 100644 --- a/cmd/yorkie/context/list.go +++ b/cmd/yorkie/context/list.go @@ -30,7 +30,7 @@ func newListCommand() *cobra.Command { return &cobra.Command{ Use: "ls", Short: "List all contexts from configuration", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/context/remove.go b/cmd/yorkie/context/remove.go index beb584a24..35e26157f 100644 --- a/cmd/yorkie/context/remove.go +++ b/cmd/yorkie/context/remove.go @@ -29,7 +29,7 @@ func newRemoveCmd() *cobra.Command { Use: "remove [rpcAddr]", Short: "Remove the context for the specified rpcAddr", Args: cobra.ExactArgs(1), - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/context/set.go b/cmd/yorkie/context/set.go index 7f09f2c70..dc9f726fe 100644 --- a/cmd/yorkie/context/set.go +++ b/cmd/yorkie/context/set.go @@ -29,7 +29,7 @@ func newSetContextCmd() *cobra.Command { return &cobra.Command{ Use: "set", Short: "Set the current global flags as the context", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/document/list.go b/cmd/yorkie/document/list.go index ab45ced7d..7c42f78e7 100644 --- a/cmd/yorkie/document/list.go +++ b/cmd/yorkie/document/list.go @@ -40,7 +40,7 @@ func newListCommand() *cobra.Command { return &cobra.Command{ Use: "ls [project name]", Short: "List all documents in the project", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("project is required") diff --git a/cmd/yorkie/document/remove.go b/cmd/yorkie/document/remove.go index 7c1b96168..49ef5100e 100644 --- a/cmd/yorkie/document/remove.go +++ b/cmd/yorkie/document/remove.go @@ -36,7 +36,7 @@ func newRemoveCommand() *cobra.Command { Use: "remove [project name] [document key]", Short: "Remove documents in the project", Example: "yorkie document remove sample-project sample-document [options]", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") diff --git a/cmd/yorkie/history.go b/cmd/yorkie/history.go index 4d8b7264f..56eda5feb 100644 --- a/cmd/yorkie/history.go +++ b/cmd/yorkie/history.go @@ -39,7 +39,7 @@ func newHistoryCmd() *cobra.Command { return &cobra.Command{ Use: "history [project name] [document key]", Short: "Show the history of a document", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 2 { return errors.New("project name and document key are required") diff --git a/cmd/yorkie/login.go b/cmd/yorkie/login.go index 5a5ea96d8..08444fffa 100644 --- a/cmd/yorkie/login.go +++ b/cmd/yorkie/login.go @@ -35,7 +35,7 @@ func newLoginCmd() *cobra.Command { return &cobra.Command{ Use: "login", Short: "Log in to the Yorkie server", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { cli, err := admin.Dial(viper.GetString("rpcAddr"), admin.WithInsecure(viper.GetBool("isInsecure"))) if err != nil { diff --git a/cmd/yorkie/logout.go b/cmd/yorkie/logout.go index e562eb939..4041ca597 100644 --- a/cmd/yorkie/logout.go +++ b/cmd/yorkie/logout.go @@ -34,7 +34,7 @@ func newLogoutCmd() *cobra.Command { return &cobra.Command{ Use: "logout", Short: "Log out from the Yorkie server", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { conf, err := config.Load() if err != nil { diff --git a/cmd/yorkie/project/create.go b/cmd/yorkie/project/create.go index d0761f4a1..983025e6b 100644 --- a/cmd/yorkie/project/create.go +++ b/cmd/yorkie/project/create.go @@ -36,7 +36,7 @@ func newCreateCommand() *cobra.Command { Use: "create [name]", Short: "Create a new project", Example: "yorkie project create sample-project", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required") diff --git a/cmd/yorkie/project/list.go b/cmd/yorkie/project/list.go index b6bc1e0cf..a3c29cc93 100644 --- a/cmd/yorkie/project/list.go +++ b/cmd/yorkie/project/list.go @@ -33,7 +33,7 @@ func newListCommand() *cobra.Command { return &cobra.Command{ Use: "ls", Short: "List all projects", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { rpcAddr := viper.GetString("rpcAddr") token, err := config.LoadToken(rpcAddr) diff --git a/cmd/yorkie/project/update.go b/cmd/yorkie/project/update.go index adb93365d..16d71a96e 100644 --- a/cmd/yorkie/project/update.go +++ b/cmd/yorkie/project/update.go @@ -43,7 +43,7 @@ func newUpdateCommand() *cobra.Command { Use: "update [name]", Short: "Update a project", Example: "yorkie project update name [options]", - PreRunE: config.ReadConfig, + PreRunE: config.Preload, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("name is required")