restartmanager: add SetPolicy() to the RestartManager interface

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-04-07 13:40:15 +02:00
parent d68b68fc43
commit efb97da0da
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 2 additions and 7 deletions

View file

@ -557,13 +557,7 @@ func (container *Container) InitDNSHostConfig() {
// UpdateMonitor updates monitor configure for running container // UpdateMonitor updates monitor configure for running container
func (container *Container) UpdateMonitor(restartPolicy containertypes.RestartPolicy) { func (container *Container) UpdateMonitor(restartPolicy containertypes.RestartPolicy) {
type policySetter interface { container.RestartManager().SetPolicy(restartPolicy)
SetPolicy(containertypes.RestartPolicy)
}
if rm, ok := container.RestartManager().(policySetter); ok {
rm.SetPolicy(restartPolicy)
}
} }
// FullHostname returns hostname and optional domain appended to it. // FullHostname returns hostname and optional domain appended to it.

View file

@ -23,6 +23,7 @@ var ErrRestartCanceled = errors.New("restart canceled")
type RestartManager interface { type RestartManager interface {
Cancel() Cancel()
ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error) ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool, executionDuration time.Duration) (bool, chan error, error)
SetPolicy(policy container.RestartPolicy)
} }
type restartManager struct { type restartManager struct {