@@ -110,7 +110,7 @@ func CidsByHost(client danmclientset.Interface, host string)(map[string]danmtype
110
110
}
111
111
112
112
// FindByPodName returns a map of DanmEps which belong to the same Pod in a given namespace
113
- // If no Pod name is provided, function returns all DanmEps
113
+ // If no Pod name is provided, function returns no DanmEps
114
114
func FindByPodName (client danmclientset.Interface , podName , ns string ) ([]danmtypes.DanmEp , error ) {
115
115
result , err := client .DanmV1 ().DanmEps (ns ).List (context .TODO (), meta_v1.ListOptions {})
116
116
if err != nil {
@@ -130,6 +130,27 @@ func FindByPodName(client danmclientset.Interface, podName, ns string) ([]danmty
130
130
return ret , nil
131
131
}
132
132
133
+ // FindByPodUid returns a map of DanmEps which belong to the same Pod instance in a given namespace
134
+ // If no Pod name is provided, function returns no DanmEps
135
+ func FindByPodUid (client danmclientset.Interface , podUid , ns string ) ([]danmtypes.DanmEp , error ) {
136
+ result , err := client .DanmV1 ().DanmEps (ns ).List (context .TODO (), meta_v1.ListOptions {})
137
+ if err != nil {
138
+ return nil , errors .New ("cannot list DanmEps because:" + err .Error ())
139
+ }
140
+ ret := make ([]danmtypes.DanmEp , 0 )
141
+ if result == nil {
142
+ return ret , nil
143
+ }
144
+ eplist := result .Items
145
+ for _ , ep := range eplist {
146
+ if podUid != "" && string (ep .Spec .PodUID ) != podUid {
147
+ continue
148
+ }
149
+ ret = append (ret , ep )
150
+ }
151
+ return ret , nil
152
+ }
153
+
133
154
134
155
func AddIpvlanInterface (dnet * danmtypes.DanmNet , ep * danmtypes.DanmEp ) error {
135
156
if ep .Spec .NetworkType != "ipvlan" {
0 commit comments