@@ -14,6 +14,7 @@ import (
1414
1515 "github.com/containerd/log"
1616 "github.com/docker/docker/api/types"
17+ "github.com/docker/docker/api/types/container"
1718 "github.com/docker/docker/api/types/network"
1819 "github.com/docker/docker/errdefs"
1920 "github.com/docker/go-connections/nat"
@@ -299,76 +300,76 @@ func (v *View) GetAllNames() map[string][]string {
299300
300301// transform maps a (deep) copied Container object to what queries need.
301302// A lock on the Container is not held because these are immutable deep copies.
302- func (v * View ) transform (container * Container ) * Snapshot {
303+ func (v * View ) transform (ctr * Container ) * Snapshot {
303304 health := types .NoHealthcheck
304- if container .Health != nil {
305- health = container .Health .Status ()
305+ if ctr .Health != nil {
306+ health = ctr .Health .Status ()
306307 }
307308 snapshot := & Snapshot {
308309 Container : types.Container {
309- ID : container .ID ,
310- Names : v .getNames (container .ID ),
311- ImageID : container .ImageID .String (),
310+ ID : ctr .ID ,
311+ Names : v .getNames (ctr .ID ),
312+ ImageID : ctr .ImageID .String (),
312313 Ports : []types.Port {},
313- Mounts : container .GetMountPoints (),
314- State : container .State .StateString (),
315- Status : container .State .String (),
316- Created : container .Created .Unix (),
314+ Mounts : ctr .GetMountPoints (),
315+ State : ctr .State .StateString (),
316+ Status : ctr .State .String (),
317+ Created : ctr .Created .Unix (),
317318 },
318- CreatedAt : container .Created ,
319- StartedAt : container .StartedAt ,
320- Name : container .Name ,
321- Pid : container .Pid ,
322- Managed : container .Managed ,
319+ CreatedAt : ctr .Created ,
320+ StartedAt : ctr .StartedAt ,
321+ Name : ctr .Name ,
322+ Pid : ctr .Pid ,
323+ Managed : ctr .Managed ,
323324 ExposedPorts : make (nat.PortSet ),
324325 PortBindings : make (nat.PortSet ),
325326 Health : health ,
326- Running : container .Running ,
327- Paused : container .Paused ,
328- ExitCode : container .ExitCode (),
327+ Running : ctr .Running ,
328+ Paused : ctr .Paused ,
329+ ExitCode : ctr .ExitCode (),
329330 }
330331
331332 if snapshot .Names == nil {
332333 // Dead containers will often have no name, so make sure the response isn't null
333334 snapshot .Names = []string {}
334335 }
335336
336- if container .HostConfig != nil {
337- snapshot .Container .HostConfig .NetworkMode = string (container .HostConfig .NetworkMode )
338- snapshot .Container .HostConfig .Annotations = maps .Clone (container .HostConfig .Annotations )
339- snapshot .HostConfig .Isolation = string (container .HostConfig .Isolation )
340- for binding := range container .HostConfig .PortBindings {
337+ if ctr .HostConfig != nil {
338+ snapshot .Container .HostConfig .NetworkMode = string (ctr .HostConfig .NetworkMode )
339+ snapshot .Container .HostConfig .Annotations = maps .Clone (ctr .HostConfig .Annotations )
340+ snapshot .HostConfig .Isolation = string (ctr .HostConfig .Isolation )
341+ for binding := range ctr .HostConfig .PortBindings {
341342 snapshot .PortBindings [binding ] = struct {}{}
342343 }
343344 }
344345
345- if container .Config != nil {
346- snapshot .Image = container .Config .Image
347- snapshot .Labels = container .Config .Labels
348- for exposed := range container .Config .ExposedPorts {
346+ if ctr .Config != nil {
347+ snapshot .Image = ctr .Config .Image
348+ snapshot .Labels = ctr .Config .Labels
349+ for exposed := range ctr .Config .ExposedPorts {
349350 snapshot .ExposedPorts [exposed ] = struct {}{}
350351 }
351352 }
352353
353- if len (container .Args ) > 0 {
354+ if len (ctr .Args ) > 0 {
354355 var args []string
355- for _ , arg := range container .Args {
356+ for _ , arg := range ctr .Args {
356357 if strings .Contains (arg , " " ) {
357358 args = append (args , fmt .Sprintf ("'%s'" , arg ))
358359 } else {
359360 args = append (args , arg )
360361 }
361362 }
362363 argsAsString := strings .Join (args , " " )
363- snapshot .Command = fmt .Sprintf ("%s %s" , container .Path , argsAsString )
364+ snapshot .Command = fmt .Sprintf ("%s %s" , ctr .Path , argsAsString )
364365 } else {
365- snapshot .Command = container .Path
366+ snapshot .Command = ctr .Path
366367 }
367368
368369 snapshot .Ports = []types.Port {}
369370 networks := make (map [string ]* network.EndpointSettings )
370- if container .NetworkSettings != nil {
371- for name , netw := range container .NetworkSettings .Networks {
371+ if ctr .NetworkSettings != nil {
372+ for name , netw := range ctr .NetworkSettings .Networks {
372373 if netw == nil || netw .EndpointSettings == nil {
373374 continue
374375 }
@@ -390,7 +391,7 @@ func (v *View) transform(container *Container) *Snapshot {
390391 }
391392 }
392393 }
393- for port , bindings := range container .NetworkSettings .Ports {
394+ for port , bindings := range ctr .NetworkSettings .Ports {
394395 p , err := nat .ParsePort (port .Port ())
395396 if err != nil {
396397 log .G (context .TODO ()).WithError (err ).Warn ("invalid port map" )
@@ -418,7 +419,7 @@ func (v *View) transform(container *Container) *Snapshot {
418419 }
419420 }
420421 }
421- snapshot .NetworkSettings = & types. SummaryNetworkSettings {Networks : networks }
422+ snapshot .NetworkSettings = & container. NetworkSettingsSummary {Networks : networks }
422423
423424 return snapshot
424425}
0 commit comments