-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
169 additions
and
83 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
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
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,27 @@ | ||
// Whether the IP CIDR change shrinks the block. | ||
func isShrinkageIpCidr(old, new, _ interface{}) bool { | ||
_, oldCidr, oldErr := net.ParseCIDR(old.(string)) | ||
_, newCidr, newErr := net.ParseCIDR(new.(string)) | ||
|
||
if oldErr != nil || newErr != nil { | ||
// This should never happen. The ValidateFunc on the field ensures it. | ||
return false | ||
} | ||
|
||
oldStart, oldEnd := cidr.AddressRange(oldCidr) | ||
|
||
if newCidr.Contains(oldStart) && newCidr.Contains(oldEnd) { | ||
// This is a CIDR range expansion, no need to ForceNew, we have an update method for it. | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
|
||
func splitSubnetID(id string) (region string, name string) { | ||
parts := strings.Split(id, "/") | ||
region = parts[0] | ||
name = parts[1] | ||
return | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CustomizeDiff: customdiff.All( | ||
customdiff.ForceNewIfChange("ip_cidr_range", isShrinkageIpCidr), | ||
), |
Oops, something went wrong.