Skip to content

Commit 1951240

Browse files
committed
container/docker: inline some vars
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent cbd29b2 commit 1951240

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

container/docker/handler.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,18 @@ func newContainerHandler(
197197
rootfsStorageDir: rootfsStorageDir,
198198
envs: make(map[string]string),
199199
labels: ctnr.Config.Labels,
200+
image: ctnr.Config.Image,
200201
metrics: includedMetrics,
201202
thinPoolName: thinPoolName,
202203
zfsParent: zfsParent,
204+
reference: info.ContainerReference{
205+
// Add the name and bare ID as aliases of the container.
206+
Id: id,
207+
Name: name,
208+
Aliases: []string{strings.TrimPrefix(ctnr.Name, "/"), id},
209+
Namespace: DockerNamespace,
210+
},
211+
libcontainerHandler: containerlibcontainer.NewHandler(cgroupManager, rootFs, ctnr.State.Pid, metrics),
203212
}
204213
// Health status may be nil if no health check is configured
205214
if ctnr.State.Health != nil {
@@ -210,16 +219,6 @@ func newContainerHandler(
210219
if err != nil {
211220
return nil, fmt.Errorf("failed to parse the create timestamp %q for container %q: %v", ctnr.Created, id, err)
212221
}
213-
handler.libcontainerHandler = containerlibcontainer.NewHandler(cgroupManager, rootFs, ctnr.State.Pid, metrics)
214-
215-
// Add the name and bare ID as aliases of the container.
216-
handler.reference = info.ContainerReference{
217-
Id: id,
218-
Name: name,
219-
Aliases: []string{strings.TrimPrefix(ctnr.Name, "/"), id},
220-
Namespace: DockerNamespace,
221-
}
222-
handler.image = ctnr.Config.Image
223222

224223
if ctnr.RestartCount > 0 {
225224
handler.labels["restartcount"] = strconv.Itoa(ctnr.RestartCount)

container/podman/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func newContainerHandler(
153153
thinPoolName: thinPoolName,
154154
zfsParent: zfsParent,
155155
reference: info.ContainerReference{
156+
// Add the name and bare ID as aliases of the container.
156157
Id: id,
157158
Name: name,
158159
Aliases: []string{strings.TrimPrefix(ctnr.Name, "/"), id},

0 commit comments

Comments
 (0)