Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLC-442]: Fix defers #436

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions base/commands/migration/migration_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ In order to cancel the migration, use the 'cancel' command.
return err
}
defer func() {
maybePrintWarnings(ctx, ec, sts.ci, mID)
finalizeErr := finalizeMigration(ctx, ec, sts.ci, mID, ec.Props().GetString(flagOutputDir))
if err == nil {
err = finalizeErr
if sts.ci != nil {
maybePrintWarnings(ctx, ec, sts.ci, mID)
finalizeErr := finalizeMigration(ctx, ec, sts.ci, mID, ec.Props().GetString(flagOutputDir))
if err == nil {
err = finalizeErr
}
}
}()
sp := stage.NewFixedProvider(sts.Build(ctx, ec)...)
Expand Down
10 changes: 6 additions & 4 deletions base/commands/migration/migration_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ func (s StatusCmd) Exec(ctx context.Context, ec plug.ExecContext) (err error) {
return err
}
defer func() {
maybePrintWarnings(ctx, ec, sts.ci, mID.(string))
finalizeErr := finalizeMigration(ctx, ec, sts.ci, mID.(string), ec.Props().GetString(flagOutputDir))
if err == nil {
err = finalizeErr
if sts.ci != nil {
maybePrintWarnings(ctx, ec, sts.ci, mID.(string))
finalizeErr := finalizeMigration(ctx, ec, sts.ci, mID.(string), ec.Props().GetString(flagOutputDir))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the stage.Execute call above so it uses "" instead of any(nil) as the initial state value?

mID, err := stage.Execute(ctx, ec, "", sp)

So the state type is string and casting it to string here is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if err == nil {
err = finalizeErr
}
}
}()
mStages, err := createMigrationStages(ctx, ec, sts.ci, mID.(string))
Expand Down
Loading