monitor: move remaining controller functionality into monitor
This creates a `Monitor` type that keeps the global state between monitor invocations and allows the monitor to exist during the build so it can be utilized for callbacks. The result handler is now registered with the monitor during the build and `Run` will use the result if it is present and the configuration intends the monitor to be invoked with the given result. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
@@ -37,4 +37,20 @@ type InvokeConfig struct {
|
||||
Tty bool
|
||||
Rollback bool
|
||||
Initial bool
|
||||
SuspendOn SuspendOn
|
||||
}
|
||||
|
||||
func (cfg *InvokeConfig) NeedsDebug(err error) bool {
|
||||
return cfg.SuspendOn.DebugEnabled(err)
|
||||
}
|
||||
|
||||
type SuspendOn int
|
||||
|
||||
const (
|
||||
SuspendError SuspendOn = iota
|
||||
SuspendAlways
|
||||
)
|
||||
|
||||
func (s SuspendOn) DebugEnabled(err error) bool {
|
||||
return err != nil || s == SuspendAlways
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user