Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
76a95e8c
Commit
76a95e8c
authored
May 24, 2017
by
Matt Potter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor to remove loop / use sets.String{}
parent
743cc5d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
dns.go
federation/pkg/federation-controller/service/dns.go
+7
-12
No files found.
federation/pkg/federation-controller/service/dns.go
View file @
76a95e8c
...
...
@@ -333,28 +333,23 @@ func findRrset(list []dnsprovider.ResourceRecordSet, rrset dnsprovider.ResourceR
non-nil error is also returned (possibly along with a partially complete list of resolved endpoints.
*/
func
getResolvedEndpoints
(
endpoints
[]
string
)
([]
string
,
error
)
{
resolvedEndpoints
:=
make
([]
string
,
0
,
len
(
endpoints
))
resolvedEndpoints
:=
sets
.
String
{}
for
_
,
endpoint
:=
range
endpoints
{
if
net
.
ParseIP
(
endpoint
)
==
nil
{
// It's not a valid IP address, so assume it's a DNS name, and try to resolve it,
// replacing its DNS name with its IP addresses in expandedEndpoints
ipAddrs
,
err
:=
net
.
LookupHost
(
endpoint
)
if
err
!=
nil
{
return
resolvedEndpoints
,
err
return
resolvedEndpoints
.
List
(),
err
}
for
_
,
ip
:=
range
ipAddrs
{
resolvedEndpoints
=
resolvedEndpoints
.
Union
(
sets
.
NewString
(
ip
))
}
resolvedEndpoints
=
append
(
resolvedEndpoints
,
ipAddrs
...
)
}
else
{
resolvedEndpoints
=
append
(
resolvedEndpoints
,
endpoint
)
}
}
deduped
:=
sets
.
String
{}
for
_
,
endpoint
:=
range
resolvedEndpoints
{
if
!
deduped
.
Has
(
endpoint
)
{
deduped
.
Insert
(
endpoint
)
resolvedEndpoints
=
resolvedEndpoints
.
Union
(
sets
.
NewString
(
endpoint
))
}
}
return
deduped
.
List
(),
nil
return
resolvedEndpoints
.
List
(),
nil
}
/* ensureDNSRrsets ensures (idempotently, and with minimum mutations) that all of the DNS resource record sets for dnsName are consistent with endpoints.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment