in internal/workload/podspec_updates.go [177:198]
func (u *Updater) FindMatchingAuthProxyWorkloads(pl *cloudsqlapi.AuthProxyWorkloadList, wl *PodWorkload, owners []Workload) []*cloudsqlapi.AuthProxyWorkload {
// starting with this pod, traverse the pod and its owners, and
// fill wls with a list of workload resources that match an AuthProxyWorkload
// in the pl.
wls := u.filterMatchingInstances(pl, wl.Object())
for _, owner := range owners {
wls = append(wls, u.filterMatchingInstances(pl, owner.Object())...)
}
// remove duplicates from wls by Name
m := map[string]*cloudsqlapi.AuthProxyWorkload{}
for _, w := range wls {
m[w.GetNamespace()+"/"+w.GetName()] = w
}
wls = make([]*cloudsqlapi.AuthProxyWorkload, 0, len(m))
for _, w := range m {
wls = append(wls, w)
}
// if this was updated return matching DBInstances
return wls
}