api/types/events: define "Action" type and consts

Define consts for the Actions we use for events, instead of "ad-hoc" strings.
Having these consts makes it easier to find where specific events are triggered,
makes the events less error-prone, and allows documenting each Action (if needed).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-08-26 15:24:46 +02:00
parent 10a3a3bc49
commit 0f871f8cb7
70 changed files with 284 additions and 156 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/errdefs"
"github.com/pkg/errors"
)
@@ -75,7 +76,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
ctr.UpdateMonitor(hostConfig.RestartPolicy)
}
defer daemon.LogContainerEvent(ctr, "update")
defer daemon.LogContainerEvent(ctr, events.ActionUpdate)
// If container is not running, update hostConfig struct is enough,
// resources will be updated when the container is started again.