(*Daemon).fillRootlessVersion: fix nil panic

Fix issue 47085

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2024-01-17 00:48:12 +09:00
parent 5c4189e6b2
commit a6d9462cb1
No known key found for this signature in database
GPG key ID: 49524C6F9F638F1A

View file

@ -239,16 +239,27 @@ func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version)
if err != nil {
return errors.Wrap(err, "failed to retrieve RootlessKit version")
}
v.Components = append(v.Components, types.ComponentVersion{
rlV := types.ComponentVersion{
Name: "rootlesskit",
Version: rlInfo.Version,
Details: map[string]string{
"ApiVersion": rlInfo.APIVersion,
"StateDir": rlInfo.StateDir,
"NetworkDriver": rlInfo.NetworkDriver.Driver,
"PortDriver": rlInfo.PortDriver.Driver,
},
})
}
if netDriver := rlInfo.NetworkDriver; netDriver != nil {
// netDriver is nil for the "host" network driver
// (not used for Rootless Docker)
rlV.Details["NetworkDriver"] = netDriver.Driver
}
if portDriver := rlInfo.PortDriver; portDriver != nil {
// portDriver is nil for the "implicit" port driver
// (used with "pasta" network driver)
//
// Because the ports are not managed via RootlessKit API in this case.
rlV.Details["PortDriver"] = portDriver.Driver
}
v.Components = append(v.Components, rlV)
switch rlInfo.NetworkDriver.Driver {
case "slirp4netns":