-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16930 from ewbankkit/b-various-aws_route-fixes-Ma…
…rkVII r/aws_route: Correctly handle update of route target
- Loading branch information
Showing
13 changed files
with
1,734 additions
and
869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
resource/aws_route: Validate route destination and target attributes | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_route: Correctly handle updates to the route target attributes (`egress_only_gateway_id`, `gateway_id`, `instance_id`, `local_gateway_id`, `nat_gateway_id`, `network_interface_id`, `transit_gateway_id`, `vpc_peering_connection_id`) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
// CIDRBlocksEqual returns whether or not two CIDR blocks are equal: | ||
// - Both CIDR blocks parse to an IP address and network | ||
// - The string representation of the IP addresses are equal | ||
// - The string representation of the networks are equal | ||
// This function is especially useful for IPv6 CIDR blocks which have multiple valid representations. | ||
func CIDRBlocksEqual(cidr1, cidr2 string) bool { | ||
ip1, ipnet1, err := net.ParseCIDR(cidr1) | ||
if err != nil { | ||
return false | ||
} | ||
ip2, ipnet2, err := net.ParseCIDR(cidr2) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
return ip2.String() == ip1.String() && ipnet2.String() == ipnet1.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_CIDRBlocksEqual(t *testing.T) { | ||
for _, ts := range []struct { | ||
cidr1 string | ||
cidr2 string | ||
equal bool | ||
}{ | ||
{"10.2.2.0/24", "10.2.2.0/24", true}, | ||
{"10.2.2.0/1234", "10.2.2.0/24", false}, | ||
{"10.2.2.0/24", "10.2.2.0/1234", false}, | ||
{"2001::/15", "2001::/15", true}, | ||
{"::/0", "2001::/15", false}, | ||
{"::/0", "::0/0", true}, | ||
{"", "", false}, | ||
} { | ||
equal := CIDRBlocksEqual(ts.cidr1, ts.cidr2) | ||
if ts.equal != equal { | ||
t.Fatalf("CIDRBlocksEqual(%q, %q) should be: %t", ts.cidr1, ts.cidr2, ts.equal) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.