| 48 | } |
| 49 | |
| 50 | func CompleteLabels(ctx context.Context, vs ...*Target) { |
| 51 | ml := turn(vs) |
| 52 | for n, vm := range ml { |
| 53 | if n == Special { |
| 54 | continue |
| 55 | } else if service, has := auto.GetService(n.Name()); has { |
| 56 | nl := utils.MapKeys(vm) |
| 57 | labels := service.GetLabels(ctx, nl...) |
| 58 | if labels == nil { |
| 59 | continue |
| 60 | } |
| 61 | for _, v := range vs { |
| 62 | if lv, h := labels[v.Name]; h { |
| 63 | v.Label = lv |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func turn(vs []*Target) map[PermitType]map[string]*Target { |
| 71 | rs := make(map[PermitType]map[string]*Target) |