@@ -21,7 +21,6 @@ import (
21
21
"encoding/json"
22
22
"errors"
23
23
"fmt"
24
- "slices"
25
24
26
25
containerd "github.com/containerd/containerd/v2/client"
27
26
"github.com/containerd/log"
@@ -60,7 +59,7 @@ func Inspect(ctx context.Context, client *containerd.Client, options types.Netwo
60
59
61
60
network := netList [0 ]
62
61
63
- var filters = []string {fmt .Sprintf (" labels.%q~=%q" , labels .Networks , network .Name )}
62
+ var filters = []string {fmt .Sprintf (` labels.%q~="\\\"%s\\\""` , labels .Networks , network .Name )}
64
63
filteredContainers , err := client .Containers (ctx , filters ... )
65
64
if err != nil {
66
65
return err
@@ -76,13 +75,7 @@ func Inspect(ctx context.Context, client *containerd.Client, options types.Netwo
76
75
continue
77
76
}
78
77
79
- isNetworkMember , err := isContainerInNetwork (ctx , container , network .Name )
80
- if err != nil {
81
- return err
82
- }
83
- if isNetworkMember {
84
- containers = append (containers , nativeContainer )
85
- }
78
+ containers = append (containers , nativeContainer )
86
79
}
87
80
88
81
r := & native.Network {
@@ -119,20 +112,3 @@ func Inspect(ctx context.Context, client *containerd.Client, options types.Netwo
119
112
120
113
return err
121
114
}
122
-
123
- func isContainerInNetwork (ctx context.Context , container containerd.Container , networkName string ) (bool , error ) {
124
- info , err := container .Info (ctx )
125
- if err != nil {
126
- return false , err
127
- }
128
- networkLabels , ok := info .Labels [labels .Networks ]
129
- if ! ok {
130
- return false , nil
131
- }
132
-
133
- var containerNetworks []string
134
- if err := json .Unmarshal ([]byte (networkLabels ), & containerNetworks ); err != nil {
135
- return false , err
136
- }
137
- return slices .Contains (containerNetworks , networkName ), nil
138
- }
0 commit comments