Skip to content

Commit

Permalink
Group By Endpoint names per Hosted Zone on AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocaylent committed Mar 3, 2024
1 parent b8053fe commit e55200a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ func sortChangesByActionNameType(cs Route53Changes) Route53Changes {
// changesByZone separates a multi-zone change into a single change per zone.
func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Changes) map[string]Route53Changes {
changes := make(map[string]Route53Changes)
visitedHostnames := make(map[string]map[string]bool)
visitedHostnames := make(map[string]map[string]map[string]bool)

for _, z := range zones {
changes[aws.StringValue(z.Id)] = Route53Changes{}
Expand All @@ -994,15 +994,16 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change
continue
}
for _, z := range zones {
// Initialize the map for the current zone if it doesn't exist
if visitedHostnames[aws.StringValue(z.Id)] == nil {
visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool)
// Initialize the map for the Current Zone & Record Type if it doesn't exist
if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] == nil {

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 998 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index
visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] = make(map[string]bool)

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 999 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index
}

if visitedHostnames[aws.StringValue(z.Id)][hostname] {
log.Debugf("Skipping duplicate %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id))
if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] {

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1002 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index
log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type)
continue
}

if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias {
// alias record is to be created; target needs to be in the same zone as endpoint
// if it's not, this will fail
Expand All @@ -1018,8 +1019,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change
}
}
changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c)
visitedHostnames[aws.StringValue(z.Id)][hostname] = true
log.Debugf("Adding %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id))
visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] = true

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index) (typecheck)

Check failure on line 1022 in provider/aws/aws.go

View workflow job for this annotation

GitHub Actions / Build

cannot use c.ResourceRecordSet.Type (variable of type *string) as string value in map index (typecheck)
log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type)
}
}

Expand Down

0 comments on commit e55200a

Please sign in to comment.