Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7b3a1d

Browse files
committedApr 5, 2025·
fix: check for nil values and remove unecessary if block
Signed-off-by: Tushar Gupta <[email protected]>
1 parent 199291b commit f7b3a1d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed
 

‎pkg/cmd/network/inspect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Inspect(ctx context.Context, client *containerd.Client, options types.Netwo
7373
if err != nil {
7474
continue
7575
}
76-
if nativeContainer.Process.Status.Status != containerd.Running {
76+
if nativeContainer.Process == nil || nativeContainer.Process.Status.Status != containerd.Running {
7777
continue
7878
}
7979
containers = append(containers, nativeContainer)

‎pkg/inspecttypes/dockercompat/dockercompat.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -940,15 +940,13 @@ func NetworkFromNative(n *native.Network) (*Network, error) {
940940
}
941941

942942
res.Containers = make(map[string]EndpointResource)
943-
if n.Containers != nil {
944-
for _, container := range n.Containers {
945-
res.Containers[container.ID] = EndpointResource{
946-
Name: container.Labels[labels.Name],
947-
// EndpointID: container.EndpointID,
948-
// MacAddress: container.MacAddress,
949-
// IPv4Address: container.IPv4Address,
950-
// IPv6Address: container.IPv6Address,
951-
}
943+
for _, container := range n.Containers {
944+
res.Containers[container.ID] = EndpointResource{
945+
Name: container.Labels[labels.Name],
946+
// EndpointID: container.EndpointID,
947+
// MacAddress: container.MacAddress,
948+
// IPv4Address: container.IPv4Address,
949+
// IPv6Address: container.IPv6Address,
952950
}
953951
}
954952

0 commit comments

Comments
 (0)
Please sign in to comment.