pulumi/pkg/engine/engine.go
Matt Ellis 865422567c Alow multiple instances of engine.Engine
This refactors the engine so all of the APIs on it are instance
methods on the type instead of raw methods that float around and use
data from a global engine.

A mechcanical change as we remove the global `E` and then make
anything that interacted with that in pkg/engine to be an instance
method and the dealing with the fallout.
2017-08-24 18:09:37 -07:00

32 lines
581 B
Go

package engine
import (
"io"
"github.com/pulumi/pulumi-fabric/pkg/diag"
"github.com/pulumi/pulumi-fabric/pkg/util/contract"
)
type Engine struct {
Stdout io.Writer
Stderr io.Writer
snk diag.Sink
}
func (e *Engine) Diag() diag.Sink {
if e.snk == nil {
e.InitDiag(diag.FormatOptions{})
}
return e.snk
}
func (e *Engine) InitDiag(opts diag.FormatOptions) {
contract.Assertf(e.snk == nil, "Cannot initialize diagnostics sink more than once")
// Force using our stdout and stderr
opts.Stdout = e.Stdout
opts.Stderr = e.Stderr
e.snk = diag.DefaultSink(opts)
}