Image events
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
f6639cb46d
commit
0ac4ad0580
|
@ -44,30 +44,6 @@ func (daemon *Daemon) LogContainerEventWithAttributes(container *container.Conta
|
||||||
daemon.EventsService.Log(action, events.ContainerEventType, actor)
|
daemon.EventsService.Log(action, events.ContainerEventType, actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogImageEvent generates an event related to an image with only the default attributes.
|
|
||||||
func (daemon *Daemon) LogImageEvent(imageID, refName, action string) {
|
|
||||||
daemon.LogImageEventWithAttributes(imageID, refName, action, map[string]string{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
|
|
||||||
func (daemon *Daemon) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
|
|
||||||
img, err := daemon.GetImage(imageID)
|
|
||||||
if err == nil && img.Config != nil {
|
|
||||||
// image has not been removed yet.
|
|
||||||
// it could be missing if the event is `delete`.
|
|
||||||
copyAttributes(attributes, img.Config.Labels)
|
|
||||||
}
|
|
||||||
if refName != "" {
|
|
||||||
attributes["name"] = refName
|
|
||||||
}
|
|
||||||
actor := events.Actor{
|
|
||||||
ID: imageID,
|
|
||||||
Attributes: attributes,
|
|
||||||
}
|
|
||||||
|
|
||||||
daemon.EventsService.Log(action, events.ImageEventType, actor)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogPluginEvent generates an event related to a plugin with only the default attributes.
|
// LogPluginEvent generates an event related to a plugin with only the default attributes.
|
||||||
func (daemon *Daemon) LogPluginEvent(pluginID, refName, action string) {
|
func (daemon *Daemon) LogPluginEvent(pluginID, refName, action string) {
|
||||||
daemon.LogPluginEventWithAttributes(pluginID, refName, action, map[string]string{})
|
daemon.LogPluginEventWithAttributes(pluginID, refName, action, map[string]string{})
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package daemon // import "github.com/docker/docker/daemon"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/docker/api/types/events"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LogImageEvent generates an event related to an image with only the default attributes.
|
||||||
|
func (daemon *Daemon) LogImageEvent(imageID, refName, action string) {
|
||||||
|
daemon.LogImageEventWithAttributes(imageID, refName, action, map[string]string{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
|
||||||
|
func (daemon *Daemon) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
|
||||||
|
img, err := daemon.GetImage(imageID)
|
||||||
|
if err == nil && img.Config != nil {
|
||||||
|
// image has not been removed yet.
|
||||||
|
// it could be missing if the event is `delete`.
|
||||||
|
copyAttributes(attributes, img.Config.Labels)
|
||||||
|
}
|
||||||
|
if refName != "" {
|
||||||
|
attributes["name"] = refName
|
||||||
|
}
|
||||||
|
actor := events.Actor{
|
||||||
|
ID: imageID,
|
||||||
|
Attributes: attributes,
|
||||||
|
}
|
||||||
|
|
||||||
|
daemon.EventsService.Log(action, events.ImageEventType, actor)
|
||||||
|
}
|
Loading…
Reference in New Issue