Skip to content

Commit

Permalink
fix Yuce's comments 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Oct 19, 2023
1 parent 2d916cf commit 0c7028c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion base/commands/migration/migration_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions base/commands/migration/start_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package migration
import (
"context"
"encoding/json"
"errors"
"fmt"

"github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage"
Expand All @@ -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] {
Expand Down
5 changes: 2 additions & 3 deletions base/commands/migration/status_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion base/commands/migration/status_stages_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}

Expand Down

0 comments on commit 0c7028c

Please sign in to comment.