engine: Rename world API and add a context
We want to be able to pass ctx through for various reasons.
This commit is contained in:
@@ -143,8 +143,8 @@ func (obj *World) hostKeyCallback() (ssh.HostKeyCallback, error) {
|
||||
return knownhosts.New(p)
|
||||
}
|
||||
|
||||
// Init runs first.
|
||||
func (obj *World) Init(init *engine.WorldInit) error {
|
||||
// Connect runs first.
|
||||
func (obj *World) Connect(ctx context.Context, init *engine.WorldInit) error {
|
||||
obj.init = init
|
||||
obj.cleanups = []func() error{}
|
||||
|
||||
@@ -310,11 +310,11 @@ func (obj *World) Init(init *engine.WorldInit) error {
|
||||
StandaloneFs: obj.StandaloneFs,
|
||||
GetURI: obj.GetURI,
|
||||
}
|
||||
if err := obj.World.Init(init); err != nil {
|
||||
if err := obj.World.Connect(ctx, init); err != nil {
|
||||
return errwrap.Append(obj.cleanup(), err)
|
||||
}
|
||||
obj.cleanups = append(obj.cleanups, func() error {
|
||||
e := obj.World.Close()
|
||||
e := obj.World.Cleanup()
|
||||
if obj.init.Debug && e != nil {
|
||||
obj.init.Logf("world close error: %+v", e)
|
||||
}
|
||||
@@ -337,7 +337,7 @@ func (obj *World) cleanup() error {
|
||||
return errs
|
||||
}
|
||||
|
||||
// Close runs last.
|
||||
func (obj *World) Close() error {
|
||||
// CLeanup runs last.
|
||||
func (obj *World) Cleanup() error {
|
||||
return obj.cleanup()
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ type World struct {
|
||||
cleanups []func() error
|
||||
}
|
||||
|
||||
// Init runs first.
|
||||
func (obj *World) Init(init *engine.WorldInit) error {
|
||||
// Connect runs first.
|
||||
func (obj *World) Connect(ctx context.Context, init *engine.WorldInit) error {
|
||||
obj.init = init
|
||||
|
||||
obj.client = obj.Client // legacy default
|
||||
@@ -135,8 +135,8 @@ func (obj *World) cleanup() error {
|
||||
return errs
|
||||
}
|
||||
|
||||
// Close runs last.
|
||||
func (obj *World) Close() error {
|
||||
// Cleanup runs last.
|
||||
func (obj *World) Cleanup() error {
|
||||
return obj.cleanup()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user