diff --git a/base/commands/migration/migration_start.go b/base/commands/migration/migration_start.go index 5b430641..68c5bc03 100644 --- a/base/commands/migration/migration_start.go +++ b/base/commands/migration/migration_start.go @@ -54,7 +54,10 @@ Selected data structures in the source cluster will be migrated to the target cl } ec.PrintlnUnnecessary("") mID := MakeMigrationID() - sts := NewStartStages(ec.Logger(), mID, ec.GetStringArg(argDMTConfig)) + sts, err := NewStartStages(ec.Logger(), mID, ec.GetStringArg(argDMTConfig)) + if err != nil { + return err + } sp := stage.NewFixedProvider(sts.Build(ctx, ec)...) if _, err := stage.Execute(ctx, ec, any(nil), sp); err != nil { return err diff --git a/base/commands/migration/start_stages.go b/base/commands/migration/start_stages.go index ce3b089a..d2d1842a 100644 --- a/base/commands/migration/start_stages.go +++ b/base/commands/migration/start_stages.go @@ -5,6 +5,7 @@ package migration import ( "context" "encoding/json" + "errors" "fmt" "github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage" @@ -23,15 +24,15 @@ type StartStages struct { logger log.Logger } -func NewStartStages(logger log.Logger, migrationID, configDir string) *StartStages { +func NewStartStages(logger log.Logger, migrationID, configDir string) (*StartStages, error) { if migrationID == "" { - panic("migrationID is required") + return nil, errors.New("migrationID is required") } return &StartStages{ migrationID: migrationID, configDir: configDir, logger: logger, - } + }, nil } func (st *StartStages) Build(ctx context.Context, ec plug.ExecContext) []stage.Stage[any] { diff --git a/base/commands/migration/status_stages.go b/base/commands/migration/status_stages.go index e6d87fc5..fbd29ef0 100644 --- a/base/commands/migration/status_stages.go +++ b/base/commands/migration/status_stages.go @@ -54,12 +54,11 @@ func (st *StatusStages) connectStage(ec plug.ExecContext) func(context.Context, return nil, err } if len(all) == 0 { - return nil, fmt.Errorf("there are no migrations are in progress on migration cluster") + return nil, fmt.Errorf("there are no migrations in progress") } var mip MigrationInProgress m := all[0].(serialization.JSON) - err = json.Unmarshal(m, &mip) - if err != nil { + if err = json.Unmarshal(m, &mip); err != nil { return nil, fmt.Errorf("parsing migration in progress: %w", err) } st.statusMap, err = st.ci.Client().GetMap(ctx, StatusMapName) diff --git a/base/commands/migration/status_stages_it_test.go b/base/commands/migration/status_stages_it_test.go index 715a5b64..a5f7cd85 100644 --- a/base/commands/migration/status_stages_it_test.go +++ b/base/commands/migration/status_stages_it_test.go @@ -46,7 +46,7 @@ func noMigrationsStatusTest(t *testing.T) { execErr = tcx.CLC().Execute(ctx, "status") }) wg.Wait() - require.Contains(t, execErr.Error(), "there are no migrations are in progress on migration cluster") + require.Contains(t, execErr.Error(), "there are no migrations in progress") }) }