Skip to content

Commit

Permalink
modules: start using managerclient by importing submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-kokoszka committed Sep 3, 2024
1 parent 3a3f8f9 commit 61acf93
Show file tree
Hide file tree
Showing 53 changed files with 5,554 additions and 430 deletions.
14 changes: 8 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ require (
github.com/google/uuid v1.6.0
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed
github.com/hashicorp/go-version v1.7.0
github.com/hbollon/go-edlib v1.5.0
github.com/json-iterator/go v1.1.12
github.com/lnquy/cron v1.1.1
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.0
Expand All @@ -31,9 +29,9 @@ require (
github.com/scylladb/go-reflectx v1.0.1
github.com/scylladb/go-set v1.0.2
github.com/scylladb/gocqlx/v2 v2.8.0
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902114746-64513d98fa9a
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902095357-774019f5533d
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20240902123022-df2d6812cdb0
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902115944-7914bb0d3b80
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902115944-7914bb0d3b80
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stoewer/go-strcase v1.3.0
Expand Down Expand Up @@ -79,16 +77,18 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/hbollon/go-edlib v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lnquy/cron v1.1.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -97,7 +97,9 @@ require (
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/rfjakob/eme v1.1.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
Expand Down
22 changes: 12 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,8 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hbollon/go-edlib v1.5.0 h1:IfyK67aiP8/Z+i1DsbT5Jwhk5xIdvCfI5xVL/6xVEts=
github.com/hbollon/go-edlib v1.5.0/go.mod h1:wnt6o6EIVEzUfgbUZY7BerzQ2uvzp354qmS2xaLkrhM=
github.com/hbollon/go-edlib v1.6.0 h1:ga7AwwVIvP8mHm9GsPueC0d71cfRU/52hmPJ7Tprv4E=
github.com/hbollon/go-edlib v1.6.0/go.mod h1:wnt6o6EIVEzUfgbUZY7BerzQ2uvzp354qmS2xaLkrhM=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
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=
Expand Down Expand Up @@ -965,8 +965,8 @@ github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
Expand Down Expand Up @@ -1025,6 +1025,8 @@ github.com/putdotio/go-putio/putio v0.0.0-20200123120452-16d982cac2b8/go.mod h1:
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rfjakob/eme v1.1.1 h1:t+CgvcOn+eDvj2xdglxsSnkgg8LM8jwdxnV7OnsrTn0=
github.com/rfjakob/eme v1.1.1/go.mod h1:U2bmx0hDj8EyDdcxmD5t3XHDnBFnyNNc22n1R4008eM=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand All @@ -1051,12 +1053,12 @@ github.com/scylladb/google-api-go-client v0.34.1-patched h1:DW+T0HA+74o6FDr3TFzV
github.com/scylladb/google-api-go-client v0.34.1-patched/go.mod h1:RriRmS2wJXH+2yd9PRTEcR380U9AXmurWwznqVhzsSc=
github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e h1:lJRphCtu+nKd+mfo8whOTeFkgjMWvk8iCSlqgibKSa8=
github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e/go.mod h1:JGZp4EvCUK+6AM1Fe1dye5xvihTc/Bk0WnHHSCJOePM=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902085609-d14eed1d24a2 h1:uIG3O1MUbso3XsP3ohAsGG4f9HHELsxorR7R/MJTRt8=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902085609-d14eed1d24a2/go.mod h1:C1f2+Ss6btQ18I7lF2d0AW3LeUbmd1g8HuyOwWJekE4=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902114746-64513d98fa9a h1:a2H/yAW+MCUdZ+OYoLi9q3udokVAJlcmaKD4+hTj17o=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902114746-64513d98fa9a/go.mod h1:+sPCx2oaOXmMpy/ODNNEDGJ7vCghBeKP4S7xEfMI+eA=
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902095357-774019f5533d h1:x7b/vQKSR6iHdGdBQIC9rA7TwPSZuCdM0e+ndAiw3DY=
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902095357-774019f5533d/go.mod h1:Oxfuz1XcXi9iV4ggSGfQdn+p6gPz6djPOegRMMe/6/s=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20240902123022-df2d6812cdb0 h1:du1LCxGo1ckkYuSRfvMYrlLxi1InLpIWw5dKfpsNxJU=
github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20240902123022-df2d6812cdb0/go.mod h1:AQyWEkxdYc+zAEKofGOKOTPyvW2HhoL1+iMQrESFqdY=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902115944-7914bb0d3b80 h1:M6M3mnFawPskN4nBnZ9MJ+k89Mqhd26xubww07uN72w=
github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20240902115944-7914bb0d3b80/go.mod h1:+sPCx2oaOXmMpy/ODNNEDGJ7vCghBeKP4S7xEfMI+eA=
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902115944-7914bb0d3b80 h1:MS2Lir2OkmpvFzfwroJC31NLLVHc8m/76SBz7+ayj1A=
github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20240902115944-7914bb0d3b80/go.mod h1:Oxfuz1XcXi9iV4ggSGfQdn+p6gPz6djPOegRMMe/6/s=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4 h1:8qmTC5ByIXO3GP/IzBkxcZ/99VITvnIETDhdFz/om7A=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/sctool/sctool.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/scylladb/scylla-manager/v3/pkg/command/suspend"
"github.com/scylladb/scylla-manager/v3/pkg/command/tasks"
"github.com/scylladb/scylla-manager/v3/pkg/command/version"
managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/spf13/cobra"
)

Expand All @@ -44,15 +44,15 @@ func main() {

cmd := buildCommand()
if err := cmd.Execute(); err != nil {
managerclient2.PrintError(cmd.OutOrStderr(), err)
managerclient.PrintError(cmd.OutOrStderr(), err)
os.Exit(1)
}

os.Exit(0)
}

func buildCommand() *cobra.Command {
var client managerclient2.Client
var client managerclient.Client

backupCmd := backup.NewCommand(&client)
backupCmd.AddCommand(
Expand Down
18 changes: 9 additions & 9 deletions pkg/command/backup/backupvalidate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/command/flag"
managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
Expand All @@ -21,23 +21,23 @@ var updateRes []byte

type command struct {
flag.TaskBase
client *managerclient2.Client
client *managerclient.Client

cluster string
location []string
deleteOrphanedFiles bool
parallel int
}

func NewCommand(client *managerclient2.Client) *cobra.Command {
func NewCommand(client *managerclient.Client) *cobra.Command {
cmd := newCommand(client, false)
updateCmd := newCommand(client, true)
cmd.AddCommand(&updateCmd.Command)

return &cmd.Command
}

func newCommand(client *managerclient2.Client, update bool) *command {
func newCommand(client *managerclient.Client, update bool) *command {
var (
cmd = &command{
client: client,
Expand Down Expand Up @@ -74,20 +74,20 @@ func (cmd *command) init() {

func (cmd *command) run(args []string) error {
var (
task *managerclient2.Task
task *managerclient.Task
ok bool
)

if cmd.Update() {
a := managerclient2.ValidateBackupTask
a := managerclient.ValidateBackupTask
if len(args) > 0 {
a = args[0]
}
taskType, taskID, err := cmd.client.TaskSplit(cmd.Context(), cmd.cluster, a)
if err != nil {
return err
}
if taskType != managerclient2.ValidateBackupTask {
if taskType != managerclient.ValidateBackupTask {
return fmt.Errorf("can't handle %s task", taskType)
}
task, err = cmd.client.GetTask(cmd.Context(), cmd.cluster, taskType, taskID)
Expand All @@ -96,7 +96,7 @@ func (cmd *command) run(args []string) error {
}
ok = cmd.UpdateTask(task)
} else {
task = cmd.CreateTask(managerclient2.ValidateBackupTask)
task = cmd.CreateTask(managerclient.ValidateBackupTask)
}

props := task.Properties.(map[string]interface{})
Expand Down Expand Up @@ -128,6 +128,6 @@ func (cmd *command) run(args []string) error {
return errors.New("nothing to do")
}

fmt.Fprintln(cmd.OutOrStdout(), managerclient2.TaskID(task))
fmt.Fprintln(cmd.OutOrStdout(), managerclient.TaskID(task))
return nil
}
18 changes: 9 additions & 9 deletions pkg/command/backup/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/command/flag"
managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/spf13/cobra"
"go.uber.org/atomic"
"gopkg.in/yaml.v2"
Expand All @@ -23,7 +23,7 @@ var updateRes []byte

type command struct {
flag.TaskBase
client *managerclient2.Client
client *managerclient.Client

cluster string
dc []string
Expand All @@ -39,15 +39,15 @@ type command struct {
purgeOnly bool
}

func NewCommand(client *managerclient2.Client) *cobra.Command {
func NewCommand(client *managerclient.Client) *cobra.Command {
cmd := newCommand(client, false)
updateCmd := newCommand(client, true)
cmd.AddCommand(&updateCmd.Command)

return &cmd.Command
}

func newCommand(client *managerclient2.Client, update bool) *command {
func newCommand(client *managerclient.Client, update bool) *command {
var (
cmd = &command{
client: client,
Expand Down Expand Up @@ -92,20 +92,20 @@ func (cmd *command) init() {

func (cmd *command) run(args []string) error {
var (
task *managerclient2.Task
task *managerclient.Task
ok bool
)

if cmd.Update() {
a := managerclient2.BackupTask
a := managerclient.BackupTask
if len(args) > 0 {
a = args[0]
}
taskType, taskID, err := cmd.client.TaskSplit(cmd.Context(), cmd.cluster, a)
if err != nil {
return err
}
if taskType != managerclient2.BackupTask {
if taskType != managerclient.BackupTask {
return fmt.Errorf("can't handle %s task", taskType)
}
task, err = cmd.client.GetTask(cmd.Context(), cmd.cluster, taskType, taskID)
Expand All @@ -114,7 +114,7 @@ func (cmd *command) run(args []string) error {
}
ok = cmd.UpdateTask(task)
} else {
task = cmd.CreateTask(managerclient2.BackupTask)
task = cmd.CreateTask(managerclient.BackupTask)
}

props := task.Properties.(map[string]interface{})
Expand Down Expand Up @@ -192,6 +192,6 @@ func (cmd *command) run(args []string) error {
return errors.New("nothing to do")
}

fmt.Fprintln(cmd.OutOrStdout(), managerclient2.TaskID(task))
fmt.Fprintln(cmd.OutOrStdout(), managerclient.TaskID(task))
return nil
}
8 changes: 4 additions & 4 deletions pkg/command/cluster/clusteradd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/command/flag"
managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/util/clipper"
"github.com/scylladb/scylla-manager/v3/pkg/util/fsutil"
"github.com/spf13/cobra"
Expand All @@ -21,7 +21,7 @@ var res []byte

type command struct {
cobra.Command
client *managerclient2.Client
client *managerclient.Client

id string
name string
Expand All @@ -38,7 +38,7 @@ type command struct {
forceNonSSLSessionPort bool
}

func NewCommand(client *managerclient2.Client) *cobra.Command {
func NewCommand(client *managerclient.Client) *cobra.Command {
cmd := &command{
client: client,
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func (cmd *command) run() error {
}
}

c := &managerclient2.Cluster{
c := &managerclient.Cluster{
ID: cmd.id,
Name: cmd.name,
Labels: cmd.label.NewLabels(),
Expand Down
8 changes: 4 additions & 4 deletions pkg/command/info/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"

"github.com/scylladb/scylla-manager/v3/pkg/command/flag"
managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
Expand All @@ -17,14 +17,14 @@ var res []byte

type command struct {
cobra.Command
client *managerclient2.Client
client *managerclient.Client

cluster string
limit int
cause bool
}

func NewCommand(client *managerclient2.Client) *cobra.Command {
func NewCommand(client *managerclient.Client) *cobra.Command {
cmd := &command{
client: client,
Command: cobra.Command{
Expand Down Expand Up @@ -66,7 +66,7 @@ func (cmd *command) run(args []string) error {
return fmt.Errorf("expected exactly 1 task, got %d", len(tasks.TaskListItemSlice))
}

ti := managerclient2.TaskInfo{
ti := managerclient.TaskInfo{
TaskListItem: tasks.TaskListItemSlice[0],
}
if err := ti.Render(w); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/command/info/cmd_integration_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"regexp"
"testing"

managerclient2 "github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/pkg/managerclient"
"github.com/scylladb/scylla-manager/v3/swagger/gen/scylla-manager/models"
)

Expand All @@ -22,7 +22,7 @@ const (
)

func TestSctoolInfoLabelsIntegrationAPITest(t *testing.T) {
client, err := managerclient2.NewClient("http://localhost:5080/api/v1")
client, err := managerclient.NewClient("http://localhost:5080/api/v1")
if err != nil {
t.Fatalf("Unable to create managerclient to consume manager HTTP API, err = {%v}", err)
}
Expand All @@ -41,7 +41,7 @@ func TestSctoolInfoLabelsIntegrationAPITest(t *testing.T) {
}
}()

taskID, err := client.CreateTask(context.Background(), clusterID, &managerclient2.Task{
taskID, err := client.CreateTask(context.Background(), clusterID, &managerclient.Task{
Type: "repair",
Enabled: true,
Labels: map[string]string{
Expand All @@ -53,7 +53,7 @@ func TestSctoolInfoLabelsIntegrationAPITest(t *testing.T) {
t.Logf("Failed to create task, err = {%v}", err)
}

if err := client.UpdateTask(context.Background(), clusterID, &managerclient2.Task{
if err := client.UpdateTask(context.Background(), clusterID, &managerclient.Task{
ID: taskID.String(),
Type: "repair",
Enabled: true,
Expand Down
Loading

0 comments on commit 61acf93

Please sign in to comment.