Browse code

Image events

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2018/02/22 07:18:28
Showing 2 changed files
... ...
@@ -44,30 +44,6 @@ func (daemon *Daemon) LogContainerEventWithAttributes(container *container.Conta
44 44
 	daemon.EventsService.Log(action, events.ContainerEventType, actor)
45 45
 }
46 46
 
47
-// LogImageEvent generates an event related to an image with only the default attributes.
48
-func (daemon *Daemon) LogImageEvent(imageID, refName, action string) {
49
-	daemon.LogImageEventWithAttributes(imageID, refName, action, map[string]string{})
50
-}
51
-
52
-// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
53
-func (daemon *Daemon) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
54
-	img, err := daemon.GetImage(imageID)
55
-	if err == nil && img.Config != nil {
56
-		// image has not been removed yet.
57
-		// it could be missing if the event is `delete`.
58
-		copyAttributes(attributes, img.Config.Labels)
59
-	}
60
-	if refName != "" {
61
-		attributes["name"] = refName
62
-	}
63
-	actor := events.Actor{
64
-		ID:         imageID,
65
-		Attributes: attributes,
66
-	}
67
-
68
-	daemon.EventsService.Log(action, events.ImageEventType, actor)
69
-}
70
-
71 47
 // LogPluginEvent generates an event related to a plugin with only the default attributes.
72 48
 func (daemon *Daemon) LogPluginEvent(pluginID, refName, action string) {
73 49
 	daemon.LogPluginEventWithAttributes(pluginID, refName, action, map[string]string{})
74 50
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+package daemon // import "github.com/docker/docker/daemon"
1
+
2
+import (
3
+	"github.com/docker/docker/api/types/events"
4
+)
5
+
6
+// LogImageEvent generates an event related to an image with only the default attributes.
7
+func (daemon *Daemon) LogImageEvent(imageID, refName, action string) {
8
+	daemon.LogImageEventWithAttributes(imageID, refName, action, map[string]string{})
9
+}
10
+
11
+// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
12
+func (daemon *Daemon) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
13
+	img, err := daemon.GetImage(imageID)
14
+	if err == nil && img.Config != nil {
15
+		// image has not been removed yet.
16
+		// it could be missing if the event is `delete`.
17
+		copyAttributes(attributes, img.Config.Labels)
18
+	}
19
+	if refName != "" {
20
+		attributes["name"] = refName
21
+	}
22
+	actor := events.Actor{
23
+		ID:         imageID,
24
+		Attributes: attributes,
25
+	}
26
+
27
+	daemon.EventsService.Log(action, events.ImageEventType, actor)
28
+}