forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Much of the code that made of the CIDR validation was there to give a custom description of what made the CIDR provided invalid. This has been removed in favor of using the error returned by the golang library's ParseCIDR function. Additionally, the code to determine whether two CIDRs overlap was unnecessary complex because it did not take advantage of the fact that CIDRs only overlap if one is a subset of the other. https://jira.coreos.com/browse/CORS-850
- Loading branch information
Showing
26 changed files
with
538 additions
and
193 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,19 @@ | ||
package validation | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
|
||
"github.com/openshift/installer/pkg/types/aws" | ||
) | ||
|
||
// ValidateMachinePool checks that the specified machine pool is valid. | ||
func ValidateMachinePool(p *aws.MachinePool, fldPath *field.Path) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
if p.IOPS < 0 { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("iops"), p.IOPS, "Storage IOPS must be positive")) | ||
} | ||
if p.Size < 0 { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("size"), p.IOPS, "Storage size must be positive")) | ||
} | ||
return allErrs | ||
} |
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,37 @@ | ||
package validation | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
|
||
"github.com/openshift/installer/pkg/types/aws" | ||
"github.com/openshift/installer/pkg/validate" | ||
) | ||
|
||
var ( | ||
validRegionValues = func() []string { | ||
validValues := make([]string, len(aws.ValidRegions)) | ||
i := 0 | ||
for r := range aws.ValidRegions { | ||
validValues[i] = r | ||
i++ | ||
} | ||
return validValues | ||
}() | ||
) | ||
|
||
// ValidatePlatform checks that the specified platform is valid. | ||
func ValidatePlatform(p *aws.Platform, fldPath *field.Path) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
if _, ok := aws.ValidRegions[p.Region]; !ok { | ||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("region"), p.Region, validRegionValues)) | ||
} | ||
if p.DefaultMachinePlatform != nil { | ||
allErrs = append(allErrs, ValidateMachinePool(p.DefaultMachinePlatform, fldPath.Child("defaultMachinePlatform"))...) | ||
} | ||
if p.VPCCIDRBlock != nil { | ||
if err := validate.SubnetCIDR(&p.VPCCIDRBlock.IPNet); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("vpcCIDRBlock"), p.VPCCIDRBlock, err.Error())) | ||
} | ||
} | ||
return allErrs | ||
} |
Oops, something went wrong.