diff --git a/.golangci.yml b/.golangci.yml index 257373b..854636d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,11 +1,12 @@ run: - go: '1.19' - deadline: 210s + go: '1.23' timeout: 10m - skip-dirs: + +issues: + exclude-dirs: - mocks - '.*_mock' - skip-files: + exclude-files: - '.*_mock.go' - ".*\\.pb\\.go$" diff --git a/Makefile b/Makefile index d9b1d48..4fbca0a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ NAME = stream-cli -GOLANGCI_VERSION = 1.55.2 +GOLANGCI_VERSION = 1.62.2 GOLANGCI = .bin/golangci/$(GOLANGCI_VERSION)/golangci-lint $(GOLANGCI): @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(dir $(GOLANGCI)) v$(GOLANGCI_VERSION) diff --git a/go.mod b/go.mod index 1677c79..db867e3 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/GetStream/stream-cli -go 1.22 +go 1.23 require ( github.com/AlecAivazis/survey/v2 v2.3.4 - github.com/GetStream/stream-chat-go/v5 v5.8.1 + github.com/GetStream/stream-chat-go/v8 v8.3.0 github.com/MakeNowJust/heredoc v1.0.0 github.com/cheynewallace/tabby v1.1.1 github.com/gizak/termui/v3 v3.1.0 @@ -18,7 +18,7 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect - github.com/golang-jwt/jwt/v4 v4.4.1 // indirect + github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect diff --git a/go.sum b/go.sum index f11ddd2..17c04e8 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/AlecAivazis/survey/v2 v2.3.4 h1:pchTU9rsLUSvWEl2Aq9Pv3k0IE2fkqtGxazsk github.com/AlecAivazis/survey/v2 v2.3.4/go.mod h1:hrV6Y/kQCLhIZXGcriDCUBtB3wnN7156gMXJ3+b23xM= 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= -github.com/GetStream/stream-chat-go/v5 v5.8.1 h1:nO3pfa4p4o6KEZOAXaaII3bhdrMrfT2zs6VduchuJws= -github.com/GetStream/stream-chat-go/v5 v5.8.1/go.mod h1:ET7NyUYplNy8+tyliin6Q3kKwbd/+FHQWMAW6zucisY= +github.com/GetStream/stream-chat-go/v8 v8.3.0 h1:mFtQZ0PkcCXMPjCDlnZcex3roOvE+UOaxBcNdq3o62s= +github.com/GetStream/stream-chat-go/v8 v8.3.0/go.mod h1:frj3A1yv9mjyWlGNwaZKnXcX9JYYTPWSDqzyOFeHPac= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= @@ -79,9 +79,8 @@ github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmy github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= -github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= -github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/pkg/cmd/chat/app/app.go b/pkg/cmd/chat/app/app.go index ff3e50b..6876bb4 100644 --- a/pkg/cmd/chat/app/app.go +++ b/pkg/cmd/chat/app/app.go @@ -4,7 +4,7 @@ import ( "encoding/json" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -46,7 +46,7 @@ func getCmd() *cobra.Command { return err } - r, err := c.GetAppConfig(cmd.Context()) + r, err := c.GetAppSettings(cmd.Context()) if err != nil { return err } diff --git a/pkg/cmd/chat/channel/channel.go b/pkg/cmd/chat/channel/channel.go index 3887ad0..8140843 100644 --- a/pkg/cmd/chat/channel/channel.go +++ b/pkg/cmd/chat/channel/channel.go @@ -5,7 +5,7 @@ import ( "errors" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -551,7 +551,7 @@ func hideCmd() *cobra.Command { return err } - cmd.Printf("Successfully hid channel for " + userID + "\n") + cmd.Printf("Successfully hid channel for %s\n", userID) return nil }, } diff --git a/pkg/cmd/chat/channel/channel_test.go b/pkg/cmd/chat/channel/channel_test.go index fd300a7..34b1aca 100644 --- a/pkg/cmd/chat/channel/channel_test.go +++ b/pkg/cmd/chat/channel/channel_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/stretchr/testify/require" "github.com/GetStream/stream-cli/test" diff --git a/pkg/cmd/chat/channeltype/channeltype.go b/pkg/cmd/chat/channeltype/channeltype.go index 4be3561..4650233 100644 --- a/pkg/cmd/chat/channeltype/channeltype.go +++ b/pkg/cmd/chat/channeltype/channeltype.go @@ -3,7 +3,7 @@ package channeltype import ( "encoding/json" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" diff --git a/pkg/cmd/chat/device/device.go b/pkg/cmd/chat/device/device.go index 09ed6db..267e70d 100644 --- a/pkg/cmd/chat/device/device.go +++ b/pkg/cmd/chat/device/device.go @@ -1,7 +1,7 @@ package device import ( - stream_chat "github.com/GetStream/stream-chat-go/v5" + stream_chat "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" diff --git a/pkg/cmd/chat/imports/imports.go b/pkg/cmd/chat/imports/imports.go index d8910b3..b971521 100644 --- a/pkg/cmd/chat/imports/imports.go +++ b/pkg/cmd/chat/imports/imports.go @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -76,6 +76,12 @@ func uploadCmd() *cobra.Command { mode = stream.InsertMode } + var opts []stream.CreateImportOption + if cmd.Flags().Changed("merge-custom") { + mergeCustom, _ := cmd.Flags().GetBool("merge-custom") + opts = append(opts, stream.WithMergeCustom(mergeCustom)) + } + createImportURLResp, err := c.CreateImportURL(cmd.Context(), filepath.Base(filename)) if err != nil { return err @@ -84,7 +90,7 @@ func uploadCmd() *cobra.Command { if err := uploadToS3(cmd.Context(), filename, createImportURLResp.UploadURL); err != nil { return err } - createImportResp, err := c.CreateImport(cmd.Context(), createImportURLResp.Path, mode) + createImportResp, err := c.CreateImport(cmd.Context(), createImportURLResp.Path, mode, opts...) if err != nil { return err } @@ -94,7 +100,8 @@ func uploadCmd() *cobra.Command { } fl := cmd.Flags() - fl.StringP("mode", "m", "upsert", "[optional] Import mode. Canbe upsert or insert") + fl.StringP("mode", "m", "upsert", "[optional] Import mode. Can be upsert or insert") + fl.Bool("merge-custom", false, "[optional] Merge custom data during import") fl.StringP("output-format", "o", "json", "[optional] Output format. Can be json or tree") fl.Bool("lighter-validation-id", false, "[optional] allows to pass ! in channel ID") diff --git a/pkg/cmd/chat/imports/imports_test.go b/pkg/cmd/chat/imports/imports_test.go index 14f6335..c654571 100644 --- a/pkg/cmd/chat/imports/imports_test.go +++ b/pkg/cmd/chat/imports/imports_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - stream_chat "github.com/GetStream/stream-chat-go/v5" + stream_chat "github.com/GetStream/stream-chat-go/v8" "github.com/stretchr/testify/require" "github.com/GetStream/stream-cli/test" diff --git a/pkg/cmd/chat/message/message.go b/pkg/cmd/chat/message/message.go index e509431..b4b63ba 100644 --- a/pkg/cmd/chat/message/message.go +++ b/pkg/cmd/chat/message/message.go @@ -3,7 +3,7 @@ package message import ( "strings" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" diff --git a/pkg/cmd/chat/push/push.go b/pkg/cmd/chat/push/push.go index 1fea575..e5494fa 100644 --- a/pkg/cmd/chat/push/push.go +++ b/pkg/cmd/chat/push/push.go @@ -3,7 +3,7 @@ package push import ( "encoding/json" - stream_chat "github.com/GetStream/stream-chat-go/v5" + stream_chat "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" diff --git a/pkg/cmd/chat/reaction/reaction.go b/pkg/cmd/chat/reaction/reaction.go index b53f3d5..7b6d474 100644 --- a/pkg/cmd/chat/reaction/reaction.go +++ b/pkg/cmd/chat/reaction/reaction.go @@ -1,7 +1,7 @@ package reaction import ( - stream_chat "github.com/GetStream/stream-chat-go/v5" + stream_chat "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" diff --git a/pkg/cmd/chat/user/user.go b/pkg/cmd/chat/user/user.go index f0d8d1d..3edc9d5 100644 --- a/pkg/cmd/chat/user/user.go +++ b/pkg/cmd/chat/user/user.go @@ -5,7 +5,7 @@ import ( "errors" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -359,9 +359,11 @@ func queryCmd() *cobra.Command { return err } - q := &stream.QueryOption{ - Filter: m, - Limit: limit, + q := &stream.QueryUsersOptions{ + QueryOption: stream.QueryOption{ + Filter: m, + Limit: limit, + }, } resp, err := c.QueryUsers(cmd.Context(), q) if err != nil { diff --git a/pkg/cmd/chat/utils/async.go b/pkg/cmd/chat/utils/async.go index 0b89c62..63819b6 100644 --- a/pkg/cmd/chat/utils/async.go +++ b/pkg/cmd/chat/utils/async.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/spf13/cobra" ) diff --git a/pkg/cmd/chat/utils/fileupload.go b/pkg/cmd/chat/utils/fileupload.go index 5246df7..30c0637 100644 --- a/pkg/cmd/chat/utils/fileupload.go +++ b/pkg/cmd/chat/utils/fileupload.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/spf13/cobra" ) diff --git a/pkg/config/config.go b/pkg/config/config.go index 823276f..98d6950 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/spf13/cobra" "github.com/spf13/viper" ) diff --git a/pkg/utils/param.go b/pkg/utils/param.go index 520626d..498cbe8 100644 --- a/pkg/utils/param.go +++ b/pkg/utils/param.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strings" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/spf13/pflag" ) diff --git a/test/helpers.go b/test/helpers.go index bbdb649..59e8771 100644 --- a/test/helpers.go +++ b/test/helpers.go @@ -6,9 +6,8 @@ import ( "math/rand" "os" "testing" - "time" - stream "github.com/GetStream/stream-chat-go/v5" + stream "github.com/GetStream/stream-chat-go/v8" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -91,7 +90,6 @@ func DeleteMessage(id string) { } func RandomString(n int) string { - rand.Seed(time.Now().UnixNano()) bytes := make([]byte, n) for i := 0; i < n; i++ { bytes[i] = byte(65 + rand.Intn(25)) // A=65 and Z = 65+25