Skip to content

Commit afc6074

Browse files
committed
container/docker: inline some vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 3314af1 commit afc6074

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

container/docker/handler.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ type containerHandler struct {
9494
libcontainerHandler *containerlibcontainer.Handler
9595

9696
// the docker client is needed to inspect the container and get the health status
97-
client docker.APIClient
97+
client dclient.APIClient
9898
}
9999

100100
var _ container.ContainerHandler = &containerHandler{}
@@ -199,26 +199,26 @@ func newContainerHandler(
199199
rootfsStorageDir: rootfsStorageDir,
200200
envs: make(map[string]string),
201201
labels: ctnr.Config.Labels,
202+
image: ctnr.Config.Image,
202203
metrics: includedMetrics,
203204
thinPoolName: thinPoolName,
204205
zfsParent: zfsParent,
205206
client: client,
207+
reference: info.ContainerReference{
208+
// Add the name and bare ID as aliases of the container.
209+
Id: id,
210+
Name: name,
211+
Aliases: []string{strings.TrimPrefix(ctnr.Name, "/"), id},
212+
Namespace: DockerNamespace,
213+
},
214+
libcontainerHandler: containerlibcontainer.NewHandler(cgroupManager, rootFs, ctnr.State.Pid, metrics),
206215
}
216+
207217
// Timestamp returned by Docker is in time.RFC3339Nano format.
208218
handler.creationTime, err = time.Parse(time.RFC3339Nano, ctnr.Created)
209219
if err != nil {
210220
return nil, fmt.Errorf("failed to parse the create timestamp %q for container %q: %v", ctnr.Created, id, err)
211221
}
212-
handler.libcontainerHandler = containerlibcontainer.NewHandler(cgroupManager, rootFs, ctnr.State.Pid, metrics)
213-
214-
// Add the name and bare ID as aliases of the container.
215-
handler.reference = info.ContainerReference{
216-
Id: id,
217-
Name: name,
218-
Aliases: []string{strings.TrimPrefix(ctnr.Name, "/"), id},
219-
Namespace: DockerNamespace,
220-
}
221-
handler.image = ctnr.Config.Image
222222

223223
if ctnr.RestartCount > 0 {
224224
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)