mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
Avoid duplicated notifications with Kubernetes DaemonSet (#252)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,9 @@ func (c *Client) PodList(opts metav1.ListOptions) ([]v1.Pod, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
podList = append(podList, pods.Items...)
|
for _, pod := range pods.Items {
|
||||||
|
podList = appendPod(podList, pod)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(podList, func(i, j int) bool {
|
sort.Slice(podList, func(i, j int) bool {
|
||||||
@@ -25,3 +27,12 @@ func (c *Client) PodList(opts metav1.ListOptions) ([]v1.Pod, error) {
|
|||||||
|
|
||||||
return podList, nil
|
return podList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func appendPod(pods []v1.Pod, i v1.Pod) []v1.Pod {
|
||||||
|
for _, pod := range pods {
|
||||||
|
if len(pod.OwnerReferences) > 0 && len(i.OwnerReferences) > 0 && pod.OwnerReferences[0].UID == i.OwnerReferences[0].UID {
|
||||||
|
return pods
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return append(pods, i)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user