refactor to use sets.String

This commit is contained in:
Matt Potter 2017-05-15 11:04:20 +01:00
parent b8c0314861
commit ae102d64c4

View File

@ -27,6 +27,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime" pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
@ -346,14 +347,14 @@ func getResolvedEndpoints(endpoints []string) ([]string, error) {
resolvedEndpoints = append(resolvedEndpoints, endpoint) resolvedEndpoints = append(resolvedEndpoints, endpoint)
} }
} }
deduped := []string{} deduped := sets.String{}
for _, value := range resolvedEndpoints { for _, endpoint := range resolvedEndpoints {
if !dedupeEndpoints(value, deduped) { if !deduped.Has(endpoint) {
deduped = append(deduped, value) deduped.Insert(endpoint)
} }
} }
return deduped, nil return deduped.List(), nil
} }
/* ensureDNSRrsets ensures (idempotently, and with minimum mutations) that all of the DNS resource record sets for dnsName are consistent with endpoints. /* ensureDNSRrsets ensures (idempotently, and with minimum mutations) that all of the DNS resource record sets for dnsName are consistent with endpoints.