Skip to content

Commit

Permalink
Fix Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocaylent committed Mar 16, 2024
1 parent f4f39d8 commit 0ca2796
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ func (e *Endpoint) String() string {
// only endpoints that match.
func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint {
filtered := []*Endpoint{}
visited := make(map[EndpointKey]bool) // Initialize the visited map
// Initialize the map for detecting duplicated endpoints
visited := make(map[EndpointKey]bool)

for _, ep := range eps {
// key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong
key := ep.Key()
// This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier.
// This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier.
if visited[key] { //Do not contain duplicated endpoints
log.Debugf(`Already loaded endpoint %v `, ep)
continue
Expand All @@ -308,7 +310,9 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint {
filtered = append(filtered, ep)
log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID)
}
visited[key] = true
if (key != EndpointKey{}) {
visited[key] = true
}
}

return filtered
Expand Down

0 comments on commit 0ca2796

Please sign in to comment.