Skip to content

Commit b72810d

Browse files
committed
refactor: remove NoRollback, use nil instead
1 parent edf18c3 commit b72810d

File tree

7 files changed

+9
-15
lines changed

7 files changed

+9
-15
lines changed

dsl/execute.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func Execute(ctx context.Context, expr types.Expr) (_ types.Value, result error)
4848

4949
val, rollback, err := expr.Eval(ctx)
5050
if err != nil {
51-
rollback()
51+
if rollback != nil {
52+
rollback()
53+
}
5254
return nil, errors.Wrap(err, "expression returned an error")
5355
}
5456
return val, nil

dsl/ops/func_lockjson_write.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ func (*lockJSONWriteOp) InvertExpr(_ context.Context, args []types.Value) (types
3333
return LockJSONWriteOp.Bind(args...)
3434
}
3535

36-
func (*lockJSONWriteOp) EvalExpr(ctx context.Context, args []types.Value) (_ types.Value, rollback func(), result error) {
37-
rollback = NoRollback
38-
36+
func (*lockJSONWriteOp) EvalExpr(ctx context.Context, args []types.Value) (_ types.Value, _ func(), result error) {
3937
lockJSON := ctx.Value(dslctx.LockJSONKey).(*lockjson.LockJSON)
4038
result = lockJSON.Write()
4139
if result != nil {

dsl/ops/func_migrate_plugconf_config_func.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ func (*migratePlugconfConfigFuncOp) InvertExpr(_ context.Context, args []types.V
4444
return MigratePlugconfConfigFuncOp.Bind(args...)
4545
}
4646

47-
func (*migratePlugconfConfigFuncOp) EvalExpr(ctx context.Context, args []types.Value) (_ types.Value, rollback func(), result error) {
48-
rollback = NoRollback
47+
func (*migratePlugconfConfigFuncOp) EvalExpr(ctx context.Context, args []types.Value) (_ types.Value, _ func(), result error) {
4948
lockJSON := ctx.Value(dslctx.LockJSONKey).(*lockjson.LockJSON)
5049
cfg := ctx.Value(dslctx.ConfigKey).(*config.Config)
5150

dsl/ops/macro_array.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ func (*arrayOp) Bind(args ...types.Value) (types.Expr, error) {
2828
}
2929

3030
func (*arrayOp) EvalExpr(ctx context.Context, args []types.Value) (types.Value, func(), error) {
31-
return types.NewArray(args, types.AnyValue), NoRollback, nil
31+
return types.NewArray(args, types.AnyValue), nil, nil
3232
}

dsl/ops/macro_eval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (*evalOp) Bind(args ...types.Value) (types.Expr, error) {
3030

3131
func (*evalOp) EvalExpr(ctx context.Context, args []types.Value) (types.Value, func(), error) {
3232
if err := util.Signature(types.AnyValue).Check(args); err != nil {
33-
return nil, NoRollback, err
33+
return nil, nil, err
3434
}
3535
return args[0].Eval(ctx)
3636
}

dsl/ops/macro_invert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func (*invertOp) Bind(args ...types.Value) (types.Expr, error) {
3030

3131
func (*invertOp) EvalExpr(ctx context.Context, args []types.Value) (types.Value, func(), error) {
3232
if err := util.Signature(types.AnyValue).Check(args); err != nil {
33-
return nil, NoRollback, err
33+
return nil, nil, err
3434
}
3535
val, err := args[0].Invert(ctx)
36-
return val, NoRollback, err
36+
return val, nil, err
3737
}

dsl/ops/rollback.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)